Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions includes/classes/SupportMonitor/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public function get_setting( $setting_key = null ) {
$settings['server_url'] = 'https://monitor.10up.com';
}

// Disable support monitor for local environments to prevent polluting monitor with .test/.local domains
if ( $this->is_local_environment() ) {
$settings['enable_support_monitor'] = 'no';
}

if ( defined( 'SUPPORT_MONITOR_SERVER_URL' ) ) {
$settings['server_url'] = SUPPORT_MONITOR_SERVER_URL;
}
Expand All @@ -160,6 +165,16 @@ public function get_setting( $setting_key = null ) {
return $settings;
}

/**
* Check if we're in a local environment
*
* @since 2.1
* @return bool
*/
public function is_local_environment() {
return function_exists( 'wp_get_environment_type' ) && 'local' === wp_get_environment_type();
}

/**
* Output setting section description
*
Expand All @@ -170,6 +185,16 @@ public function setting_section_description() {
<p>
<?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' ); ?>
</p>
<?php if ( $this->is_local_environment() ) : ?>
<div class="notice notice-info inline">
<p>
<strong>
<?php esc_html_e( 'Local Environment Detected:', 'tenup' ); ?>
</strong>
<?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' ); ?>
</p>
</div>
<?php endif; ?>
<?php
}

Expand Down Expand Up @@ -244,8 +269,8 @@ public function sanitize_settings( $settings ) {
public function enable_field() {
$value = $this->get_setting( 'enable_support_monitor' );
?>
<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>
<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>
<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>
<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>
<?php
}

Expand Down
Loading