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 | 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 +10 -6
- assets/script.min.js +1 -1
- classes/HomePage.php +2 -2
- classes/Main.php +9 -7
- classes/Update.php +5 -1
- readme.txt +5 -2
- templates/settings-home-page.php +2 -8
- wpacu.php +1 -1
assets/script.js
CHANGED
@@ -182,12 +182,16 @@ jQuery(document).ready(function($) {
|
|
182 |
};
|
183 |
|
184 |
if ('btoa' in window) {
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
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
|
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 |
-
}
|
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 |
-
$
|
130 |
-
$settings = $
|
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 |
-
|
|
|
|
|
|
|
|
|
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 |
-
Stable tag: 1.2.5.
|
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 |
-
}
|
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
|
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" -> "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 -> 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" -> "Reading") OR a special layout (from a theme or plugin) was enabled. When you edit a page/post (e.g. "Posts" -> "All Posts", "Pages" -> "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.
|
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/
|