Skip to content

Commit dabb2c3

Browse files
authored
release: small fixes
* Adds PHP 8.2 compatibility * Update promotions
2 parents 76c09a0 + c72e375 commit dabb2c3

File tree

10 files changed

+117
-50
lines changed

10 files changed

+117
-50
lines changed

assets/js/build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-api', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins'), 'version' => '4990ea029287f2766945');
1+
<?php return array('dependencies' => array('wp-api', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => 'c832265831709a5f577f');

assets/js/build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/build/style-index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/OptimoleNotice/index.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import {__} from '@wordpress/i18n';
21
import {useState} from '@wordpress/element';
32
import {Button} from '@wordpress/components';
43

54
import './style.scss';
65
import {activatePlugin, installPlugin} from "../common/utils";
76
import useSettings from "../common/useSettings";
87

9-
export default function OptimoleNotice({stacked = false, noImage = false, type, onDismiss}) {
8+
export default function OptimoleNotice({stacked = false, noImage = false, type, onDismiss, onSuccess, initialStatus = null }) {
109
const {
1110
assets,
1211
title,
@@ -21,7 +20,7 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
2120
const [showForm, setShowForm] = useState(false);
2221
const [email, setEmail] = useState(initialEmail || '');
2322
const [dismissed, setDismissed] = useState(false);
24-
const [progress, setProgress] = useState(null);
23+
const [progress, setProgress] = useState( initialStatus );
2524
const [getOption, updateOption] = useSettings();
2625

2726

@@ -66,6 +65,10 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
6665
}),
6766
});
6867

