Asset CleanUp: Page Speed Booster - Version 1.2.5.3

Version Description

  • Bug Fix: PHP Warning when array was passed to json_decode(), instead of string
Download this release

Release Info

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

Code changes from version 1.2.5.2 to 1.2.5.3

Files changed (3) hide show
  1. classes/Main.php +16 -29
  2. readme.txt +4 -1
  3. wpacu.php +1 -1
classes/Main.php CHANGED
@@ -24,10 +24,10 @@ class Main
24
*/
25
public static $domGetType = 'direct';
26
27
- /**
28
- * @var array
29
- */
30
- public $assetsRemoved = array();
31
32
/**
33
* @var array
@@ -104,7 +104,10 @@ class Main
104
*/
105
public $postTypesUnloaded = array();
106
107
- public $settings = array();
108
109
/**
110
* @var Main|null
@@ -294,17 +297,8 @@ class Main
294
// Post, Page or Front-page?
295
$toRemove = $this->getAssetsUnloaded();
296
297
- // if null or array (string has to be returned)
298
- if (! $toRemove || is_array($toRemove)) {
299
- return;
300
- }
301
-
302
$jsonList = @json_decode($toRemove);
303
304
- if (json_last_error()) {
305
- return;
306
- }
307
-
308
$list = array();
309
310
if (isset($jsonList->scripts)) {
@@ -396,17 +390,8 @@ class Main
396
// Post, Page or Front-page
397
$toRemove = $this->getAssetsUnloaded();
398
399
- // if null or array (string has to be returned)
400
- if (! $toRemove || is_array($toRemove)) {
401
- return;
402
- }
403
-
404
$jsonList = @json_decode($toRemove);
405
406
- if (json_last_error()) {
407
- return;
408
- }
409
-
410
$list = array();
411
412
if (isset($jsonList->styles)) {
@@ -1075,7 +1060,7 @@ class Main
1075
1076
/**
1077
* @param int $postId
1078
- * @return array|mixed|string
1079
*/
1080
public function getAssetsUnloaded($postId = 0)
1081
{
@@ -1086,18 +1071,20 @@ class Main
1086
1087
$isInAdminPageViaAjax = (is_admin() && defined('DOING_AJAX') && DOING_AJAX);
1088
1089
- if (! $this->assetsRemoved) {
1090
// For Home Page (latest blog posts)
1091
if ($postId < 1 && ($isInAdminPageViaAjax || Misc::isHomePage())) {
1092
$this->assetsRemoved = get_option(WPACU_PLUGIN_NAME . '_front_page_no_load');
1093
- return $this->assetsRemoved;
1094
} elseif ($postId > 0) {
1095
$this->assetsRemoved = get_post_meta($postId, '_' . WPACU_PLUGIN_NAME . '_no_load', true);
1096
}
1097
1098
- if ($this->assetsRemoved == '') {
1099
- $this->assetsRemoved = json_encode(array('styles' => array(), 'scripts' => array()));
1100
- }
1101
}
1102
1103
return $this->assetsRemoved;
24
*/
25
public static $domGetType = 'direct';
26
27
+ /**
28
+ * @var string
29
+ */
30
+ public $assetsRemoved = '';
31
32
/**
33
* @var array
104
*/
105
public $postTypesUnloaded = array();
106
107
+ /**
108
+ * @var array
109
+ */
110
+ public $settings = array();
111
112
/**
113
* @var Main|null
297
// Post, Page or Front-page?
298
$toRemove = $this->getAssetsUnloaded();
299
300
$jsonList = @json_decode($toRemove);
301
302
$list = array();
303
304
if (isset($jsonList->scripts)) {
390
// Post, Page or Front-page
391
$toRemove = $this->getAssetsUnloaded();
392
393
$jsonList = @json_decode($toRemove);
394
395
$list = array();
396
397
if (isset($jsonList->styles)) {
1060
1061
/**
1062
* @param int $postId
1063
+ * @return string (The returned value must be a JSON one)
1064
*/
1065
public function getAssetsUnloaded($postId = 0)
1066
{
1071
1072
$isInAdminPageViaAjax = (is_admin() && defined('DOING_AJAX') && DOING_AJAX);
1073
1074
+ if (empty($this->assetsRemoved)) {
1075
// For Home Page (latest blog posts)
1076
if ($postId < 1 && ($isInAdminPageViaAjax || Misc::isHomePage())) {
1077
$this->assetsRemoved = get_option(WPACU_PLUGIN_NAME . '_front_page_no_load');
1078
} elseif ($postId > 0) {
1079
$this->assetsRemoved = get_post_meta($postId, '_' . WPACU_PLUGIN_NAME . '_no_load', true);
1080
}
1081
1082
+ @json_decode($this->assetsRemoved);
1083
+
1084
+ if (! (json_last_error() === JSON_ERROR_NONE) || empty($this->assetsRemoved)) {
1085
+ // Reset value to a JSON formatted one
1086
+ $this->assetsRemoved = json_encode(array('styles' => array(), 'scripts' => array()));
1087
+ }
1088
}
1089
1090
return $this->assetsRemoved;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: speed, pagespeed, dequeue style, dequeue script, unload style, unload scri
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,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.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
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.3
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.3 =
106
+ * Bug Fix: PHP Warning when array was passed to json_decode(), instead of string
107
+
108
= 1.2.5.2 =
109
* Bug Fix: Unload on All Pages of [post_type_here] post type wasn't keeping previous records when choosing new values to unload
110
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.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/
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.3
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/