Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions assets/css/style-wizard.css
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ h2.wpmm-title span img {
font-size: 18px;
}

.subscribe-step .opt-in-container {
display: flex;
gap: 8px;
margin-top: 20px;
}

.subscribe-step .opt-in-container svg.components-checkbox-control__checked {
top: 20%;
}

.subscribe-step .opt-in-container label {
text-align: left;
}
#email-input-wrap {
position: relative;
display: flex;
Expand Down
2 changes: 2 additions & 0 deletions assets/js/scripts-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,13 @@ jQuery( function( $ ) {

emailInput.removeClass( 'invalid' );
subscribeButton.addClass( 'is-busy' );
const optIn = $('#wizard-opt-in').is( ':checked' );

$.post( wpmmVars.ajaxURL, {
action: 'wpmm_subscribe',
email,
_wpnonce: wpmmVars.wizardNonce,
opt_in: optIn ? 1 : 0,
}, function( response ) {
if ( ! response.success ) {
alert( response.data );
Expand Down
4 changes: 4 additions & 0 deletions includes/classes/wp-maintenance-mode-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ public function subscribe_newsletter() {
die( esc_html__( 'Empty field: email', 'wp-maintenance-mode' ) );
}

if ( isset( $_POST['opt_in'] ) && sanitize_text_field( $_POST['opt_in'] ) ) {
update_option( 'wp_maintenance_mode_logger_flag', 'yes' );
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the checkbox is unchecked (opt_in is 0 or false), the code doesn't explicitly set the option to 'no' or delete it. This means if a user previously opted in and then unchecks the box, the telemetry will remain enabled. Consider adding an else clause to set the option to 'no' or delete it when the user opts out.

Suggested change
update_option( 'wp_maintenance_mode_logger_flag', 'yes' );
update_option( 'wp_maintenance_mode_logger_flag', 'yes' );
} else {
update_option( 'wp_maintenance_mode_logger_flag', 'no' );

Copilot uses AI. Check for mistakes.
}

$response = wp_remote_post(
self::SUBSCRIBE_ROUTE,
array(
Expand Down
27 changes: 27 additions & 0 deletions includes/classes/wp-maintenance-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ function() {
}
);
}

add_action( 'init', array( $this, 'initialize_telemetry' ) );

}

/**
Expand Down Expand Up @@ -1449,6 +1452,30 @@ public function set_current_page_category( $category ) {
public function get_current_page_category() {
return $this->current_page_category;
}

/**
* Initialize telemetry.
*
* @return void
*/
public function initialize_telemetry() {
if ( 'yes' === get_option( 'wp_maintenance_mode_logger_flag' ) ) {
add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );
add_filter(
'themeisle_sdk_telemetry_products',
function( $products ) {
foreach ( $products as &$product ) {
if ( isset( $product['slug'] ) && 'wp' === $product['slug'] ) {
$product['slug'] = 'wp_maintenance_mode';
}
}

return $products;
}
);
}

}
}

}
7 changes: 7 additions & 0 deletions views/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
<input type="text" value="<?php echo esc_attr( get_bloginfo( 'admin_email' ) ); ?>" />
<input type="button" class="button button-primary button-big subscribe-button" value="<?php esc_attr_e( 'Sign me up', 'wp-maintenance-mode' ); ?>" />
</div>
<div class="opt-in-container">
<span class="components-checkbox-control__input-container">
<input id="wizard-opt-in" type="checkbox" class="components-checkbox-control__input" checked>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="presentation" class="components-checkbox-control__checked" aria-hidden="true" focusable="false"><path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path></svg>
</span>
<label for="wizard-opt-in"><?php echo esc_html__( 'Help us improve LightStart by opting in to anonymous usage tracking. No sensitive data is collected.', 'wp-maintenance-mode' ); ?></label>
</div>
<input id="skip-subscribe" type="button" class="button button-link skip-link" value="<?php esc_attr_e( 'I\'ll skip for now, thanks!', 'wp-maintenance-mode' ); ?>" />
</div>
</div>
Expand Down
Loading