Skip to content

Commit 9f023bc

Browse files
authored
Merge pull request #898 from Codeinwp/feat/opml-service/1347
Add optimizaiton tips in sidebar
2 parents a0cdd5f + c07eb35 commit 9f023bc

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* WordPress dependencies.
3+
*/
4+
import { Icon } from '@wordpress/components';
5+
import { closeSmall, check } from '@wordpress/icons';
6+
7+
import { useSelect } from '@wordpress/data';
8+
9+
const OptimizationStatus = () => {
10+
const statuses = useSelect( select => {
11+
const { getSiteSettings } = select( 'optimole' );
12+
const siteSettings = getSiteSettings();
13+
return [
14+
{
15+
active: 'enabled' === siteSettings?.image_replacer,
16+
label: optimoleDashboardApp.strings.optimization_status.statusTitle1,
17+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle1
18+
},
19+
{
20+
active: 'enabled' === siteSettings?.lazyload,
21+
label: optimoleDashboardApp.strings.optimization_status.statusTitle2,
22+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle2
23+
},
24+
{
25+
active: 'disabled' === siteSettings?.scale,
26+
label: optimoleDashboardApp.strings.optimization_status.statusTitle3,
27+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle3
28+
}
29+
];
30+
});
31+
32+
return (
33+
<div className="bg-white flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
34+
<h3 className="text-base m-0">{ optimoleDashboardApp.strings.optimization_status.title }</h3>
35+
<ul>
36+
{ statuses.map( ( status, index ) => {
37+
let statusClass = status.active ? 'success' : 'danger';
38+
return (
39+
<li
40+
key={ index }
41+
className="flex items-start gap-2"
42+
>
43+
{ status.active ? (
44+
<Icon icon={check} className="fill-success bg-success/20 rounded-full" size={20} />
45+
) : (
46+
<Icon icon={closeSmall} className="fill-danger bg-danger/20 rounded-full" size={20} />
47+
) }
48+
49+
<div>
50+
<span className='text-gray-700 font-normal font-semibold'>
51+
{ status.label }
52+
</span>
53+
<p className="m-0">{ status.description }</p>
54+
</div>
55+
</li>
56+
);
57+
}) }
58+
</ul>
59+
<p
60+
className="m-0 mt-3"
61+
dangerouslySetInnerHTML={ {
62+
__html: optimoleDashboardApp.strings.optimization_tips
63+
} }
64+
/>
65+
</div>
66+
);
67+
};
68+
69+
export default OptimizationStatus;

assets/src/dashboard/parts/connected/Sidebar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { useSelect } from '@wordpress/data';
1212
import { addQueryArgs } from '@wordpress/url';
1313

1414
import SPCRecommendation from './SPCRecommendation';
15+
import OptimizationStatus from './OptimizationStatus';
16+
1517
const reasons = [
1618
optimoleDashboardApp.strings.upgrade.reason_1,
1719
optimoleDashboardApp.strings.upgrade.reason_2,
@@ -125,6 +127,8 @@ const Sidebar = () => {
125127
</Button>
126128
) }
127129

130+
<OptimizationStatus />
131+
128132
{ showSPCRecommendation && (
129133
<SPCRecommendation />
130134
) }

inc/admin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,21 @@ private function get_dashboard_strings() {
20722072
],
20732073
'cron_error' => sprintf( /* translators: 1 is code to disable cron, 2 value of the constant */ __( 'It seems that you have the %1$s constant defined as %2$s. The offloading process uses cron events to offload the images in the background. Please remove the constant from your wp-config.php file in order for the offloading process to work.', 'optimole-wp' ), '<code>DISABLE_WP_CRON</code>', '<code>true</code>' ),
20742074
'cancel' => __( 'Cancel', 'optimole-wp' ),
2075+
'optimization_status' => [
2076+
'title' => __( 'Optimization Status', 'optimole-wp' ),
2077+
'statusTitle1' => __( 'Image Handling', 'optimole-wp' ),
2078+
'statusSubTitle1' => __( 'All images are optimized automatically', 'optimole-wp' ),
2079+
'statusTitle2' => __( 'Smart Lazy-Loading', 'optimole-wp' ),
2080+
'statusSubTitle2' => __( 'Images load as visitors scroll', 'optimole-wp' ),
2081+
'statusTitle3' => __( 'Image Scalling', 'optimole-wp' ),
2082+
'statusSubTitle3' => __( 'All images are perfectly sized for devices', 'optimole-wp' ),
2083+
],
2084+
'optimization_tips' => sprintf(
2085+
/* translators: 1 is the opening anchor tag, 2 is the closing anchor tag */
2086+
__( '%1$sView all optimization tips%2$s', 'optimole-wp' ),
2087+
'<a class="flex justify-center font-bold rounded hover:opacity-90 transition-opacity" href="https://docs.optimole.com/article/2238-optimization-tips" target="_blank"> ',
2088+
'<span style="text-decoration:none; font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>'
2089+
),
20752090
];
20762091
}
20772092

0 commit comments

Comments
 (0)