68+
if (onSuccess) {
69+
onSuccess();
70+
}
71+
6972
setProgress('done');
7073
} catch (e) {
7174
setProgress('done');
@@ -81,9 +84,9 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
8184
if (progress === 'done') {
8285
return (
8386
<div className={"done"}>
84-
<p>{__('Awesome! You are all set!', 'textdomain')}</p>
87+
<p>Awesome! You are all set!</p>
8588
<Button icon={'external'} isPrimary href={optimoleDash} target="_blank">
86-
{__('Go to Optimole dashboard', 'textdomain')}
89+
Go to Optimole dashboard
8790
</Button>
8891
</div>
8992
);
@@ -94,9 +97,9 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
9497
<p className="om-progress">
9598
<span className="dashicons dashicons-update spin"/>
9699
<span>
97-
{progress === 'installing' && __('Installing', 'textdomain')}
98-
{progress === 'activating' && __('Activating', 'textdomain')}
99-
{progress === 'connecting' && __('Connecting to API', 'textdomain')}
100+
{progress === 'installing' && 'Installing'}
101+
{progress === 'activating' && 'Activating'}
102+
{progress === 'connecting' && 'Connecting to API'}
100103
&hellip;
101104
</span>
102105
</p>
@@ -105,17 +108,17 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
105108

106109
return (
107110
<>
108-
<span>{__('Enter your email address to create & connect your account', 'textdomain')}</span>
111+
<span>Enter your email address to create & connect your account</span>
109112
<form onSubmit={submitForm}>
110113
<input
111114
defaultValue={email}
112115
type="email"
113116
onChange={updateEmail}
114-
placeholder={__('Email address', 'textdomain')}
117+
placeholder="Email address"
115118
/>
116119

117120
<Button isPrimary type="submit">
118-
{__('Start using Optimole', 'textdomain')}
121+
Start using Optimole
119122
</Button>
120123
</form>
121124
</>
@@ -136,23 +139,23 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
136139
<div className="ti-om-stack-wrap">
137140
<div className="om-stack-notice">
138141
{dismissButton()}
139-
<img src={assets + '/optimole-logo.svg'} alt={__('Optimole logo', 'textdomain')}/>
142+
<img src={assets + '/optimole-logo.svg'} alt="Optimole logo"/>
140143

141-
<h2>{__('Get more with Optimole', 'textdomain')}</h2>
144+
<h2>Get more with Optimole</h2>
142145

143146
<p>
144-
{type === 'om-editor' ?
145-
__('Increase this page speed and SEO ranking by optimizing images with Optimole.', 'textdomain') :
146-
__('Leverage Optimole\'s full integration with Elementor to automatically lazyload, resize, compress to AVIF/WebP and deliver from 400 locations around the globe!', 'textdomain')
147+
{(type === 'om-editor' || type === 'om-image-block') ?
148+
'Increase this page speed and SEO ranking by optimizing images with Optimole.' :
149+
'Leverage Optimole\'s full integration with Elementor to automatically lazyload, resize, compress to AVIF/WebP and deliver from 400 locations around the globe!'
147150
}
148151
</p>
149152

150-
{!showForm && (
153+
{( !showForm && 'done' !== progress ) && (
151154
<Button isPrimary onClick={toggleForm} className="cta">
152-
{__('Get Started Free', 'textdomain')}
155+
Get Started Free
153156
</Button>
154157
)}
155-
{showForm && form()}
158+
{( showForm || 'done' === progress ) && form()}
156159

157160
<i>{title}</i>
158161
</div>
@@ -164,22 +167,22 @@ export default function OptimoleNotice({stacked = false, noImage = false, type,
164167
<>
165168
{dismissButton()}
166169
<div className="content">
167-
{!noImage && <img src={assets + '/optimole-logo.svg'} alt={__('Optimole logo', 'textdomain')}/>}
170+
{!noImage && <img src={assets + '/optimole-logo.svg'} alt="Optimole logo"/>}
168171

169172
<div>
170173
<p>{title}</p>
171174
<p className="description">{
172175
type === 'om-media' ?
173-
__('Save your server space by storing images to Optimole and deliver them optimized from 400 locations around the globe. Unlimited images, Unlimited traffic.', 'textdomain') :
174-
__('Optimize, store and deliver this image with 80% less size while looking just as great, using Optimole.', 'textdomain')
176+
'Save your server space by storing images to Optimole and deliver them optimized from 400 locations around the globe. Unlimited images, Unlimited traffic.' :
177+
'This image looks to be too large and would affect your site speed, we recommend you to install Optimole to optimize your images.'
175178
}</p>
176179
{!showForm && (
177180
<div className="actions">
178181
<Button isPrimary onClick={toggleForm}>
179-
{__('Get Started Free', 'textdomain')}
182+
Get Started Free
180183
</Button>
181184
<Button isLink target="_blank" href="https://wordpress.org/plugins/optimole-wp">
182-
{__('Learn more', 'textdomain')}
185+
Learn more
183186
</Button>
184187
</div>
185188
)}

assets/js/src/OptimoleNotice/style.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@
177177
}
178178
}
179179

180+
.block-editor-block-inspector {
181+
.ti-om-stack-wrap {
182+
border-top: 1px solid #e0e0e0;
183+
}
184+
}
185+
180186

181187
.om-progress {
182188
gap: 5px;

assets/js/src/common/useSettings.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*/
44
import api from '@wordpress/api';
55

6-
import { __ } from '@wordpress/i18n';
7-
86
import { dispatch } from '@wordpress/data';
97

108
import {
@@ -56,7 +54,7 @@ const useSettings = () => {
5654
return settings?.[option];
5755
};
5856

59-
const updateOption = ( option, value, success = __( 'Settings saved.', 'textdomain' ) ) => {
57+
const updateOption = ( option, value, success = 'Settings saved.' ) => {
6058
setStatus( 'saving' );
6159

6260
const save = new api.models.Settings({ [option]: value }).save();
@@ -80,7 +78,7 @@ const useSettings = () => {
8078

8179
createNotice(
8280
'error',
83-
__( 'An unknown error occurred.', 'textdomain' ),
81+
'An unknown error occurred.',
8482
{
8583
isDismissible: true,
8684
type: 'snackbar'
@@ -96,7 +94,7 @@ const useSettings = () => {
9694

9795
createNotice(
9896
'error',
99-
response.responseJSON.message ? response.responseJSON.message : __( 'An unknown error occurred.', 'textdomain' ),
97+
response.responseJSON.message ? response.responseJSON.message : 'An unknown error occurred.',
10098
{
10199
isDismissible: true,
102100
type: 'snackbar'

assets/js/src/optimole.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import {render, unmountComponentAtNode, useState} from '@wordpress/element';
1+
import {Fragment, render, unmountComponentAtNode, useState} from '@wordpress/element';
22
import {registerPlugin,} from '@wordpress/plugins';
33
import {PluginPostPublishPanel} from '@wordpress/edit-post';
44
import {useSelect} from '@wordpress/data';
5+
import {createHigherOrderComponent} from '@wordpress/compose';
6+
import {addFilter} from '@wordpress/hooks';
7+
import {InspectorControls} from '@wordpress/block-editor';
58

69
import {getBlocksByType} from "./common/utils";
710
import OptimoleNotice from "./OptimoleNotice";
@@ -62,6 +65,9 @@ class Optimole {
6265
case 'om-editor' :
6366
this.runEditorPromo();
6467
break;
68+
case 'om-image-block' :
69+
this.runImageBlockPromo();
70+
break;
6571
case 'om-elementor' :
6672
this.runElementorPromo();
6773
break;
@@ -100,11 +106,49 @@ class Optimole {
100106
/>, root);
101107
}
102108

109+
runImageBlockPromo() {
110+
if (window.themeisleSDKPromotions.option['om-image-block']) {
111+
return;
112+
}
113+
114+
let showNotice = true;
115+
let initialStatus = null;
116+
117+
const withImagePromo = createHigherOrderComponent( BlockEdit => {
118+
return props => {
119+
if ( 'core/image' === props.name && showNotice ) {
120+
return (
121+
<Fragment>
122+
<BlockEdit { ...props } />
123+
<InspectorControls>
124+
<OptimoleNotice
125+
stacked
126+
type="om-image-block"
127+
initialStatus={ initialStatus }
128+
onDismiss={() => {
129+
showNotice = false;
130+
}}
131+
onSuccess={() => {
132+
initialStatus = 'done';
133+
}}
134+
/>
135+
</InspectorControls>
136+
</Fragment>
137+
);
138+
}
139+
140+
return <BlockEdit { ...props } />;
141+
};
142+
}, 'withImagePromo' );
143+
144+
addFilter( 'editor.BlockEdit', 'optimole-promo/image-promo', withImagePromo, 99 );
145+
}
146+
103147
runEditorPromo() {
104148
if (window.themeisleSDKPromotions.option['om-editor']) {
105149
return;
106150
}
107-
registerPlugin('post-publish-panel-test', {
151+
registerPlugin('optimole-promo', {
108152
render: TiSdkMoleEditorPromo,
109153
});
110154
}
@@ -202,6 +246,7 @@ class Optimole {
202246
this.runAttachmentPromo();
203247
this.runMediaPromo();
204248
this.runEditorPromo();
249+
this.runImageBlockPromo();
205250
this.runElementorPromo();
206251
}
207252
}

assets/js/src/otter.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {__} from '@wordpress/i18n';
21
import {InspectorControls} from '@wordpress/block-editor';
32
import {Button, PanelBody} from '@wordpress/components';
43
import {createHigherOrderComponent} from '@wordpress/compose';
@@ -36,18 +35,18 @@ const style = {
3635

3736
const upsells = {
3837
'blocks-css': {
39-
title: __('Custom CSS', 'textdomain'),
40-
description: __('Enable Otter Blocks to add Custom CSS for this block.'),
38+
title: 'Custom CSS',
39+
description: 'Enable Otter Blocks to add Custom CSS for this block.',
4140
image: 'css.jpg'
4241
},
4342
'blocks-animation': {
44-
title: __('Animations', 'textdomain'),
45-
description: __('Enable Otter Blocks to add Animations for this block.'),
43+
title: 'Animations',
44+
description: 'Enable Otter Blocks to add Animations for this block.',
4645
image: 'animation.jpg'
4746
},
4847
'blocks-conditions': {
49-
title: __('Visibility Conditions', 'textdomain'),
50-
description: __('Enable Otter Blocks to add Visibility Conditions for this block.'),
48+
title: 'Visibility Conditions',
49+
description: 'Enable Otter Blocks to add Visibility Conditions for this block.',
5150
image: 'conditions.jpg'
5251
}
5352
};
@@ -60,9 +59,9 @@ const Footer = ({onClick}) => {
6059
variant="tertiary"
6160
onClick={onClick}
6261
>
63-
{__('Skip for now')}
62+
Skip for now
6463
</Button>
65-
<span style={style.skip.poweredby}>{__('Recommended by ') + window.themeisleSDKPromotions.product}</span>
64+
<span style={style.skip.poweredby}>Recommended by {window.themeisleSDKPromotions.product}</span>
6665
</div>
6766
);
6867
};
@@ -88,7 +87,7 @@ const withInspectorControls = createHigherOrderComponent((BlockEdit) => {
8887

8988
const Install = () => {
9089
if ('installed' === installStatus) {
91-
return <p><strong>{__('Awesome! Refresh the page to see Otter Blocks in action.')}</strong></p>;
90+
return <p><strong>Awesome! Refresh the page to see Otter Blocks in action.</strong></p>;
9291
}
9392

9493
return (
@@ -98,7 +97,7 @@ const withInspectorControls = createHigherOrderComponent((BlockEdit) => {
9897
isBusy={isLoading}
9998
style={style.button}
10099
>
101-
{__('Install & Activate Otter Blocks')}
100+
Install & Activate Otter Blocks
102101
</Button>
103102
);
104103
};

0 commit comments

Comments
 (0)