Version Description
- Bug Fix: Sometimes the assets exceptions list (when disabled globally) for the homepage is not loaded from the right source
Download this release
Release Info
Developer | gabelivan |
Plugin | ![]() |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.2.1
- assets/style.css +8 -5
- assets/style.scss +0 -200
- classes/HomePage.php +2 -50
- classes/Main.php +28 -14
- classes/Menu.php +5 -5
- classes/Settings.php +1 -2
- readme.txt +8 -2
- templates/settings-plugin.php +4 -2
- wpacu-load.php +4 -2
- wpacu.php +1 -1
assets/style.css
CHANGED
@@ -108,6 +108,9 @@ ul.wpacu_asset_options {
|
|
108 |
margin-right: 4px; }
|
109 |
|
110 |
/* Assets Table */
|
|
|
|
|
|
|
111 |
.wpacu_widefat {
|
112 |
border: 1px solid #e5e5e5 !important; }
|
113 |
.wpacu_widefat td {
|
@@ -117,9 +120,9 @@ ul.wpacu_asset_options {
|
|
117 |
background-color: #f9f9f9 !important; }
|
118 |
|
119 |
.wpacu_update_btn {
|
120 |
-
-moz-box-shadow: inset
|
121 |
-
-webkit-box-shadow: inset
|
122 |
-
box-shadow: inset
|
123 |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7)) !important;
|
124 |
background: -moz-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
125 |
background: -webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
@@ -138,7 +141,7 @@ ul.wpacu_asset_options {
|
|
138 |
font-size: 15px !important;
|
139 |
padding: 10px 24px !important;
|
140 |
text-decoration: none !important;
|
141 |
-
text-shadow:
|
142 |
.wpacu_update_btn:hover {
|
143 |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1)) !important;
|
144 |
background: -moz-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
@@ -150,4 +153,4 @@ ul.wpacu_asset_options {
|
|
150 |
background-color: #0061a7 !important; }
|
151 |
.wpacu_update_btn:active {
|
152 |
position: relative !important;
|
153 |
-
top: 1px !important; }
|
108 |
margin-right: 4px; }
|
109 |
|
110 |
/* Assets Table */
|
111 |
+
.wp-asset-clean-up.widefat {
|
112 |
+
width: 99%; }
|
113 |
+
|
114 |
.wpacu_widefat {
|
115 |
border: 1px solid #e5e5e5 !important; }
|
116 |
.wpacu_widefat td {
|
120 |
background-color: #f9f9f9 !important; }
|
121 |
|
122 |
.wpacu_update_btn {
|
123 |
+
-moz-box-shadow: inset 0 1px 0 0 #54a3f7 !important;
|
124 |
+
-webkit-box-shadow: inset 0 1px 0 0 #54a3f7 !important;
|
125 |
+
box-shadow: inset 0 1px 0 0 #54a3f7 !important;
|
126 |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7)) !important;
|
127 |
background: -moz-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
128 |
background: -webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
141 |
font-size: 15px !important;
|
142 |
padding: 10px 24px !important;
|
143 |
text-decoration: none !important;
|
144 |
+
text-shadow: 0 1px 0 #154682 !important; }
|
145 |
.wpacu_update_btn:hover {
|
146 |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1)) !important;
|
147 |
background: -moz-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
153 |
background-color: #0061a7 !important; }
|
154 |
.wpacu_update_btn:active {
|
155 |
position: relative !important;
|
156 |
+
top: 1px !important; }
|
assets/style.scss
DELETED
@@ -1,200 +0,0 @@
|
|
1 |
-
tr.wpacu_not_load {
|
2 |
-
th, td {
|
3 |
-
background: #FFE1E1;
|
4 |
-
}
|
5 |
-
}
|
6 |
-
|
7 |
-
.widefat .check-column.wpacu_check {
|
8 |
-
padding: 10px;
|
9 |
-
}
|
10 |
-
|
11 |
-
#wpacu_meta_box_content {
|
12 |
-
width: 99%;
|
13 |
-
|
14 |
-
h3 {
|
15 |
-
margin-left: 0;
|
16 |
-
padding-left: 0;
|
17 |
-
}
|
18 |
-
div.wpacu_note {
|
19 |
-
padding: 10px;
|
20 |
-
background-color: #f5f5f5;
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
#wpacu_wrap_assets div.wpacu_note {
|
25 |
-
padding: 10px;
|
26 |
-
background-color: #f5f5f5;
|
27 |
-
}
|
28 |
-
|
29 |
-
#wpacu_meta_box_content div.wpacu_warning, #wpacu_wrap_assets div.wpacu_warning {
|
30 |
-
border: 1px solid #cc0000;
|
31 |
-
}
|
32 |
-
|
33 |
-
#wpacu_meta_box_content {
|
34 |
-
div.wpacu_verified {
|
35 |
-
padding: 10px;
|
36 |
-
background-color: #f5f5f5;
|
37 |
-
border-left: 1px solid #ddd;
|
38 |
-
span {
|
39 |
-
color: #0073aa;
|
40 |
-
font-weight: bold;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
ul.wpacu_asset_options {
|
44 |
-
margin: 0;
|
45 |
-
padding: 0;
|
46 |
-
li {
|
47 |
-
list-style: none;
|
48 |
-
display: inline-block;
|
49 |
-
}
|
50 |
-
label {
|
51 |
-
margin-right: 20px;
|
52 |
-
font-weight: normal;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
/*
|
58 |
-
* Asset List Styling: Front-end and Back-end
|
59 |
-
*/
|
60 |
-
|
61 |
-
#wpacu_wrap_assets {
|
62 |
-
color: #000000 !important;
|
63 |
-
text-align: left;
|
64 |
-
clear: both;
|
65 |
-
width: 90%;
|
66 |
-
padding: 20px;
|
67 |
-
margin: 30px 0 0 15px;
|
68 |
-
border: 1px solid #cdcdcd;
|
69 |
-
z-index: 10000 !important;
|
70 |
-
position: relative;
|
71 |
-
background-color: white;
|
72 |
-
img {
|
73 |
-
display: inline-block !important;
|
74 |
-
}
|
75 |
-
p {
|
76 |
-
margin: 10px 0;
|
77 |
-
line-height: 22px;
|
78 |
-
text-align: left;
|
79 |
-
}
|
80 |
-
h1 {
|
81 |
-
margin: 0 0 20px;
|
82 |
-
font-size: 160%;
|
83 |
-
text-align: left;
|
84 |
-
}
|
85 |
-
h3 {
|
86 |
-
margin: 20px 0;
|
87 |
-
font-size: 130%;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
.wpacu_verified {
|
92 |
-
margin: 0 0 10px 0;
|
93 |
-
}
|
94 |
-
|
95 |
-
.wpacu_asset_row td {
|
96 |
-
padding: 10px;
|
97 |
-
p {
|
98 |
-
margin-bottom: 10px;
|
99 |
-
word-wrap: break-word;
|
100 |
-
}
|
101 |
-
label {
|
102 |
-
cursor: pointer !important;
|
103 |
-
display: inline-block !important;
|
104 |
-
font-size: 100%;
|
105 |
-
font-weight: normal;
|
106 |
-
span {
|
107 |
-
font-size: 100% !important;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
&.wpacu_check {
|
111 |
-
width: 50px;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
/* Dashboard adjust */
|
116 |
-
|
117 |
-
body.wp-admin .wpacu_asset_row td.wpacu_check {
|
118 |
-
width: 25px;
|
119 |
-
}
|
120 |
-
|
121 |
-
label {
|
122 |
-
&.wpacu_add_global {
|
123 |
-
cursor: pointer;
|
124 |
-
}
|
125 |
-
&.wpacu_global_checked {
|
126 |
-
font-weight: bold;
|
127 |
-
color: #d54e21;
|
128 |
-
}
|
129 |
-
&.wpacu_global_unload_exception {
|
130 |
-
font-weight: bold;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
ul.wpacu_asset_options {
|
135 |
-
margin: 0;
|
136 |
-
padding: 0;
|
137 |
-
li {
|
138 |
-
list-style: none;
|
139 |
-
display: inline-block;
|
140 |
-
}
|
141 |
-
label {
|
142 |
-
margin-right: 20px;
|
143 |
-
font-weight: normal;
|
144 |
-
input {
|
145 |
-
margin-right: 4px;
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
/* Assets Table */
|
151 |
-
|
152 |
-
.wpacu_widefat {
|
153 |
-
border: 1px solid #e5e5e5 !important;
|
154 |
-
td {
|
155 |
-
border: 1px solid #e5e5e5 !important;
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
.wpacu_striped > tbody > :nth-child(odd), ul.wpacu_striped > :nth-child(odd) {
|
160 |
-
background-color: #f9f9f9 !important;
|
161 |
-
}
|
162 |
-
|
163 |
-
.wpacu_update_btn {
|
164 |
-
-moz-box-shadow: inset 0px 1px 0px 0px #54a3f7 !important;
|
165 |
-
-webkit-box-shadow: inset 0px 1px 0px 0px #54a3f7 !important;
|
166 |
-
box-shadow: inset 0px 1px 0px 0px #54a3f7 !important;
|
167 |
-
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7)) !important;
|
168 |
-
background: -moz-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
169 |
-
background: -webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
170 |
-
background: -o-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
171 |
-
background: -ms-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
172 |
-
background: linear-gradient(to bottom, #007dc1 5%, #0061a7 100%) !important;
|
173 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#007dc1', endColorstr='#0061a7',GradientType=0) !important;
|
174 |
-
background-color: #007dc1 !important;
|
175 |
-
-moz-border-radius: 3px !important;
|
176 |
-
-webkit-border-radius: 3px !important;
|
177 |
-
border-radius: 3px !important;
|
178 |
-
border: 1px solid #124d77 !important;
|
179 |
-
display: inline-block !important;
|
180 |
-
cursor: pointer !important;
|
181 |
-
color: #ffffff !important;
|
182 |
-
font-size: 15px !important;
|
183 |
-
padding: 10px 24px !important;
|
184 |
-
text-decoration: none !important;
|
185 |
-
text-shadow: 0px 1px 0px #154682 !important;
|
186 |
-
&:hover {
|
187 |
-
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1)) !important;
|
188 |
-
background: -moz-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
189 |
-
background: -webkit-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
190 |
-
background: -o-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
191 |
-
background: -ms-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
192 |
-
background: linear-gradient(to bottom, #0061a7 5%, #007dc1 100%) !important;
|
193 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0061a7', endColorstr='#007dc1',GradientType=0) !important;
|
194 |
-
background-color: #0061a7 !important;
|
195 |
-
}
|
196 |
-
&:active {
|
197 |
-
position: relative !important;
|
198 |
-
top: 1px !important;
|
199 |
-
}
|
200 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/HomePage.php
CHANGED
@@ -12,23 +12,6 @@ class HomePage
|
|
12 |
*/
|
13 |
public $data = array();
|
14 |
|
15 |
-
/**
|
16 |
-
* @var HomePage|null
|
17 |
-
*/
|
18 |
-
private static $singleton = null;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @return null|HomePage
|
22 |
-
*/
|
23 |
-
public static function instance()
|
24 |
-
{
|
25 |
-
if (is_null(self::$singleton)) {
|
26 |
-
self::$singleton = new self();
|
27 |
-
}
|
28 |
-
|
29 |
-
return self::$singleton;
|
30 |
-
}
|
31 |
-
|
32 |
/**
|
33 |
* Settings constructor.
|
34 |
*/
|
@@ -61,43 +44,12 @@ class HomePage
|
|
61 |
}
|
62 |
|
63 |
$this->data['site_url'] = $postUrl;
|
64 |
-
|
65 |
-
add_action('admin_head', array($this, 'inlineAdminHead'));
|
66 |
-
|
67 |
add_action('admin_enqueue_scripts', array(Main::instance(), 'stylesAndScriptsForAdmin'));
|
68 |
}
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
/**
|
73 |
-
*
|
74 |
-
*/
|
75 |
-
public function init()
|
76 |
-
{
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
*
|
81 |
-
*/
|
82 |
-
public function inlineAdminHead()
|
83 |
-
{
|
84 |
-
?>
|
85 |
-
<style type="text/css">
|
86 |
-
.wp-asset-clean-up.widefat {
|
87 |
-
width: 99%;
|
88 |
-
}
|
89 |
-
</style>
|
90 |
-
<?php
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
*
|
95 |
-
*/
|
96 |
-
public function introPage()
|
97 |
-
{
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
/**
|
102 |
* @param $wpacuNoLoadAssets
|
103 |
*/
|
@@ -133,7 +85,7 @@ class HomePage
|
|
133 |
|
134 |
$noncePost = isset($_POST[$this->data['nonce_name']])
|
135 |
? $_POST[$this->data['nonce_name']] : '';
|
136 |
-
|
137 |
if (is_array($wpacuNoLoadAssets) && wp_verify_nonce($noncePost, $this->data['nonce_name'])) {
|
138 |
$this->updateFrontPage($wpacuNoLoadAssets);
|
139 |
}
|
12 |
*/
|
13 |
public $data = array();
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* Settings constructor.
|
17 |
*/
|
44 |
}
|
45 |
|
46 |
$this->data['site_url'] = $postUrl;
|
47 |
+
|
|
|
|
|
48 |
add_action('admin_enqueue_scripts', array(Main::instance(), 'stylesAndScriptsForAdmin'));
|
49 |
}
|
50 |
}
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* @param $wpacuNoLoadAssets
|
55 |
*/
|
85 |
|
86 |
$noncePost = isset($_POST[$this->data['nonce_name']])
|
87 |
? $_POST[$this->data['nonce_name']] : '';
|
88 |
+
|
89 |
if (is_array($wpacuNoLoadAssets) && wp_verify_nonce($noncePost, $this->data['nonce_name'])) {
|
90 |
$this->updateFrontPage($wpacuNoLoadAssets);
|
91 |
}
|
classes/Main.php
CHANGED
@@ -119,11 +119,14 @@ class Main
|
|
119 |
|
120 |
// Front-end View - Unload the assets
|
121 |
if (! isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
122 |
-
// Unload Scripts
|
123 |
add_action('wp_print_scripts', array($this, 'filterScripts'), 100000);
|
124 |
-
add_action('wp_print_footer_scripts', array($this, 'filterScripts'), 100000);
|
125 |
|
126 |
-
// Unload
|
|
|
|
|
|
|
|
|
127 |
add_action('wp_print_styles', array($this, 'filterStyles'), 100000);
|
128 |
}
|
129 |
|
@@ -232,7 +235,8 @@ class Main
|
|
232 |
// Post, Page or Front-page?
|
233 |
$toRemove = $this->getAssetsUnloaded();
|
234 |
|
235 |
-
if
|
|
|
236 |
return;
|
237 |
}
|
238 |
|
@@ -317,7 +321,8 @@ class Main
|
|
317 |
// Post, Page or Front-page
|
318 |
$toRemove = $this->getAssetsUnloaded();
|
319 |
|
320 |
-
if
|
|
|
321 |
return;
|
322 |
}
|
323 |
|
@@ -494,12 +499,18 @@ class Main
|
|
494 |
$exceptionsListJson = '';
|
495 |
$exceptionsListEmpty = $exceptionsList = array('styles' => array(), 'scripts' => array());
|
496 |
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
498 |
$exceptionsListJson = get_post_meta(
|
499 |
$postId, '_' . WPACU_PLUGIN_NAME . '_load_exceptions',
|
500 |
true
|
501 |
);
|
502 |
} elseif ($type == 'front_page') {
|
|
|
503 |
$exceptionsListJson = get_option(
|
504 |
WPACU_PLUGIN_NAME . '_front_page_load_exceptions'
|
505 |
);
|
@@ -519,6 +530,7 @@ class Main
|
|
519 |
/**
|
520 |
* @param string $type
|
521 |
* @param string $postId
|
|
|
522 |
*/
|
523 |
public function saveLoadExceptions($type = 'post', $postId = '')
|
524 |
{
|
@@ -550,7 +562,7 @@ class Main
|
|
550 |
}
|
551 |
|
552 |
// Load Exception
|
553 |
-
if
|
554 |
foreach ($_POST['wpacu_styles_load_it'] as $wpacuHandle) {
|
555 |
// Do not append it if the global unload is removed
|
556 |
if (isset($_POST['wpacu_options_styles'][$wpacuHandle])
|
@@ -970,6 +982,8 @@ class Main
|
|
970 |
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
971 |
$getPostId = (isset($_GET['post'])) ? (int)$_GET['post'] : '';
|
972 |
|
|
|
|
|
973 |
if (isset($post->ID)) {
|
974 |
$this->loadPluginAssets = true;
|
975 |
}
|
@@ -979,7 +993,7 @@ class Main
|
|
979 |
}
|
980 |
|
981 |
if ($page == WPACU_PLUGIN_NAME.'_home_page'
|
982 |
-
&&
|
983 |
) {
|
984 |
$this->loadPluginAssets = true;
|
985 |
}
|
@@ -1020,10 +1034,10 @@ class Main
|
|
1020 |
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
1021 |
|
1022 |
$getPostId = (isset($_GET['post'])
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
|
1028 |
$postId = (isset($post->ID)) ? $post->ID : 0;
|
1029 |
|
@@ -1035,7 +1049,7 @@ class Main
|
|
1035 |
$postId = 0; // for home page
|
1036 |
}
|
1037 |
|
1038 |
-
// Not home page (posts list)? See if the
|
1039 |
if ($postId > 0) {
|
1040 |
$postStatus = get_post_status($postId);
|
1041 |
|
@@ -1316,7 +1330,7 @@ class Main
|
|
1316 |
}
|
1317 |
|
1318 |
if ($this->assetsRemoved == '') {
|
1319 |
-
$this->assetsRemoved = array('styles' => array(), 'scripts' => array
|
1320 |
}
|
1321 |
}
|
1322 |
|
119 |
|
120 |
// Front-end View - Unload the assets
|
121 |
if (! isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
122 |
+
// Unload Scripts - HEAD
|
123 |
add_action('wp_print_scripts', array($this, 'filterScripts'), 100000);
|
|
|
124 |
|
125 |
+
// Unload Scripts - FOOTER
|
126 |
+
// Needs to be triggered very soon as some old plugins/themes use wp_footer() to enqueue scripts
|
127 |
+
add_action('wp_print_footer_scripts', array($this, 'filterScripts'), 1);
|
128 |
+
|
129 |
+
// Unload Styles - HEAD only
|
130 |
add_action('wp_print_styles', array($this, 'filterStyles'), 100000);
|
131 |
}
|
132 |
|
235 |
// Post, Page or Front-page?
|
236 |
$toRemove = $this->getAssetsUnloaded();
|
237 |
|
238 |
+
// if null or array (string has to be returned)
|
239 |
+
if (! $toRemove || is_array($toRemove)) {
|
240 |
return;
|
241 |
}
|
242 |
|
321 |
// Post, Page or Front-page
|
322 |
$toRemove = $this->getAssetsUnloaded();
|
323 |
|
324 |
+
// if null or array (string has to be returned)
|
325 |
+
if (! $toRemove || is_array($toRemove)) {
|
326 |
return;
|
327 |
}
|
328 |
|
499 |
$exceptionsListJson = '';
|
500 |
$exceptionsListEmpty = $exceptionsList = array('styles' => array(), 'scripts' => array());
|
501 |
|
502 |
+
$homepageClass = new HomePage;
|
503 |
+
|
504 |
+
// Post or Post of the Homepage (if chosen in the Dashboard)
|
505 |
+
if ($type == 'post'
|
506 |
+
|| $homepageClass->data['show_on_front'] === 'page'
|
507 |
+
) {
|
508 |
$exceptionsListJson = get_post_meta(
|
509 |
$postId, '_' . WPACU_PLUGIN_NAME . '_load_exceptions',
|
510 |
true
|
511 |
);
|
512 |
} elseif ($type == 'front_page') {
|
513 |
+
// The home page could also be the list of the latest blog posts
|
514 |
$exceptionsListJson = get_option(
|
515 |
WPACU_PLUGIN_NAME . '_front_page_load_exceptions'
|
516 |
);
|
530 |
/**
|
531 |
* @param string $type
|
532 |
* @param string $postId
|
533 |
+
* @return bool
|
534 |
*/
|
535 |
public function saveLoadExceptions($type = 'post', $postId = '')
|
536 |
{
|
562 |
}
|
563 |
|
564 |
// Load Exception
|
565 |
+
if (isset($_POST['wpacu_styles_load_it']) && ! empty($_POST['wpacu_styles_load_it'])) {
|
566 |
foreach ($_POST['wpacu_styles_load_it'] as $wpacuHandle) {
|
567 |
// Do not append it if the global unload is removed
|
568 |
if (isset($_POST['wpacu_options_styles'][$wpacuHandle])
|
982 |
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
983 |
$getPostId = (isset($_GET['post'])) ? (int)$_GET['post'] : '';
|
984 |
|
985 |
+
$homepageClass = new HomePage;
|
986 |
+
|
987 |
if (isset($post->ID)) {
|
988 |
$this->loadPluginAssets = true;
|
989 |
}
|
993 |
}
|
994 |
|
995 |
if ($page == WPACU_PLUGIN_NAME.'_home_page'
|
996 |
+
&& $homepageClass->data['show_on_front'] === 'posts'
|
997 |
) {
|
998 |
$this->loadPluginAssets = true;
|
999 |
}
|
1034 |
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
1035 |
|
1036 |
$getPostId = (isset($_GET['post'])
|
1037 |
+
&& isset($_GET['action'])
|
1038 |
+
&& $_GET['action'] === 'edit'
|
1039 |
+
&& $pagenow == 'post.php')
|
1040 |
+
? (int)$_GET['post'] : '';
|
1041 |
|
1042 |
$postId = (isset($post->ID)) ? $post->ID : 0;
|
1043 |
|
1049 |
$postId = 0; // for home page
|
1050 |
}
|
1051 |
|
1052 |
+
// Not home page (posts list)? See if the individual post is published to continue
|
1053 |
if ($postId > 0) {
|
1054 |
$postStatus = get_post_status($postId);
|
1055 |
|
1330 |
}
|
1331 |
|
1332 |
if ($this->assetsRemoved == '') {
|
1333 |
+
$this->assetsRemoved = json_encode(array('styles' => array(), 'scripts' => array()));
|
1334 |
}
|
1335 |
}
|
1336 |
|
classes/Menu.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
namespace WpAssetCleanUp;
|
3 |
|
|
|
|
|
|
|
|
|
4 |
class Menu
|
5 |
{
|
6 |
/**
|
7 |
* Menu constructor.
|
8 |
*/
|
9 |
public function __construct()
|
10 |
-
{
|
11 |
-
}
|
12 |
-
|
13 |
-
public function init()
|
14 |
{
|
15 |
add_action('admin_menu', array($this, 'activeMenu'));
|
16 |
}
|
@@ -38,7 +38,7 @@ class Menu
|
|
38 |
__('Home Page', WPACU_PLUGIN_NAME),
|
39 |
$capability,
|
40 |
WPACU_PLUGIN_NAME.'_home_page',
|
41 |
-
array(HomePage
|
42 |
);
|
43 |
|
44 |
$GLOBALS['submenu'][$menuSlug][0][0] = esc_attr__('Settings', WPACU_PLUGIN_NAME);
|
1 |
<?php
|
2 |
namespace WpAssetCleanUp;
|
3 |
|
4 |
+
/**
|
5 |
+
* Class Menu
|
6 |
+
* @package WpAssetCleanUp
|
7 |
+
*/
|
8 |
class Menu
|
9 |
{
|
10 |
/**
|
11 |
* Menu constructor.
|
12 |
*/
|
13 |
public function __construct()
|
|
|
|
|
|
|
|
|
14 |
{
|
15 |
add_action('admin_menu', array($this, 'activeMenu'));
|
16 |
}
|
38 |
__('Home Page', WPACU_PLUGIN_NAME),
|
39 |
$capability,
|
40 |
WPACU_PLUGIN_NAME.'_home_page',
|
41 |
+
array(new HomePage, 'page')
|
42 |
);
|
43 |
|
44 |
$GLOBALS['submenu'][$menuSlug][0][0] = esc_attr__('Settings', WPACU_PLUGIN_NAME);
|
classes/Settings.php
CHANGED
@@ -22,7 +22,7 @@ class Settings
|
|
22 |
{
|
23 |
// Register settings
|
24 |
register_setting('wpacu-plugin-settings-group', WPACU_PLUGIN_NAME.'_frontend_show');
|
25 |
-
|
26 |
register_setting('wpacu-global-settings-group', WPACU_PLUGIN_NAME.'_global_styles_unload');
|
27 |
register_setting('wpacu-global-settings-group', WPACU_PLUGIN_NAME.'_global_scripts_unload');
|
28 |
}
|
@@ -33,7 +33,6 @@ class Settings
|
|
33 |
public static function settingsPage()
|
34 |
{
|
35 |
$data = array();
|
36 |
-
|
37 |
$data['frontend_show'] = get_option(WPACU_PLUGIN_NAME.'_frontend_show');
|
38 |
|
39 |
Main::instance()->parseTemplate('settings-plugin', $data, true);
|
22 |
{
|
23 |
// Register settings
|
24 |
register_setting('wpacu-plugin-settings-group', WPACU_PLUGIN_NAME.'_frontend_show');
|
25 |
+
|
26 |
register_setting('wpacu-global-settings-group', WPACU_PLUGIN_NAME.'_global_styles_unload');
|
27 |
register_setting('wpacu-global-settings-group', WPACU_PLUGIN_NAME.'_global_scripts_unload');
|
28 |
}
|
33 |
public static function settingsPage()
|
34 |
{
|
35 |
$data = array();
|
|
|
36 |
$data['frontend_show'] = get_option(WPACU_PLUGIN_NAME.'_frontend_show');
|
37 |
|
38 |
Main::instance()->parseTemplate('settings-plugin', $data, true);
|
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: http://www.gabelivan.com/donate/
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.2
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
@@ -92,6 +92,12 @@ If that's the case, then it's advisable to consult with a developer (ideally the
|
|
92 |
4. Scripts (.JS) are selected for site-wide unload
|
93 |
|
94 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
= 1.2 =
|
96 |
* Disable assets site-wide
|
97 |
* Add exceptions on pages where assets should load (if they are disabled everywhere)
|
3 |
Tags: speed, pagespeed, dequeue style, dequeue script, unload style, unload script, fast
|
4 |
Donate link: http://www.gabelivan.com/donate/
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.6.1
|
7 |
+
Stable tag: 1.2.2
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
92 |
4. Scripts (.JS) are selected for site-wide unload
|
93 |
|
94 |
== Changelog ==
|
95 |
+
= 1.2.2 =
|
96 |
+
* Bug Fix: Sometimes scripts in the footer were not detected for unloading
|
97 |
+
|
98 |
+
= 1.2.1 =
|
99 |
+
* Bug Fix: Sometimes the assets exceptions list (when disabled globally) for the homepage is not loaded from the right source
|
100 |
+
|
101 |
= 1.2 =
|
102 |
* Disable assets site-wide
|
103 |
* Add exceptions on pages where assets should load (if they are disabled everywhere)
|
templates/settings-plugin.php
CHANGED
@@ -15,8 +15,10 @@ if (! isset($data)) {
|
|
15 |
<?php do_settings_sections('wpacu-plugin-settings-group'); ?>
|
16 |
<table class="form-table">
|
17 |
<tr valign="top">
|
18 |
-
<th scope="row">
|
19 |
-
|
|
|
|
|
20 |
<?php echo (($data['frontend_show'] == 1) ? 'checked="checked"' : ''); ?>
|
21 |
name="<?php echo WPACU_PLUGIN_NAME.'_frontend_show'; ?>"
|
22 |
value="1" /> <small>If you are logged in, this will make the list of assets show below the page that you view (either home page, a post or a page).</small>
|
15 |
<?php do_settings_sections('wpacu-plugin-settings-group'); ?>
|
16 |
<table class="form-table">
|
17 |
<tr valign="top">
|
18 |
+
<th scope="row">
|
19 |
+
<label for="wpacu_frontend">Manage in the Front-end?</label>
|
20 |
+
</th>
|
21 |
+
<td><input id="wpacu_frontend" type="checkbox"
|
22 |
<?php echo (($data['frontend_show'] == 1) ? 'checked="checked"' : ''); ?>
|
23 |
name="<?php echo WPACU_PLUGIN_NAME.'_frontend_show'; ?>"
|
24 |
value="1" /> <small>If you are logged in, this will make the list of assets show below the page that you view (either home page, a post or a page).</small>
|
wpacu-load.php
CHANGED
@@ -39,6 +39,8 @@ WpAssetCleanUp\Main::instance();
|
|
39 |
// Settings
|
40 |
new WpAssetCleanUp\Settings;
|
41 |
|
|
|
|
|
|
|
42 |
// Menu
|
43 |
-
|
44 |
-
$wpacuMenu->init();
|
39 |
// Settings
|
40 |
new WpAssetCleanUp\Settings;
|
41 |
|
42 |
+
// HomePage
|
43 |
+
new WpAssetCleanUp\HomePage;
|
44 |
+
|
45 |
// Menu
|
46 |
+
new \WpAssetCleanUp\Menu;
|
|
wpacu.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
* Plugin Name: WP Asset Clean Up
|
4 |
* Plugin URI: http://www.bitrepository.com/remove-unused-scripts-styles-wordpress-pages.html
|
5 |
-
* Version: 1.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 Clean Up
|
4 |
* Plugin URI: http://www.bitrepository.com/remove-unused-scripts-styles-wordpress-pages.html
|
5 |
+
* Version: 1.2.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/
|