@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Outputs JS code for the rules panel. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( $ao_ccss_debug ) { |
|
6 | +if ($ao_ccss_debug) { |
|
7 | 7 | echo "console.log('[WARN] Autoptimize CriticalCSS Power-Up is in DEBUG MODE!');\n"; |
8 | 8 | echo "console.log('[WARN] Avoid using debug mode on production/live environments unless for ad-hoc troubleshooting purposes and make sure to disable it after!');\n"; |
9 | 9 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | jQuery(document).ready(function() { |
24 | 24 | critCssArray=JSON.parse(document.getElementById("critCssOrigin").value); |
25 | 25 | <?php |
26 | - if ( $ao_ccss_debug ) { |
|
26 | + if ($ao_ccss_debug) { |
|
27 | 27 | echo "console.log('Rules Object:', critCssArray);\n"; |
28 | 28 | } |
29 | 29 | ?> |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | jQuery("#rules-list").empty(); |
40 | 40 | jQuery.each(critCssArray,function(k,v) { |
41 | 41 | if (k=="paths") { |
42 | - kstring="<?php _e( 'Path Based Rules', 'autoptimize' ); ?>"; |
|
42 | + kstring="<?php _e('Path Based Rules', 'autoptimize'); ?>"; |
|
43 | 43 | } else { |
44 | - kstring="<?php _e( 'Conditional Tags, Custom Post Types and Page Templates Rules', 'autoptimize' ); ?>"; |
|
44 | + kstring="<?php _e('Conditional Tags, Custom Post Types and Page Templates Rules', 'autoptimize'); ?>"; |
|
45 | 45 | } |
46 | 46 | if (!(jQuery.isEmptyObject(v))) { |
47 | 47 | jQuery("#rules-list").append("<tr><td colspan='5'><h4>" + kstring + "</h4></td></tr>"); |
48 | - jQuery("#rules-list").append("<tr class='header "+k+"Rule'><th><?php _e( 'Type', 'autoptimize' ); ?></th><th><?php _e( 'Target', 'autoptimize' ); ?></th><th><?php _e( 'Critical CSS File', 'autoptimize' ); ?></th><th colspan='2'><?php _e( 'Actions', 'autoptimize' ); ?></th></tr>"); |
|
48 | + jQuery("#rules-list").append("<tr class='header "+k+"Rule'><th><?php _e('Type', 'autoptimize'); ?></th><th><?php _e('Target', 'autoptimize'); ?></th><th><?php _e('Critical CSS File', 'autoptimize'); ?></th><th colspan='2'><?php _e('Actions', 'autoptimize'); ?></th></tr>"); |
|
49 | 49 | } |
50 | 50 | nodeNumber=0; |
51 | 51 | jQuery.each(v,function(i,nv){ |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | file=nv.file; |
56 | 56 | filest=nv.file; |
57 | 57 | if (file == 0) { |
58 | - file='<?php _e( 'To be fetched from criticalcss.com in the next queue run...', 'autoptimize' ); ?>'; |
|
58 | + file='<?php _e('To be fetched from criticalcss.com in the next queue run...', 'autoptimize'); ?>'; |
|
59 | 59 | } |
60 | 60 | if (nv.hash === 0 && filest != 0) { |
61 | - type='<?php _e( 'MANUAL', 'autoptimize' ); ?>'; |
|
61 | + type='<?php _e('MANUAL', 'autoptimize'); ?>'; |
|
62 | 62 | typeClass = 'manual'; |
63 | 63 | } else { |
64 | - type='<?php _e( 'AUTO', 'autoptimize' ); ?>'; |
|
64 | + type='<?php _e('AUTO', 'autoptimize'); ?>'; |
|
65 | 65 | typeClass = 'auto'; |
66 | 66 | } |
67 | 67 | if (file && typeof file == 'string') { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } else { |
78 | 78 | target = i.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,''); |
79 | 79 | } |
80 | - jQuery("#rules-list").append("<tr class='rule "+k+"Rule'><td class='type'><span class='badge " + typeClass + "'>" + type + "</span>" + rmark + "</td><td class='target'>" + target + "</td><td class='file'>" + file + "</td><td class='btn edit'><span class=\"button-secondary\" id=\"" + nodeId + "_edit\"><?php _e( 'Edit', 'autoptimize' ); ?></span></td><td class='btn delete'><span class=\"button-secondary\" id=\"" + nodeId + "_remove\"><?php _e( 'Remove', 'autoptimize' ); ?></span></td></tr>"); |
|
80 | + jQuery("#rules-list").append("<tr class='rule "+k+"Rule'><td class='type'><span class='badge " + typeClass + "'>" + type + "</span>" + rmark + "</td><td class='target'>" + target + "</td><td class='file'>" + file + "</td><td class='btn edit'><span class=\"button-secondary\" id=\"" + nodeId + "_edit\"><?php _e('Edit', 'autoptimize'); ?></span></td><td class='btn delete'><span class=\"button-secondary\" id=\"" + nodeId + "_remove\"><?php _e('Remove', 'autoptimize'); ?></span></td></tr>"); |
|
81 | 81 | jQuery("#" + nodeId + "_edit").click(function(){addEditRow(this.id);}); |
82 | 82 | jQuery("#" + nodeId + "_remove").click(function(){confirmRemove(this.id);}); |
83 | 83 | }) |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | height:235, |
91 | 91 | modal: true, |
92 | 92 | buttons: { |
93 | - "<?php _e( 'Delete', 'autoptimize' ); ?>": function() { |
|
93 | + "<?php _e('Delete', 'autoptimize'); ?>": function() { |
|
94 | 94 | removeRow(idToRemove); |
95 | 95 | updateAfterChange(); |
96 | 96 | jQuery( this ).dialog( "close" ); |
97 | 97 | }, |
98 | - "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() { |
|
98 | + "<?php _e('Cancel', 'autoptimize'); ?>": function() { |
|
99 | 99 | jQuery( this ).dialog( "close" ); |
100 | 100 | } |
101 | 101 | } |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | height:235, |
109 | 109 | modal: true, |
110 | 110 | buttons: { |
111 | - "<?php _e( 'Delete All', 'autoptimize' ); ?>": function() { |
|
111 | + "<?php _e('Delete All', 'autoptimize'); ?>": function() { |
|
112 | 112 | critCssArray={'paths':[],'types':[]}; |
113 | 113 | drawTable(critCssArray); |
114 | 114 | updateAfterChange(); |
115 | 115 | removeAllCcssFilesOnServer(); |
116 | 116 | jQuery( this ).dialog( "close" ); |
117 | 117 | }, |
118 | - "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() { |
|
118 | + "<?php _e('Cancel', 'autoptimize'); ?>": function() { |
|
119 | 119 | jQuery( this ).dialog( "close" ); |
120 | 120 | } |
121 | 121 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | var data = { |
134 | 134 | 'action': 'rm_critcss', |
135 | - 'critcss_rm_nonce': '<?php echo wp_create_nonce( 'rm_critcss_nonce' ); ?>', |
|
135 | + 'critcss_rm_nonce': '<?php echo wp_create_nonce('rm_critcss_nonce'); ?>', |
|
136 | 136 | 'cachebustingtimestamp': new Date().getTime(), |
137 | 137 | 'critcssfile': crit_file |
138 | 138 | }; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | function removeAllCcssFilesOnServer() { |
154 | 154 | var data = { |
155 | 155 | 'action': 'rm_critcss_all', |
156 | - 'critcss_rm_all_nonce': '<?php echo wp_create_nonce( 'rm_critcss_all_nonce' ); ?>', |
|
156 | + 'critcss_rm_all_nonce': '<?php echo wp_create_nonce('rm_critcss_all_nonce'); ?>', |
|
157 | 157 | 'cachebustingtimestamp': new Date().getTime() |
158 | 158 | }; |
159 | 159 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | function addEditRow(idToEdit) { |
174 | 174 | resetForm(); |
175 | 175 | if (idToEdit) { |
176 | - dialogTitle="<?php _e( 'Edit Critical CSS Rule', 'autoptimize' ); ?>"; |
|
176 | + dialogTitle="<?php _e('Edit Critical CSS Rule', 'autoptimize'); ?>"; |
|
177 | 177 | |
178 | 178 | splits=idToEdit.split(/_/); |
179 | 179 | crit_type=splits[0]; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | jQuery("#critcss_addedit_id").val(idToEdit); |
185 | 185 | jQuery("#critcss_addedit_type").val(crit_type); |
186 | 186 | jQuery("#critcss_addedit_file").val(crit_file); |
187 | - jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'Loading critical CSS...', 'autoptimize' ); ?>"); |
|
187 | + jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('Loading critical CSS...', 'autoptimize'); ?>"); |
|
188 | 188 | jQuery("#critcss_addedit_type").attr("disabled",true); |
189 | 189 | |
190 | 190 | if (crit_type==="paths") { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | var data = { |
201 | 201 | 'action': 'fetch_critcss', |
202 | - 'critcss_fetch_nonce': '<?php echo wp_create_nonce( 'fetch_critcss_nonce' ); ?>', |
|
202 | + 'critcss_fetch_nonce': '<?php echo wp_create_nonce('fetch_critcss_nonce'); ?>', |
|
203 | 203 | 'cachebustingtimestamp': new Date().getTime(), |
204 | 204 | 'critcssfile': crit_file |
205 | 205 | }; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | }); |
215 | 215 | } else { |
216 | - dialogTitle="<?php _e( 'Add Critical CSS Rule', 'autotimize' ); ?>"; |
|
216 | + dialogTitle="<?php _e('Add Critical CSS Rule', 'autotimize'); ?>"; |
|
217 | 217 | |
218 | 218 | // default: paths, hide content type field |
219 | 219 | jQuery("#critcss_addedit_type").val("paths"); |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | if(this.value==="types") { |
225 | 225 | jQuery("#critcss_addedit_pagetype_wrapper").show(); |
226 | 226 | jQuery("#critcss_addedit_path_wrapper").hide(); |
227 | - jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For type based rules, paste your specific and minified critical CSS here and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\".', 'autoptimize' ); ?>"); |
|
227 | + jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For type based rules, paste your specific and minified critical CSS here and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\".', 'autoptimize'); ?>"); |
|
228 | 228 | } else { |
229 | 229 | jQuery("#critcss_addedit_path_wrapper").show(); |
230 | 230 | jQuery("#critcss_addedit_pagetype_wrapper").hide(); |
231 | - jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize' ); ?>"); |
|
231 | + jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize'); ?>"); |
|
232 | 232 | } |
233 | 233 | }); |
234 | 234 | } |
@@ -240,21 +240,21 @@ discard block |
||
240 | 240 | title: dialogTitle, |
241 | 241 | modal: true, |
242 | 242 | buttons: { |
243 | - "<?php _e( 'Submit', 'autoptimize' ); ?>": function() { |
|
243 | + "<?php _e('Submit', 'autoptimize'); ?>": function() { |
|
244 | 244 | rpath = jQuery("#critcss_addedit_path").val(); |
245 | 245 | rtype = jQuery("#critcss_addedit_pagetype option:selected").val(); |
246 | 246 | rccss = jQuery("#critcss_addedit_css").val(); |
247 | 247 | console.log('rpath: ' + rpath, 'rtype: ' + rtype, 'rccss: ' + rccss); |
248 | 248 | if (rpath === '' && rtype === '') { |
249 | - alert('<?php _e( "RULE VALIDATION ERROR!\\n\\nBased on your rule type, you SHOULD set a path or conditional tag.", 'autoptimize' ); ?>'); |
|
249 | + alert('<?php _e("RULE VALIDATION ERROR!\\n\\nBased on your rule type, you SHOULD set a path or conditional tag.", 'autoptimize'); ?>'); |
|
250 | 250 | } else if (rtype !== '' && rccss == '') { |
251 | - alert('<?php _e( "RULE VALIDATION ERROR!\\n\\nType based rules REQUIRES a minified critical CSS.", 'autoptimize' ); ?>'); |
|
251 | + alert('<?php _e("RULE VALIDATION ERROR!\\n\\nType based rules REQUIRES a minified critical CSS.", 'autoptimize'); ?>'); |
|
252 | 252 | } else { |
253 | 253 | saveEditCritCss(); |
254 | 254 | jQuery(this).dialog('close'); |
255 | 255 | } |
256 | 256 | }, |
257 | - "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() { |
|
257 | + "<?php _e('Cancel', 'autoptimize'); ?>": function() { |
|
258 | 258 | resetForm(); |
259 | 259 | jQuery(this).dialog("close"); |
260 | 260 | } |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | autoOpen: true, |
269 | 269 | height: 505, |
270 | 270 | width: 700, |
271 | - title: "<?php _e( 'Default Critical CSS', 'autoptimize' ); ?>", |
|
271 | + title: "<?php _e('Default Critical CSS', 'autoptimize'); ?>", |
|
272 | 272 | modal: true, |
273 | 273 | buttons: { |
274 | - "<?php _e( 'Submit', 'autoptimize' ); ?>": function() { |
|
274 | + "<?php _e('Submit', 'autoptimize'); ?>": function() { |
|
275 | 275 | document.getElementById("autoptimize_css_defer_inline").value=document.getElementById("dummyDefault").value; |
276 | 276 | jQuery("#unSavedWarning").show(); |
277 | 277 | jQuery("#default_critcss_wrapper").dialog( "close" ); |
278 | 278 | }, |
279 | - "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() { |
|
279 | + "<?php _e('Cancel', 'autoptimize'); ?>": function() { |
|
280 | 280 | jQuery("#default_critcss_wrapper").dialog( "close" ); |
281 | 281 | } |
282 | 282 | } |
@@ -289,15 +289,15 @@ discard block |
||
289 | 289 | autoOpen: true, |
290 | 290 | height: 505, |
291 | 291 | width: 700, |
292 | - title: "<?php _e( 'Additional Critical CSS', 'autoptimize' ); ?>", |
|
292 | + title: "<?php _e('Additional Critical CSS', 'autoptimize'); ?>", |
|
293 | 293 | modal: true, |
294 | 294 | buttons: { |
295 | - "<?php _e( 'Submit', 'autoptimize' ); ?>": function() { |
|
295 | + "<?php _e('Submit', 'autoptimize'); ?>": function() { |
|
296 | 296 | document.getElementById("autoptimize_ccss_additional").value=document.getElementById("dummyAdditional").value; |
297 | 297 | jQuery("#unSavedWarning").show(); |
298 | 298 | jQuery("#additional_critcss_wrapper").dialog( "close" ); |
299 | 299 | }, |
300 | - "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() { |
|
300 | + "<?php _e('Cancel', 'autoptimize'); ?>": function() { |
|
301 | 301 | jQuery("#additional_critcss_wrapper").dialog( "close" ); |
302 | 302 | } |
303 | 303 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | critCssArray[critcsstype][critcsstarget].file=critcssfile; |
334 | 334 | |
335 | 335 | <?php |
336 | - if ( $ao_ccss_debug ) { |
|
336 | + if ($ao_ccss_debug) { |
|
337 | 337 | echo "console.log('[RULE PROPERTIES] Type:', critcsstype, ', Target:', critcsstarget, ', Hash:', 0, ', File:', critcssfile);"; |
338 | 338 | } |
339 | 339 | ?> |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | var data = { |
344 | 344 | 'action': 'save_critcss', |
345 | - 'critcss_save_nonce': '<?php echo wp_create_nonce( 'save_critcss_nonce' ); ?>', |
|
345 | + 'critcss_save_nonce': '<?php echo wp_create_nonce('save_critcss_nonce'); ?>', |
|
346 | 346 | 'critcssfile': critcssfile, |
347 | 347 | 'critcsscontents': critcsscontents |
348 | 348 | }; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | function resetForm() { |
370 | - jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize' ); ?>"); |
|
370 | + jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize'); ?>"); |
|
371 | 371 | jQuery("#critcss_addedit_type").attr("disabled",false); |
372 | 372 | jQuery("#critcss_addedit_path_wrapper").show(); |
373 | 373 | jQuery("#critcss_addedit_id").val(""); |
@@ -12,27 +12,27 @@ discard block |
||
12 | 12 | * @param string $message Message. |
13 | 13 | * @param string $color Color to highlight message in. |
14 | 14 | */ |
15 | -function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) { |
|
16 | - if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) { |
|
17 | - $key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' ); |
|
15 | +function ao_ccss_render_key($key, $status, $status_msg, $message, $color) { |
|
16 | + if (defined('AUTOPTIMIZE_CRITICALCSS_API_KEY')) { |
|
17 | + $key = __('API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize'); |
|
18 | 18 | } |
19 | 19 | ?> |
20 | 20 | <ul id="key-panel"> |
21 | 21 | <li class="itemDetail"> |
22 | - <h2 class="itemTitle fleft"><?php _e( 'API Key', 'autoptimize' ); ?>: <span style="color:<?php echo $color; ?>;"><?php echo $status_msg; ?></span></h2> |
|
22 | + <h2 class="itemTitle fleft"><?php _e('API Key', 'autoptimize'); ?>: <span style="color:<?php echo $color; ?>;"><?php echo $status_msg; ?></span></h2> |
|
23 | 23 | <button type="button" class="toggle-btn"> |
24 | - <?php if ( 'valid' != $status ) { ?> |
|
24 | + <?php if ('valid' != $status) { ?> |
|
25 | 25 | <span class="toggle-indicator dashicons dashicons-arrow-up"></span> |
26 | 26 | <?php } else { ?> |
27 | 27 | <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span> |
28 | 28 | <?php } ?> |
29 | 29 | </button> |
30 | - <?php if ( 'valid' != $status ) { ?> |
|
30 | + <?php if ('valid' != $status) { ?> |
|
31 | 31 | <div class="collapsible"> |
32 | 32 | <?php } else { ?> |
33 | 33 | <div class="collapsible hidden"> |
34 | 34 | <?php } ?> |
35 | - <?php if ( 'valid' != $status ) { ?> |
|
35 | + <?php if ('valid' != $status) { ?> |
|
36 | 36 | <div style="clear:both;padding:2px 10px;border-left:solid;border-left-width:5px;border-left-color:<?php echo $color; ?>;background-color:white;"> |
37 | 37 | <p><?php echo $message; ?></p> |
38 | 38 | </div> |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | <table id="key" class="form-table"> |
41 | 41 | <tr> |
42 | 42 | <th scope="row"> |
43 | - <?php _e( 'Your API Key', 'autoptimize' ); ?> |
|
43 | + <?php _e('Your API Key', 'autoptimize'); ?> |
|
44 | 44 | </th> |
45 | 45 | <td> |
46 | - <textarea id="autoptimize_ccss_key" name="autoptimize_ccss_key" rows='3' style="width:100%;" placeholder="<?php _e( 'Please enter your criticalcss.com API key here.', 'autoptimize' ); ?>"><?php echo trim( $key ); ?></textarea> |
|
46 | + <textarea id="autoptimize_ccss_key" name="autoptimize_ccss_key" rows='3' style="width:100%;" placeholder="<?php _e('Please enter your criticalcss.com API key here.', 'autoptimize'); ?>"><?php echo trim($key); ?></textarea> |
|
47 | 47 | <p class="notes"> |
48 | - <?php _e( 'Enter your <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> API key above. The key is revalidated every time a new job is sent to it.<br />To obtain your API key, go to <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> > Account > API Keys.<br />Requests to generate a critical CSS via the API are priced at £5 per domain per month.<br /><strong>Not sure yet? With the <a href="https://criticalcss.com/faq/?aff=1#trial" target="_blank">30 day money back guarantee</a>, you have nothing to lose!</strong>', 'autoptimize' ); ?> |
|
48 | + <?php _e('Enter your <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> API key above. The key is revalidated every time a new job is sent to it.<br />To obtain your API key, go to <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> > Account > API Keys.<br />Requests to generate a critical CSS via the API are priced at £5 per domain per month.<br /><strong>Not sure yet? With the <a href="https://criticalcss.com/faq/?aff=1#trial" target="_blank">30 day money back guarantee</a>, you have nothing to lose!</strong>', 'autoptimize'); ?> |
|
49 | 49 | </p> |
50 | 50 | </td> |
51 | 51 | </tr> |
@@ -16,66 +16,66 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if (!defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
23 | -define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.7.2' ); |
|
23 | +define('AUTOPTIMIZE_PLUGIN_VERSION', '2.7.2'); |
|
24 | 24 | |
25 | 25 | // plugin_dir_path() returns the trailing slash! |
26 | -define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
27 | -define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ ); |
|
26 | +define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
27 | +define('AUTOPTIMIZE_PLUGIN_FILE', __FILE__); |
|
28 | 28 | |
29 | 29 | // Bail early if attempting to run on non-supported php versions. |
30 | -if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
30 | +if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
31 | 31 | function autoptimize_incompatible_admin_notice() { |
32 | - echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>'; |
|
33 | - if ( isset( $_GET['activate'] ) ) { |
|
34 | - unset( $_GET['activate'] ); |
|
32 | + echo '<div class="error"><p>'.__('Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize').'</p></div>'; |
|
33 | + if (isset($_GET['activate'])) { |
|
34 | + unset($_GET['activate']); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | function autoptimize_deactivate_self() { |
38 | - deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) ); |
|
38 | + deactivate_plugins(plugin_basename(AUTOPTIMIZE_PLUGIN_FILE)); |
|
39 | 39 | } |
40 | - add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' ); |
|
41 | - add_action( 'admin_init', 'autoptimize_deactivate_self' ); |
|
40 | + add_action('admin_notices', 'autoptimize_incompatible_admin_notice'); |
|
41 | + add_action('admin_init', 'autoptimize_deactivate_self'); |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | -function autoptimize_autoload( $class_name ) { |
|
46 | - if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) { |
|
47 | - $file = strtolower( $class_name ); |
|
48 | - $file = str_replace( '_', '-', $file ); |
|
49 | - $path = dirname( __FILE__ ) . '/classes/external/php/'; |
|
50 | - $filepath = $path . $file . '.php'; |
|
51 | - } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) { |
|
52 | - $file = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name ); |
|
53 | - $path = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/'; |
|
54 | - $filepath = $path . $file . '.php'; |
|
55 | - } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) { |
|
45 | +function autoptimize_autoload($class_name) { |
|
46 | + if (in_array($class_name, array('Minify_HTML', 'JSMin'))) { |
|
47 | + $file = strtolower($class_name); |
|
48 | + $file = str_replace('_', '-', $file); |
|
49 | + $path = dirname(__FILE__).'/classes/external/php/'; |
|
50 | + $filepath = $path.$file.'.php'; |
|
51 | + } elseif (false !== strpos($class_name, 'Autoptimize\\tubalmartin\\CssMin')) { |
|
52 | + $file = str_replace('Autoptimize\\tubalmartin\\CssMin\\', '', $class_name); |
|
53 | + $path = dirname(__FILE__).'/classes/external/php/yui-php-cssmin-bundled/'; |
|
54 | + $filepath = $path.$file.'.php'; |
|
55 | + } elseif ('autoptimize' === substr($class_name, 0, 11)) { |
|
56 | 56 | // One of our "old" classes. |
57 | 57 | $file = $class_name; |
58 | - $path = dirname( __FILE__ ) . '/classes/'; |
|
59 | - $filepath = $path . $file . '.php'; |
|
60 | - } elseif ( 'PAnD' === $class_name ) { |
|
58 | + $path = dirname(__FILE__).'/classes/'; |
|
59 | + $filepath = $path.$file.'.php'; |
|
60 | + } elseif ('PAnD' === $class_name) { |
|
61 | 61 | $file = 'persist-admin-notices-dismissal'; |
62 | - $path = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/'; |
|
63 | - $filepath = $path . $file . '.php'; |
|
62 | + $path = dirname(__FILE__).'/classes/external/php/persist-admin-notices-dismissal/'; |
|
63 | + $filepath = $path.$file.'.php'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // If we didn't match one of our rules, bail! |
67 | - if ( ! isset( $filepath ) ) { |
|
67 | + if (!isset($filepath)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | require $filepath; |
72 | 72 | } |
73 | 73 | |
74 | -spl_autoload_register( 'autoptimize_autoload' ); |
|
74 | +spl_autoload_register('autoptimize_autoload'); |
|
75 | 75 | |
76 | 76 | // Load WP CLI command(s) on demand. |
77 | -if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
78 | - require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php'; |
|
77 | +if (defined('WP_CLI') && WP_CLI) { |
|
78 | + require AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | function autoptimize() { |
87 | 87 | static $plugin = null; |
88 | 88 | |
89 | - if ( null === $plugin ) { |
|
90 | - $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE ); |
|
89 | + if (null === $plugin) { |
|
90 | + $plugin = new autoptimizeMain(AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $plugin; |