Asset CleanUp: Page Speed Booster - Version 1.2.5.2

Version Description

  • Bug Fix: Unload on All Pages of [post_type_here] post type wasn't keeping previous records when choosing new values to unload
Download this release

Release Info

Developer gabelivan
Plugin Icon 128x128 Asset CleanUp: Page Speed Booster
Version 1.2.5.2
Comparing to
See all releases

Code changes from version 1.2.5.1 to 1.2.5.2

assets/script.js CHANGED
@@ -182,12 +182,16 @@ jQuery(document).ready(function($) {
182
};
183
184
if ('btoa' in window) {
185
- // Non-Latin Characters get stripped
186
- // We only need the content related to the assets
187
- contents = contents.replace(/[\u0250-\ue007]/g, '');
188
- contents = contents.replace(/[^\x00-\x7F]/g, '');
189
-
190
- data.contents = window.btoa(contents);
191
}
192
193
//console.log(data);
182
};
183
184
if ('btoa' in window) {
185
+ try {
186
+ // Non-Latin Characters get stripped
187
+ // We only need the content related to the assets
188
+ contents = contents.replace(/[\u0250-\ue007]/g, '');
189
+ contents = contents.replace(/[^\x00-\x7F]/g, '');
190
+
191
+ data.contents = window.btoa(contents);
192
+ } catch(err) {
193
+ data.contents = '';
194
+ }
195
}
196
197
//console.log(data);
assets/script.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){var b={load:function(){var b,c=".icheckbox_square-red";a(c).iCheck({checkboxClass:"icheckbox_square-red"}),a(c).on("ifChecked",function(b){a(b.target).closest("tr").addClass("wpacu_not_load")}),a(c).on("ifUnchecked",function(b){a(b.target).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_global_unload").click(function(){b=a(this).attr("data-handle"),a(this).prop("checked")?a(this).parent("label").addClass("wpacu_global_checked"):a(this).parent("label").removeClass("wpacu_global_checked")}),a(".wpacu_post_type_unload").click(function(){a(this).prop("checked")?a(this).parent("label").addClass("wpacu_post_type_unload_active"):a(this).parent("label").removeClass("wpacu_post_type_unload_active")}),a(".wpacu_load_it_option").click(function(){var b=a(this).attr("data-handle");if(a(this).prop("checked")){a(this).parent("label").addClass("wpacu_global_unload_exception");var c="";a(this).hasClass("wpacu_style")?c="style":a(this).hasClass("wpacu_script")&&(c="script"),a("#"+c+"_"+b).iCheck("uncheck")}else a(this).parent("label").removeClass("wpacu_global_unload_exception")})}};if(a("#wpacu_post_type_select").change(function(){a("#wpacu_post_type_form").submit()}),a(".wpacu_remove_rule").click(function(){var b=a(this).parents(".wpacu_global_rule_row");a(this).prop("checked")?b.addClass("selected"):b.removeClass("selected")}),a("#wpacu_wrap_assets").length>0&&b.load(),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;var c={};"direct"===wpacu_object.dom_get_type?(c[wpacu_object.plugin_name+"_load"]=1,a.post(wpacu_object.post_url,c,function(c){var d=c.substring(c.lastIndexOf(wpacu_object.start_del)+wpacu_object.start_del.length,c.lastIndexOf(wpacu_object.end_del)),e={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list:d,post_id:wpacu_object.post_id,post_url:wpacu_object.post_url};"btoa"in window&&(c=c.replace(/[\u0250-\ue007]/g,""),c=c.replace(/[^\x00-\x7F]/g,""),e.contents=window.btoa(c)),a.post(wpacu_object.ajax_url,e,function(c){return!!c&&(a("#wpacu_meta_box_content").html(c),a("#wpacu_home_page_form").length>0&&a("#submit").show(),void b.load())})})):"wp_remote_post"===wpacu_object.dom_get_type&&(c={action:wpacu_object.plugin_name+"_get_loaded_assets",post_id:wpacu_object.post_id,post_url:wpacu_object.post_url},a.post(wpacu_object.ajax_url,c,function(c){return!!c&&(a("#wpacu_meta_box_content").html(c),a("#wpacu_home_page_form").length>0&&a("#submit").show(),void b.load())}))});
1
+ jQuery(document).ready(function(a){var b={load:function(){var b,c=".icheckbox_square-red";a(c).iCheck({checkboxClass:"icheckbox_square-red"}),a(c).on("ifChecked",function(b){a(b.target).closest("tr").addClass("wpacu_not_load")}),a(c).on("ifUnchecked",function(b){a(b.target).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_global_unload").click(function(){b=a(this).attr("data-handle"),a(this).prop("checked")?a(this).parent("label").addClass("wpacu_global_checked"):a(this).parent("label").removeClass("wpacu_global_checked")}),a(".wpacu_post_type_unload").click(function(){a(this).prop("checked")?a(this).parent("label").addClass("wpacu_post_type_unload_active"):a(this).parent("label").removeClass("wpacu_post_type_unload_active")}),a(".wpacu_load_it_option").click(function(){var b=a(this).attr("data-handle");if(a(this).prop("checked")){a(this).parent("label").addClass("wpacu_global_unload_exception");var c="";a(this).hasClass("wpacu_style")?c="style":a(this).hasClass("wpacu_script")&&(c="script"),a("#"+c+"_"+b).iCheck("uncheck")}else a(this).parent("label").removeClass("wpacu_global_unload_exception")})}};if(a("#wpacu_post_type_select").change(function(){a("#wpacu_post_type_form").submit()}),a(".wpacu_remove_rule").click(function(){var b=a(this).parents(".wpacu_global_rule_row");a(this).prop("checked")?b.addClass("selected"):b.removeClass("selected")}),a("#wpacu_wrap_assets").length>0&&b.load(),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;var c={};"direct"===wpacu_object.dom_get_type?(c[wpacu_object.plugin_name+"_load"]=1,a.post(wpacu_object.post_url,c,function(c){var d=c.substring(c.lastIndexOf(wpacu_object.start_del)+wpacu_object.start_del.length,c.lastIndexOf(wpacu_object.end_del)),e={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list:d,post_id:wpacu_object.post_id,post_url:wpacu_object.post_url};if("btoa"in window)try{c=c.replace(/[\u0250-\ue007]/g,""),c=c.replace(/[^\x00-\x7F]/g,""),e.contents=window.btoa(c)}catch(a){e.contents=""}a.post(wpacu_object.ajax_url,e,function(c){return!!c&&(a("#wpacu_meta_box_content").html(c),a("#wpacu_home_page_form").length>0&&a("#submit").show(),void b.load())})})):"wp_remote_post"===wpacu_object.dom_get_type&&(c={action:wpacu_object.plugin_name+"_get_loaded_assets",post_id:wpacu_object.post_id,post_url:wpacu_object.post_url},a.post(wpacu_object.ajax_url,c,function(c){return!!c&&(a("#wpacu_meta_box_content").html(c),a("#wpacu_home_page_form").length>0&&a("#submit").show(),void b.load())}))});
classes/HomePage.php CHANGED
@@ -24,7 +24,7 @@ class HomePage
24
25
// Only continue if we are on the plugin's homepage edit mode
26
if (! $isHomePageEdit) {
27
- return '';
28
}
29
30
if ($this->data['show_on_front'] === 'page') {
@@ -40,7 +40,7 @@ class HomePage
40
if ($this->data['page_for_posts']) {
41
$this->data['page_for_posts_title'] = get_the_title($this->data['page_for_posts']);
42
}
43
- } elseif ($this->data['show_on_front'] === 'posts') {
44
// Your latest posts
45
$postUrl = get_site_url();
46
24
25
// Only continue if we are on the plugin's homepage edit mode
26
if (! $isHomePageEdit) {
27
+ return;
28
}
29
30
if ($this->data['show_on_front'] === 'page') {
40
if ($this->data['page_for_posts']) {
41
$this->data['page_for_posts_title'] = get_the_title($this->data['page_for_posts']);
42
}
43
+ } else {
44
// Your latest posts
45
$postUrl = get_site_url();
46
classes/Main.php CHANGED
@@ -104,6 +104,8 @@ class Main
104
*/
105
public $postTypesUnloaded = array();
106
107
/**
108
* @var Main|null
109
*/
@@ -126,14 +128,14 @@ class Main
126
*/
127
public function __construct()
128
{
129
- $wpacuSettings = new Settings();
130
- $settings = $wpacuSettings->getAll();
131
132
- $this->frontendShow = $settings['frontend_show'];
133
- $this->dashboardShow = $settings['dashboard_show'];
134
135
- if ($this->dashboardShow && $settings['dom_get_type'] != '') {
136
- self::$domGetType = $settings['dom_get_type'];
137
}
138
139
if (array_key_exists(WPACU_PLUGIN_NAME.'_load', $_POST)) {
@@ -171,7 +173,7 @@ class Main
171
172
// Do not load the meta box nor do any AJAX calls
173
// if the asset management is not enabled for the Dashboard
174
- if ($settings['dashboard_show'] == 1) {
175
// Send an AJAX request to get the list of loaded scripts and styles and print it nicely
176
add_action(
177
'wp_ajax_'. WPACU_PLUGIN_NAME . '_get_loaded_assets',
104
*/
105
public $postTypesUnloaded = array();
106
107
+ public $settings = array();
108
+
109
/**
110
* @var Main|null
111
*/
128
*/
129
public function __construct()
130
{
131
+ $wpacuSettingsClass = new Settings();
132
+ $this->settings = $wpacuSettingsClass->getAll();
133
134
+ $this->frontendShow = $this->settings['frontend_show'];
135
+ $this->dashboardShow = $this->settings['dashboard_show'];
136
137
+ if ($this->dashboardShow && $this->settings['dom_get_type'] != '') {
138
+ self::$domGetType = $this->settings['dom_get_type'];
139
}
140
141
if (array_key_exists(WPACU_PLUGIN_NAME.'_load', $_POST)) {
173
174
// Do not load the meta box nor do any AJAX calls
175
// if the asset management is not enabled for the Dashboard
176
+ if ($this->settings['dashboard_show'] == 1) {
177
// Send an AJAX request to get the list of loaded scripts and styles and print it nicely
178
add_action(
179
'wp_ajax_'. WPACU_PLUGIN_NAME . '_get_loaded_assets',
classes/Update.php CHANGED
@@ -442,7 +442,11 @@ class Update
442
443
if ($bulkType === 'post_type') {
444
foreach ($values as $postType => $handles) {
445
- $existingList[$assetType]['post_type'][$postType] = array_unique($handles);
446
}
447
}
448
}
442
443
if ($bulkType === 'post_type') {
444
foreach ($values as $postType => $handles) {
445
+ foreach (array_unique($handles) as $handle) {
446
+ $existingList[ $assetType ]['post_type'][ $postType ][] = $handle;
447
+ }
448
+
449
+ $existingList[ $assetType ]['post_type'][ $postType ] = array_unique($existingList[ $assetType ]['post_type'][ $postType ]);
450
}
451
}
452
}
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: gabelivan
3
Tags: speed, pagespeed, dequeue style, dequeue script, unload style, unload script, fast
4
Donate link: https://www.gabelivan.com/donate/
5
Requires at least: 4.0
6
- Tested up to: 4.7.8
7
- Stable tag: 1.2.5.1
8
License: GPLv3
9
License URI: http://www.gnu.org/licenses/gpl.html
10
@@ -102,6 +102,9 @@ If that's the case, then it's advisable to consult with a developer (ideally the
102
4. Scripts (.JS) are selected for site-wide unload
103
104
== Changelog ==
105
= 1.2.5.1 =
106
* Bug Fix: Better accuracy for determining the current post ID and whether the page is the home page
107
3
Tags: speed, pagespeed, dequeue style, dequeue script, unload style, unload script, fast
4
Donate link: https://www.gabelivan.com/donate/
5
Requires at least: 4.0
6
+ Tested up to: 4.9
7
+ Stable tag: 1.2.5.2
8
License: GPLv3
9
License URI: http://www.gnu.org/licenses/gpl.html
10
102
4. Scripts (.JS) are selected for site-wide unload
103
104
== Changelog ==
105
+ = 1.2.5.2 =
106
+ * Bug Fix: Unload on All Pages of [post_type_here] post type wasn't keeping previous records when choosing new values to unload
107
+
108
= 1.2.5.1 =
109
* Bug Fix: Better accuracy for determining the current post ID and whether the page is the home page
110
templates/settings-home-page.php CHANGED
@@ -45,12 +45,12 @@ if ($data['show_on_front'] === 'page') {
45
</div>
46
<p><?php echo sprintf(__('To read more about creating a static front page in WordPress, %scheck the Codex%s.', WPACU_PLUGIN_NAME), '<a href="https://codex.wordpress.org/Creating_a_Static_Front_Page">', '</a>'); ?></p>
47
<?php
48
- } elseif ($data['show_on_front'] == 'posts') {
49
?>
50
<form id="wpacu_home_page_form" method="post" action="">
51
<p><?php echo sprintf(__('Your front (home) page URL is <strong>%s</strong>'), $data['site_url']); ?></p>
52
53
- <p><?php _e('Here you can manage the assets that are not loading for the home page. It is only applicable if "Front page displays" is set to "Your latest posts" (in "Settings" -&gt; "Reading"). When you edit a page/post (e.g. "Posts" -&gt; "All Posts", "Pages" -&gt; "All Pages" etc.), you will see the list inside a meta box.', WPACU_PLUGIN_NAME); ?></p>
54
55
<p>The plugin uses <a target="_blank" href="https://codex.wordpress.org/Function_Reference/is_front_page">is_front_page()</a> and <a href="https://codex.wordpress.org/Conditional_Tags#The_Main_Page">is_home()</a> WordPress functions to check if the visitor is on the home page. Note that the setting will also apply to pages such as <code>/page/2</code> <code>page/3</code> etc. in case the latest blog posts are paginated.</p>
56
@@ -69,10 +69,4 @@ if ($data['show_on_front'] === 'page') {
69
<p class="submit"><input type="submit" name="submit" id="submit" class="hidden button button-primary" value="<?php esc_attr_e('Update', WPACU_PLUGIN_NAME); ?>"></p>
70
</form>
71
<?php
72
- } else {
73
- ?>
74
- <p>It looks like in "Settings" -&gt; "Reading" (/wp-admin/options-reading.php), you have neither of the following options checked: "Your latest posts" and "A static page (select below)".</p>
75
- <p>Your theme or a plugin could interfere with it. Consider enabling "Manage in the Front-end?" in plugin's settings (WP Asset CleanUp -&gt; Settings). This should show the list of all assets at the bottom of your home page on front-end view (only if you're logged in).</p>
76
- <p>If you already tried the suggested option and still can't make it work, <a href="https://wordpress.org/support/plugin/wp-asset-clean-up">please open a ticket</a> on the plugin's support page.</p>
77
- <?php
78
}
45
</div>
46
<p><?php echo sprintf(__('To read more about creating a static front page in WordPress, %scheck the Codex%s.', WPACU_PLUGIN_NAME), '<a href="https://codex.wordpress.org/Creating_a_Static_Front_Page">', '</a>'); ?></p>
47
<?php
48
+ } else {
49
?>
50
<form id="wpacu_home_page_form" method="post" action="">
51
<p><?php echo sprintf(__('Your front (home) page URL is <strong>%s</strong>'), $data['site_url']); ?></p>
52
53
+ <p><?php _e('Here you can unload assets that are loading on the home page. "Front page displays" (from "Settings" - "Reading") is set to either "Your latest posts" (in "Settings" -&gt; "Reading") OR a special layout (from a theme or plugin) was enabled. When you edit a page/post (e.g. "Posts" -&gt; "All Posts", "Pages" -&gt; "All Pages" etc.), you will see the list inside a meta box.', WPACU_PLUGIN_NAME); ?></p>
54
55
<p>The plugin uses <a target="_blank" href="https://codex.wordpress.org/Function_Reference/is_front_page">is_front_page()</a> and <a href="https://codex.wordpress.org/Conditional_Tags#The_Main_Page">is_home()</a> WordPress functions to check if the visitor is on the home page. Note that the setting will also apply to pages such as <code>/page/2</code> <code>page/3</code> etc. in case the latest blog posts are paginated.</p>
56
69
<p class="submit"><input type="submit" name="submit" id="submit" class="hidden button button-primary" value="<?php esc_attr_e('Update', WPACU_PLUGIN_NAME); ?>"></p>
70
</form>
71
<?php
72
}
wpacu.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
* Plugin Name: WP Asset CleanUp (Page Speed Optimizer)
4
* Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
- * Version: 1.2.5.1
6
* Description: Prevent Chosen Scripts & Styles from loading in Posts/Pages that you don't need
7
* Author: Gabriel Livan
8
* Author URI: http://www.gabelivan.com/
2
/*
3
* Plugin Name: WP Asset CleanUp (Page Speed Optimizer)
4
* Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
+ * Version: 1.2.5.2
6
* Description: Prevent Chosen Scripts & Styles from loading in Posts/Pages that you don't need
7
* Author: Gabriel Livan
8
* Author URI: http://www.gabelivan.com/