diff --git a/assets/src/dashboard/parts/connected/Toasts.js b/assets/src/dashboard/parts/connected/Toasts.js
index 43864a849..45f6fbc87 100644
--- a/assets/src/dashboard/parts/connected/Toasts.js
+++ b/assets/src/dashboard/parts/connected/Toasts.js
@@ -1,15 +1,14 @@
import { filter } from 'lodash';
import { SnackbarList } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
-import { store as noticesStore } from '@wordpress/notices';
export default function() {
const notices = useSelect(
- ( select ) => select( noticesStore ).getNotices(),
+ ( select ) => select( 'core/notices' ).getNotices(),
[]
);
- const { removeNotice } = useDispatch( noticesStore );
+ const { removeNotice } = useDispatch( 'core/notices' );
const snackbarNotices = filter( notices, {
type: 'snackbar'
diff --git a/assets/src/dashboard/parts/connected/settings/Compression.js b/assets/src/dashboard/parts/connected/settings/Compression.js
index b44dc63c0..5816e6250 100644
--- a/assets/src/dashboard/parts/connected/settings/Compression.js
+++ b/assets/src/dashboard/parts/connected/settings/Compression.js
@@ -14,6 +14,7 @@ import {
BaseControl,
Button,
Icon,
+ RadioControl,
RangeControl,
ToggleControl,
@@ -173,32 +174,51 @@ const Compression = ({
}
}, [ showSample ]);
+ const compressionModes = [
+ {
+ className: 'bg-blue-500',
+ label: optimoleDashboardApp.strings.options_strings.compression_mode_speed_optimized,
+ value: 'speed_optimized'
+ },
+ {
+ label: optimoleDashboardApp.strings.options_strings.compression_mode_quality_optimized,
+ value: 'quality_optimized'
+ },
+ {
+ label: optimoleDashboardApp.strings.options_strings.compression_mode_custom,
+ value: 'custom'
+ }
+ ];
+
+ const compressionModeLabel = (
+
transformCompressionMode( value ) }
/>
-
-
-
+ ) }
{'speed_optimized' === compressionMode && (
{optimoleDashboardApp.strings.options_strings.compression_mode_speed_optimized_desc}
diff --git a/assets/src/dashboard/parts/connected/settings/__tests__/Compression.test.js b/assets/src/dashboard/parts/connected/settings/__tests__/Compression.test.js
new file mode 100644
index 000000000..5fbf23fc6
--- /dev/null
+++ b/assets/src/dashboard/parts/connected/settings/__tests__/Compression.test.js
@@ -0,0 +1,83 @@
+/**
+ * The compression mode control on WordPress versions whose @wordpress/components has no
+ * ToggleGroupControl (below 5.9).
+ */
+import { act } from 'react-dom/test-utils';
+import { createRoot } from 'react-dom/client';
+
+jest.mock( '@wordpress/components', () => ({
+ BaseControl: ({ children }) => children,
+ Button: ({ children }) => children,
+ Icon: () => null,
+ RangeControl: () => null,
+ ToggleControl: () => null,
+ RadioControl: ({ options, selected, onChange }) => options.map( option => (
+ onChange( option.value ) }
+ />
+ ) )
+}) );
+jest.mock( '@wordpress/data', () => ({
+ useSelect: () => ({ sampleImages: {}, isLoading: false })
+}) );
+jest.mock( '@wordpress/icons', () => ({ rotateRight: null }) );
+jest.mock( 'react-compare-image', () => () => null );
+jest.mock( '../../../../utils/api', () => ({ sampleRate: jest.fn() }) );
+jest.mock( '../../../components/ProgressBar', () => () => null );
+
+global.IS_REACT_ACT_ENVIRONMENT = true;
+global.optimoleDashboardApp = {
+ strings: {
+ options_strings: new Proxy({}, { get: ( target, name ) => name })
+ }
+};
+
+const Compression = require( '../Compression' ).default;
+
+describe( 'Compression', () => {
+ let container;
+ let root;
+
+ beforeEach( () => {
+ container = document.createElement( 'div' );
+ document.body.appendChild( container );
+ root = createRoot( container );
+ });
+
+ afterEach( () => {
+ act( () => root.unmount() );
+ container.remove();
+ });
+
+ test( 'offers the three compression modes without ToggleGroupControl', () => {
+ const setSettings = jest.fn();
+
+ act( () => {
+ root.render(
+
+ );
+ });
+
+ const radios = container.querySelectorAll( 'input[type="radio"]' );
+ expect( Array.from( radios, radio => radio.value ) ).toEqual([ 'speed_optimized', 'quality_optimized', 'custom' ]);
+ expect( container.querySelector( 'input:checked' ).value ).toBe( 'quality_optimized' );
+
+ act( () => radios[0].click() );
+
+ expect( setSettings ).toHaveBeenCalledWith( expect.objectContaining({
+ compression_mode: 'speed_optimized',
+ retina_images: 'disabled'
+ }) );
+ });
+});
diff --git a/assets/src/dashboard/style.scss b/assets/src/dashboard/style.scss
index 69ac06e46..2bb8edbd2 100644
--- a/assets/src/dashboard/style.scss
+++ b/assets/src/dashboard/style.scss
@@ -84,6 +84,11 @@ $mango-yellow: #FBBF24;
}
.components-toggle-group-control{
border-color: var(--wp-components-color-foreground);
+ // Selected-option indicator drawn by ToggleGroupControl's ::before.
+ &::before{
+ background: var(--wp-components-color-foreground);
+ border-color: var(--wp-components-color-foreground);
+ }
}
.base-control-label {
color: #363636;
diff --git a/assets/src/dashboard/utils/__tests__/api.test.js b/assets/src/dashboard/utils/__tests__/api.test.js
index 09566d36f..61ab5e308 100644
--- a/assets/src/dashboard/utils/__tests__/api.test.js
+++ b/assets/src/dashboard/utils/__tests__/api.test.js
@@ -7,14 +7,16 @@ const mockActions = {};
jest.mock( '@wordpress/api-fetch', () => jest.fn() );
jest.mock( '@wordpress/data', () => ({
- dispatch: () => new Proxy({}, {
+
+ // Like the default registry, an unregistered store name resolves to null.
+ dispatch: store => [ 'optimole', 'core/notices' ].includes( store ) ? new Proxy({}, {
get: ( target, name ) => {
if ( ! mockActions[ name ]) {
mockActions[ name ] = jest.fn();
}
return mockActions[ name ];
}
- }),
+ }) : null,
select: () => ({
getOptimizedImages: () => [],
getQueryArgs: () => ({}),
@@ -24,8 +26,8 @@ jest.mock( '@wordpress/data', () => ({
}) );
jest.mock( '@wordpress/url', () => ({ addQueryArgs: url => url }) );
-// Provided by WordPress at runtime, not installed.
-jest.mock( '@wordpress/notices', () => ({ store: 'core/notices' }), { virtual: true });
+// Provided by WordPress at runtime, not installed; before 5.7 it has no `store` export.
+jest.mock( '@wordpress/notices', () => ({}), { virtual: true });
jest.mock( '../helpers', () => ({ toggleDashboardSidebarSubmenu: jest.fn() }) );
global.optimoleDashboardApp = {
@@ -37,6 +39,12 @@ global.jQuery = { ajax: jest.fn() };
const apiFetch = require( '@wordpress/api-fetch' );
const { callSync } = require( '../api' );
+describe( 'api module', () => {
+ test( 'loads when @wordpress/notices has no store export', () => {
+ expect( () => jest.isolateModules( () => require( '../api' ) ) ).not.toThrow();
+ });
+});
+
const flushPromises = () => new Promise( resolve => setTimeout( resolve, 0 ) );
describe( 'callSync', () => {
diff --git a/assets/src/dashboard/utils/api.js b/assets/src/dashboard/utils/api.js
index 2b93b898e..8588d1903 100644
--- a/assets/src/dashboard/utils/api.js
+++ b/assets/src/dashboard/utils/api.js
@@ -9,7 +9,9 @@ import {
} from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
-import { store as noticesStore } from '@wordpress/notices';
+
+// Registers the core/notices store; its `store` export only exists from WordPress 5.7.
+import '@wordpress/notices';
import { toggleDashboardSidebarSubmenu } from './helpers';
const {
@@ -52,7 +54,7 @@ const {
getSiteSettings
} = select( 'optimole' );
-const { createNotice } = dispatch( noticesStore );
+const { createNotice } = dispatch( 'core/notices' );
export const sendOnboardingImages = ( data = {}) => {
diff --git a/assets/src/widget/index.js b/assets/src/widget/index.js
index e7ddd84e0..684bca00d 100644
--- a/assets/src/widget/index.js
+++ b/assets/src/widget/index.js
@@ -1,7 +1,12 @@
-import { createRoot } from '@wordpress/element';
+import { createRoot, render } from '@wordpress/element';
import App from './App';
import './style.scss';
-const root = createRoot( document.getElementById( 'optimole-dashboard-widget-root' ) );
+const container = document.getElementById( 'optimole-dashboard-widget-root' );
-root.render( );
+// createRoot ships with WordPress 6.2 (React 18).
+if ( createRoot ) {
+ createRoot( container ).render( );
+} else {
+ render( , container );
+}
diff --git a/composer.json b/composer.json
index e0933ec99..c0f420d23 100644
--- a/composer.json
+++ b/composer.json
@@ -58,7 +58,7 @@
"require": {
"php": ">=7.4",
"codeinwp/themeisle-sdk": "^3.3.65",
- "codeinwp/optimole-sdk": "^1.2",
+ "codeinwp/optimole-sdk": "^1.3",
"enshrined/svg-sanitize": "^1.0.0"
}
}
diff --git a/composer.lock b/composer.lock
index 07d43a3b4..d0b191dbb 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "1c6cb28ea9cfac46761c17ca70f1a8d0",
+ "content-hash": "fea9ed731d69e59f5089fa14a003e3e3",
"packages": [
{
"name": "codeinwp/optimole-sdk",
- "version": "v1.2.4",
+ "version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/Codeinwp/optimole-php-sdk.git",
- "reference": "2f7a48525014bd681f39ddc85c55521b719d5879"
+ "reference": "15ce5e000ff005c6a8dfb15142916780eae645a1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Codeinwp/optimole-php-sdk/zipball/2f7a48525014bd681f39ddc85c55521b719d5879",
- "reference": "2f7a48525014bd681f39ddc85c55521b719d5879",
+ "url": "https://api.github.com/repos/Codeinwp/optimole-php-sdk/zipball/15ce5e000ff005c6a8dfb15142916780eae645a1",
+ "reference": "15ce5e000ff005c6a8dfb15142916780eae645a1",
"shasum": ""
},
"require": {
@@ -60,20 +60,20 @@
"issues": "https://github.com/Codeinwp/codeinwp/optimole-php-sdk/issues",
"source": "https://github.com/Codeinwp/optimole-php-sdk"
},
- "time": "2025-11-14T18:01:16+00:00"
+ "time": "2026-11-05T09:54:25+00:00"
},
{
"name": "codeinwp/themeisle-sdk",
- "version": "3.3.71",
+ "version": "3.3.72",
"source": {
"type": "git",
"url": "https://github.com/Codeinwp/themeisle-sdk.git",
- "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991"
+ "reference": "66036fa0ef8168f7e5a3f7bf06dc88733e1d46db"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/cd7acfc0b01b8d5712736aa3721d689591ced991",
- "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991",
+ "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/66036fa0ef8168f7e5a3f7bf06dc88733e1d46db",
+ "reference": "66036fa0ef8168f7e5a3f7bf06dc88733e1d46db",
"shasum": ""
},
"require-dev": {
@@ -99,9 +99,9 @@
],
"support": {
"issues": "https://github.com/Codeinwp/themeisle-sdk/issues",
- "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.71"
+ "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.72"
},
- "time": "2026-11-04T20:22:53+00:00"
+ "time": "2026-11-06T13:01:52+00:00"
},
{
"name": "enshrined/svg-sanitize",
@@ -904,11 +904,11 @@
},
{
"name": "phpstan/phpstan",
- "version": "2.3.3",
+ "version": "2.3.5",
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4b57dc8ca7456b635d1661845f44bc060b02c6b0",
- "reference": "4b57dc8ca7456b635d1661845f44bc060b02c6b0",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/645a1bd6bead15fc1b8474137467961d0fa30a79",
+ "reference": "645a1bd6bead15fc1b8474137467961d0fa30a79",
"shasum": ""
},
"require": {
@@ -964,7 +964,7 @@
"type": "github"
}
],
- "time": "2026-10-27T14:06:26+00:00"
+ "time": "2026-11-03T12:14:22+00:00"
},
{
"name": "phpunit/php-code-coverage",
diff --git a/inc/admin.php b/inc/admin.php
index 72fb017ff..0641d2599 100755
--- a/inc/admin.php
+++ b/inc/admin.php
@@ -13,6 +13,7 @@
use enshrined\svgSanitize\Sanitizer;
use OptimoleWP\BgOptimizer\Lazyload;
use OptimoleWP\PageProfiler\Profile;
+use OptimoleWP\RequestToken;
/**
* Class Optml_Admin
*/
@@ -23,7 +24,7 @@ class Optml_Admin {
const IMAGE_DATA_COLLECTED_BATCH = 100;
- const BF_PROMO_DISMISS_KEY = 'optml_bf25_notice_dismiss';
+ const SDK_BF_DISMISS_META = 'themeisle_sdk_dismissed_notice_black_friday';
const SPC_BANNER_DISMISS_KEY = 'optml_spc_banner_dismiss';
@@ -565,8 +566,9 @@ public function inline_bootstrap_script() {
$lazyload_bg_selectors[] = '.' . $key;
}
$lazyload_bg_selectors = empty( $lazyload_bg_selectors ) ? '' : sprintf( '%s', implode( ', ', (array) $lazyload_bg_selectors ) );
- $bgclasses = empty( $bgclasses ) ? '' : sprintf( '"%s"', implode( '","', (array) $bgclasses ) );
- $watcher_classes = empty( $watcher_classes ) ? '' : sprintf( '"%s"', implode( '","', (array) $watcher_classes ) );
+ $bgclasses = wp_json_encode( array_values( array_map( 'wp_strip_all_tags', (array) $bgclasses ) ) );
+ $watcher_classes = wp_json_encode( array_values( array_map( 'wp_strip_all_tags', (array) $watcher_classes ) ) );
+ $lazyload_bg_selectors = wp_json_encode( wp_strip_all_tags( $lazyload_bg_selectors ) );
$default_network = ( $this->settings->get( 'network_optimization' ) === 'enabled' );
$limit_dimensions = $this->settings->get( 'limit_dimensions' ) === 'enabled';
$limit_width = $limit_dimensions ? $this->settings->get( 'limit_width' ) : 0;
@@ -607,11 +609,11 @@ public function inline_bootstrap_script() {
b.appendChild(s);
w.optimoleData = {
lazyloadOnly: "optimole-lazy-only",
- backgroundReplaceClasses: [%s],
+ backgroundReplaceClasses: %s,
nativeLazyload : %s,
scalingDisabled: %s,
- watchClasses: [%s],
- backgroundLazySelectors: "%s",
+ watchClasses: %s,
+ backgroundLazySelectors: %s,
network_optimizations: %s,
ignoreDpr: %s,
quality: %d,
@@ -620,14 +622,14 @@ public function inline_bootstrap_script() {
}
}(window, document));
',
- Optml_Lazyload_Replacer::IFRAME_TEMP_COMMENT,
+ $this->settings->get( 'video_lazyload' ) === 'enabled' ? Optml_Lazyload_Replacer::IFRAME_PLACEHOLDER_CLASS : '',
esc_url( $domain ),
$min,
- wp_strip_all_tags( $bgclasses ),
+ $bgclasses,
$native_lazy_enabled ? 'true' : 'false',
$scale_is_disabled ? 'true' : 'false',
- wp_strip_all_tags( $watcher_classes ),
- addcslashes( wp_strip_all_tags( $lazyload_bg_selectors ), '"' ),
+ $watcher_classes,
+ $lazyload_bg_selectors,
defined( 'OPTML_NETWORK_ON' ) && constant( 'OPTML_NETWORK_ON' ) ? ( OPTML_NETWORK_ON ? 'true' : 'false' ) : ( $default_network ? 'true' : 'false' ),
$retina_ready ? 'true' : 'false',
$this->settings->get_numeric_quality(),
@@ -1008,7 +1010,7 @@ protected function get_background_lazy_css() {
}
$css = implode( ",\n", $css ) . ' { background-image: none !important; }';
- $css = Lazyload::MARKER . "\n" . strip_tags( $css ) . "\n" . Lazyload::MARKER;
+ $css = Lazyload::get_marker() . "\n" . strip_tags( $css ) . "\n" . Lazyload::get_marker();
return $css;
}
@@ -1064,7 +1066,7 @@ function () {
public static function get_optimizer_script( $placeholder = true ) {
if ( $placeholder ) {
- return '';
+ return '';
}
return '';
+ return '';
}
/**
* Maybe redirect to dashboard page.
@@ -1646,6 +1648,40 @@ private function get_spc_status() {
return 'not-installed';
}
+ /**
+ * Check if the current user dismissed the SDK Black Friday notice this year.
+ *
+ * The SDK uses one dismissal for the notices of all ThemeIsle products.
+ *
+ * @param DateTime $now The current date.
+ *
+ * @return bool
+ */
+ public static function is_sdk_bf_notice_dismissed( $now ) {
+ $dismissed_at = get_user_meta( get_current_user_id(), self::SDK_BF_DISMISS_META, true );
+
+ return ! empty( $dismissed_at ) && wp_date( 'Y', (int) $dismissed_at ) === $now->format( 'Y' );
+ }
+
+ /**
+ * Dismiss the SDK Black Friday notice for the current user.
+ *
+ * Called when the user dismisses the Optimole banner. It also hides the SDK
+ * notice of the other ThemeIsle products.
+ *
+ * @return void
+ */
+ public static function dismiss_sdk_bf_notice() {
+ /**
+ * The current date.
+ *
+ * @var DateTime $now Current date.
+ */
+ $now = apply_filters( 'themeisle_sdk_current_date', new \DateTime( 'now' ) );
+
+ update_user_meta( get_current_user_id(), self::SDK_BF_DISMISS_META, $now->getTimestamp() );
+ }
+
/**
* Get the black friday notices.
*
@@ -1705,10 +1741,11 @@ public function get_bf_notices( $user_plan ) {
'' . $promo_code . '',
'' . __( '25% discount', 'optimole-wp' ) . ''
),
- 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm25', 'sidebarnotice' ) ),
+ 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm', 'sidebarnotice' ) ),
];
- if ( get_option( self::BF_PROMO_DISMISS_KEY ) === 'yes' ) {
+ // The banner shares the SDK dismissal, which resets every year.
+ if ( self::is_sdk_bf_notice_dismissed( $now ) ) {
return $notices;
}
@@ -1718,7 +1755,7 @@ public function get_bf_notices( $user_plan ) {
'' . $promo_code . '',
'' . __( '25% discount', 'optimole-wp' ) . ''
);
- $cta_link = esc_url_raw( tsdk_utmify( self::get_upgrade_base_link(), 'bfcm25', 'notice' ) );
+ $cta_link = esc_url_raw( tsdk_utmify( self::get_upgrade_base_link(), 'bfcm', 'notice' ) );
$cta_text = __( 'Claim now', 'optimole-wp' );
$notices['banner'] = [
@@ -1729,7 +1766,7 @@ public function get_bf_notices( $user_plan ) {
'subtitle' => $message,
'cta_text' => $cta_text,
'cta_link' => $cta_link,
- 'dismiss_key' => self::BF_PROMO_DISMISS_KEY,
+ 'dismiss_key' => self::SDK_BF_DISMISS_META,
];
return $notices;
diff --git a/inc/lazyload_replacer.php b/inc/lazyload_replacer.php
index e9c561d3d..de740ce49 100644
--- a/inc/lazyload_replacer.php
+++ b/inc/lazyload_replacer.php
@@ -29,8 +29,6 @@ final class Optml_Lazyload_Replacer extends Optml_App_Replacer {
}';
const IFRAME_PLACEHOLDER_STYLE = '';
- const IFRAME_TEMP_COMMENT = '/** optmliframelazyloadplaceholder */';
-
const SVG_PLACEHOLDER = 'data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20#width#%20#height#%22%20width%3D%22#width#%22%20height%3D%22#height#%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20width%3D%22#width#%22%20height%3D%22#height#%22%20fill%3D%22#fill#%22%2F%3E%3C%2Fsvg%3E';
/**
* If frame lazyload is present on page.
diff --git a/inc/manager.php b/inc/manager.php
index ea43e0968..b55c2de33 100644
--- a/inc/manager.php
+++ b/inc/manager.php
@@ -500,29 +500,6 @@ public function should_send_temporary_cache_header( $sent_headers = null, $do_no
return apply_filters( 'optml_send_temporary_cache_header', $send ) === true;
}
- /**
- * Expand the iframe placeholder marker printed in
, or inject the placeholder style there.
- *
- * Copies of the marker after the head come from page content and are left untouched.
- * The head ends at , or at is omitted.
- *
- * @param string $html Page HTML.
- *
- * @return string HTML with the iframe placeholder CSS added.
- */
- private function add_iframe_placeholder_css( string $html ): string {
- if ( ! preg_match( '/<\/head>|]/i', $html, $head_end, PREG_OFFSET_CAPTURE ) ) {
- return $html;
- }
-
- $head = substr( $html, 0, $head_end[0][1] );
- if ( strpos( $head, Optml_Lazyload_Replacer::IFRAME_TEMP_COMMENT ) !== false ) {
- return str_replace( Optml_Lazyload_Replacer::IFRAME_TEMP_COMMENT, Optml_Lazyload_Replacer::IFRAME_PLACEHOLDER_CLASS, $head ) . substr( $html, $head_end[0][1] );
- }
-
- return preg_replace( '/(.*)<\/head>/ism', ' $1' . Optml_Lazyload_Replacer::IFRAME_PLACEHOLDER_STYLE . '', $html ) ?? $html;
- }
-
/**
* Filter raw HTML content for urls.
*
@@ -564,8 +541,10 @@ public function replace_content( $html, $partial = false ) {
Profile::set_current_profile_id( $profile_id );
$this->page_profiler->set_current_profile_data();
- if ( $should_show_comment ) {
- $html = str_replace( '', '' . $this->page_profiler->get_current_profile_html_comment(), $html );
+ // The last is taken as the document end, so earlier copies in page content stay as written.
+ $html_end = $should_show_comment ? strrpos( $html, '