Version Description
- Now the asset list can be updated on the front-end (below the loaded page, post, front page) if feature is enabled in the "Settings"
Download this release
Release Info
Developer | gabelivan |
Plugin | Asset CleanUp: Page Speed Booster |
Version | 1.1.4.6 |
Comparing to | |
See all releases |
Version 1.1.4.6
- assets/icheck/icheck.min.js +11 -0
- assets/icheck/skins/square/red.css +59 -0
- assets/icheck/skins/square/red.png +0 -0
- assets/icheck/skins/square/red@2x.png +0 -0
- assets/img/icon-clean-up.png +0 -0
- assets/img/icon-warning.png +0 -0
- assets/script.js +47 -0
- assets/style.css +37 -0
- classes/HomePage.php +119 -0
- classes/Main.php +1036 -0
- classes/Menu.php +46 -0
- classes/PluginManager.php +10 -0
- classes/Settings.php +42 -0
- readme.txt +115 -0
- templates/meta-box-loaded.php +180 -0
- templates/meta-box.php +20 -0
- templates/settings-frontend.php +29 -0
- templates/settings-home-page.php +58 -0
- templates/settings-plugin.php +30 -0
- wpacu-load.php +48 -0
- wpacu.php +31 -0
assets/icheck/icheck.min.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! iCheck v1.0.2 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */
|
2 |
+
(function(f){function A(a,b,d){var c=a[0],g=/er/.test(d)?_indeterminate:/bl/.test(d)?n:k,e=d==_update?{checked:c[k],disabled:c[n],indeterminate:"true"==a.attr(_indeterminate)||"false"==a.attr(_determinate)}:c[g];if(/^(ch|di|in)/.test(d)&&!e)x(a,g);else if(/^(un|en|de)/.test(d)&&e)q(a,g);else if(d==_update)for(var f in e)e[f]?x(a,f,!0):q(a,f,!0);else if(!b||"toggle"==d){if(!b)a[_callback]("ifClicked");e?c[_type]!==r&&q(a,g):x(a,g)}}function x(a,b,d){var c=a[0],g=a.parent(),e=b==k,u=b==_indeterminate,
|
3 |
+
v=b==n,s=u?_determinate:e?y:"enabled",F=l(a,s+t(c[_type])),B=l(a,b+t(c[_type]));if(!0!==c[b]){if(!d&&b==k&&c[_type]==r&&c.name){var w=a.closest("form"),p='input[name="'+c.name+'"]',p=w.length?w.find(p):f(p);p.each(function(){this!==c&&f(this).data(m)&&q(f(this),b)})}u?(c[b]=!0,c[k]&&q(a,k,"force")):(d||(c[b]=!0),e&&c[_indeterminate]&&q(a,_indeterminate,!1));D(a,e,b,d)}c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"default");g[_add](B||l(a,b)||"");g.attr("role")&&!u&&g.attr("aria-"+(v?n:k),"true");
|
4 |
+
g[_remove](F||l(a,s)||"")}function q(a,b,d){var c=a[0],g=a.parent(),e=b==k,f=b==_indeterminate,m=b==n,s=f?_determinate:e?y:"enabled",q=l(a,s+t(c[_type])),r=l(a,b+t(c[_type]));if(!1!==c[b]){if(f||!d||"force"==d)c[b]=!1;D(a,e,s,d)}!c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"pointer");g[_remove](r||l(a,b)||"");g.attr("role")&&!f&&g.attr("aria-"+(m?n:k),"false");g[_add](q||l(a,s)||"")}function E(a,b){if(a.data(m)){a.parent().html(a.attr("style",a.data(m).s||""));if(b)a[_callback](b);a.off(".i").unwrap();
|
5 |
+
f(_label+'[for="'+a[0].id+'"]').add(a.closest(_label)).off(".i")}}function l(a,b,f){if(a.data(m))return a.data(m).o[b+(f?"":"Class")]}function t(a){return a.charAt(0).toUpperCase()+a.slice(1)}function D(a,b,f,c){if(!c){if(b)a[_callback]("ifToggled");a[_callback]("ifChanged")[_callback]("if"+t(f))}}var m="iCheck",C=m+"-helper",r="radio",k="checked",y="un"+k,n="disabled";_determinate="determinate";_indeterminate="in"+_determinate;_update="update";_type="type";_click="click";_touch="touchbegin.i touchend.i";
|
6 |
+
_add="addClass";_remove="removeClass";_callback="trigger";_label="label";_cursor="cursor";_mobile=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);f.fn[m]=function(a,b){var d='input[type="checkbox"], input[type="'+r+'"]',c=f(),g=function(a){a.each(function(){var a=f(this);c=a.is(d)?c.add(a):c.add(a.find(d))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))return a=a.toLowerCase(),g(this),c.each(function(){var c=
|
7 |
+
f(this);"destroy"==a?E(c,"ifDestroyed"):A(c,!0,a);f.isFunction(b)&&b()});if("object"!=typeof a&&a)return this;var e=f.extend({checkedClass:k,disabledClass:n,indeterminateClass:_indeterminate,labelHover:!0},a),l=e.handle,v=e.hoverClass||"hover",s=e.focusClass||"focus",t=e.activeClass||"active",B=!!e.labelHover,w=e.labelHoverClass||"hover",p=(""+e.increaseArea).replace("%","")|0;if("checkbox"==l||l==r)d='input[type="'+l+'"]';-50>p&&(p=-50);g(this);return c.each(function(){var a=f(this);E(a);var c=this,
|
8 |
+
b=c.id,g=-p+"%",d=100+2*p+"%",d={position:"absolute",top:g,left:g,display:"block",width:d,height:d,margin:0,padding:0,background:"#fff",border:0,opacity:0},g=_mobile?{position:"absolute",visibility:"hidden"}:p?d:{position:"absolute",opacity:0},l="checkbox"==c[_type]?e.checkboxClass||"icheckbox":e.radioClass||"i"+r,z=f(_label+'[for="'+b+'"]').add(a.closest(_label)),u=!!e.aria,y=m+"-"+Math.random().toString(36).substr(2,6),h='<div class="'+l+'" '+(u?'role="'+c[_type]+'" ':"");u&&z.each(function(){h+=
|
9 |
+
'aria-labelledby="';this.id?h+=this.id:(this.id=y,h+=y);h+='"'});h=a.wrap(h+"/>")[_callback]("ifCreated").parent().append(e.insert);d=f('<ins class="'+C+'"/>').css(d).appendTo(h);a.data(m,{o:e,s:a.attr("style")}).css(g);e.inheritClass&&h[_add](c.className||"");e.inheritID&&b&&h.attr("id",m+"-"+b);"static"==h.css("position")&&h.css("position","relative");A(a,!0,_update);if(z.length)z.on(_click+".i mouseover.i mouseout.i "+_touch,function(b){var d=b[_type],e=f(this);if(!c[n]){if(d==_click){if(f(b.target).is("a"))return;
|
10 |
+
A(a,!1,!0)}else B&&(/ut|nd/.test(d)?(h[_remove](v),e[_remove](w)):(h[_add](v),e[_add](w)));if(_mobile)b.stopPropagation();else return!1}});a.on(_click+".i focus.i blur.i keyup.i keydown.i keypress.i",function(b){var d=b[_type];b=b.keyCode;if(d==_click)return!1;if("keydown"==d&&32==b)return c[_type]==r&&c[k]||(c[k]?q(a,k):x(a,k)),!1;if("keyup"==d&&c[_type]==r)!c[k]&&x(a,k);else if(/us|ur/.test(d))h["blur"==d?_remove:_add](s)});d.on(_click+" mousedown mouseup mouseover mouseout "+_touch,function(b){var d=
|
11 |
+
b[_type],e=/wn|up/.test(d)?t:v;if(!c[n]){if(d==_click)A(a,!1,!0);else{if(/wn|er|in/.test(d))h[_add](e);else h[_remove](e+" "+t);if(z.length&&B&&e==v)z[/ut|nd/.test(d)?_remove:_add](w)}if(_mobile)b.stopPropagation();else return!1}})})}})(window.jQuery||window.Zepto);
|
assets/icheck/skins/square/red.css
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* iCheck plugin Square skin, red
|
2 |
+
----------------------------------- */
|
3 |
+
.icheckbox_square-red,
|
4 |
+
.iradio_square-red {
|
5 |
+
display: inline-block;
|
6 |
+
*display: inline;
|
7 |
+
vertical-align: middle;
|
8 |
+
margin: 0;
|
9 |
+
padding: 0;
|
10 |
+
width: 22px;
|
11 |
+
height: 22px;
|
12 |
+
background: url(red.png) no-repeat;
|
13 |
+
border: none;
|
14 |
+
cursor: pointer;
|
15 |
+
}
|
16 |
+
|
17 |
+
.icheckbox_square-red {
|
18 |
+
background-position: 0 0;
|
19 |
+
}
|
20 |
+
.icheckbox_square-red.hover {
|
21 |
+
background-position: -24px 0;
|
22 |
+
}
|
23 |
+
.icheckbox_square-red.checked {
|
24 |
+
background-position: -48px 0;
|
25 |
+
}
|
26 |
+
.icheckbox_square-red.disabled {
|
27 |
+
background-position: -72px 0;
|
28 |
+
cursor: default;
|
29 |
+
}
|
30 |
+
.icheckbox_square-red.checked.disabled {
|
31 |
+
background-position: -96px 0;
|
32 |
+
}
|
33 |
+
|
34 |
+
.iradio_square-red {
|
35 |
+
background-position: -120px 0;
|
36 |
+
}
|
37 |
+
.iradio_square-red.hover {
|
38 |
+
background-position: -144px 0;
|
39 |
+
}
|
40 |
+
.iradio_square-red.checked {
|
41 |
+
background-position: -168px 0;
|
42 |
+
}
|
43 |
+
.iradio_square-red.disabled {
|
44 |
+
background-position: -192px 0;
|
45 |
+
cursor: default;
|
46 |
+
}
|
47 |
+
.iradio_square-red.checked.disabled {
|
48 |
+
background-position: -216px 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
/* HiDPI support */
|
52 |
+
@media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi), (min-resolution: 1.25dppx) {
|
53 |
+
.icheckbox_square-red,
|
54 |
+
.iradio_square-red {
|
55 |
+
background-image: url(red@2x.png);
|
56 |
+
-webkit-background-size: 240px 24px;
|
57 |
+
background-size: 240px 24px;
|
58 |
+
}
|
59 |
+
}
|
assets/icheck/skins/square/red.png
ADDED
Binary file
|
assets/icheck/skins/square/red@2x.png
ADDED
Binary file
|
assets/img/icon-clean-up.png
ADDED
Binary file
|
assets/img/icon-warning.png
ADDED
Binary file
|
assets/script.js
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WP Asset Clean Up - Dashboard
|
3 |
+
*/
|
4 |
+
jQuery(document).ready(function($) {
|
5 |
+
if (typeof wpacu_object === 'undefined' || $('#wpacu_meta_box_content').length < 1) {
|
6 |
+
return false; // stop if we are not on the right page (with asset list)
|
7 |
+
}
|
8 |
+
|
9 |
+
// Get URL
|
10 |
+
var data = wpacu_object.plugin_name + '_load=1';
|
11 |
+
|
12 |
+
jQuery.post(wpacu_object.post_url, data, function (contents) {
|
13 |
+
var data = {
|
14 |
+
'action': wpacu_object.plugin_name + '_get_loaded_assets',
|
15 |
+
'contents': contents,
|
16 |
+
'post_id': wpacu_object.post_id,
|
17 |
+
'post_url': wpacu_object.post_url
|
18 |
+
}
|
19 |
+
|
20 |
+
jQuery.post(wpacu_object.ajax_url, data, function (response) {
|
21 |
+
if (response == '') {
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
|
25 |
+
$('#wpacu_meta_box_content').html(response);
|
26 |
+
|
27 |
+
if ($('#wpacu_home_page_form').length > 0) {
|
28 |
+
$('#submit').show();
|
29 |
+
}
|
30 |
+
|
31 |
+
var cbSelector = '.icheckbox_square-red';
|
32 |
+
|
33 |
+
$(cbSelector).iCheck({
|
34 |
+
checkboxClass: 'icheckbox_square-red',
|
35 |
+
increaseArea: '20%' // optional
|
36 |
+
});
|
37 |
+
|
38 |
+
$(cbSelector).on('ifChecked', function (event) {
|
39 |
+
$(event.target).closest('tr').addClass('wpacu_not_load');
|
40 |
+
});
|
41 |
+
|
42 |
+
$(cbSelector).on('ifUnchecked', function (event) {
|
43 |
+
$(event.target).closest('tr').removeClass('wpacu_not_load');
|
44 |
+
});
|
45 |
+
});
|
46 |
+
});
|
47 |
+
});
|
assets/style.css
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tr.wpacu_not_load th,
|
2 |
+
tr.wpacu_not_load td {
|
3 |
+
background: #FFE1E1;
|
4 |
+
}
|
5 |
+
|
6 |
+
.widefat .check-column.wpacu_check {
|
7 |
+
padding: 10px;
|
8 |
+
}
|
9 |
+
|
10 |
+
#wpacu_meta_box_content {
|
11 |
+
width: 99%;
|
12 |
+
}
|
13 |
+
|
14 |
+
#wpacu_meta_box_content h3 {
|
15 |
+
margin-left: 0px;
|
16 |
+
padding-left: 0px;
|
17 |
+
}
|
18 |
+
|
19 |
+
#wpacu_meta_box_content div.wpacu_note {
|
20 |
+
padding: 10px;
|
21 |
+
background-color: #f5f5f5;
|
22 |
+
}
|
23 |
+
|
24 |
+
#wpacu_meta_box_content div.wpacu_warning {
|
25 |
+
border: 1px solid #cc0000;
|
26 |
+
}
|
27 |
+
|
28 |
+
#wpacu_meta_box_content div.wpacu_verified {
|
29 |
+
padding: 10px;
|
30 |
+
background-color: #f5f5f5;
|
31 |
+
border-left: 1px solid #ddd;
|
32 |
+
}
|
33 |
+
|
34 |
+
#wpacu_meta_box_content div.wpacu_verified span {
|
35 |
+
color: #0073aa;
|
36 |
+
font-weight: bold;
|
37 |
+
}
|
classes/HomePage.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace WpAssetCleanUp;
|
3 |
+
|
4 |
+
class HomePage
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @var HomePage|null
|
8 |
+
*/
|
9 |
+
private static $singleton = null;
|
10 |
+
|
11 |
+
public $data = array();
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return null|HomePage
|
15 |
+
*/
|
16 |
+
public static function instance()
|
17 |
+
{
|
18 |
+
if (is_null(self::$singleton)) {
|
19 |
+
self::$singleton = new self();
|
20 |
+
}
|
21 |
+
|
22 |
+
return self::$singleton;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Settings constructor.
|
27 |
+
*/
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
$this->data['nonce_name'] = WPACU_PLUGIN_NAME.'_settings';
|
31 |
+
$this->data['show_on_front'] = get_option('show_on_front');
|
32 |
+
|
33 |
+
if (isset($_GET['page']) && $_GET['page'] == WPACU_PLUGIN_NAME.'_home_page') {
|
34 |
+
|
35 |
+
if ($this->data['show_on_front'] === 'page') {
|
36 |
+
// Front page displays: A Static Page
|
37 |
+
$this->data['page_on_front'] = get_option('page_on_front');
|
38 |
+
|
39 |
+
if ($this->data['page_on_front']) {
|
40 |
+
$this->data['page_on_front_title'] = get_the_title($this->data['page_on_front']);
|
41 |
+
}
|
42 |
+
|
43 |
+
$this->data['page_for_posts'] = get_option('page_for_posts');
|
44 |
+
|
45 |
+
if ($this->data['page_for_posts']) {
|
46 |
+
$this->data['page_for_posts_title'] = get_the_title($this->data['page_for_posts']);
|
47 |
+
}
|
48 |
+
} elseif ($this->data['show_on_front'] === 'posts') {
|
49 |
+
// Your latest posts
|
50 |
+
$postUrl = get_option('siteurl');
|
51 |
+
|
52 |
+
if (substr($postUrl, -1) != '/') {
|
53 |
+
$postUrl .= '/';
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->data['site_url'] = $postUrl;
|
57 |
+
|
58 |
+
add_action('admin_head', array($this, 'inlineAdminHead'));
|
59 |
+
|
60 |
+
add_action('admin_enqueue_scripts', array(Main::instance(), 'stylesAndScriptsForAdmin'));
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public function init()
|
66 |
+
{
|
67 |
+
}
|
68 |
+
|
69 |
+
public function inlineAdminHead()
|
70 |
+
{
|
71 |
+
?>
|
72 |
+
<style type="text/css">
|
73 |
+
.wp-asset-clean-up.widefat {
|
74 |
+
width: 99%;
|
75 |
+
}
|
76 |
+
</style>
|
77 |
+
<?php
|
78 |
+
}
|
79 |
+
|
80 |
+
public function introPage()
|
81 |
+
{
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @param $wpacuNoLoadAssets
|
87 |
+
*/
|
88 |
+
public function updateFrontPage($wpacuNoLoadAssets)
|
89 |
+
{
|
90 |
+
if (! is_array($wpacuNoLoadAssets)) {
|
91 |
+
return; // only arrays (empty or not) should be used
|
92 |
+
}
|
93 |
+
|
94 |
+
$jsonNoAssetsLoadList = json_encode($wpacuNoLoadAssets);
|
95 |
+
|
96 |
+
if (! update_option(WPACU_PLUGIN_NAME . '_front_page_no_load', $jsonNoAssetsLoadList)) {
|
97 |
+
add_option(WPACU_PLUGIN_NAME . '_front_page_no_load', $jsonNoAssetsLoadList);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
*
|
103 |
+
*/
|
104 |
+
public function page()
|
105 |
+
{
|
106 |
+
$wpacuNoLoadAssets = isset($_POST[WPACU_PLUGIN_NAME])
|
107 |
+
? $_POST[WPACU_PLUGIN_NAME] : array();
|
108 |
+
|
109 |
+
$noncePost = isset($_POST[$this->data['nonce_name']]) ? $_POST[$this->data['nonce_name']] : '';
|
110 |
+
|
111 |
+
if (is_array($wpacuNoLoadAssets) && !empty($wpacuNoLoadAssets) && wp_verify_nonce($noncePost, $this->data['nonce_name'])) {
|
112 |
+
$this->updateFrontPage($wpacuNoLoadAssets);
|
113 |
+
}
|
114 |
+
|
115 |
+
$this->data['nonce_value'] = wp_create_nonce($this->data['nonce_name']);
|
116 |
+
|
117 |
+
Main::instance()->parseTemplate('settings-home-page', $this->data, true);
|
118 |
+
}
|
119 |
+
}
|
classes/Main.php
ADDED
@@ -0,0 +1,1036 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace WpAssetCleanUp;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Main
|
6 |
+
* @package WpAssetCleanUp
|
7 |
+
*/
|
8 |
+
class Main
|
9 |
+
{
|
10 |
+
const STARTDEL = '<!-- BEGIN WPACU PLUGIN JSON -->';
|
11 |
+
const ENDDEL = '<!-- END WPACU PLUGIN JSON -->';
|
12 |
+
|
13 |
+
const FRONT_NONCE_ACTION_NAME = 'wpacu_front_update';
|
14 |
+
const FRONT_NONCE_FIELD_NAME = 'wpacu_front_nonce';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var Main|null
|
18 |
+
*/
|
19 |
+
private static $singleton = null;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
public $assetsRemoved = array();
|
25 |
+
|
26 |
+
public $loadPluginAssets = false; // default
|
27 |
+
|
28 |
+
public $fetchUrl;
|
29 |
+
|
30 |
+
public $frontendShow = false;
|
31 |
+
|
32 |
+
public $assetsInFooter = array();
|
33 |
+
|
34 |
+
public $wpScripts = array();
|
35 |
+
public $wpStyles = array();
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return null|Main
|
39 |
+
*/
|
40 |
+
public static function instance()
|
41 |
+
{
|
42 |
+
if (is_null(self::$singleton)) {
|
43 |
+
self::$singleton = new self();
|
44 |
+
}
|
45 |
+
|
46 |
+
return self::$singleton;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Parser constructor.
|
51 |
+
*/
|
52 |
+
public function __construct()
|
53 |
+
{
|
54 |
+
$this->frontendShow = (get_option(WPACU_PLUGIN_NAME.'_frontend_show'));
|
55 |
+
|
56 |
+
add_action('admin_enqueue_scripts', array($this, 'stylesAndScriptsForAdmin'));
|
57 |
+
add_action('wp_enqueue_scripts', array($this, 'stylesAndScriptsForPublic'));
|
58 |
+
|
59 |
+
if ($this->frontendShow) {
|
60 |
+
add_action('wp_head', array($this, 'frontendHead'));
|
61 |
+
add_action('wp', array($this, 'frontendUpdate'));
|
62 |
+
}
|
63 |
+
|
64 |
+
// Used as a fallback in case something goes wrong
|
65 |
+
add_action('admin_footer', array($this, 'footerArea'));
|
66 |
+
|
67 |
+
// After post/page is saved - update your styles/scripts lists
|
68 |
+
add_action('save_post', array($this, 'savePost'));
|
69 |
+
|
70 |
+
// Fetch the page in the background to see what scripts/styles are already loading
|
71 |
+
if (isset($_POST[WPACU_PLUGIN_NAME.'_load']) || $this->frontendShow) {
|
72 |
+
if (isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
73 |
+
add_filter('show_admin_bar', '__return_false'); // not relevant
|
74 |
+
}
|
75 |
+
|
76 |
+
add_action('wp_head', array($this, 'saveFooterAssets'), 100000000);
|
77 |
+
add_action('wp_footer', array($this, 'printScriptsStyles'), 100000000);
|
78 |
+
}
|
79 |
+
|
80 |
+
// Front-end View - Unload the assets
|
81 |
+
if (! isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
82 |
+
// Unload Scripts (HEAD and FOOTER)
|
83 |
+
add_action('wp_print_scripts', array($this, 'filterScripts'), 100000);
|
84 |
+
add_action('wp_print_footer_scripts', array($this, 'filterScripts'), 100000);
|
85 |
+
|
86 |
+
// Unload Styles
|
87 |
+
add_action('wp_print_styles', array($this, 'filterStyles'), 100000);
|
88 |
+
}
|
89 |
+
|
90 |
+
// Send an AJAX request to get the list of loaded scripts and styles and print it nicely
|
91 |
+
add_action(
|
92 |
+
'wp_ajax_'. WPACU_PLUGIN_NAME . '_get_loaded_assets',
|
93 |
+
array($this, 'ajaxGetJsonListCallback')
|
94 |
+
);
|
95 |
+
|
96 |
+
add_action('add_meta_boxes', array($this, 'addMetaBox'));
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @param $postType
|
101 |
+
*/
|
102 |
+
public function addMetaBox($postType)
|
103 |
+
{
|
104 |
+
$obj = get_post_type_object($postType);
|
105 |
+
|
106 |
+
if ($obj->public > 0) {
|
107 |
+
add_meta_box(
|
108 |
+
WPACU_PLUGIN_NAME.'_asset_list',
|
109 |
+
__('WP Asset Clean Up', WPACU_PLUGIN_NAME),
|
110 |
+
array($this, 'renderMetaBoxContent'),
|
111 |
+
$postType,
|
112 |
+
'advanced',
|
113 |
+
'high'
|
114 |
+
);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
*/
|
121 |
+
public function renderMetaBoxContent()
|
122 |
+
{
|
123 |
+
global $post;
|
124 |
+
|
125 |
+
if (! isset($post->ID)) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
$postId = $post->ID;
|
130 |
+
|
131 |
+
$getAssets = true;
|
132 |
+
|
133 |
+
if (get_post_status($postId) != 'publish') {
|
134 |
+
$getAssets = false;
|
135 |
+
}
|
136 |
+
|
137 |
+
if ($getAssets) {
|
138 |
+
// Add an nonce field so we can check for it later.
|
139 |
+
wp_nonce_field(WPACU_PLUGIN_NAME . '_meta_box', WPACU_PLUGIN_NAME . '_nonce');
|
140 |
+
}
|
141 |
+
|
142 |
+
$data = array();
|
143 |
+
|
144 |
+
$data['get_assets'] = $getAssets;
|
145 |
+
|
146 |
+
$data['fetch_url'] = $this->fetchUrl;
|
147 |
+
|
148 |
+
$this->parseTemplate('meta-box', $data, true);
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* See if there is any list with scripts to be removed in JSON format
|
153 |
+
* Only the handles (the ID of the scripts) is stored
|
154 |
+
*/
|
155 |
+
public function filterScripts()
|
156 |
+
{
|
157 |
+
if (is_admin() || (!is_singular() && !is_front_page())) {
|
158 |
+
return;
|
159 |
+
}
|
160 |
+
|
161 |
+
$toRemove = $this->getAssetsUnloaded();
|
162 |
+
|
163 |
+
if (! $toRemove) {
|
164 |
+
return;
|
165 |
+
}
|
166 |
+
|
167 |
+
$jsonList = json_decode($toRemove);
|
168 |
+
|
169 |
+
if (json_last_error()) {
|
170 |
+
return;
|
171 |
+
}
|
172 |
+
|
173 |
+
if (! isset($jsonList->scripts)) {
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
|
177 |
+
$list = (array)$jsonList->scripts;
|
178 |
+
|
179 |
+
if (empty($list)) {
|
180 |
+
return;
|
181 |
+
}
|
182 |
+
|
183 |
+
global $wp_scripts;
|
184 |
+
|
185 |
+
// Only fill it once
|
186 |
+
if (empty($this->wpScripts)) {
|
187 |
+
$this->wpScripts = (array)$wp_scripts;
|
188 |
+
|
189 |
+
$i = 1;
|
190 |
+
|
191 |
+
foreach ($this->wpScripts['registered'] as $handle => $value) {
|
192 |
+
$this->wpScripts['registered'][$handle]->wpacu_pos = $i;
|
193 |
+
$i++;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
foreach ($list as $handle) {
|
198 |
+
$handle = trim($handle);
|
199 |
+
|
200 |
+
wp_deregister_script($handle);
|
201 |
+
wp_dequeue_script($handle);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* See if there is any list with styles to be removed in JSON format
|
207 |
+
* Only the handles (the ID of the styles) is stored
|
208 |
+
*/
|
209 |
+
public function filterStyles()
|
210 |
+
{
|
211 |
+
if (is_admin() || (!is_singular() && !is_front_page())) {
|
212 |
+
return;
|
213 |
+
}
|
214 |
+
|
215 |
+
$toRemove = $this->getAssetsUnloaded();
|
216 |
+
|
217 |
+
if (! $toRemove) {
|
218 |
+
return;
|
219 |
+
}
|
220 |
+
|
221 |
+
$jsonList = json_decode($toRemove);
|
222 |
+
|
223 |
+
if (json_last_error()) {
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
if (! isset($jsonList->styles)) {
|
228 |
+
return;
|
229 |
+
}
|
230 |
+
|
231 |
+
$list = (array)$jsonList->styles;
|
232 |
+
|
233 |
+
if (empty($list)) {
|
234 |
+
return;
|
235 |
+
}
|
236 |
+
|
237 |
+
global $wp_styles;
|
238 |
+
|
239 |
+
// Only fill it once
|
240 |
+
if (empty($this->wpStyles)) {
|
241 |
+
$this->wpStyles = (array)$wp_styles;
|
242 |
+
|
243 |
+
$i = 1;
|
244 |
+
|
245 |
+
foreach ($this->wpStyles['registered'] as $handle => $value) {
|
246 |
+
$this->wpStyles['registered'][$handle]->wpacu_pos = $i;
|
247 |
+
$i++;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
foreach ($list as $handle) {
|
252 |
+
$handle = trim($handle);
|
253 |
+
|
254 |
+
wp_deregister_style($handle);
|
255 |
+
wp_dequeue_style($handle);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Save post metadata when a post is saved.
|
261 |
+
*
|
262 |
+
* @param $postId
|
263 |
+
*/
|
264 |
+
public function savePost($postId, $post = array())
|
265 |
+
{
|
266 |
+
if (empty($post)) {
|
267 |
+
global $post;
|
268 |
+
}
|
269 |
+
|
270 |
+
if (! isset($post->ID)) {
|
271 |
+
return;
|
272 |
+
}
|
273 |
+
|
274 |
+
// Has to be a public post type
|
275 |
+
$obj = get_post_type_object($post->post_type);
|
276 |
+
|
277 |
+
if ($obj->public < 1) {
|
278 |
+
return;
|
279 |
+
}
|
280 |
+
|
281 |
+
// only for admins
|
282 |
+
if (! current_user_can('manage_options')) {
|
283 |
+
return;
|
284 |
+
}
|
285 |
+
|
286 |
+
$wpacuNoLoadAssets = isset($_POST[WPACU_PLUGIN_NAME])
|
287 |
+
? $_POST[WPACU_PLUGIN_NAME] : array();
|
288 |
+
|
289 |
+
if (is_array($wpacuNoLoadAssets)) {
|
290 |
+
$jsonNoAssetsLoadList = json_encode($wpacuNoLoadAssets);
|
291 |
+
|
292 |
+
if (! add_post_meta($postId, '_'.WPACU_PLUGIN_NAME.'_no_load', $jsonNoAssetsLoadList, true)) {
|
293 |
+
update_post_meta($postId, '_'.WPACU_PLUGIN_NAME.'_no_load', $jsonNoAssetsLoadList);
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
public function frontendUpdate()
|
299 |
+
{
|
300 |
+
global $post;
|
301 |
+
|
302 |
+
// Check nonce
|
303 |
+
$nonceName = self::FRONT_NONCE_FIELD_NAME;
|
304 |
+
$nonceAction = self::FRONT_NONCE_ACTION_NAME;
|
305 |
+
|
306 |
+
$updateAction = isset($_POST['wpacu_update_asset_frontend']) ?
|
307 |
+
$_POST['wpacu_update_asset_frontend'] : '';
|
308 |
+
|
309 |
+
if (! isset($_POST[$nonceName]) || $updateAction != 1 || ! $this->frontendShow) {
|
310 |
+
return;
|
311 |
+
}
|
312 |
+
|
313 |
+
if (! wp_verify_nonce($_POST[$nonceName], $nonceAction)) {
|
314 |
+
$postUrlAnchor = get_permalink($post->ID).'#wpacu_wrap_assets';
|
315 |
+
wp_die(
|
316 |
+
sprintf(
|
317 |
+
__('The nonce expired or is not correct, thus the request was not processed. %sPlease retry%s.', WPACU_PLUGIN_NAME),
|
318 |
+
'<a href="'.$postUrlAnchor.'">',
|
319 |
+
'</a>'
|
320 |
+
),
|
321 |
+
__('Nonce Expired', WPACU_PLUGIN_NAME)
|
322 |
+
);
|
323 |
+
}
|
324 |
+
|
325 |
+
if (is_front_page()) {
|
326 |
+
$wpacuNoLoadAssets = isset($_POST[WPACU_PLUGIN_NAME])
|
327 |
+
? $_POST[WPACU_PLUGIN_NAME] : array();
|
328 |
+
|
329 |
+
HomePage::instance()->updateFrontPage($wpacuNoLoadAssets);
|
330 |
+
} else {
|
331 |
+
$this->savePost($post->ID, $post);
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
public function saveFooterAssets()
|
336 |
+
{
|
337 |
+
global $wp_scripts;
|
338 |
+
|
339 |
+
$this->assetsInFooter = $wp_scripts->in_footer;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* This output will be extracted and the JSON will be processed
|
344 |
+
* in the WP Dashboard when editing a post
|
345 |
+
*
|
346 |
+
* It will also print the asset list in the front-end
|
347 |
+
* if the option was enabled in the Settings
|
348 |
+
*/
|
349 |
+
public function printScriptsStyles()
|
350 |
+
{
|
351 |
+
if (defined('DOING_AJAX') && DOING_AJAX) {
|
352 |
+
// Not for AJAX calls
|
353 |
+
return;
|
354 |
+
}
|
355 |
+
|
356 |
+
global $post;
|
357 |
+
|
358 |
+
$isFrontEndView = ($this->frontendShow && current_user_can('manage_options')
|
359 |
+
&& !isset($_POST[WPACU_PLUGIN_NAME.'_load'])
|
360 |
+
&& !is_admin());
|
361 |
+
$isDashboardView = (!$isFrontEndView && isset($_POST[WPACU_PLUGIN_NAME.'_load']));
|
362 |
+
|
363 |
+
if (!$isFrontEndView && !$isDashboardView) {
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
|
367 |
+
// This is the list of the scripts an styles that were eventually loaded
|
368 |
+
// We have also the list of the ones that were unloaded
|
369 |
+
// located in $this->wpScripts and $this->wpStyles
|
370 |
+
// We will add it to the list as they will be marked
|
371 |
+
|
372 |
+
$stylesBeforeUnload = $this->wpStyles;
|
373 |
+
$scriptsBeforeUnload = $this->wpScripts;
|
374 |
+
|
375 |
+
global $wp_scripts, $wp_styles;
|
376 |
+
|
377 |
+
$list = array();
|
378 |
+
|
379 |
+
$currentUnloaded = (array)json_decode(
|
380 |
+
$this->getAssetsUnloaded($post->ID)
|
381 |
+
);
|
382 |
+
|
383 |
+
/*
|
384 |
+
* Style List
|
385 |
+
*/
|
386 |
+
if (! empty($wp_styles)) {
|
387 |
+
$skipStyles = array('admin-bar', WPACU_PLUGIN_NAME . '-icheck-square-red', WPACU_PLUGIN_NAME . '-style');
|
388 |
+
|
389 |
+
foreach ($wp_styles->done as $handle) {
|
390 |
+
if ($isFrontEndView && in_array($handle, $skipStyles)) {
|
391 |
+
continue;
|
392 |
+
}
|
393 |
+
|
394 |
+
$wpacuPos = isset($stylesBeforeUnload['registered'][$handle]->wpacu_pos)
|
395 |
+
? $stylesBeforeUnload['registered'][$handle]->wpacu_pos
|
396 |
+
: '';
|
397 |
+
|
398 |
+
if ($wpacuPos) {
|
399 |
+
$list['styles'][$wpacuPos] = $wp_styles->registered[$handle];
|
400 |
+
} else {
|
401 |
+
$list['styles'][] = $wp_styles->registered[$handle];
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
// Apppend unloaded ones (if any)
|
406 |
+
if (! empty($currentUnloaded['styles']) && !empty($stylesBeforeUnload)) {
|
407 |
+
foreach ($currentUnloaded['styles'] as $sbuHandle) {
|
408 |
+
if (!in_array($sbuHandle, $wp_styles->done)) {
|
409 |
+
$sbuValue = $stylesBeforeUnload['registered'][$sbuHandle];
|
410 |
+
$wpacuPos = $sbuValue->wpacu_pos;
|
411 |
+
|
412 |
+
$list['styles'][$wpacuPos] = $sbuValue;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
ksort($list['styles']);
|
418 |
+
}
|
419 |
+
|
420 |
+
/*
|
421 |
+
* Scripts List
|
422 |
+
*/
|
423 |
+
if (! empty($wp_scripts)) {
|
424 |
+
$skipScripts = array('admin-bar', WPACU_PLUGIN_NAME . '-icheck');
|
425 |
+
|
426 |
+
foreach ($wp_scripts->done as $handle) {
|
427 |
+
if ($isFrontEndView && in_array($handle, $skipScripts)) {
|
428 |
+
continue;
|
429 |
+
}
|
430 |
+
|
431 |
+
$wpacuPos = isset($scriptsBeforeUnload['registered'][$handle]->wpacu_pos)
|
432 |
+
? $scriptsBeforeUnload['registered'][$handle]->wpacu_pos
|
433 |
+
: '';
|
434 |
+
|
435 |
+
if ($wpacuPos) {
|
436 |
+
$list['scripts'][$wpacuPos] = $wp_scripts->registered[$handle];
|
437 |
+
} else {
|
438 |
+
$list['scripts'][] = $wp_scripts->registered[$handle];
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
// Apppend unloaded ones (if any)
|
443 |
+
if (! empty($currentUnloaded['scripts']) && !empty($scriptsBeforeUnload)) {
|
444 |
+
foreach ($currentUnloaded['scripts'] as $sbuHandle) {
|
445 |
+
if (!in_array($sbuHandle, $wp_scripts->done)) {
|
446 |
+
$sbuValue = $scriptsBeforeUnload['registered'][$sbuHandle];
|
447 |
+
$wpacuPos = $sbuValue->wpacu_pos;
|
448 |
+
|
449 |
+
$list['scripts'][$wpacuPos] = $sbuValue;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
ksort($list['scripts']);
|
455 |
+
}
|
456 |
+
|
457 |
+
|
458 |
+
// Front-end View while admin is logged in
|
459 |
+
if ($isFrontEndView) {
|
460 |
+
$data = array();
|
461 |
+
|
462 |
+
$data['current'] = $currentUnloaded;
|
463 |
+
|
464 |
+
$data['all']['scripts'] = $list['scripts'];
|
465 |
+
$data['all']['styles'] = $list['styles'];
|
466 |
+
|
467 |
+
$this->fetchUrl = (is_front_page())
|
468 |
+
? get_option('siteurl') : $this->getPostUrl($post->ID);
|
469 |
+
|
470 |
+
$data['fetch_url'] = $this->fetchUrl;
|
471 |
+
|
472 |
+
$data['nonce_name'] = self::FRONT_NONCE_FIELD_NAME;
|
473 |
+
$data['nonce_action'] = self::FRONT_NONCE_ACTION_NAME;
|
474 |
+
|
475 |
+
$data = $this->alterAssetObj($data);
|
476 |
+
|
477 |
+
$this->parseTemplate('settings-frontend', $data, true);
|
478 |
+
} elseif ($isDashboardView) {
|
479 |
+
// AJAX call from the WordPress Dashboard
|
480 |
+
echo self::STARTDEL
|
481 |
+
.base64_encode(json_encode($list)).
|
482 |
+
self::ENDDEL;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* @param $name
|
488 |
+
* @param array $data
|
489 |
+
* @param bool|false $echo
|
490 |
+
* @return bool|string
|
491 |
+
*/
|
492 |
+
public function parseTemplate($name, $data = array(), $echo = false)
|
493 |
+
{
|
494 |
+
define('WPACU_TPL_LOADED', true);
|
495 |
+
|
496 |
+
$templateFile = dirname(__DIR__) . '/templates/' . $name . '.php';
|
497 |
+
|
498 |
+
if (! file_exists($templateFile)) {
|
499 |
+
wp_die('Template '.$name.' not found.');
|
500 |
+
}
|
501 |
+
|
502 |
+
ob_start();
|
503 |
+
include $templateFile;
|
504 |
+
$result = ob_get_clean();
|
505 |
+
|
506 |
+
if ($echo) {
|
507 |
+
echo $result;
|
508 |
+
return true;
|
509 |
+
}
|
510 |
+
|
511 |
+
return $result;
|
512 |
+
}
|
513 |
+
|
514 |
+
/**
|
515 |
+
*
|
516 |
+
*/
|
517 |
+
public function stylesAndScriptsForAdmin()
|
518 |
+
{
|
519 |
+
global $post;
|
520 |
+
|
521 |
+
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
522 |
+
$getPostId = (isset($_GET['post'])) ? (int)$_GET['post'] : '';
|
523 |
+
|
524 |
+
if (isset($post->ID)) {
|
525 |
+
$this->loadPluginAssets = true;
|
526 |
+
}
|
527 |
+
|
528 |
+
if ($getPostId > 0) {
|
529 |
+
$this->loadPluginAssets = true;
|
530 |
+
}
|
531 |
+
|
532 |
+
if ($page == WPACU_PLUGIN_NAME.'_home_page'
|
533 |
+
&& HomePage::instance()->data['show_on_front'] === 'posts'
|
534 |
+
) {
|
535 |
+
$this->loadPluginAssets = true;
|
536 |
+
}
|
537 |
+
|
538 |
+
if (! $this->loadPluginAssets) {
|
539 |
+
return;
|
540 |
+
}
|
541 |
+
|
542 |
+
$this->enqueueAdminStyles();
|
543 |
+
$this->enqueueAdminScripts();
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
*
|
548 |
+
*/
|
549 |
+
public function stylesAndScriptsForPublic()
|
550 |
+
{
|
551 |
+
$this->enqueuePublicStyles();
|
552 |
+
$this->enqueuePublicScripts();
|
553 |
+
}
|
554 |
+
|
555 |
+
/**
|
556 |
+
*
|
557 |
+
*/
|
558 |
+
private function enqueueAdminStyles()
|
559 |
+
{
|
560 |
+
wp_enqueue_style(WPACU_PLUGIN_NAME . '-style', plugins_url('/assets/style.css', WPACU_PLUGIN_FILE));
|
561 |
+
wp_enqueue_style(WPACU_PLUGIN_NAME . '-icheck-square-red', plugins_url('/assets/icheck/skins/square/red.css', WPACU_PLUGIN_FILE));
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
*
|
566 |
+
*/
|
567 |
+
private function enqueueAdminScripts()
|
568 |
+
{
|
569 |
+
global $post, $pagenow;
|
570 |
+
|
571 |
+
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
572 |
+
|
573 |
+
$getPostId = (isset($_GET['post'])
|
574 |
+
&& isset($_GET['action'])
|
575 |
+
&& $_GET['action'] === 'edit'
|
576 |
+
&& $pagenow == 'post.php')
|
577 |
+
? (int)$_GET['post'] : '';
|
578 |
+
|
579 |
+
$postId = (isset($post->ID)) ? $post->ID : 0;
|
580 |
+
|
581 |
+
if ($getPostId > 0 && $getPostId != $postId) {
|
582 |
+
$postId = $getPostId;
|
583 |
+
}
|
584 |
+
|
585 |
+
if ($page == WPACU_PLUGIN_NAME.'_home_page' || $postId < 1) {
|
586 |
+
$postId = 0; // for home page
|
587 |
+
}
|
588 |
+
|
589 |
+
// Not home page (posts list)? See if the invididual post is published to continue
|
590 |
+
if ($postId > 0) {
|
591 |
+
$postStatus = get_post_status($postId);
|
592 |
+
|
593 |
+
if (! $postStatus) {
|
594 |
+
return;
|
595 |
+
}
|
596 |
+
|
597 |
+
// Only for Published Posts
|
598 |
+
if ($postStatus != 'publish') {
|
599 |
+
return;
|
600 |
+
}
|
601 |
+
}
|
602 |
+
|
603 |
+
wp_register_script(WPACU_PLUGIN_NAME . '-script', plugins_url('/assets/script.js', WPACU_PLUGIN_FILE), array('jquery'), '1.1');
|
604 |
+
|
605 |
+
// It can also be the front page URL
|
606 |
+
$postUrl = $this->getPostUrl($postId);
|
607 |
+
|
608 |
+
$this->fetchUrl = $postUrl;
|
609 |
+
|
610 |
+
wp_localize_script(
|
611 |
+
WPACU_PLUGIN_NAME . '-script',
|
612 |
+
'wpacu_object',
|
613 |
+
array(
|
614 |
+
'plugin_name' => WPACU_PLUGIN_NAME,
|
615 |
+
'ajax_url' => admin_url('admin-ajax.php'),
|
616 |
+
'post_id' => $postId,
|
617 |
+
'post_url' => $postUrl
|
618 |
+
)
|
619 |
+
);
|
620 |
+
|
621 |
+
wp_enqueue_script(WPACU_PLUGIN_NAME . '-script');
|
622 |
+
wp_enqueue_script(WPACU_PLUGIN_NAME . '-icheck', plugins_url('/assets/icheck/icheck.min.js', WPACU_PLUGIN_FILE), array('jquery'));
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
*
|
627 |
+
*/
|
628 |
+
private function enqueuePublicStyles()
|
629 |
+
{
|
630 |
+
if ($this->frontendShow && current_user_can('manage_options') && !isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
631 |
+
wp_enqueue_style(WPACU_PLUGIN_NAME . '-style', plugins_url('/assets/style.css', WPACU_PLUGIN_FILE));
|
632 |
+
wp_enqueue_style(WPACU_PLUGIN_NAME . '-icheck-square-red', plugins_url('/assets/icheck/skins/square/red.css', WPACU_PLUGIN_FILE));
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
*
|
638 |
+
*/
|
639 |
+
public function enqueuePublicScripts()
|
640 |
+
{
|
641 |
+
if ($this->frontendShow && current_user_can('manage_options') && !isset($_POST[WPACU_PLUGIN_NAME.'_load'])) {
|
642 |
+
wp_enqueue_script(WPACU_PLUGIN_NAME . '-icheck', plugins_url('/assets/icheck/icheck.min.js', WPACU_PLUGIN_FILE), array('jquery'));
|
643 |
+
}
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* @param $postId
|
648 |
+
* @return false|mixed|string|void
|
649 |
+
*/
|
650 |
+
public function getPostUrl($postId)
|
651 |
+
{
|
652 |
+
if ($postId > 0) {
|
653 |
+
$postUrl = get_permalink($postId);
|
654 |
+
} else {
|
655 |
+
$postUrl = get_option('siteurl');
|
656 |
+
|
657 |
+
if (substr($postUrl, -1) != '/') {
|
658 |
+
$postUrl .= '/';
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
// If we are in the Dashboard on a HTTPS connection,
|
663 |
+
// then we will make the AJAX call over HTTPS as well for the front-end
|
664 |
+
// to avoid blocking
|
665 |
+
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
|
666 |
+
|
667 |
+
if ($https && strpos($postUrl, 'http://') === 0) {
|
668 |
+
$postUrl = str_ireplace('http://', 'https://', $postUrl);
|
669 |
+
}
|
670 |
+
|
671 |
+
return $postUrl;
|
672 |
+
}
|
673 |
+
|
674 |
+
/**
|
675 |
+
*
|
676 |
+
*/
|
677 |
+
public function ajaxGetJsonListCallback()
|
678 |
+
{
|
679 |
+
$contents = $_POST['contents'];
|
680 |
+
$postId = (int)$_POST['post_id'];
|
681 |
+
$postUrl = $_POST['post_url'];
|
682 |
+
|
683 |
+
$json = base64_decode(
|
684 |
+
$this->extractBetween(
|
685 |
+
$contents,
|
686 |
+
self::STARTDEL,
|
687 |
+
self::ENDDEL
|
688 |
+
)
|
689 |
+
);
|
690 |
+
|
691 |
+
$data = array();
|
692 |
+
|
693 |
+
$data['all'] = (array)json_decode($json);
|
694 |
+
$data['contents'] = $contents;
|
695 |
+
|
696 |
+
$data = $this->alterAssetObj($data);
|
697 |
+
|
698 |
+
// Check any existing results
|
699 |
+
$data['current'] = (array)json_decode($this->getAssetsUnloaded($postId));
|
700 |
+
|
701 |
+
// Set to empty if not set to avoid any errors
|
702 |
+
if (! isset($data['current']['styles'])) {
|
703 |
+
$data['current']['styles'] = array();
|
704 |
+
}
|
705 |
+
|
706 |
+
if (! isset($data['current']['scripts'])) {
|
707 |
+
$data['current']['scripts'] = array();
|
708 |
+
}
|
709 |
+
|
710 |
+
$data['fetch_url'] = $postUrl;
|
711 |
+
|
712 |
+
$this->parseTemplate('meta-box-loaded', $data, true);
|
713 |
+
|
714 |
+
exit;
|
715 |
+
}
|
716 |
+
|
717 |
+
public function alterAssetObj($data)
|
718 |
+
{
|
719 |
+
$siteUrl = get_option('siteurl');
|
720 |
+
|
721 |
+
if (! empty($data['all']['styles'])) {
|
722 |
+
$data['core_styles_loaded'] = false;
|
723 |
+
|
724 |
+
foreach ($data['all']['styles'] as $key => $obj) {
|
725 |
+
if (! isset($obj->handle)) {
|
726 |
+
continue;
|
727 |
+
}
|
728 |
+
|
729 |
+
if (isset($data['all']['styles'][$key])) {
|
730 |
+
if (isset($obj->src) && $obj->src) {
|
731 |
+
$part = str_replace(
|
732 |
+
array(
|
733 |
+
'http://',
|
734 |
+
'https://',
|
735 |
+
'//'
|
736 |
+
),
|
737 |
+
'',
|
738 |
+
$obj->src
|
739 |
+
);
|
740 |
+
|
741 |
+
list(,$parentDir) = explode('/', $part);
|
742 |
+
|
743 |
+
// Loaded from WordPress directories (Core)
|
744 |
+
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
|
745 |
+
$data['all']['styles'][$key]->wp = true;
|
746 |
+
$data['core_styles_loaded'] = true;
|
747 |
+
}
|
748 |
+
|
749 |
+
// Determine source href
|
750 |
+
if (substr($obj->src, 0, 1) == '/'
|
751 |
+
&& substr($obj->src, 0, 2) != '//'
|
752 |
+
) {
|
753 |
+
$obj->srcHref = $siteUrl . $obj->src;
|
754 |
+
} else {
|
755 |
+
$obj->srcHref = $obj->src;
|
756 |
+
}
|
757 |
+
}
|
758 |
+
}
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
if (! empty($data['all']['scripts'])) {
|
763 |
+
$data['core_scripts_loaded'] = false;
|
764 |
+
|
765 |
+
if (isset($data['contents'])) {
|
766 |
+
$headPart = $this->extractBetween($data['contents'], '<head', '</head>');
|
767 |
+
$bodyPart = $this->extractBetween($data['contents'], '<body', '</body>');
|
768 |
+
}
|
769 |
+
|
770 |
+
foreach ($data['all']['scripts'] as $key => $obj) {
|
771 |
+
if (! isset($obj->handle)) {
|
772 |
+
continue;
|
773 |
+
}
|
774 |
+
|
775 |
+
// From WordPress directories (false by default)
|
776 |
+
$data['all']['scripts'][$key]->wp = false;
|
777 |
+
|
778 |
+
$toCheck = $obj->src;
|
779 |
+
$toCheckExtra = str_replace(
|
780 |
+
array(',', '&'),
|
781 |
+
array('%2C', '&'),
|
782 |
+
$obj->src
|
783 |
+
);
|
784 |
+
|
785 |
+
if (isset($data['contents'])) {
|
786 |
+
if (stripos($headPart, $toCheck) !== false || stripos($headPart, $toCheckExtra) !== false) {
|
787 |
+
$data['all']['scripts'][$key]->position = 'head';
|
788 |
+
} elseif (stripos($bodyPart, $toCheck) !== false || stripos($bodyPart, $toCheckExtra) !== false) {
|
789 |
+
$data['all']['scripts'][$key]->position = 'body';
|
790 |
+
}
|
791 |
+
} elseif (in_array($obj->handle, $this->assetsInFooter)) {
|
792 |
+
$data['all']['scripts'][$key]->position = 'body';
|
793 |
+
} else {
|
794 |
+
$data['all']['scripts'][$key]->position = 'head';
|
795 |
+
}
|
796 |
+
|
797 |
+
if (isset($data['all']['scripts'][$key])) {
|
798 |
+
if (isset($obj->src) && $obj->src) {
|
799 |
+
$part = str_replace(
|
800 |
+
array(
|
801 |
+
'http://',
|
802 |
+
'https://',
|
803 |
+
'//'
|
804 |
+
),
|
805 |
+
'',
|
806 |
+
$obj->src
|
807 |
+
);
|
808 |
+
|
809 |
+
list(,$parentDir) = explode('/', $part);
|
810 |
+
|
811 |
+
// Loaded from WordPress directories (Core)
|
812 |
+
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
|
813 |
+
$data['all']['scripts'][$key]->wp = true;
|
814 |
+
$data['core_scripts_loaded'] = true;
|
815 |
+
}
|
816 |
+
|
817 |
+
// Determine source href
|
818 |
+
if (substr($obj->src, 0, 1) == '/'
|
819 |
+
&& substr($obj->src, 0, 2) != '//'
|
820 |
+
) {
|
821 |
+
$obj->srcHref = $siteUrl . $obj->src;
|
822 |
+
} else {
|
823 |
+
$obj->srcHref = $obj->src;
|
824 |
+
}
|
825 |
+
}
|
826 |
+
|
827 |
+
if (in_array($obj->handle, array('jquery'))) {
|
828 |
+
$data['all']['scripts'][$key]->wp = true;
|
829 |
+
$data['core_scripts_loaded'] = true;
|
830 |
+
}
|
831 |
+
}
|
832 |
+
}
|
833 |
+
}
|
834 |
+
|
835 |
+
return $data;
|
836 |
+
}
|
837 |
+
|
838 |
+
/**
|
839 |
+
* @param string $postId
|
840 |
+
* @return array|mixed|void
|
841 |
+
*/
|
842 |
+
public function getAssetsUnloaded($postId = 0)
|
843 |
+
{
|
844 |
+
// Post Type (Overwrites 'front' if we are in a singular post)
|
845 |
+
global $post;
|
846 |
+
$postId = (isset($post->ID) && is_singular()) ? $post->ID : $postId;
|
847 |
+
|
848 |
+
if (! $this->assetsRemoved) {
|
849 |
+
// For Home Page (latest blog posts)
|
850 |
+
if ($postId < 1) {
|
851 |
+
$this->assetsRemoved = get_option(WPACU_PLUGIN_NAME . '_front_page_no_load');
|
852 |
+
return $this->assetsRemoved;
|
853 |
+
} elseif ($postId > 0) {
|
854 |
+
$this->assetsRemoved = get_post_meta($postId, '_' . WPACU_PLUGIN_NAME . '_no_load', true);
|
855 |
+
}
|
856 |
+
}
|
857 |
+
|
858 |
+
return $this->assetsRemoved;
|
859 |
+
}
|
860 |
+
|
861 |
+
public function frontendHead()
|
862 |
+
{
|
863 |
+
// Only visible for the logged in admin
|
864 |
+
if (! current_user_can('manage_options')) {
|
865 |
+
return;
|
866 |
+
}
|
867 |
+
?>
|
868 |
+
<style type="text/css">
|
869 |
+
#wpacu_wrap_assets {
|
870 |
+
color: #000000 !important; text-align: left; clear:both; width: 90%; padding: 20px; margin: 30px 0 0 15px; border: 1px solid #cdcdcd; z-index: 10000 !important; position: relative; background-color: white;
|
871 |
+
}
|
872 |
+
|
873 |
+
#wpacu_wrap_assets img {
|
874 |
+
display: inline-block !important;
|
875 |
+
}
|
876 |
+
|
877 |
+
#wpacu_wrap_assets p {
|
878 |
+
margin: 10px 0;
|
879 |
+
text-align: left;
|
880 |
+
}
|
881 |
+
|
882 |
+
#wpacu_wrap_assets h1 {
|
883 |
+
margin: 0 0 20px;
|
884 |
+
font-size: 160%;
|
885 |
+
text-align: left;
|
886 |
+
}
|
887 |
+
|
888 |
+
#wpacu_wrap_assets h3 {
|
889 |
+
margin: 20px 0;
|
890 |
+
font-size: 130%;
|
891 |
+
}
|
892 |
+
|
893 |
+
.wpacu_verified {
|
894 |
+
margin: 0 0 10px 0;
|
895 |
+
}
|
896 |
+
|
897 |
+
.wpacu_asset_row td {
|
898 |
+
padding: 10px;
|
899 |
+
}
|
900 |
+
|
901 |
+
.wpacu_asset_row td p {
|
902 |
+
margin-bottom: 10px;
|
903 |
+
word-wrap: break-word;
|
904 |
+
}
|
905 |
+
|
906 |
+
.wpacu_asset_row td label {
|
907 |
+
cursor: pointer !important;
|
908 |
+
display: inline-block !important;
|
909 |
+
font-size: 100%;
|
910 |
+
}
|
911 |
+
|
912 |
+
.wpacu_asset_row td.wpacu_check {
|
913 |
+
width: 50px;
|
914 |
+
}
|
915 |
+
|
916 |
+
/* Assets Table */
|
917 |
+
.wpacu_widefat, .wpacu_widefat td {
|
918 |
+
border: 1px solid #e5e5e5 !important;
|
919 |
+
}
|
920 |
+
|
921 |
+
.wpacu_striped>tbody>:nth-child(odd), ul.wpacu_striped>:nth-child(odd) {
|
922 |
+
background-color: #f9f9f9 !important;
|
923 |
+
}
|
924 |
+
|
925 |
+
.wpacu_update_btn {
|
926 |
+
-moz-box-shadow:inset 0px 1px 0px 0px #54a3f7 !important;
|
927 |
+
-webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7 !important;
|
928 |
+
box-shadow:inset 0px 1px 0px 0px #54a3f7 !important;
|
929 |
+
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7)) !important;
|
930 |
+
background:-moz-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
931 |
+
background:-webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
932 |
+
background:-o-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
933 |
+
background:-ms-linear-gradient(top, #007dc1 5%, #0061a7 100%) !important;
|
934 |
+
background:linear-gradient(to bottom, #007dc1 5%, #0061a7 100%) !important;
|
935 |
+
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#007dc1', endColorstr='#0061a7',GradientType=0) !important;
|
936 |
+
background-color:#007dc1 !important;
|
937 |
+
-moz-border-radius:3px !important;
|
938 |
+
-webkit-border-radius:3px !important;
|
939 |
+
border-radius:3px !important;
|
940 |
+
border:1px solid #124d77 !important;
|
941 |
+
display:inline-block !important;
|
942 |
+
cursor:pointer !important;
|
943 |
+
color:#ffffff !important;
|
944 |
+
font-size:15px !important;
|
945 |
+
padding:10px 24px !important;
|
946 |
+
text-decoration:none !important;
|
947 |
+
text-shadow:0px 1px 0px #154682 !important;
|
948 |
+
}
|
949 |
+
|
950 |
+
.wpacu_update_btn:hover {
|
951 |
+
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1)) !important;
|
952 |
+
background:-moz-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
953 |
+
background:-webkit-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
954 |
+
background:-o-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
955 |
+
background:-ms-linear-gradient(top, #0061a7 5%, #007dc1 100%) !important;
|
956 |
+
background:linear-gradient(to bottom, #0061a7 5%, #007dc1 100%) !important;
|
957 |
+
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0061a7', endColorstr='#007dc1',GradientType=0) !important;
|
958 |
+
background-color:#0061a7 !important;
|
959 |
+
}
|
960 |
+
|
961 |
+
.wpacu_update_btn:active {
|
962 |
+
position:relative !important;
|
963 |
+
top:1px !important;
|
964 |
+
}
|
965 |
+
</style>
|
966 |
+
|
967 |
+
<script type="text/javascript">
|
968 |
+
jQuery(document).ready(function($) {
|
969 |
+
var cbSelector = '.icheckbox_square-red';
|
970 |
+
|
971 |
+
$(cbSelector).iCheck({
|
972 |
+
checkboxClass: 'icheckbox_square-red',
|
973 |
+
increaseArea: '20%' // optional
|
974 |
+
});
|
975 |
+
|
976 |
+
$(cbSelector).on('ifChecked', function (event) {
|
977 |
+
$(event.target).closest('tr').addClass('wpacu_not_load');
|
978 |
+
});
|
979 |
+
|
980 |
+
$(cbSelector).on('ifUnchecked', function (event) {
|
981 |
+
$(event.target).closest('tr').removeClass('wpacu_not_load');
|
982 |
+
});
|
983 |
+
});
|
984 |
+
</script>
|
985 |
+
<?php
|
986 |
+
}
|
987 |
+
|
988 |
+
/**
|
989 |
+
*
|
990 |
+
*/
|
991 |
+
public function footerArea()
|
992 |
+
{
|
993 |
+
// Hmm, for some reason the WPACU script was not loaded
|
994 |
+
// based on the conditions set and we have to hard code it here
|
995 |
+
// Not the ideal way in terms of coding and loading
|
996 |
+
// but a fallback to make the plugin work 100%
|
997 |
+
if (! defined('WPACU_TPL_LOADED')) {
|
998 |
+
?>
|
999 |
+
<link rel='stylesheet' id='wpassetcleanup-style-css'
|
1000 |
+
href='<?php echo plugins_url('/assets/style.css', WPACU_PLUGIN_FILE); ?>?ver=4.4.1'
|
1001 |
+
type='text/css' media='all'/>
|
1002 |
+
<link rel='stylesheet' id='wpassetcleanup-icheck-square-red-css'
|
1003 |
+
href='<?php echo plugins_url('/assets/icheck/skins/square/red.css', WPACU_PLUGIN_FILE); ?>?ver=4.4.1'
|
1004 |
+
type='text/css' media='all'/>
|
1005 |
+
|
1006 |
+
<script type='text/javascript'
|
1007 |
+
src='<?php echo plugins_url('/assets/script.js', WPACU_PLUGIN_FILE); ?>?ver=1.1'></script>
|
1008 |
+
<script type='text/javascript'
|
1009 |
+
src='<?php echo plugins_url('/assets/icheck/icheck.min.js', WPACU_PLUGIN_FILE); ?>?ver=4.4'></script>
|
1010 |
+
<?php
|
1011 |
+
}
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
/**
|
1015 |
+
* @param $string
|
1016 |
+
* @param $start
|
1017 |
+
* @param $end
|
1018 |
+
* @return string
|
1019 |
+
*/
|
1020 |
+
public function extractBetween($string, $start, $end)
|
1021 |
+
{
|
1022 |
+
$pos = stripos($string, $start);
|
1023 |
+
|
1024 |
+
$str = substr($string, $pos);
|
1025 |
+
|
1026 |
+
$strTwo = substr($str, strlen($start));
|
1027 |
+
|
1028 |
+
$secondPos = stripos($strTwo, $end);
|
1029 |
+
|
1030 |
+
$strThree = substr($strTwo, 0, $secondPos);
|
1031 |
+
|
1032 |
+
$unit = trim($strThree); // remove whitespaces
|
1033 |
+
|
1034 |
+
return $unit;
|
1035 |
+
}
|
1036 |
+
}
|
classes/Menu.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
public function activeMenu()
|
22 |
+
{
|
23 |
+
$menuSlug = WPACU_PLUGIN_NAME.'_settings';
|
24 |
+
$capability = 'manage_options';
|
25 |
+
|
26 |
+
add_menu_page(
|
27 |
+
__('WP Asset Clean Up', WPACU_PLUGIN_NAME),
|
28 |
+
__('WP Asset Clean Up', WPACU_PLUGIN_NAME),
|
29 |
+
$capability,
|
30 |
+
$menuSlug,
|
31 |
+
array(Settings::instance(), 'page'),
|
32 |
+
plugin_dir_url(WPACU_PLUGIN_FILE).'/assets/img/icon-clean-up.png'
|
33 |
+
);
|
34 |
+
|
35 |
+
add_submenu_page(
|
36 |
+
$menuSlug,
|
37 |
+
__('Home Page', WPACU_PLUGIN_NAME),
|
38 |
+
__('Home Page', WPACU_PLUGIN_NAME),
|
39 |
+
$capability,
|
40 |
+
WPACU_PLUGIN_NAME.'_home_page',
|
41 |
+
array(HomePage::instance(), 'page')
|
42 |
+
);
|
43 |
+
|
44 |
+
$GLOBALS['submenu'][$menuSlug][0][0] = esc_attr__('Settings', WPACU_PLUGIN_NAME);
|
45 |
+
}
|
46 |
+
}
|
classes/PluginManager.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace WpAssetCleanUp;
|
3 |
+
|
4 |
+
class PluginManager
|
5 |
+
{
|
6 |
+
public static function init()
|
7 |
+
{
|
8 |
+
|
9 |
+
}
|
10 |
+
}
|
classes/Settings.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace WpAssetCleanUp;
|
3 |
+
|
4 |
+
class Settings
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @var Settings|null
|
8 |
+
*/
|
9 |
+
private static $singleton = null;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return null|Settings
|
13 |
+
*/
|
14 |
+
public static function instance()
|
15 |
+
{
|
16 |
+
if (is_null(self::$singleton)) {
|
17 |
+
self::$singleton = new self();
|
18 |
+
}
|
19 |
+
|
20 |
+
return self::$singleton;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
add_action('admin_init', array($this, 'registerSettings'));
|
26 |
+
}
|
27 |
+
|
28 |
+
public function registerSettings()
|
29 |
+
{
|
30 |
+
// Register settings
|
31 |
+
register_setting('wpacu-plugin-settings-group', WPACU_PLUGIN_NAME.'_frontend_show');
|
32 |
+
}
|
33 |
+
|
34 |
+
public function page()
|
35 |
+
{
|
36 |
+
$data = array();
|
37 |
+
|
38 |
+
$data['frontend_show'] = esc_attr(get_option(WPACU_PLUGIN_NAME.'_frontend_show'));
|
39 |
+
|
40 |
+
Main::instance()->parseTemplate('settings-plugin', $data, true);
|
41 |
+
}
|
42 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP Asset Clean Up ===
|
2 |
+
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.4
|
7 |
+
Stable tag: trunk
|
8 |
+
License: GPLv3
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
+
|
11 |
+
Make your website load FASTER by preventing specific scripts (.JS) & styles (.CSS) from loading on pages/posts and home page
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
* Make your web pages load FASTER with "WP Asset Clean Up"
|
15 |
+
* Faster page load = Happier Visitors = More Conversions
|
16 |
+
|
17 |
+
There are often times when you are using a theme and a number of plugins which are enabled and run on the same page. However, you don't need to use all of them and to improve the speed of your website and make the HTML source code cleaner (convenient for debugging purposes), it's better to prevent those styles and scripts from loading.
|
18 |
+
|
19 |
+
For instance, you might use a plugin that generates contact forms and it loads its assets (.CSS and .JS files) in every page of your website instead of doing it only in the /contact page (if that's the only place where you need it).
|
20 |
+
|
21 |
+
WP Asset Clean Up scans your page and detects all the assets that are loaded. All you have to do when editing a page/post is just to select the ones you DO NOT wish to load.
|
22 |
+
|
23 |
+
= This plugin's benefits include =
|
24 |
+
* Decreases number of HTTP requests loaded (important for faster load)
|
25 |
+
* Reduces the HTML code of the actual page (that's even better if GZIP compression is enabled)
|
26 |
+
* Makes source code easier to scan in case you're a developer and want to search for something
|
27 |
+
* Remove possible conflicts between plugins/theme (e.g. 2 JavaScript files that are loading from different plugins and they interfere one with another)
|
28 |
+
* Better performance score if you test your URL on websites such as GTmetrix, PageSpeed Insights, Pingdom Website Speed Test
|
29 |
+
* Google will love your website more as it would be faster and fast page load is nowadays a factor in search ranking
|
30 |
+
* Your server access log files (e.g the Apache ones) will be easier to scan and would take less space on your server
|
31 |
+
|
32 |
+
Plugin works with WordPress Multisite Network enabled!
|
33 |
+
|
34 |
+
NOTE: People that have tested the plugin are so far happy with it and I want to keep a good reputation for it. In case something is not working for you or have any suggestions, please write to me on the forum and I will be happy to assist you.
|
35 |
+
|
36 |
+
**BEFORE rating this plugin**, please check the following post http://chrislema.com/theres-wrong-way-give-plugin-feedback-wordpress-org/ and then use your common sense when writing the feedback.
|
37 |
+
|
38 |
+
== Installation ==
|
39 |
+
1. Upload the "wp-asset-clean-up" folder in your plugins folder
|
40 |
+
2. Activate the plugin (if server's PHP version is below 5.3, it will show you an error and activation will not be made)
|
41 |
+
3. Edit any page / post/ custom post and you will see a meta box called "WP Asset Clean Up" which will load the list of all the loaded .css and .js files
|
42 |
+
4. To unload the assets for the "Home Page", go to "WP Asset Clean Up" menu on the left panel of the Dashboard
|
43 |
+
|
44 |
+
== Frequently Asked Questions ==
|
45 |
+
= What PHP version is required for this plugin to work? =
|
46 |
+
|
47 |
+
5.3+
|
48 |
+
|
49 |
+
= I've noticed scripts and styles that are loaded on the page, but they do not show in the "WP Asset Clean Up" list when editing the page. Why is that? =
|
50 |
+
|
51 |
+
If that's the case, then those assets weren't loaded properly into WordPress by the theme/plugin author as they were likely hardcoded and not enqueued the WordPress way. Here's a tutorial that will help you understand better the enqueuing process: http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/
|
52 |
+
|
53 |
+
= jQuery and jQuery Migrate are often loading on pages/post. Are they always needed? =
|
54 |
+
|
55 |
+
Well known jQuery library is being used by many themes and plugins so it's recommended to keep it on. jQuery Migrate was created to simplify the transition from older versions of jQuery. It restores deprecated features and behaviors so that older code will still run properly on jQuery 1.9 and later.
|
56 |
+
|
57 |
+
However, there are cases when you might not need jQuery at all in a page. If that's the case, feel free to unload it. Make sure you properly test the page afterwards, including testing it for mobile view.
|
58 |
+
|
59 |
+
= Is the plugin working with WordPress Multisite Network? =
|
60 |
+
|
61 |
+
Yes, the plugin has been tested for WordPress Multisite and all its settings are applied correctly to any of the sites that you will be updating.
|
62 |
+
|
63 |
+
= When editing a post/page, I can see the message "We're getting the loaded scripts and styles for this page. Please wait...", but nothing loads! Why? =
|
64 |
+
|
65 |
+
The plugin makes AJAX calls to retrieve the data from the front-end page with 100% accuracy. Possible reasons why nothing is shown despite the wait might be:
|
66 |
+
|
67 |
+
- Your internet connection cut off after you loaded the edit post/post (before the AJAX calls were trigerred). Make sure to check that and refresh the page if it's back on - it happened to me a few times
|
68 |
+
|
69 |
+
- There could be a conflict between plugins or your theme and something is interfering with the script that is retrieving the assets
|
70 |
+
|
71 |
+
Although I've written the code to ensure maximum compatibility, there are factors which are not up to the quality of the plugin that could interfere with it.
|
72 |
+
In case the assets are not loading for you, please write me on the forum and I will be happy to assist you!
|
73 |
+
|
74 |
+
== Screenshots ==
|
75 |
+
1. When editing a post/page (custom post type as well) a meta box will load with the asset list
|
76 |
+
2. Styles (.CSS) loaded for the home page when accessing the "WP Asset Clean Up" Dashboard's menu
|
77 |
+
3. Scripts (.JS) loaded for the home page having an alert message when accessing the "WP Asset Clean Up" Dashboard's menu
|
78 |
+
|
79 |
+
== Changelog ==
|
80 |
+
= 1.1.4.6 =
|
81 |
+
* Now the asset list can be updated on the front-end (below the loaded page, post, front page) if feature is enabled in the "Settings"
|
82 |
+
|
83 |
+
= 1.1.4.5 =
|
84 |
+
* Some assets containing specific ASCII characters in the URL were not shown. This is solved now and they will show fine in the list.
|
85 |
+
* A warning icon is shown next to each script that is part of WordPress core. Also, a message on the top of the list warns the user about the risks of unloading core files
|
86 |
+
|
87 |
+
= 1.1.4.4 =
|
88 |
+
* If the Dashboard is accessed through HTTPS, then the AJAX call to the front-end must be through HTTPS too - otherwise the call gets blocked and the assets list will not show (loading message will appear and confuse user)
|
89 |
+
|
90 |
+
= 1.1.4.3 =
|
91 |
+
* Improved code to not show any PHP errors in case WP_DEBUG constant is set to 'true'
|
92 |
+
|
93 |
+
= 1.1.4.2 =
|
94 |
+
* Prevent JavaScript errors from showing in the background and interfere with the functionality of other plugins in case script.js is loaded in pages where the plugin is not needed
|
95 |
+
|
96 |
+
= 1.1.4.1 =
|
97 |
+
* Prevent any calls to be made for non-published posts/pages as the list of assets is relevant only after the post is published and all assets (from plugins and the themes) are properly loaded on that post/page
|
98 |
+
|
99 |
+
= 1.1.4 =
|
100 |
+
* Bug fix that prevented the AJAX calls from triggering on specific WordPress settings
|
101 |
+
|
102 |
+
= 1.1.3 =
|
103 |
+
* Improved the code and made sure that the actual URL being fetch is shown to avoid confusion
|
104 |
+
|
105 |
+
= 1.1.2 =
|
106 |
+
* Fixed a bug that wasn't loading the iCheck jQuery plugin all the time when it was needed
|
107 |
+
* Better check if PHP version is 5.3+ (notification is shown only in the Dashboard and the plugin does not load in the front-end)
|
108 |
+
|
109 |
+
= 1.1 =
|
110 |
+
* Remove assets from loading in public custom post types too besides the basic 'post' and 'page' ones
|
111 |
+
* Remove assets from loading in home page as well if "Front page displays" is set to "Your latest posts" in "Settings" -> "Reading"
|
112 |
+
* The plugin uses is_front_page() function to determine where the visitor is on your website
|
113 |
+
|
114 |
+
= 1.0 =
|
115 |
+
* Initial Release
|
templates/meta-box-loaded.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* No direct access to this file
|
4 |
+
* This content is placed inside #wpacu_meta_box_content meta box DIV element
|
5 |
+
*/
|
6 |
+
if (! isset($data)) {
|
7 |
+
exit;
|
8 |
+
}
|
9 |
+
?>
|
10 |
+
<div class="wpacu_verified">
|
11 |
+
<strong>Verified Page:</strong> <a target="_blank" href="<?php echo $data['fetch_url']; ?>"><span><?php echo $data['fetch_url']; ?></span></a>
|
12 |
+
</div>
|
13 |
+
|
14 |
+
<h3><?php _e('Styles (.css files)', WPACU_PLUGIN_NAME); ?></h3>
|
15 |
+
<?php
|
16 |
+
if (! empty($data['all']['styles'])) {
|
17 |
+
?>
|
18 |
+
<p><?php echo sprintf(__('The following styles are loading on this page. Please select the ones that are %sNOT NEEDED%s. If you are not sure which ones to unload, it is better to leave them enabled and consult with a developer about unloading the assets.', WPACU_PLUGIN_NAME), '<span style="color: #CC0000;"><strong>', '</strong></span>'); ?></p>
|
19 |
+
|
20 |
+
<?php
|
21 |
+
if ($data['core_styles_loaded']) {
|
22 |
+
?>
|
23 |
+
<div class="wpacu_note wpacu_warning"><em><?php
|
24 |
+
echo sprintf(
|
25 |
+
__('Assets that are marked with %s are part of WordPress core files. Be careful if you decide to unload them!', WPACU_PLUGIN_NAME),
|
26 |
+
'<img src="'.WPACU_PLUGIN_URL.'/assets/img/icon-warning.png" width="20" height="20" alt="" align="top" />'
|
27 |
+
);
|
28 |
+
?>
|
29 |
+
</em></div><br />
|
30 |
+
<?php
|
31 |
+
}
|
32 |
+
?>
|
33 |
+
|
34 |
+
<table class="wp-asset-clean-up wp-list-table widefat wpacu_widefat fixed striped wpacu_striped">
|
35 |
+
<tbody>
|
36 |
+
<?php
|
37 |
+
foreach ($data['all']['styles'] as $obj) {
|
38 |
+
$active = (isset($data['current']['styles']) && in_array($obj->handle, $data['current']['styles']));
|
39 |
+
|
40 |
+
$class = ($active) ? 'wpacu_not_load' : '';
|
41 |
+
$checked = ($active) ? 'checked="checked"' : '';
|
42 |
+
?>
|
43 |
+
<tr class="wpacu_asset_row <?php echo $class; ?>">
|
44 |
+
<td scope="row" class="wpacu_check check-column" valign="top"><input id="style_<?php echo $obj->handle; ?>" <?php echo $checked; ?> name="<?php echo WPACU_PLUGIN_NAME; ?>[styles][]" class="icheckbox_square-red" type="checkbox" value="<?php echo $obj->handle; ?>" /></td>
|
45 |
+
<td valign="top" style="width: 100%;">
|
46 |
+
<p style="margin-top: 0px;">
|
47 |
+
<label for="style_<?php echo $obj->handle; ?>"><?php _e('Handle:', WPACU_PLUGIN_NAME); ?> <strong><span style="color: green;"><?php echo $obj->handle; ?></span></strong></label>
|
48 |
+
<?php
|
49 |
+
if (isset($obj->wp) && $obj->wp) {
|
50 |
+
?>
|
51 |
+
<img src="<?php echo WPACU_PLUGIN_URL; ?>/assets/img/icon-warning.png"
|
52 |
+
width="20"
|
53 |
+
height="20"
|
54 |
+
alt=""
|
55 |
+
align="top" />
|
56 |
+
<?php
|
57 |
+
}
|
58 |
+
?>
|
59 |
+
</p>
|
60 |
+
|
61 |
+
<?php
|
62 |
+
if (isset($obj->src) && $obj->src != '') {
|
63 |
+
?>
|
64 |
+
<p><?php _e('Source:', WPACU_PLUGIN_NAME); ?> <a target="_blank" href="<?php echo $obj->srcHref; ?>"><?php echo $obj->src; ?></a></p>
|
65 |
+
<?php }
|
66 |
+
|
67 |
+
if (! empty($obj->deps)) {
|
68 |
+
?>
|
69 |
+
<p><?php echo __('Depends on:', WPACU_PLUGIN_NAME) . ' ' . implode(', ', $obj->deps); ?></p>
|
70 |
+
<?php
|
71 |
+
}
|
72 |
+
|
73 |
+
if ($obj->ver) {
|
74 |
+
?>
|
75 |
+
<p><?php _e('Version:', WPACU_PLUGIN_NAME); ?> <?php echo $obj->ver; ?></p>
|
76 |
+
<?php
|
77 |
+
}
|
78 |
+
|
79 |
+
if (isset($obj->extra->data) && ! empty($obj->extra->data)) { ?>
|
80 |
+
<p><?php _e('Inline:', WPACU_PLUGIN_NAME); ?> <em><?php echo $obj->extra->data; ?></em></p>
|
81 |
+
<?php } ?>
|
82 |
+
</td>
|
83 |
+
</tr>
|
84 |
+
<?php
|
85 |
+
}
|
86 |
+
?>
|
87 |
+
</tbody>
|
88 |
+
</table>
|
89 |
+
<?php
|
90 |
+
} else {
|
91 |
+
echo __('It looks like there are no public .css files loaded or the ones visible do not follow <a href="https://codex.wordpress.org/Function_Reference/wp_enqueue_style">the WordPress way of enqueuing styles</a>.', WPACU_PLUGIN_NAME);
|
92 |
+
}
|
93 |
+
?>
|
94 |
+
<h3><?php _e('Scripts (.js files)', WPACU_PLUGIN_NAME); ?></h3>
|
95 |
+
<?php
|
96 |
+
if (! empty($data['all']['scripts'])) {
|
97 |
+
?>
|
98 |
+
<p><?php echo sprintf(__('The following scripts are loading on this page. Please select the ones that are %sNOT NEEDED%s. If you are not sure which ones to unload, it is better to leave them enabled and consult with a developer about unloading the assets.', WPACU_PLUGIN_NAME), '<span style="color: #CC0000;"><strong>', '</strong></span>'); ?></p>
|
99 |
+
|
100 |
+
<?php
|
101 |
+
if ($data['core_scripts_loaded']) {
|
102 |
+
?>
|
103 |
+
<div class="wpacu_note wpacu_warning"><em><?php
|
104 |
+
echo sprintf(
|
105 |
+
__('Assets that are marked with %s are part of WordPress core files. Be careful if you decide to unload them!', WPACU_PLUGIN_NAME),
|
106 |
+
'<img src="'.WPACU_PLUGIN_URL.'/assets/img/icon-warning.png" width="20" height="20" alt="" align="top" />'
|
107 |
+
);
|
108 |
+
?>
|
109 |
+
</em></div><br />
|
110 |
+
<?php
|
111 |
+
}
|
112 |
+
?>
|
113 |
+
|
114 |
+
<table class="wp-list-table widefat wpacu_widefat fixed striped wpacu_striped">
|
115 |
+
<tbody>
|
116 |
+
<?php
|
117 |
+
foreach ($data['all']['scripts'] as $obj) {
|
118 |
+
$active = (isset($data['current']['scripts']) && in_array($obj->handle, $data['current']['scripts']));
|
119 |
+
|
120 |
+
$class = ($active) ? 'wpacu_not_load' : '';
|
121 |
+
$checked = ($active) ? 'checked="checked"' : '';
|
122 |
+
?>
|
123 |
+
<tr class="wpacu_asset_row <?php echo $class; ?>">
|
124 |
+
<td scope="row" class="wpacu_check check-column" valign="top"><input id="script_<?php echo $obj->handle; ?>" <?php echo $checked; ?> name="<?php echo WPACU_PLUGIN_NAME; ?>[scripts][]" class="icheckbox_square-red" type="checkbox" value="<?php echo $obj->handle; ?>" /></td>
|
125 |
+
<td valign="top" style="width: 100%;">
|
126 |
+
<p style="margin-top: 0px;">
|
127 |
+
<label for="script_<?php echo $obj->handle; ?>"><?php _e('Handle:', WPACU_PLUGIN_NAME); ?> <strong><span style="color: green;"><?php echo $obj->handle; ?></span></strong></label>
|
128 |
+
<?php
|
129 |
+
if (isset($obj->wp) && $obj->wp) {
|
130 |
+
?>
|
131 |
+
<img src="<?php echo WPACU_PLUGIN_URL; ?>/assets/img/icon-warning.png"
|
132 |
+
width="20"
|
133 |
+
height="20"
|
134 |
+
alt=""
|
135 |
+
align="top" />
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
?>
|
139 |
+
</p>
|
140 |
+
<?php
|
141 |
+
if (isset($obj->src) && $obj->src != '') {
|
142 |
+
?>
|
143 |
+
<p><?php _e('Source:', WPACU_PLUGIN_NAME); ?> <a target="_blank" href="<?php echo $obj->srcHref; ?>"><?php echo $obj->src; ?></a></p>
|
144 |
+
<?php } ?>
|
145 |
+
|
146 |
+
<?php
|
147 |
+
if (! empty($obj->deps)) {
|
148 |
+
?>
|
149 |
+
<p><?php echo __('Depends on:', WPACU_PLUGIN_NAME) . ' ' . implode(', ', $obj->deps); ?></p>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
if (isset($obj->ver) && $obj->ver != '') {
|
154 |
+
?>
|
155 |
+
<p><?php _e('Version:', WPACU_PLUGIN_NAME); ?> <?php echo $obj->ver; ?></p>
|
156 |
+
<?php
|
157 |
+
}
|
158 |
+
|
159 |
+
if (isset($obj->extra->data) && ! empty($obj->extra->data)) { ?>
|
160 |
+
<p><?php _e('Inline:', WPACU_PLUGIN_NAME); ?> <em><?php echo $obj->extra->data; ?></em></p>
|
161 |
+
<?php
|
162 |
+
}
|
163 |
+
|
164 |
+
if (isset($obj->position) && $obj->position != '') {
|
165 |
+
?>
|
166 |
+
<p><?php _e('Position:', WPACU_PLUGIN_NAME); ?> <?php echo ($obj->position == 'head') ? 'HEAD' : 'BODY'; ?></p>
|
167 |
+
<?php
|
168 |
+
}
|
169 |
+
?>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
<?php
|
173 |
+
}
|
174 |
+
?>
|
175 |
+
</tbody>
|
176 |
+
</table>
|
177 |
+
<?php
|
178 |
+
} else {
|
179 |
+
echo __('It looks like there are no public .js files loaded or the ones visible do not follow <a href="https://codex.wordpress.org/Function_Reference/wp_enqueue_script">the WordPress way of enqueuing scripts</a>.', WPACU_PLUGIN_NAME);
|
180 |
+
}
|
templates/meta-box.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* No direct access to this file
|
4 |
+
*/
|
5 |
+
if (! isset($data)) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
?>
|
9 |
+
<div id="wpacu_meta_box_content">
|
10 |
+
<?php
|
11 |
+
if ($data['get_assets']) {
|
12 |
+
?>
|
13 |
+
<img src="<?php echo admin_url(); ?>/images/spinner.gif" align="top" width="20" height="20" alt="" />
|
14 |
+
<?php echo sprintf(__('Fetching the loaded scripts and styles for <strong>%s</strong> <br /><br /> Please wait... <br /><br /> In case the list does not show consider checking your internet connection and the actual page that is being fetched to see if it loads completely.', WPACU_PLUGIN_NAME), $data['fetch_url']); ?>
|
15 |
+
<?php
|
16 |
+
} else {
|
17 |
+
_e('The styles and scripts will be available for unload once this post/page is <strong>public</strong> and <strong>publish</strong>ed as the whole page needs to be scanned for all the loaded assets.', WPACU_PLUGIN_NAME);
|
18 |
+
}
|
19 |
+
?>
|
20 |
+
</div>
|
templates/settings-frontend.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* No direct access to this file
|
4 |
+
*/
|
5 |
+
if (! isset($data)) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
?>
|
9 |
+
|
10 |
+
<form action="#wpacu_wrap_assets" method="post">
|
11 |
+
<div id="wpacu_wrap_assets">
|
12 |
+
<h1>WP Asset Clean Up</h1>
|
13 |
+
<p><small>* this area is shown only for the admin users and if "Manage in the Front-end?" was selected in the plugin's settings</small></p>
|
14 |
+
<p><small>* 'admin-bar', 'wpassetcleanup-icheck-square-red' and 'wpassetcleanup-style' are not included as they are irrelevant since they are used by the plugin for this area</small></p>
|
15 |
+
<?php
|
16 |
+
require_once 'meta-box-loaded.php';
|
17 |
+
?>
|
18 |
+
<div style="margin: 10px 0;">
|
19 |
+
<input class="wpacu_update_btn"
|
20 |
+
type="submit"
|
21 |
+
name="submit"
|
22 |
+
value="<?php esc_attr_e('UPDATE', WPACU_PLUGIN_NAME); ?>" />
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<p align="right"><small>Powered by WP Asset Clean Up</small></p>
|
26 |
+
</div>
|
27 |
+
<?php wp_nonce_field($data['nonce_action'], $data['nonce_name']); ?>
|
28 |
+
<input type="hidden" name="wpacu_update_asset_frontend" value="1" />
|
29 |
+
</form>
|
templates/settings-home-page.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* No direct access to this file
|
4 |
+
*/
|
5 |
+
if (! isset($data)) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
?>
|
9 |
+
<h1><?php _e('WP Asset Clean Up', WPACU_PLUGIN_NAME); ?></h1>
|
10 |
+
<h2><?php _e('Home Page Scripts & Styles Management', WPACU_PLUGIN_NAME); ?></h2>
|
11 |
+
|
12 |
+
<?php
|
13 |
+
if ($data['show_on_front'] === 'page') {
|
14 |
+
?>
|
15 |
+
<p><?php _e('In "Settings" -> "Reading" you have selected a static page for "Front page displays" setting. To manage the assets (.CSS & .JS) that will NOT LOAD, use the link(s) below:', WPACU_PLUGIN_NAME); ?></p>
|
16 |
+
<div>
|
17 |
+
<ul>
|
18 |
+
<?php
|
19 |
+
if ($data['page_on_front']) {
|
20 |
+
?>
|
21 |
+
<li>
|
22 |
+
<?php _e('Front page:', WPACU_PLUGIN_NAME); ?>
|
23 |
+
<a href="post.php?post=<?php echo $data['page_on_front']; ?>&action=edit#<?php echo WPACU_PLUGIN_NAME; ?>_asset_list"><strong><?php echo $data['page_on_front_title']; ?></strong></a>
|
24 |
+
</li>
|
25 |
+
<?php
|
26 |
+
}
|
27 |
+
|
28 |
+
if ($data['page_for_posts']) {
|
29 |
+
?>
|
30 |
+
<li>
|
31 |
+
<?php _e('Posts page:', WPACU_PLUGIN_NAME); ?>
|
32 |
+
<a href="post.php?post=<?php echo $data['page_for_posts']; ?>&action=edit#<?php echo WPACU_PLUGIN_NAME; ?>_asset_list"><strong><?php echo $data['page_for_posts_title']; ?></strong></a>
|
33 |
+
</li>
|
34 |
+
<?php
|
35 |
+
}
|
36 |
+
?>
|
37 |
+
</ul>
|
38 |
+
</div>
|
39 |
+
<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>
|
40 |
+
<?php
|
41 |
+
} elseif ($data['show_on_front'] == 'posts') {
|
42 |
+
?>
|
43 |
+
<form id="wpacu_home_page_form" method="post" action="">
|
44 |
+
<p><?php echo sprintf(__('Your front (home) page URL is <strong>%s</strong>'), $data['site_url']); ?></p>
|
45 |
+
|
46 |
+
<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" -> "Reading"). 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>
|
47 |
+
|
48 |
+
<p>The plugin uses <a target="_blank" href="https://codex.wordpress.org/Function_Reference/is_front_page">is_front_page()</a> WordPress function 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>
|
49 |
+
|
50 |
+
<div id="wpacu_meta_box_content">
|
51 |
+
<img src="<?php echo admin_url(); ?>/images/spinner.gif" align="top" width="20" height="20" alt="" />
|
52 |
+
<?php _e('We\'re getting the loaded scripts and styles for the home page. Please wait...', WPACU_PLUGIN_NAME); ?>
|
53 |
+
</div>
|
54 |
+
<input type="hidden" name="<?php echo $data['nonce_name']; ?>" value="<?php echo $data['nonce_value']; ?>" />
|
55 |
+
<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>
|
56 |
+
</form>
|
57 |
+
<?php
|
58 |
+
}
|
templates/settings-plugin.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* No direct access to this file
|
4 |
+
*/
|
5 |
+
if (! isset($data)) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
?>
|
9 |
+
<div class="wrap">
|
10 |
+
<h1><?php _e('WP Asset Clean Up', WPACU_PLUGIN_NAME); ?></h1>
|
11 |
+
<h2><?php _e('Plugin Settings', WPACU_PLUGIN_NAME); ?></h2>
|
12 |
+
|
13 |
+
<form method="post" action="options.php">
|
14 |
+
<?php settings_fields('wpacu-plugin-settings-group'); ?>
|
15 |
+
<?php do_settings_sections('wpacu-plugin-settings-group'); ?>
|
16 |
+
<table class="form-table">
|
17 |
+
<tr valign="top">
|
18 |
+
<th scope="row">Manage in the Front-end?</th>
|
19 |
+
<td><input type="checkbox"
|
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>
|
23 |
+
<p><small>The area will be shown through the <code>wp_footer</code> action so in case you do not see the asset list at the bottom of the page, make sure the theme is using <a href="https://codex.wordpress.org/Function_Reference/wp_footer"><code>wp_footer()</code></a> function before the <code></body></code> tag. Any theme that follows the standards should have it. If not, you will have to add it to make sure other plugins and code from functions.php will work fine.</small></p>
|
24 |
+
</td>
|
25 |
+
</tr>
|
26 |
+
</table>
|
27 |
+
|
28 |
+
<?php submit_button(); ?>
|
29 |
+
</form>
|
30 |
+
</div>
|
wpacu-load.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if (! defined('ABSPATH')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
define('WPACU_PLUGIN_NAME', 'wpassetcleanup');
|
8 |
+
define('WPACU_PLUGIN_CLASSES_PATH', dirname(__FILE__).'/classes/');
|
9 |
+
define('WPACU_PLUGIN_FILE', $pluginFile);
|
10 |
+
define('WPACU_PLUGIN_URL', plugins_url('', WPACU_PLUGIN_FILE));
|
11 |
+
|
12 |
+
// Autoload Classes
|
13 |
+
function includeWpAssetCleanUpClassesAutoload($class)
|
14 |
+
{
|
15 |
+
$classes = array(
|
16 |
+
'WpAssetCleanUp\ClassLoader' => 'ClassLoader',
|
17 |
+
'WpAssetCleanUp\HomePage' => 'HomePage',
|
18 |
+
'WpAssetCleanUp\Main' => 'Main',
|
19 |
+
'WpAssetCleanUp\PluginManager' => 'PluginManager',
|
20 |
+
'WpAssetCleanUp\Menu' => 'Menu',
|
21 |
+
'WpAssetCleanUp\Settings' => 'Settings'
|
22 |
+
);
|
23 |
+
|
24 |
+
if (! isset($classes[$class])) {
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$pathToClass = WPACU_PLUGIN_CLASSES_PATH.$classes[$class].'.php';
|
29 |
+
|
30 |
+
if (file_exists($pathToClass)) {
|
31 |
+
include_once $pathToClass;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
spl_autoload_register('includeWpAssetCleanUpClassesAutoload');
|
36 |
+
|
37 |
+
// Main Class
|
38 |
+
new WpAssetCleanUp\Main;
|
39 |
+
|
40 |
+
// Settings
|
41 |
+
new WpAssetCleanUp\Settings;
|
42 |
+
|
43 |
+
// Plugin Manager
|
44 |
+
WpAssetCleanUp\PluginManager::init();
|
45 |
+
|
46 |
+
// Menu
|
47 |
+
$wpacuMenu = new \WpAssetCleanUp\Menu;
|
48 |
+
$wpacuMenu->init();
|
wpacu.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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.1.4.6
|
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/
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Exit if accessed directly
|
12 |
+
if (! defined('ABSPATH')) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
// Do not load the plugin if the PHP version is below 5.3
|
17 |
+
$wpacuWrongPhp = version_compare(PHP_VERSION, '5.3.0', '<');
|
18 |
+
|
19 |
+
if (is_admin() && $wpacuWrongPhp) { // Dashboard
|
20 |
+
wp_die(
|
21 |
+
__('This plugin requires <span style="color: green;"><strong>5.3+</strong> PHP version</span> installed. You have <strong>'.PHP_VERSION.'</strong>. If your website is working in 5.3+ (check with your developers if you are not sure), then an upgrade is highly recommended.', AFP_TEXT_DOMAIN),
|
22 |
+
__('Plugin Activation Error', AFP_TEXT_DOMAIN),
|
23 |
+
array('response' => 200, 'back_link' => true)
|
24 |
+
);
|
25 |
+
} elseif ($wpacuWrongPhp) { // Front
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
|
29 |
+
$pluginFile = __FILE__;
|
30 |
+
|
31 |
+
require_once dirname(__FILE__).'/wpacu-load.php';
|