Skip to content

Commit 4b2d630

Browse files
release: fixes
- Updated dependencies
2 parents c0c6247 + b2373b2 commit 4b2d630

7 files changed

Lines changed: 142 additions & 16 deletions

File tree

AGENTS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Agent Workflow
2+
3+
## Project Overview
4+
5+
WP Maintenance Mode (LightStart) is a WordPress plugin by Themeisle that displays a maintenance mode, coming soon, or landing page to visitors. Text domain: `wp-maintenance-mode`. Option key: `wpmm_settings`. All constants prefixed with `WPMM_`.
6+
7+
## Commands
8+
9+
```bash
10+
# Install dependencies
11+
composer install
12+
npm install
13+
14+
# Lint (PHP_CodeSniffer with WordPress coding standards)
15+
composer run lint
16+
17+
# Auto-fix coding standards
18+
composer run format
19+
20+
# Run PHPUnit tests
21+
./vendor/bin/phpunit
22+
23+
# Run a single test file
24+
./vendor/bin/phpunit tests/generic-test.php
25+
26+
# Build assets (minify JS + CSS via Grunt)
27+
npm run build # or: npx grunt
28+
29+
# Watch for asset changes during development
30+
npx grunt watch
31+
```
32+
33+
## Architecture
34+
35+
### Entry Point & Bootstrap
36+
37+
`wp-maintenance-mode.php` — Main plugin file. Defines all `WPMM_*` constants (paths, URLs), requires function files, then loads the two core singleton classes via `plugins_loaded`.
38+
39+
### Core Classes (`includes/classes/`)
40+
41+
- **`WP_Maintenance_Mode`** — Frontend singleton. Handles maintenance mode display logic, page templates, redirect rules, multisite/network mode support, and shortcode registration. Loaded on every request.
42+
- **`WP_Maintenance_Mode_Admin`** — Admin singleton. Settings page, AJAX handlers (prefixed `wp_ajax_wpmm_*`), wizard flow, template management, subscriber export, and notices. Only loaded in `is_admin()` context.
43+
- **`WP_Maintenance_Mode_Shortcodes`** + `shortcodes/` — Shortcode registration (e.g., login form shortcode).
44+
45+
### Functions (`includes/functions/`)
46+
47+
- **`hooks.php`** — Plugin header filters and email content type hook.
48+
- **`helpers.php`** — Utility functions (e.g., `wpmm_get_option()`).
49+
50+
### Views (`views/`)
51+
52+
PHP template files for admin settings tabs (`settings.php`, `contact.php`, `google-analytics.php`), the frontend maintenance page (`maintenance.php`), wizard (`wizard.php`), network settings, notices, and sidebar.
53+
54+
### Assets
55+
56+
- `assets/js/` — Frontend (`scripts.js`) and admin (`scripts-admin.js`, `scripts-admin-global.js`) JavaScript, plus chatbot (`bot.js`, `bot.async.js`). Grunt minifies to `.min.js`.
57+
- `assets/css/` — Stylesheets minified via PostCSS/cssnano to `.min.css`.
58+
- `assets/templates/` — Block template JSON files organized by category: `coming-soon/`, `maintenance/`, `landing-page/`.
59+
60+
### Settings Structure
61+
62+
Plugin settings stored as serialized array in `wpmm_settings` option, with sections: `general` (status, network_mode), plus additional tabs managed by the admin class. Network/multisite settings stored in `wpmm_settings_network`.
63+
64+
## Coding Standards
65+
66+
- WordPress-Core standards enforced via PHPCS (`phpcs.xml`), with specific exclusions (no Yoda conditions required, loose comparison allowed, etc.)
67+
- i18n text domain: `wp-maintenance-mode`
68+
- PHP minimum: 7.0 (runtime set in PHPCS)
69+
- Assets use `.min.` suffix in production; controlled by `SCRIPT_DEBUG` constant

assets/css/style-wizard.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ h2.wpmm-title span img {
296296
font-size: 18px;
297297
}
298298

299+
.subscribe-step .opt-in-container {
300+
display: flex;
301+
gap: 8px;
302+
margin-top: 20px;
303+
}
304+
305+
.subscribe-step .opt-in-container svg.components-checkbox-control__checked {
306+
top: 20%;
307+
}
308+
309+
.subscribe-step .opt-in-container label {
310+
text-align: left;
311+
}
299312
#email-input-wrap {
300313
position: relative;
301314
display: flex;

