Skip to content

Commit 644c1f1

Browse files
Merge branch 'development' into fix/issue-695
2 parents e16dbd9 + 60d4341 commit 644c1f1

22 files changed

+368
-48
lines changed

.distignore

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ logs
3232
grunt
3333
tests
3434
dist
35-
build
3635
artifact
3736
assets/vue
3837
.wporg

.github/workflows/build-dev-artifacts.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
branches-ignore:
77
- 'update_dependencies'
88

9-
109
concurrency:
1110
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
1211
cancel-in-progress: true
@@ -84,7 +83,7 @@ jobs:
8483
with:
8584
issue-number: ${{ steps.get-pr-number.outputs.num }}
8685
token: ${{ secrets.BOT_TOKEN }}
87-
comment-author: github-actions[bot]
86+
comment-author: pirate-bot
8887
body-includes: Download [build]
8988

9089
- name: Get comment body
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
pull_request:
3+
types: [closed]
4+
branches:
5+
- 'development'
6+
- 'new/**'
7+
jobs:
8+
pr_announcer:
9+
runs-on: ubuntu-latest
10+
name: Announce pr
11+
steps:
12+
- name: Checking merged commit
13+
uses: Codeinwp/action-pr-merged-announcer@main
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
16+
with:
17+
destination_repo: "Codeinwp/docs"
18+
issue_labels: "optimole"

assets/vue/components/last-images.vue

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
</div>
5353
</div>
5454
<div v-else>
55-
<iframe width="1" height="1" :src="home_url" style="visibility: hidden"></iframe>
5655
<h6 class="has-text-centered">{{strings.loading_latest_images}}</h6>
5756
<progress id="optml-progress-bar" class="progress is-small is-success optml-custom-label-margin" :value="startTime" :max="maxTime"></progress>
5857
</div>

assets/vue/components/lazyload.vue

+48-21
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
<toggle-button :class="'has-text-dark'"
1212
v-model="lazyloadPlaceholder"
1313
:disabled="this.$store.state.loading"
14-
:width="37"
15-
:height="20"
16-
color="#577BF9"></toggle-button>
14+
:width="37"
15+
:height="20"
16+
color="#577BF9"></toggle-button>
1717
</div>
1818
</div>
19-
<hr/>
19+
<hr/>
2020

2121
<div class="field columns optml-flex-column" >
2222
<label class="label column optml-custom-label-margin">
@@ -35,7 +35,7 @@
3535
</div>
3636

