PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.7.7
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.7.7
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
image-optimization / modules / optimization / assets / js / templates / common / index.js

index.js in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.7.7, at modules/optimization/assets/js/templates/common/index.js

50 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { UPGRADE_LINK } from '../../constants';
3 import { getUpgradeLink } from '../../../../../../assets/dev/js/utils';
4
5 const getErrorButton = ( { errorType, imagesLeft, allowRetry } ) => {
6 const isElementorOne = window?.imageOptimizerUserData?.isElementorOne || false;
7 if ( 'auth-error' === errorType ) {
8 const connectLink = window?.imageOptimizerControlSettings?.connectLink;
9
10 return `
11 <a class="button button-secondary button-large image-optimization-control__button"
12 href="${ connectLink }"
13 target="_blank" rel="noopener noreferrer">
14 ${ __( 'Connect', 'image-optimization' ) }
15 </a>
16 `;
17 } else if ( 'connection-error' === errorType ) {
18 return `
19 <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again"
20 type="button">
21 ${ __( 'Try again', 'image-optimization' ) }
22 </button>
23 `;
24 } else if ( typeof imagesLeft !== 'undefined' && 0 === imagesLeft ) {
25 if ( isElementorOne ) {
26 return '';
27 }
28
29 const subscriptionId = window?.imageOptimizerUserData?.planData?.subscription_id;
30 return `
31 <a class="button button-secondary button-large image-optimization-control__button"
32 href="${ getUpgradeLink( UPGRADE_LINK, subscriptionId ) }"
33 target="_blank" rel="noopener noreferrer">
34 ${ __( 'Upgrade', 'image-optimization' ) }
35 </a>
36 `;
37 } else if ( allowRetry ) {
38 return `
39 <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again"
40 type="button">
41 ${ __( 'Try again', 'image-optimization' ) }
42 </button>
43 `;
44 }
45 };
46
47 export {
48 getErrorButton,
49 };
50