assets/js/scripts-admin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,13 @@ jQuery( function( $ ) {
429429

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

433434
$.post( wpmmVars.ajaxURL, {
434435
action: 'wpmm_subscribe',
435436
email,
436437
_wpnonce: wpmmVars.wizardNonce,
438+
opt_in: optIn ? 1 : 0,
437439
}, function( response ) {
438440
if ( ! response.success ) {
439441
alert( response.data );

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/classes/wp-maintenance-mode-admin.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,10 @@ public function subscribe_newsletter() {
806806
die( esc_html__( 'Empty field: email', 'wp-maintenance-mode' ) );
807807
}
808808

809+
if ( isset( $_POST['opt_in'] ) && sanitize_text_field( $_POST['opt_in'] ) ) {
810+
update_option( 'wp_maintenance_mode_logger_flag', 'yes' );
811+
}
812+
809813
$response = wp_remote_post(
810814
self::SUBSCRIBE_ROUTE,
811815
array(
@@ -1324,15 +1328,19 @@ public function add_inline_global_style() {
13241328
public function add_black_friday_data( $configs ) {
13251329
$config = $configs['default'];
13261330

1327-
// translators: %1$s - plugin namce, %2$s - HTML tag, %3$s - discount, %4$s - HTML tag, %5$s - company name.
1328-
$message_template = __( 'Brought to you by the team behind %1$s— our biggest sale of the year is here: %2$sup to %3$s OFF%4$s on premium products from %5$s! Limited-time only.', 'wp-maintenance-mode' );
1331+
if ( defined( 'NEVE_VERSION' ) ) {
1332+
return $configs;
1333+
}
13291334

1330-
$config['message'] = sprintf( $message_template, 'WP Maintenance Mode', '<strong>', '70%', '</strong>', '<strong>Themeisle</strong>' );
1331-
$config['sale_url'] = add_query_arg(
1335+
// translators: 1. Number of free licenses, 2. The price of the product.
1336+
$config['message'] = sprintf( __( 'You\'re using LightStart, and the team behind it is celebrating Black Friday by giving away %1$s licences of Neve Pro. A premium WordPress theme worth %2$s, packed with starter sites, a header builder, and WooCommerce layouts. Claim yours before they run out.', 'wp-maintenance-mode' ), 100, '$69' );
1337+
$config['cta_label'] = __( 'Get Neve Pro free', 'wp-maintenance-mode' );
1338+
$config['plugin_meta_message'] = __( 'Black Friday Sale - Get Neve Pro free', 'wp-maintenance-mode' );
1339+
$config['sale_url'] = add_query_arg(
13321340
array(
13331341
'utm_term' => 'free',
13341342
),
1335-
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/all-bf', 'bfcm', 'wp-maintenance-mode' ) )
1343+
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/neve-claim-bf', 'bfcm', 'lightstart' ) )
13361344
);
13371345

13381346
$configs[ WPMM_PRODUCT_SLUG ] = $config;

includes/classes/wp-maintenance-mode.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ function() {
159159
}
160160
);
161161
}
162+
163+
add_action( 'init', array( $this, 'initialize_telemetry' ) );
164+
162165
}
163166

164167
/**
@@ -1385,7 +1388,7 @@ public function send_contact() {
13851388
*/
13861389
public function otter_add_subscriber( $form_data ) {
13871390
if ( $form_data ) {
1388-
$input_data = $form_data->get_payload_field( 'formInputsData' );
1391+
$input_data = $form_data->get_data_from_payload( 'formInputsData' );
13891392
$input_data = array_map(
13901393
function( $input_field ) {
13911394
if ( isset( $input_field['type'] ) && 'email' === $input_field['type'] ) {
@@ -1449,6 +1452,30 @@ public function set_current_page_category( $category ) {
14491452
public function get_current_page_category() {
14501453
return $this->current_page_category;
14511454
}
1455+
1456+
/**
1457+
* Initialize telemetry.
1458+
*
1459+
* @return void
1460+
*/
1461+
public function initialize_telemetry() {
1462+
if ( 'yes' === get_option( 'wp_maintenance_mode_logger_flag' ) ) {
1463+
add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );
1464+
add_filter(
1465+
'themeisle_sdk_telemetry_products',
1466+
function( $products ) {
1467+
foreach ( $products as &$product ) {
1468+
if ( isset( $product['slug'] ) && 'wp' === $product['slug'] ) {
1469+
$product['slug'] = 'wp_maintenance_mode';
1470+
}
1471+
}
1472+
1473+
return $products;
1474+
}
1475+
);
1476+
}
1477+
1478+
}
14521479
}
14531480

14541481
}

views/wizard.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@
116116
<input type="text" value="<?php echo esc_attr( get_bloginfo( 'admin_email' ) ); ?>" />
117117
<input type="button" class="button button-primary button-big subscribe-button" value="<?php esc_attr_e( 'Sign me up', 'wp-maintenance-mode' ); ?>" />
118118
</div>
119+
<div class="opt-in-container">
120+
<span class="components-checkbox-control__input-container">
121+
<input id="wizard-opt-in" type="checkbox" class="components-checkbox-control__input" checked>
122+
<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>
123+
</span>
124+
<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>
125+
</div>
119126
<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' ); ?>" />
120127
</div>
121128
</div>

0 commit comments

Comments
 (0)