3737
</div>
38-
<hr/>
38+
<hr/>
3939
<!--Native lazy toggle-->
4040
<div class="field is-fullwidth columns">
4141
<label class="label column has-text-grey-dark optml-custom-label-margin">
@@ -50,12 +50,12 @@
5050
<toggle-button :class="'has-text-dark'"
5151
v-model="nativeLazyStatus"
5252
:disabled="this.$store.state.loading"
53-
:width="37"
54-
:height="20"
55-
color="#577BF9"></toggle-button>
53+
:width="37"
54+
:height="20"
55+
color="#577BF9"></toggle-button>
5656
</div>
5757
</div>
58-
<hr/>
58+
<hr/>
5959
<div class="field is-fullwidth columns">
6060
<label class="label column has-text-grey-dark optml-custom-label-margin">
6161
{{strings.toggle_scale}}
@@ -69,12 +69,12 @@
6969
<toggle-button :class="'has-text-dark'"
7070
v-model="scaleStatus"
7171
:disabled="this.$store.state.loading"
72-
:width="37"
73-
:height="20"
74-
color="#577BF9"></toggle-button>
72+
:width="37"
73+
:height="20"
74+
color="#577BF9"></toggle-button>
7575
</div>
7676
</div>
77-
<hr/>
77+
<hr/>
7878
<div class="field columns">
7979
<label class="label column has-text-grey-dark optml-custom-label-margin">
8080
{{strings.enable_bg_lazyload_title}}
@@ -86,12 +86,12 @@
8686
<toggle-button :class="'has-text-dark'"
8787
v-model="lazyloadBgImages"
8888
:disabled="this.$store.state.loading"
89-
:width="37"
90-
:height="20"
91-
color="#577BF9"></toggle-button>
89+
:width="37"
90+
:height="20"
91+
color="#577BF9"></toggle-button>
9292
</div>
9393
</div>
94-
<hr/>
94+
<hr/>
9595
<!--Video lazyload toggle-->
9696
<div class="field columns">
9797
<label class="label column has-text-grey-dark optml-custom-label-margin">
@@ -104,12 +104,30 @@
104104
<toggle-button :class="'has-text-dark'"
105105
v-model="lazyloadVideo"
106106
:disabled="this.$store.state.loading"
107-
:width="37"
108-
:height="20"
109-
color="#577BF9"></toggle-button>
107+
:width="37"
108+
:height="20"
109+
color="#577BF9"></toggle-button>
110110
</div>
111111
</div>
112-
<hr/>
112+
<hr/>
113+
<!--Noscript toggle-->
114+
<div class="field columns">
115+
<label class="label column has-text-grey-dark optml-custom-label-margin">
116+
{{strings.enable_noscript_title}}
117+
<p class="optml-settings-desc-margin has-text-weight-normal">
118+
{{strings.enable_noscript_desc}}
119+
</p>
120+
</label>
121+
<div class="column is-1">
122+
<toggle-button :class="'has-text-dark'"
123+
v-model="noscriptToggle"
124+
:disabled="this.$store.state.loading"
125+
:width="37"
126+
:height="20"
127+
color="#577BF9"></toggle-button>
128+
</div>
129+
</div>
130+
<hr/>
113131
<div class="field columns" v-if="showBgSelectors">
114132
<div class="column">
115133
<label class="label has-text-grey-dark optml-custom-label-margin">
@@ -200,6 +218,15 @@
200218
return !(this.site_settings.video_lazyload === 'disabled');
201219
}
202220
},
221+
noscriptToggle: {
222+
set: function (value) {
223+
this.showSave = true;
224+
this.new_data.no_script = value ? 'enabled' : 'disabled';
225+
},
226+
get: function () {
227+
return !(this.site_settings.no_script === 'disabled');
228+
}
229+
},
203230
lazyloadSelectors: {
204231
set: function ( value ) {
205232
this.showSave = true;

assets/vue/store/actions.js

+33-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const connectOptimole = function ( {commit, state}, data ) {
7272
commit( 'toggleHasOptmlApp', true );
7373
}
7474

75+
sendOnboardImages();
76+
7577
console.log( '%c OptiMole API connection successful.', 'color: #59B278' );
7678

7779
} else {
@@ -115,6 +117,7 @@ const registerOptimole = function ( {commit, state}, data ) {
115117
commit( 'updateApiKey', data.apiKey );
116118
commit( 'updateUserData', response.body.data );
117119
commit( 'updateAvailableApps', response.body.data );
120+
sendOnboardImages();
118121
}
119122
return response.data;
120123
},
@@ -284,6 +287,34 @@ const retrieveOptimizedImages = function ( {commit, state}, data ) {
284287
);
285288
};
286289

