Skip to content
Merged

Release #1228

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4fe75f8
Sync branch [skip ci]
pirate-bot Nov 4, 2026
a565443
Sync branch [skip ci]
pirate-bot Nov 4, 2026
7e99825
Improved selected compression mode contrast (#1225)
girishpanchal30 Nov 5, 2026
ed124d4
Update codeinwp/optimole-sdk to 1.3.0 (#1230)
selul Nov 5, 2026
55741ef
chore(deps-dev): bump phpstan/phpstan from 2.3.3 to 2.3.4 (#1229)
dependabot[bot] Nov 5, 2026
eb31d9b
Supported media rename and video blocks on older WP versions (#1208)
girishpanchal30 Nov 5, 2026
42a09a2
fix(bf): share the SDK Black Friday dismissal and show the banner aga…
Soare-Robert-Daniel Nov 6, 2026
41e3246
chore(deps): bump codeinwp/themeisle-sdk from 3.3.71 to 3.3.72
dependabot[bot] Nov 9, 2026
43fb433
Encode inline optimizer configuration as JSON (#1233)
selul Nov 10, 2026
0a7451a
chore(deps-dev): bump phpstan/phpstan from 2.3.4 to 2.3.5 (#1234)
dependabot[bot] Nov 11, 2026
3efef42
Merge pull request #1232 from Codeinwp/dependabot/composer/developmen…
vytisbulkevicius Nov 11, 2026
0a83994
fix: replace only the background CSS markers printed in the same request
vytisbulkevicius Nov 11, 2026
afdd9bb
fix: give every page placeholder the request token
vytisbulkevicius Nov 11, 2026
9bd87bf
fix: add the root class and the debug comment only to the document it…
vytisbulkevicius Nov 11, 2026
736a7c7
fix: skip HTML comments when finding the root html tag
vytisbulkevicius Nov 11, 2026
cd077d3
fix: keep stored objects unchanged when replacing renamed attachment …
vytisbulkevicius Nov 11, 2026
e5d0f4e
fix: move and delete attachment files only inside the uploads directory
vytisbulkevicius Nov 11, 2026
6b3e021
fix: leave serialized values the renamer cannot read safely as stored
vytisbulkevicius Nov 11, 2026
a8c1f00
fix: add the iframe placeholder style at the real head end and the ro…
vytisbulkevicius Nov 11, 2026
c80a201
fix: replace only attachment files inside the uploads directory
vytisbulkevicius Nov 11, 2026
d663326
fix: add the iframe placeholder style after the head start tag
vytisbulkevicius Nov 11, 2026
eb2d262
fix: leave plain text that starts like a serialized string to the tex…
vytisbulkevicius Nov 11, 2026
dcbbcbd
fix: check the scaled offload path and keep backslashes in folder names
vytisbulkevicius Nov 11, 2026
a22e359
fix: keep the development fallback for the iframe placeholder style
vytisbulkevicius Nov 11, 2026
d6849fa
test: cover backslash folder names inside uploads and the replace err…
vytisbulkevicius Nov 11, 2026
86bfe2d
fix: add the iframe placeholder style only where the plugin printed i…
vytisbulkevicius Nov 11, 2026
f23a9e2
test: share the outside-uploads helpers and cover the replace scaled …
vytisbulkevicius Nov 11, 2026
ab3253b
fix: print the iframe placeholder style in the plugin head
vytisbulkevicius Nov 11, 2026
8a5a836
test: drop the plain-text probe test, which passes on the base
vytisbulkevicius Nov 11, 2026
e3c6b70
test: drop the iframe flag reset the placeholder tests no longer need
vytisbulkevicius Nov 12, 2026
6861701
fix: rewrite serialized values stored in strings of serialized data
vytisbulkevicius Nov 12, 2026
ab2198d
fix: keep links to image sizes the rename leaves in place
vytisbulkevicius Nov 12, 2026
b7fe113
docs: use a type hint the coding standard accepts
vytisbulkevicius Nov 12, 2026
42abe22
test: pin the nesting cap and the class restriction of nested values
vytisbulkevicius Nov 12, 2026
36e4da7
perf: look up kept size suffixes by key
vytisbulkevicius Nov 12, 2026
d71c6e8
fix: keep nested values that cannot be read safely, and handle serial…
vytisbulkevicius Nov 12, 2026
0207995
fix: rename size links only for size files the rename moved
vytisbulkevicius Nov 12, 2026
73544e2
fix: check nested values for references, and keep padded string lengt…
vytisbulkevicius Nov 12, 2026
6f70beb
test: cover escaped links of moved sizes and an empty moved list
vytisbulkevicius Nov 12, 2026
fa309fb
fix: read padded lengths and both float precisions, and share the rea…
vytisbulkevicius Nov 12, 2026
4f55b0b
fix: keep links to a size whose file another size moved, and drop the…
vytisbulkevicius Nov 12, 2026
1aad97f
Merge pull request #1236 from Codeinwp/fix/viewport-bg-marker-token
vytisbulkevicius Nov 12, 2026
a2514a5
Merge pull request #1238 from Codeinwp/fix/rename-path-checks
vytisbulkevicius Nov 12, 2026
7f612ea
Merge pull request #1237 from Codeinwp/fix/rename-serialized-values
vytisbulkevicius Nov 12, 2026
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
5 changes: 2 additions & 3 deletions assets/src/dashboard/parts/connected/Toasts.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
64 changes: 42 additions & 22 deletions assets/src/dashboard/parts/connected/settings/Compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
BaseControl,
Button,
Icon,
RadioControl,
RangeControl,
ToggleControl,

Expand Down Expand Up @@ -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 = (
<div className="mb-4">
<strong>{optimoleDashboardApp.strings.options_strings.compression_mode}</strong>
</div>
);

return (
<>

<ToggleGroupControl className=" w-4/6"
aria-label={ optimoleDashboardApp.strings.options_strings.compression_mode }
onChange={ value => transformCompressionMode( value ) }
value={ compressionMode }
label={ (
<div className="mb-4">
<strong>{optimoleDashboardApp.strings.options_strings.compression_mode}</strong>
</div>
) }
>
<ToggleGroupControlOption className="bg-blue-500"
label={ optimoleDashboardApp.strings.options_strings.compression_mode_speed_optimized }
value="speed_optimized"
{ /* ToggleGroupControl ships with WordPress 5.9. */ }
{ ToggleGroupControl ? (
<ToggleGroupControl className=" w-4/6"
aria-label={ optimoleDashboardApp.strings.options_strings.compression_mode }
onChange={ value => transformCompressionMode( value ) }
value={ compressionMode }
label={ compressionModeLabel }
>
{ compressionModes.map( mode => (
<ToggleGroupControlOption key={ mode.value } { ...mode } />
) ) }
</ToggleGroupControl>
) : (
<RadioControl
label={ compressionModeLabel }
selected={ compressionMode }
options={ compressionModes }
onChange={ value => transformCompressionMode( value ) }
/>
<ToggleGroupControlOption
label={ optimoleDashboardApp.strings.options_strings.compression_mode_quality_optimized }
value="quality_optimized"
/>
<ToggleGroupControlOption
label={ optimoleDashboardApp.strings.options_strings.compression_mode_custom }
value="custom"
/>
</ToggleGroupControl>
) }
{'speed_optimized' === compressionMode && (
<p className="text-sm text-gray-600 mb-20">
{optimoleDashboardApp.strings.options_strings.compression_mode_speed_optimized_desc}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 => (
<input
key={ option.value }
type="radio"
value={ option.value }
checked={ selected === option.value }
onChange={ () => 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(
<Compression
settings={ { compression_mode: 'quality_optimized' } }
setSettings={ setSettings }
setCanSave={ jest.fn() }
showSample={ false }
isSampleLoading={ false }
setIsSampleLoading={ jest.fn() }
/>
);
});

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'
}) );
});
});
5 changes: 5 additions & 0 deletions assets/src/dashboard/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 12 additions & 4 deletions assets/src/dashboard/utils/__tests__/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => ({}),
Expand All @@ -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 = {
Expand All @@ -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', () => {
Expand Down
6 changes: 4 additions & 2 deletions assets/src/dashboard/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -52,7 +54,7 @@ const {
getSiteSettings
} = select( 'optimole' );

const { createNotice } = dispatch( noticesStore );
const { createNotice } = dispatch( 'core/notices' );


export const sendOnboardingImages = ( data = {}) => {
Expand Down
11 changes: 8 additions & 3 deletions assets/src/widget/index.js
Original file line number Diff line number Diff line change
@@ -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( <App /> );
// createRoot ships with WordPress 6.2 (React 18).
if ( createRoot ) {
createRoot( container ).render( <App /> );
} else {
render( <App />, container );
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
32 changes: 16 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading