Skip to content

Commit 0bedf66

Browse files
committed
Disable monitor when working locally
1 parent 3066ce7 commit 0bedf66

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

includes/classes/SupportMonitor/Monitor.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ public function get_setting( $setting_key = null ) {
141141
$settings['server_url'] = 'https://monitor.10up.com';
142142
}
143143

144+
// Disable support monitor for local environments to prevent polluting monitor with .test/.local domains
145+
if ( $this->is_local_environment() ) {
146+
$settings['enable_support_monitor'] = 'no';
147+
}
148+
144149
if ( defined( 'SUPPORT_MONITOR_SERVER_URL' ) ) {
145150
$settings['server_url'] = SUPPORT_MONITOR_SERVER_URL;
146151
}
@@ -160,6 +165,16 @@ public function get_setting( $setting_key = null ) {
160165
return $settings;
161166
}
162167

168+
/**
169+
* Check if we're in a local environment
170+
*
171+
* @since 2.1
172+
* @return bool
173+
*/
174+
public function is_local_environment() {
175+
return function_exists( 'wp_get_environment_type' ) && 'local' === wp_get_environment_type();
176+
}
177+
163178
/**
164179
* Output setting section description
165180
*
@@ -170,6 +185,16 @@ public function setting_section_description() {
170185
<p>
171186
<?php esc_html_e( '10up collects data on site health including plugin, WordPress, and system versions as well as general site issues to provide proactive support to your website. No proprietary data or user information is sent back to us. Although recommended, this functionality is optional and can be disabled.', 'tenup' ); ?>
172187
</p>
188+
<?php if ( $this->is_local_environment() ) : ?>
189+
<div class="notice notice-info inline">
190+
<p>
191+
<strong>
192+
<?php esc_html_e( 'Local Environment Detected:', 'tenup' ); ?>
193+
</strong>
194+
<?php esc_html_e( 'Support monitoring is automatically disabled in local environments to prevent test/development data from being sent to the monitoring service.', 'tenup' ); ?>
195+
</p>
196+
</div>
197+
<?php endif; ?>
173198
<?php
174199
}
175200

@@ -244,8 +269,8 @@ public function sanitize_settings( $settings ) {
244269
public function enable_field() {
245270
$value = $this->get_setting( 'enable_support_monitor' );
246271
?>
247-
<input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked( 'yes', $value ); ?><?php disabled( defined( 'SUPPORT_MONITOR_ENABLE' ) ); ?> type="radio" id="tenup_enable_support_monitor_yes" value="yes"> <label for="tenup_enable_support_monitor_yes"><?php esc_html_e( 'Yes', 'tenup' ); ?></label><br>
248-
<input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked( 'no', $value ); ?><?php disabled( defined( 'SUPPORT_MONITOR_ENABLE' ) ); ?> type="radio" id="tenup_enable_support_monitor_no" value="no"> <label for="tenup_enable_support_monitor_no"><?php esc_html_e( 'No', 'tenup' ); ?></label>
272+
<input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked( 'yes', $value ); ?><?php disabled( defined( 'SUPPORT_MONITOR_ENABLE' ) || $this->is_local_environment() ); ?> type="radio" id="tenup_enable_support_monitor_yes" value="yes"> <label for="tenup_enable_support_monitor_yes"><?php esc_html_e( 'Yes', 'tenup' ); ?></label><br>
273+
<input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked( 'no', $value ); ?><?php disabled( defined( 'SUPPORT_MONITOR_ENABLE' ) || $this->is_local_environment() ); ?> type="radio" id="tenup_enable_support_monitor_no" value="no"> <label for="tenup_enable_support_monitor_no"><?php esc_html_e( 'No', 'tenup' ); ?></label>
249274
<?php
250275
}
251276

0 commit comments

Comments
 (0)