290+
const sendOnboardImages = function( offset = 0 ) {
291+
Vue.http(
292+
{
293+
url: optimoleDashboardApp.routes['upload_onboard_images'],
294+
method: 'POST',
295+
params: {
296+
offset
297+
},
298+
emulateJSON: true,
299+
headers: {'X-WP-Nonce': optimoleDashboardApp.nonce},
300+
responseType: 'json'
301+
}
302+
).then(
303+
function ( response ) {
304+
if ( false === response.body.data && offset < 1000 ) {
305+
sendOnboardImages( offset + 50 );
306+
}
307+
308+
if ( response.body.code === 'success' ) {
309+
console.log( '%c Images Crawled.', 'color: #59B278' );
310+
}
311+
}
312+
)
313+
.catch( err => {
314+
console.log( 'Error while crawling images', err );
315+
} );
316+
};
317+
287318
const retrieveWatermarks = function ( {commit, state}, data ) {
288319

289320
commit( 'toggleLoading', true );
@@ -587,15 +618,15 @@ const getNumberOfImages = function ( data, commit, consecutiveErrors = 0 ) {
587618
}
588619
} );
589620
};
590-
const getOffloadConflicts = function ({commit, state} ) {
621+
const getOffloadConflicts = function ( {commit, state} ) {
591622
Vue.http( {
592623
url: optimoleDashboardApp.routes['get_offload_conflicts'],
593624
method: 'GET',
594625
headers: {'X-WP-Nonce': optimoleDashboardApp.nonce},
595626
emulateJSON: true,
596627
responseType: 'json',
597628
} ).then( function ( response ) {
598-
commit( 'toggleCheckedOffloadConflicts', true);
629+
commit( 'toggleCheckedOffloadConflicts', true );
599630
if( response.body.data.length !== 0 ) {
600631
commit( 'updateOffloadConflicts', response );
601632
}

composer.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/admin.php

+30
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,28 @@ public function __construct() {
3838
add_action( 'init', [$this, 'check_domain_change'] );
3939
}
4040
add_action( 'admin_init', [ $this, 'maybe_redirect' ] );
41+
add_action( 'admin_init', [ $this, 'init_no_script' ] );
4142
if ( ! is_admin() && $this->settings->is_connected() && ! wp_next_scheduled( 'optml_daily_sync' ) ) {
4243
wp_schedule_event( time() + 10, 'daily', 'optml_daily_sync', [] );
4344
}
4445
add_action( 'optml_after_setup', [ $this, 'register_public_actions' ], 999999 );
4546

47+
if ( ! function_exists( 'is_wpcom_vip' ) ) {
48+
add_filter( 'upload_mimes', [ $this, 'allow_meme_types' ] ); // phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.upload_mimes
49+
}
4650
}
4751

52+
/**
53+
* Init no_script setup value based on whether the user is connected or not.
54+
*/
55+
public function init_no_script() {
56+
if ( $this->settings->is_connected() ) {
57+
$raw_settings = $this->settings->get_raw_settings();
58+
if ( ! isset( $raw_settings['no_script'] ) ) {
59+
$this->settings->update( 'no_script', 'enabled' );
60+
}
61+
}
62+
}
4863
/**
4964
* Checks if domain has changed
5065
*/
@@ -887,6 +902,8 @@ private function get_dashboard_strings() {
887902
'enable_bg_lazyload_title' => __( 'Enable lazyload for background images', 'optimole-wp' ),
888903
'enable_video_lazyload_desc' => __( 'Lazyload iframes/videos', 'optimole-wp' ),
889904
'enable_video_lazyload_title' => __( 'Enable lazyload for embedded videos and iframes.', 'optimole-wp' ),
905+
'enable_noscript_desc' => __( 'The noscript tag offers fallback images for browsers that can\'t handle JavaScript-based lazy loading or related features. Disabling it may resolve conflicts with other plugins or configurations and decrease HTML page size.', 'optimole-wp' ),
906+
'enable_noscript_title' => __( 'Enable noscript tag', 'optimole-wp' ),
890907
'enable_gif_replace_title' => __( 'Enable Gif to Video conversion', 'optimole-wp' ),
891908
'enable_report_title' => __( 'Enable error diagnosis tool', 'optimole-wp' ),
892909
'enable_report_desc' => __( 'Provides a troubleshooting mechanism which should help you identify any possible issues with your site using Optimole.', 'optimole-wp' ),
@@ -1060,4 +1077,17 @@ private function get_dashboard_strings() {
10601077
];
10611078
}
10621079

1080+
/**
1081+
* Allow SVG uploads
1082+
*
1083+
* @param array $mimes Supported mimes.
1084+
*
1085+
* @return array
1086+
* @access public
1087+
* @uses filter:upload_mimes
1088+
*/
1089+
public function allow_meme_types( $mimes ) {
1090+
$mimes['svg'] = 'image/svg+xml';
1091+
return $mimes;
1092+
}
10631093
}

0 commit comments

Comments
 (0)