Completed
Push — master ( 6fcb0f...ff22b7 )
by frank
01:47
created
classes/critcss-inc/admin_settings_explain.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@
 block discarded – undo
12 12
         .ao_settings_div {background: white;border: 1px solid #ccc;padding: 1px 15px;margin: 15px 10px 10px 0;}
13 13
         .ao_settings_div .form-table th {font-weight: normal;}
14 14
     </style>
15
-    <script>document.title = "Autoptimize: <?php _e( 'Critical CSS', 'autoptimize' ); ?> " + document.title;</script>
15
+    <script>document.title = "Autoptimize: <?php _e('Critical CSS', 'autoptimize'); ?> " + document.title;</script>
16 16
     <ul id="explain-panel">
17 17
         <div class="ao_settings_div">
18 18
             <?php
19 19
             $ccss_explanation = '';
20 20
 
21 21
             // get the HTML with the explanation of what critical CSS is.
22
-            if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) {
23
-                $ccss_explanation = get_transient( 'ao_ccss_explain' );
24
-                if ( empty( $ccss_explanation ) ) {
25
-                    $ccss_expl_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_ccss_explain.html?ao_ver=' . AUTOPTIMIZE_PLUGIN_VERSION );
26
-                    if ( ! is_wp_error( $ccss_expl_resp ) ) {
27
-                        if ( '200' == wp_remote_retrieve_response_code( $ccss_expl_resp ) ) {
28
-                            $ccss_explanation = wp_kses_post( wp_remote_retrieve_body( $ccss_expl_resp ) );
29
-                            set_transient( 'ao_ccss_explain', $ccss_explanation, WEEK_IN_SECONDS );
22
+            if (apply_filters('autoptimize_settingsscreen_remotehttp', true)) {
23
+                $ccss_explanation = get_transient('ao_ccss_explain');
24
+                if (empty($ccss_explanation)) {
25
+                    $ccss_expl_resp = wp_remote_get('https://misc.optimizingmatters.com/autoptimize_ccss_explain.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION);
26
+                    if (!is_wp_error($ccss_expl_resp)) {
27
+                        if ('200' == wp_remote_retrieve_response_code($ccss_expl_resp)) {
28
+                            $ccss_explanation = wp_kses_post(wp_remote_retrieve_body($ccss_expl_resp));
29
+                            set_transient('ao_ccss_explain', $ccss_explanation, WEEK_IN_SECONDS);
30 30
                         }
31 31
                     }
32 32
                 }
33 33
             }
34 34
 
35 35
             // placeholder text in case HTML is empty.
36
-            if ( empty( $ccss_explanation ) ) {
36
+            if (empty($ccss_explanation)) {
37 37
                 $ccss_explanation = '<h2>Fix render-blocking CSS!</h2><p>Significantly improve your first-paint times by making CSS non-render-blocking.</p><p>The next step is to sign up at <a href="https://criticalcss.com/?aff=1" target="_blank">https://criticalcss.com</a> (this is a premium service, priced 2 GBP/month for membership and 5 GBP/month per domain) <strong>and get the API key, which you can copy from <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">the API-keys page</a></strong> and paste below.</p><p>If you have any questions or need support, head on over to <a href="https://wordpress.org/support/plugin/autoptimize" target="_blank">our support forum</a> and we\'ll help you get up and running in no time!</p>';
38 38
             }
39 39
 
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_queue.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@  discard block
 block discarded – undo
11 11
     global $ao_ccss_queue;
12 12
 
13 13
     // Prepare the queue object.
14
-    if ( empty( $ao_ccss_queue ) ) {
14
+    if (empty($ao_ccss_queue)) {
15 15
         $ao_ccss_queue = '';
16 16
     } else {
17
-        $ao_ccss_queue = json_encode( $ao_ccss_queue );
17
+        $ao_ccss_queue = json_encode($ao_ccss_queue);
18 18
     }
19 19
 ?>
20 20
 
21 21
     <ul id="queue-panel">
22 22
         <li class="itemDetail">
23
-            <h2 class="itemTitle fleft"><?php _e( 'Job Queue', 'autoptimize' ); ?></h2>
23
+            <h2 class="itemTitle fleft"><?php _e('Job Queue', 'autoptimize'); ?></h2>
24 24
             <button type="button" class="toggle-btn">
25 25
                 <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
26 26
             </button>
27 27
             <?php
28
-            if ( autoptimizeCriticalCSSSettings::ao_ccss_has_autorules() ) {
28
+            if (autoptimizeCriticalCSSSettings::ao_ccss_has_autorules()) {
29 29
                 $_queue_visibility = 'hidden';
30 30
             } else {
31 31
                 $_queue_visibility = 'visible';
@@ -34,54 +34,54 @@  discard block
 block discarded – undo
34 34
             <div class="collapsible <?php echo $_queue_visibility; ?>">
35 35
                 <!-- BEGIN Queue dialogs -->
36 36
                 <!-- Retry dialog -->
37
-                <div id="queue-confirm-retry" title="<?php _e( 'Retry Job', 'autoptimize' ); ?>" class="hidden">
38
-                    <p><?php _e( 'Are you sure you want to retry this job?', 'autoptimize' ); ?></p>
37
+                <div id="queue-confirm-retry" title="<?php _e('Retry Job', 'autoptimize'); ?>" class="hidden">
38
+                    <p><?php _e('Are you sure you want to retry this job?', 'autoptimize'); ?></p>
39 39
                 </div>
40 40
 
41 41
                 <!-- Remove dialog -->
42
-                <div id="queue-confirm-rm" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>" class="hidden">
43
-                    <p><?php _e( 'Are you sure you want to delete this job?', 'autoptimize' ); ?></p>
42
+                <div id="queue-confirm-rm" title="<?php _e('Delete Job', 'autoptimize'); ?>" class="hidden">
43
+                    <p><?php _e('Are you sure you want to delete this job?', 'autoptimize'); ?></p>
44 44
                 </div>
45 45
 
46 46
                 <!-- Remove all dialog -->
47
-                <div id="queue-confirm-rm-all" title="<?php _e( 'Delete all jobs', 'autoptimize' ); ?>" class="hidden">
48
-                    <p><?php _e( 'This will delete all jobs, are you sure?', 'autoptimize' ); ?></p>
47
+                <div id="queue-confirm-rm-all" title="<?php _e('Delete all jobs', 'autoptimize'); ?>" class="hidden">
48
+                    <p><?php _e('This will delete all jobs, are you sure?', 'autoptimize'); ?></p>
49 49
                 </div>
50 50
                 <!-- END Queue dialogs -->
51 51
 
52 52
                 <!-- BEGIN Queue UI -->
53 53
                 <div class="howto">
54 54
                     <div class="title-wrap">
55
-                        <h4 class="title"><?php _e( 'How To Use Autoptimize CriticalCSS Power-Up Queue', 'autoptimize' ); ?></h4>
56
-                        <p class="subtitle"><?php _e( 'Click the side arrow to toggle instructions', 'autoptimize' ); ?></p>
55
+                        <h4 class="title"><?php _e('How To Use Autoptimize CriticalCSS Power-Up Queue', 'autoptimize'); ?></h4>
56
+                        <p class="subtitle"><?php _e('Click the side arrow to toggle instructions', 'autoptimize'); ?></p>
57 57
                     </div>
58 58
                     <button type="button" class="toggle-btn">
59 59
                         <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
60 60
                     </button>
61 61
                     <div class="howto-wrap hidden">
62
-                        <p><?php _e( 'TL;DR:<br /><strong>Queue runs every 10 minutes.</strong> Job statuses are <span class="badge new">N</span> for NEW, <span class="badge pending">P</span> for PENDING, <span class="badge error">E</span> for ERROR and <span class="badge unknown">U</span> for UNKOWN.', 'autoptimize' ); ?></p>
62
+                        <p><?php _e('TL;DR:<br /><strong>Queue runs every 10 minutes.</strong> Job statuses are <span class="badge new">N</span> for NEW, <span class="badge pending">P</span> for PENDING, <span class="badge error">E</span> for ERROR and <span class="badge unknown">U</span> for UNKOWN.', 'autoptimize'); ?></p>
63 63
                         <ol>
64
-                            <li><?php _e( 'The queue operates <strong>automatically, asynchronously and on regular intervals of 10 minutes.</strong> To view updated queue status, refresh this page.', 'autoptimize' ); ?></li>
65
-                            <li><?php _e( 'When the conditions to create a job are met (i.e. user not logged in, no matching <span class="badge manual">MANUAL</span> rule or CSS files has changed for an <span class="badge auto">AUTO</span> rule), a <span class="badge new">N</span> job is created in the queue.', 'autoptimize' ); ?></li>
66
-                            <li><?php _e( "Autoptimize CriticalCSS Power-Up constantly query the queue for <span class='badge new'>N</span> jobs. When it finds one, gears spins and jobs becomes <span class='badge pending'>P</span> while they are running and <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> doesn't return a result.", 'autoptimize' ); ?></li>
67
-                            <li><?php _e( 'As soon as <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> returns a valid critical CSS file, the job is then finished and removed from the queue.', 'autoptimize' ); ?></li>
68
-                            <li><?php _e( 'When things go wrong, a job is marked as <span class="badge error">E</span>. You can retry faulty jobs, delete them or get in touch with <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li>
69
-                            <li><?php _e( 'Sometimes an unknown condition can happen. In this case, the job status becomes <span class="badge unknown">U</span> and you may want to ask <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for help or just delete it.', 'autoptimize' ); ?></li>
70
-                            <li><?php _e( 'To get more information about jobs statuses, specially the ones with <span class="badge error">E</span> and <span class="badge unknown">U</span> status, hover your mouse in the status badge of that job. This information might be crucial when contacting <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li>
71
-                            <li><?php _e( '<strong>A word about WordPress cron:</strong> Autoptimize CriticalCSS Power-Up watch the queue by using WordPress Cron (or WP-Cron for short.) It <a href="https://www.smashingmagazine.com/2013/10/schedule-events-using-wordpress-cron/#limitations-of-wordpress-cron-and-solutions-to-fix-em" target="_blank">could be faulty</a> on very light or very heavy loads. If your site receives just a few or thousands visits a day, it might be a good idea to <a href="https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/" target="_blank">turn WP-Cron off and use your system task scheduler</a> to fire it instead.', 'autoptimize' ); ?></li>
64
+                            <li><?php _e('The queue operates <strong>automatically, asynchronously and on regular intervals of 10 minutes.</strong> To view updated queue status, refresh this page.', 'autoptimize'); ?></li>
65
+                            <li><?php _e('When the conditions to create a job are met (i.e. user not logged in, no matching <span class="badge manual">MANUAL</span> rule or CSS files has changed for an <span class="badge auto">AUTO</span> rule), a <span class="badge new">N</span> job is created in the queue.', 'autoptimize'); ?></li>
66
+                            <li><?php _e("Autoptimize CriticalCSS Power-Up constantly query the queue for <span class='badge new'>N</span> jobs. When it finds one, gears spins and jobs becomes <span class='badge pending'>P</span> while they are running and <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> doesn't return a result.", 'autoptimize'); ?></li>
67
+                            <li><?php _e('As soon as <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> returns a valid critical CSS file, the job is then finished and removed from the queue.', 'autoptimize'); ?></li>
68
+                            <li><?php _e('When things go wrong, a job is marked as <span class="badge error">E</span>. You can retry faulty jobs, delete them or get in touch with <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize'); ?></li>
69
+                            <li><?php _e('Sometimes an unknown condition can happen. In this case, the job status becomes <span class="badge unknown">U</span> and you may want to ask <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for help or just delete it.', 'autoptimize'); ?></li>
70
+                            <li><?php _e('To get more information about jobs statuses, specially the ones with <span class="badge error">E</span> and <span class="badge unknown">U</span> status, hover your mouse in the status badge of that job. This information might be crucial when contacting <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize'); ?></li>
71
+                            <li><?php _e('<strong>A word about WordPress cron:</strong> Autoptimize CriticalCSS Power-Up watch the queue by using WordPress Cron (or WP-Cron for short.) It <a href="https://www.smashingmagazine.com/2013/10/schedule-events-using-wordpress-cron/#limitations-of-wordpress-cron-and-solutions-to-fix-em" target="_blank">could be faulty</a> on very light or very heavy loads. If your site receives just a few or thousands visits a day, it might be a good idea to <a href="https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/" target="_blank">turn WP-Cron off and use your system task scheduler</a> to fire it instead.', 'autoptimize'); ?></li>
72 72
                         </ol>
73 73
                     </div>
74 74
                 </div>
75 75
                 <table id="queue-tbl" class="queue tablesorter" cellspacing="0">
76 76
                     <thead>
77
-                        <tr><th class="status"><?php _e( 'Status', 'autoptimize' ); ?></th><th><?php _e( 'Target Rule', 'autoptimize' ); ?></th><th><?php _e( 'Page Path', 'autoptimize' ); ?></th><th><?php _e( 'Page Type', 'autoptimize' ); ?></th><th><?php _e( 'Creation Date', 'autoptimize' ); ?></th><th><?php _e( 'Finish Date', 'autoptimize' ); ?></th><th class="btn"><?php _e( 'Actions', 'autoptimize' ); ?></th></tr>
77
+                        <tr><th class="status"><?php _e('Status', 'autoptimize'); ?></th><th><?php _e('Target Rule', 'autoptimize'); ?></th><th><?php _e('Page Path', 'autoptimize'); ?></th><th><?php _e('Page Type', 'autoptimize'); ?></th><th><?php _e('Creation Date', 'autoptimize'); ?></th><th><?php _e('Finish Date', 'autoptimize'); ?></th><th class="btn"><?php _e('Actions', 'autoptimize'); ?></th></tr>
78 78
                     </thead>
79 79
                     <tbody id="queue"></tbody>
80 80
                 </table>
81
-                <input class="hidden" type="text" id="ao-ccss-queue" name="autoptimize_ccss_queue" value='<?php echo( $ao_ccss_queue ); ?>'>
81
+                <input class="hidden" type="text" id="ao-ccss-queue" name="autoptimize_ccss_queue" value='<?php echo($ao_ccss_queue); ?>'>
82 82
                 <div class="submit jobs-btn">
83 83
                     <div class="alignright">
84
-                        <span id="removeAllJobs" class="button-secondary" style="color:red;"><?php _e( 'Remove all jobs', 'autoptimize' ); ?></span>
84
+                        <span id="removeAllJobs" class="button-secondary" style="color:red;"><?php _e('Remove all jobs', 'autoptimize'); ?></span>
85 85
                     </div>
86 86
                 </div>
87 87
             </div>
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_adv.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     global $ao_ccss_domain;
19 19
 
20 20
     // In case domain is not set yet (done in cron.php).
21
-    if ( empty( $ao_ccss_domain ) ) {
21
+    if (empty($ao_ccss_domain)) {
22 22
         $ao_ccss_domain = get_site_url();
23 23
     }
24 24
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 ?>
28 28
     <ul id="adv-panel">
29 29
         <li class="itemDetail">
30
-            <h2 class="itemTitle fleft"><?php _e( 'Advanced Settings', 'autoptimize' ); ?></h2>
30
+            <h2 class="itemTitle fleft"><?php _e('Advanced Settings', 'autoptimize'); ?></h2>
31 31
             <button type="button" class="toggle-btn">
32 32
                 <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
33 33
             </button>
@@ -35,103 +35,103 @@  discard block
 block discarded – undo
35 35
                 <table id="key" class="form-table">
36 36
                     <tr>
37 37
                         <th scope="row">
38
-                            <?php _e( 'Viewport Size', 'autoptimize' ); ?>
38
+                            <?php _e('Viewport Size', 'autoptimize'); ?>
39 39
                         </th>
40 40
                         <td>
41
-                            <label for="autoptimize_ccss_vw"><?php _e( 'Width', 'autoptimize' ); ?>:</label> <input type="number" id="autoptimize_ccss_vw" name="autoptimize_ccss_viewport[w]" min="800" max="4096" placeholder="1400" value="<?php echo $viewport['w']; ?>" />&nbsp;&nbsp;
42
-                            <label for="autoptimize_ccss_vh"><?php _e( 'Height', 'autoptimize' ); ?>:</label> <input type="number" id="autoptimize_ccss_vh" name="autoptimize_ccss_viewport[h]" min="600" max="2160" placeholder="1080" value="<?php echo $viewport['h']; ?>" />
41
+                            <label for="autoptimize_ccss_vw"><?php _e('Width', 'autoptimize'); ?>:</label> <input type="number" id="autoptimize_ccss_vw" name="autoptimize_ccss_viewport[w]" min="800" max="4096" placeholder="1400" value="<?php echo $viewport['w']; ?>" />&nbsp;&nbsp;
42
+                            <label for="autoptimize_ccss_vh"><?php _e('Height', 'autoptimize'); ?>:</label> <input type="number" id="autoptimize_ccss_vh" name="autoptimize_ccss_viewport[h]" min="600" max="2160" placeholder="1080" value="<?php echo $viewport['h']; ?>" />
43 43
                             <p class="notes">
44
-                                <?php _e( '<a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> default viewport size is 1400x1080 pixels (width x height). You can change this size by typing a desired width and height values above. Allowed value ranges are from 800 to 4096 for width and from 600 to 2160 for height.', 'autoptimize' ); ?>
44
+                                <?php _e('<a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> default viewport size is 1400x1080 pixels (width x height). You can change this size by typing a desired width and height values above. Allowed value ranges are from 800 to 4096 for width and from 600 to 2160 for height.', 'autoptimize'); ?>
45 45
                             </p>
46 46
                         </td>
47 47
                     </tr>
48 48
                     <tr>
49 49
                         <th scope="row">
50
-                            <?php _e( 'Force Include CSS selectors', 'autoptimize' ); ?>
50
+                            <?php _e('Force Include CSS selectors', 'autoptimize'); ?>
51 51
                         </th>
52 52
                         <td>
53
-                            <textarea id="autoptimize_ccss_finclude" name="autoptimize_ccss_finclude" rows='3' maxlenght='500' style="width:100%;" placeholder="<?php _e( '.button-special,//#footer', 'autoptimize' ); ?>"><?php echo trim( $ao_ccss_finclude ); ?></textarea>
53
+                            <textarea id="autoptimize_ccss_finclude" name="autoptimize_ccss_finclude" rows='3' maxlenght='500' style="width:100%;" placeholder="<?php _e('.button-special,//#footer', 'autoptimize'); ?>"><?php echo trim($ao_ccss_finclude); ?></textarea>
54 54
                             <p class="notes">
55
-                                <?php _e( 'Force include CSS selectors can be used to style dynamic content that is not part of the HTML that is seen during the Critical CSS generation. To use this feature, add comma separated values with both simple strings and/or regular expressions to match the desired selectors. Regular expressions must be preceeded by two forward slashes. For instance: <code>.button-special,//#footer</code>. In this example <code>.button-special</code> will match <code>.button-special</code> selector only, while <code>//#footer</code> will match <code>#footer</code>, <code>#footer-address</code> and <code>#footer-phone</code> selectors in case they exist.<br />Do take into account that changing this setting will only affect new/ updated rules, so you might want to remove old rules and clear your page cache to expedite the forceIncludes becoming used.', 'autoptimize' ); ?>
55
+                                <?php _e('Force include CSS selectors can be used to style dynamic content that is not part of the HTML that is seen during the Critical CSS generation. To use this feature, add comma separated values with both simple strings and/or regular expressions to match the desired selectors. Regular expressions must be preceeded by two forward slashes. For instance: <code>.button-special,//#footer</code>. In this example <code>.button-special</code> will match <code>.button-special</code> selector only, while <code>//#footer</code> will match <code>#footer</code>, <code>#footer-address</code> and <code>#footer-phone</code> selectors in case they exist.<br />Do take into account that changing this setting will only affect new/ updated rules, so you might want to remove old rules and clear your page cache to expedite the forceIncludes becoming used.', 'autoptimize'); ?>
56 56
                             </p>
57 57
                         </td>
58 58
                     </tr>
59 59
                     <tr>
60 60
                         <th scope="row">
61
-                            <?php _e( 'Request Limit', 'autoptimize' ); ?>
61
+                            <?php _e('Request Limit', 'autoptimize'); ?>
62 62
                         </th>
63 63
                         <td>
64 64
                             <input type="number" id="autoptimize_ccss_rlimit" name="autoptimize_ccss_rlimit" min="1" max="240" placeholder="0" value="<?php echo $ao_ccss_rlimit; ?>" />
65 65
                             <p class="notes">
66
-                                <?php _e( 'Certain hosting services impose hard limitations to background processes on either execution time, requests made from your server to any third party services, or both. This could lead to a faulty operation of the queue background process triggered by WP-Cron. If automated rules are not being created, you may be facing this limitation from your hosting provider. In that case, set the request limit to a reasonable number between 1 and 240. The queue fire a request to <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> on every 15 seconds (due to service limitations). If your hosting provider allows a 60 seconds time span to background processes runtime, set this value to 3 or 4 so the queue can operate within the boundaries. The maximum value of 240 allows enough requests for one hour long. To disable this limit and to let requests be made at will, just delete any values in this setting (a grey 0 will show).', 'autoptimize' ); ?>
66
+                                <?php _e('Certain hosting services impose hard limitations to background processes on either execution time, requests made from your server to any third party services, or both. This could lead to a faulty operation of the queue background process triggered by WP-Cron. If automated rules are not being created, you may be facing this limitation from your hosting provider. In that case, set the request limit to a reasonable number between 1 and 240. The queue fire a request to <a href="https://criticalcss.com/account/api-keys?aff=1" target="_blank">criticalcss.com</a> on every 15 seconds (due to service limitations). If your hosting provider allows a 60 seconds time span to background processes runtime, set this value to 3 or 4 so the queue can operate within the boundaries. The maximum value of 240 allows enough requests for one hour long. To disable this limit and to let requests be made at will, just delete any values in this setting (a grey 0 will show).', 'autoptimize'); ?>
67 67
                             </p>
68 68
                         </td>
69 69
                     </tr>
70 70
                     <tr>
71 71
                         <th scope="row">
72
-                            <?php _e( 'Fetch Original CSS', 'autoptimize' ); ?>
72
+                            <?php _e('Fetch Original CSS', 'autoptimize'); ?>
73 73
                         </th>
74 74
                         <td>
75
-                            <input type="checkbox" id="autoptimize_ccss_noptimize" name="autoptimize_ccss_noptimize" value="1" <?php checked( 1 == $ao_ccss_noptimize ); ?>>
75
+                            <input type="checkbox" id="autoptimize_ccss_noptimize" name="autoptimize_ccss_noptimize" value="1" <?php checked(1 == $ao_ccss_noptimize); ?>>
76 76
                             <p class="notes">
77
-                                <?php _e( 'In some (rare) cases the generation of critical CSS works better with the original CSS instead of the Autoptimized one, this option enables that behavior.', 'autoptimize' ); ?>
77
+                                <?php _e('In some (rare) cases the generation of critical CSS works better with the original CSS instead of the Autoptimized one, this option enables that behavior.', 'autoptimize'); ?>
78 78
                             </p>
79 79
                         </td>
80 80
                     </tr>
81 81
                     <tr>
82 82
                         <th scope="row">
83
-                            <?php _e( 'Add CCSS for logged in users?', 'autoptimize' ); ?>
83
+                            <?php _e('Add CCSS for logged in users?', 'autoptimize'); ?>
84 84
                         </th>
85 85
                         <td>
86
-                            <input type="checkbox" id="autoptimize_ccss_loggedin" name="autoptimize_ccss_loggedin" value="1" <?php checked( 1 == $ao_ccss_loggedin ); ?>>
86
+                            <input type="checkbox" id="autoptimize_ccss_loggedin" name="autoptimize_ccss_loggedin" value="1" <?php checked(1 == $ao_ccss_loggedin); ?>>
87 87
                             <p class="notes">
88
-                                <?php _e( 'Critical CSS is generated by criticalcss.com from your pages as seen be "anonymous visitor", disable this option if you don\'t want the "visitor" critical CSS to be used for logged on users.', 'autoptimize' ); ?>
88
+                                <?php _e('Critical CSS is generated by criticalcss.com from your pages as seen be "anonymous visitor", disable this option if you don\'t want the "visitor" critical CSS to be used for logged on users.', 'autoptimize'); ?>
89 89
                             </p>
90 90
                         </td>
91 91
                     </tr>
92 92
                     <tr>
93 93
                         <th scope="row">
94
-                            <?php _e( 'Force path-based rules to be generated for pages?', 'autoptimize' ); ?>
94
+                            <?php _e('Force path-based rules to be generated for pages?', 'autoptimize'); ?>
95 95
                         </th>
96 96
                         <td>
97
-                            <input type="checkbox" id="autoptimize_ccss_forcepath" name="autoptimize_ccss_forcepath" value="1" <?php checked( 1 == $ao_ccss_forcepath ); ?>>
97
+                            <input type="checkbox" id="autoptimize_ccss_forcepath" name="autoptimize_ccss_forcepath" value="1" <?php checked(1 == $ao_ccss_forcepath); ?>>
98 98
                             <p class="notes">
99
-                                <?php _e( 'By default for each page a separate rule is generated. If your pages have (semi-)identical above the fold look and feel and you want to keep the rules lean, you can disable that so one rule is created to all pages.', 'autoptimize' ); ?>
99
+                                <?php _e('By default for each page a separate rule is generated. If your pages have (semi-)identical above the fold look and feel and you want to keep the rules lean, you can disable that so one rule is created to all pages.', 'autoptimize'); ?>
100 100
                             </p>
101 101
                         </td>
102 102
                     </tr>
103 103
                     <tr>
104 104
                         <th scope="row">
105
-                            <?php _e( 'Defer jQuery and other non-aggregated JS-files?', 'autoptimize' ); ?>
105
+                            <?php _e('Defer jQuery and other non-aggregated JS-files?', 'autoptimize'); ?>
106 106
                         </th>
107 107
                         <td>
108
-                            <input type="checkbox" id="autoptimize_ccss_deferjquery" name="autoptimize_ccss_deferjquery" value="1" <?php checked( 1 == $ao_ccss_deferjquery ); ?>>
108
+                            <input type="checkbox" id="autoptimize_ccss_deferjquery" name="autoptimize_ccss_deferjquery" value="1" <?php checked(1 == $ao_ccss_deferjquery); ?>>
109 109
                             <p class="notes">
110
-                                <?php _e( 'Defer all non-aggregated JS, including jQuery and inline JS to fix remaining render-blocking issues. Make sure to test your site thoroughly when activating this option!', 'autoptimize' ); ?>
110
+                                <?php _e('Defer all non-aggregated JS, including jQuery and inline JS to fix remaining render-blocking issues. Make sure to test your site thoroughly when activating this option!', 'autoptimize'); ?>
111 111
                             </p>
112 112
                         </td>
113 113
                     </tr>
114 114
                     <tr>
115 115
                         <th scope="row">
116
-                            <?php _e( 'Bound domain', 'autoptimize' ); ?>
116
+                            <?php _e('Bound domain', 'autoptimize'); ?>
117 117
                         </th>
118 118
                         <td>
119
-                            <input type="text" id="autoptimize_ccss_domain" name="autoptimize_ccss_domain" style="width:100%;" placeholder="<?php _e( 'Don\'t leave this empty, put e.g. https://example.net/ or simply \'none\' to disable domain binding.', 'autoptimize' ); ?>" value="<?php echo trim( $ao_ccss_domain ); ?>">
119
+                            <input type="text" id="autoptimize_ccss_domain" name="autoptimize_ccss_domain" style="width:100%;" placeholder="<?php _e('Don\'t leave this empty, put e.g. https://example.net/ or simply \'none\' to disable domain binding.', 'autoptimize'); ?>" value="<?php echo trim($ao_ccss_domain); ?>">
120 120
                             <p class="notes">
121
-                                <?php _e( 'Only requests from this domain will be sent for Critical CSS generation (pricing is per domain/ month).', 'autoptimize' ); ?>
121
+                                <?php _e('Only requests from this domain will be sent for Critical CSS generation (pricing is per domain/ month).', 'autoptimize'); ?>
122 122
                             </p>
123 123
                         </td>
124 124
                     </tr>
125 125
                     <tr>
126 126
                         <th scope="row">
127
-                            <?php _e( 'Debug Mode', 'autoptimize' ); ?>
127
+                            <?php _e('Debug Mode', 'autoptimize'); ?>
128 128
                         </th>
129 129
                         <td>
130
-                            <input type="checkbox" id="autoptimize_ccss_debug" name="autoptimize_ccss_debug" value="1" <?php checked( 1 == $ao_ccss_debug ); ?>>
130
+                            <input type="checkbox" id="autoptimize_ccss_debug" name="autoptimize_ccss_debug" value="1" <?php checked(1 == $ao_ccss_debug); ?>>
131 131
                             <p class="notes">
132 132
                                 <?php
133
-                                _e( '<strong>CAUTION! Only use debug mode on production/live environments for ad-hoc troubleshooting and remember to turn it back off after</strong>, as this generates a lot of log-data.<br />Check the box above to enable Autoptimize CriticalCSS Power-Up debug mode. It provides debug facilities in this screen, to the browser console and to this file: ', 'autoptimize' );
134
-                                echo '<code>' . AO_CCSS_LOG . '</code>';
133
+                                _e('<strong>CAUTION! Only use debug mode on production/live environments for ad-hoc troubleshooting and remember to turn it back off after</strong>, as this generates a lot of log-data.<br />Check the box above to enable Autoptimize CriticalCSS Power-Up debug mode. It provides debug facilities in this screen, to the browser console and to this file: ', 'autoptimize');
134
+                                echo '<code>'.AO_CCSS_LOG.'</code>';
135 135
                                 ?>
136 136
                             </p>
137 137
                         </td>
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_impexp.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
     console.log('Exporting...');
10 10
     var data = {
11 11
         'action': 'ao_ccss_export',
12
-        'ao_ccss_export_nonce': '<?php echo wp_create_nonce( 'ao_ccss_export_nonce' ); ?>',
12
+        'ao_ccss_export_nonce': '<?php echo wp_create_nonce('ao_ccss_export_nonce'); ?>',
13 13
     };
14 14
 
15 15
     jQuery.post(ajaxurl, data, function(response) {
16 16
         response_array=JSON.parse(response);
17 17
         if (response_array['code'] == 200) {
18 18
             <?php
19
-            if ( is_multisite() ) {
20
-                $blog_id = '/' . get_current_blog_id() . '/';
19
+            if (is_multisite()) {
20
+                $blog_id = '/'.get_current_blog_id().'/';
21 21
             } else {
22 22
                 $blog_id = '/';
23 23
             }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             autoOpen: true,
33 33
             height: 210,
34 34
             width: 700,
35
-            title: "<?php _e( 'Export settings result', 'autoptimize' ); ?>",
35
+            title: "<?php _e('Export settings result', 'autoptimize'); ?>",
36 36
             modal: true,
37 37
             buttons: {
38 38
                 OK: function() {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     var settings_file = file[0].files[0];
51 51
     fd.append('file', settings_file);
52 52
     fd.append('action', 'ao_ccss_import');
53
-    fd.append('ao_ccss_import_nonce', '<?php echo wp_create_nonce( 'ao_ccss_import_nonce' ); ?>');
53
+    fd.append('ao_ccss_import_nonce', '<?php echo wp_create_nonce('ao_ccss_import_nonce'); ?>');
54 54
 
55 55
     jQuery.ajax({
56 56
         url: ajaxurl,
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_rules.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
 ?>
14 14
     <ul id="rules-panel">
15 15
         <li class="itemDetail">
16
-            <h2 class="itemTitle"><?php _e( 'Rules', 'autoptimize' ); ?></h2>
16
+            <h2 class="itemTitle"><?php _e('Rules', 'autoptimize'); ?></h2>
17 17
 
18 18
             <!-- BEGIN Rule dialogs -->
19 19
             <!-- Unsaved dialog -->
20 20
             <div id="unSavedWarning" class="hidden updated settings-error notice notice-warning is-dismissible">
21
-                <p><?php _e( "<strong>Rules or Queue changed!</strong> Don't forget to save your changes!", 'autoptimize' ); ?></p>
21
+                <p><?php _e("<strong>Rules or Queue changed!</strong> Don't forget to save your changes!", 'autoptimize'); ?></p>
22 22
             </div>
23 23
 
24 24
             <!-- Create/edit rule dialog -->
@@ -26,97 +26,97 @@  discard block
 block discarded – undo
26 26
                 <table class="form-table rules">
27 27
                     <tr id="critcss_addedit_type_wrapper">
28 28
                         <th scope="row">
29
-                            <?php _e( 'Rule Type', 'autoptimize' ); ?>
29
+                            <?php _e('Rule Type', 'autoptimize'); ?>
30 30
                         </th>
31 31
                         <td>
32 32
                             <select id="critcss_addedit_type" style="width:100%;">
33
-                                <option value="paths"><?php _e( 'Path', 'autoptimize' ); ?></option>
34
-                                <option value="types"><?php _e( 'Conditional Tag', 'autoptimize' ); ?></option>
33
+                                <option value="paths"><?php _e('Path', 'autoptimize'); ?></option>
34
+                                <option value="types"><?php _e('Conditional Tag', 'autoptimize'); ?></option>
35 35
                             </select>
36 36
                         </td>
37 37
                     </tr>
38 38
                     <tr id="critcss_addedit_path_wrapper">
39 39
                         <th scope="row">
40
-                            <?php _e( 'String in Path', 'autoptimize' ); ?>
40
+                            <?php _e('String in Path', 'autoptimize'); ?>
41 41
                         </th>
42 42
                         <td>
43
-                            <input type="text" id="critcss_addedit_path" placeholder="<?php _e( "Enter a part of the URL that identifies the page(s) you're targetting.", 'autoptimize' ); ?>" style="width:100%;" value="">
43
+                            <input type="text" id="critcss_addedit_path" placeholder="<?php _e("Enter a part of the URL that identifies the page(s) you're targetting.", 'autoptimize'); ?>" style="width:100%;" value="">
44 44
                         </td>
45 45
                     </tr>
46 46
                     <tr id="critcss_addedit_pagetype_wrapper">
47 47
                         <th scope="row">
48
-                            <?php _e( 'Conditional Tag, Custom Post Type or Page Template', 'autoptimize' ); ?>
48
+                            <?php _e('Conditional Tag, Custom Post Type or Page Template', 'autoptimize'); ?>
49 49
                         </th>
50 50
                         <td>
51 51
                             <select id="critcss_addedit_pagetype" style="width:100%;">
52
-                                <option value="" disabled selected><?php _e( 'Select from the list below...', 'autoptimize' ); ?></option>
53
-                                <optgroup label="<?php _e( 'Standard Conditional Tags', 'autoptimize' ); ?>">
52
+                                <option value="" disabled selected><?php _e('Select from the list below...', 'autoptimize'); ?></option>
53
+                                <optgroup label="<?php _e('Standard Conditional Tags', 'autoptimize'); ?>">
54 54
                                     <?php
55 55
                                     // Render grouped simple conditional tags.
56
-                                    foreach ( $ao_ccss_types as $ctag ) {
57
-                                        $optgrp = substr( $ctag, 0, 3 );
58
-                                        if ( substr( $ctag, 0, 3 ) === 'is_' ) {
59
-                                            echo '<option value="' . $ctag . '">' . $ctag . '</option>';
56
+                                    foreach ($ao_ccss_types as $ctag) {
57
+                                        $optgrp = substr($ctag, 0, 3);
58
+                                        if (substr($ctag, 0, 3) === 'is_') {
59
+                                            echo '<option value="'.$ctag.'">'.$ctag.'</option>';
60 60
                                         }
61
-                                        $prevgrp = substr( $ctag, 0, 3 );
61
+                                        $prevgrp = substr($ctag, 0, 3);
62 62
                                     }
63 63
 
64 64
                                     // Render grouped custom post types, templates and specific conditional tags.
65
-                                    foreach ( $ao_ccss_types as $type ) {
66
-                                        $optgrp = substr( $type, 0, 3 );
65
+                                    foreach ($ao_ccss_types as $type) {
66
+                                        $optgrp = substr($type, 0, 3);
67 67
 
68 68
                                         // Option groups labels.
69
-                                        if ( $optgrp !== $prevgrp && 'is_' !== $optgrp ) {
69
+                                        if ($optgrp !== $prevgrp && 'is_' !== $optgrp) {
70 70
                                             ?>
71 71
                                             </optgroup>
72 72
                                             <?php
73
-                                            if ( substr( $type, 0, 12 ) === 'custom_post_' ) {
73
+                                            if (substr($type, 0, 12) === 'custom_post_') {
74 74
                                                 ?>
75
-                                                <optgroup label="<?php _e( 'Custom Post Types', 'autoptimize' ); ?>">
75
+                                                <optgroup label="<?php _e('Custom Post Types', 'autoptimize'); ?>">
76 76
                                                 <?php
77
-                                            } elseif ( substr( $type, 0, 9 ) === 'template_' ) {
77
+                                            } elseif (substr($type, 0, 9) === 'template_') {
78 78
                                                 ?>
79
-                                                <optgroup label="<?php _e( 'Page Templates', 'autoptimize' ); ?>">
79
+                                                <optgroup label="<?php _e('Page Templates', 'autoptimize'); ?>">
80 80
                                                 <?php
81
-                                            } elseif ( substr( $type, 0, 4 ) === 'bbp_' ) {
81
+                                            } elseif (substr($type, 0, 4) === 'bbp_') {
82 82
                                                 ?>
83
-                                                <optgroup label="<?php _e( 'BBPress Conditional Tags', 'autoptimize' ); ?>">
83
+                                                <optgroup label="<?php _e('BBPress Conditional Tags', 'autoptimize'); ?>">
84 84
                                                 <?php
85
-                                            } elseif ( substr( $type, 0, 3 ) === 'bp_' ) {
85
+                                            } elseif (substr($type, 0, 3) === 'bp_') {
86 86
                                                 ?>
87
-                                                <optgroup label="<?php _e( 'BuddyPress Conditional Tags', 'autoptimize' ); ?>">
87
+                                                <optgroup label="<?php _e('BuddyPress Conditional Tags', 'autoptimize'); ?>">
88 88
                                                 <?php
89
-                                            } elseif ( substr( $type, 0, 4 ) === 'edd_' ) {
89
+                                            } elseif (substr($type, 0, 4) === 'edd_') {
90 90
                                                 ?>
91
-                                                <optgroup label="<?php _e( 'Easy Digital Downloads Conditional Tags', 'autoptimize' ); ?>">
91
+                                                <optgroup label="<?php _e('Easy Digital Downloads Conditional Tags', 'autoptimize'); ?>">
92 92
                                                 <?php
93
-                                            } elseif ( substr( $type, 0, 4 ) === 'woo_' ) {
93
+                                            } elseif (substr($type, 0, 4) === 'woo_') {
94 94
                                                 ?>
95
-                                                <optgroup label="<?php _e( 'WooCommerce Conditional Tags', 'autoptimize' ); ?>">
95
+                                                <optgroup label="<?php _e('WooCommerce Conditional Tags', 'autoptimize'); ?>">
96 96
                                                 <?php
97 97
                                             }
98 98
                                         }
99 99
 
100 100
                                         // Options.
101
-                                        if ( 'is_' !== $optgrp ) {
101
+                                        if ('is_' !== $optgrp) {
102 102
                                             // Remove prefix from custom post types, templates and some specific conditional tags.
103
-                                            if ( substr( $type, 0, 12 ) === 'custom_post_' ) {
104
-                                                $_type = str_replace( 'custom_post_', '', $type );
105
-                                            } elseif ( substr( $type, 0, 9 ) === 'template_' ) {
106
-                                                $_type = str_replace( 'template_', '', $type );
107
-                                            } elseif ( 'bbp_is_bbpress' == $type ) {
108
-                                                $_type = str_replace( 'bbp_', '', $type );
109
-                                            } elseif ( 'bp_is_buddypress' == $type ) {
110
-                                                $_type = str_replace( 'bp_', '', $type );
111
-                                            } elseif ( substr( $type, 0, 4 ) === 'woo_' ) {
112
-                                                $_type = str_replace( 'woo_', '', $type );
113
-                                            } elseif ( substr( $type, 0, 4 ) === 'edd_' ) {
114
-                                                $_type = str_replace( 'edd_', '', $type );
103
+                                            if (substr($type, 0, 12) === 'custom_post_') {
104
+                                                $_type = str_replace('custom_post_', '', $type);
105
+                                            } elseif (substr($type, 0, 9) === 'template_') {
106
+                                                $_type = str_replace('template_', '', $type);
107
+                                            } elseif ('bbp_is_bbpress' == $type) {
108
+                                                $_type = str_replace('bbp_', '', $type);
109
+                                            } elseif ('bp_is_buddypress' == $type) {
110
+                                                $_type = str_replace('bp_', '', $type);
111
+                                            } elseif (substr($type, 0, 4) === 'woo_') {
112
+                                                $_type = str_replace('woo_', '', $type);
113
+                                            } elseif (substr($type, 0, 4) === 'edd_') {
114
+                                                $_type = str_replace('edd_', '', $type);
115 115
                                             } else {
116 116
                                                 $_type = $type;
117 117
                                             }
118 118
 
119
-                                            echo '<option value="' . $type . '">' . $_type . '</option>';
119
+                                            echo '<option value="'.$type.'">'.$_type.'</option>';
120 120
                                             $prevgrp = $optgrp;
121 121
                                         }
122 122
                                     }
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
                     </tr>
128 128
                     <tr>
129 129
                         <th scope="row">
130
-                            <?php _e( 'Custom Critical CSS', 'autoptimize' ); ?>
130
+                            <?php _e('Custom Critical CSS', 'autoptimize'); ?>
131 131
                         </th>
132 132
                         <td>
133
-                            <textarea id="critcss_addedit_css" rows="13" cols="10" style="width:100%;" placeholder="<?php _e( 'Paste your specific critical CSS here and hit submit to save.', 'autoptimize' ); ?>"></textarea>
133
+                            <textarea id="critcss_addedit_css" rows="13" cols="10" style="width:100%;" placeholder="<?php _e('Paste your specific critical CSS here and hit submit to save.', 'autoptimize'); ?>"></textarea>
134 134
                             <input type="hidden" id="critcss_addedit_file">
135 135
                             <input type="hidden" id="critcss_addedit_id">
136 136
                         </td>
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
             </div>
140 140
 
141 141
             <!-- Remove dialog -->
142
-            <div id="confirm-rm" title="<?php _e( 'Delete Rule', 'autoptimize' ); ?>" class="hidden">
143
-                <p><?php _e( 'This Critical CSS rule will be deleted immediately and cannot be recovered.<br /><br /><strong>Are you sure?</strong>', 'autoptimize' ); ?></p>
142
+            <div id="confirm-rm" title="<?php _e('Delete Rule', 'autoptimize'); ?>" class="hidden">
143
+                <p><?php _e('This Critical CSS rule will be deleted immediately and cannot be recovered.<br /><br /><strong>Are you sure?</strong>', 'autoptimize'); ?></p>
144 144
             </div>
145 145
 
146 146
             <!-- Remove All dialog -->
147
-            <div id="confirm-rm-all" title="<?php _e( 'Delete all Rules and Jobs', 'autoptimize' ); ?>" class="hidden">
148
-                <p><?php _e( 'All Critical CSS rules will be deleted immediately and cannot be recovered.<br /><br /><strong>Are you sure?</strong>', 'autoptimize' ); ?></p>
147
+            <div id="confirm-rm-all" title="<?php _e('Delete all Rules and Jobs', 'autoptimize'); ?>" class="hidden">
148
+                <p><?php _e('All Critical CSS rules will be deleted immediately and cannot be recovered.<br /><br /><strong>Are you sure?</strong>', 'autoptimize'); ?></p>
149 149
             </div>
150 150
 
151 151
             <!-- Add/edit default critical CSS dialog -->
152 152
             <div id="default_critcss_wrapper" class="hidden">
153
-                <textarea id="dummyDefault" rows="19" cols="10" style="width:100%;" placeholder="<?php _e( 'Paste your MINIFIED default critical CSS here and hit submit to save. This is the critical CSS to be used for every page NOT MATCHING any rule.', 'autoptimize' ); ?>"></textarea>
153
+                <textarea id="dummyDefault" rows="19" cols="10" style="width:100%;" placeholder="<?php _e('Paste your MINIFIED default critical CSS here and hit submit to save. This is the critical CSS to be used for every page NOT MATCHING any rule.', 'autoptimize'); ?>"></textarea>
154 154
             </div>
155 155
 
156 156
             <!-- Add/edit additional critical CSS dialog -->
157 157
             <div id="additional_critcss_wrapper" class="hidden">
158
-                <textarea id="dummyAdditional" rows="19" cols="10" style="width:100%;" placeholder="<?php _e( 'Paste your MINIFIED additional critical CSS here and hit submit to save. This is the CSS to be added AT THE END of every critical CSS provided by a matching rule, or the default one.', 'autoptimize' ); ?>"></textarea>
158
+                <textarea id="dummyAdditional" rows="19" cols="10" style="width:100%;" placeholder="<?php _e('Paste your MINIFIED additional critical CSS here and hit submit to save. This is the CSS to be added AT THE END of every critical CSS provided by a matching rule, or the default one.', 'autoptimize'); ?>"></textarea>
159 159
             </div>
160 160
 
161 161
             <!-- Wrapper for in screen notices -->
@@ -165,38 +165,38 @@  discard block
 block discarded – undo
165 165
             <!-- BEGIN Rules UI -->
166 166
             <div class="howto">
167 167
                 <div class="title-wrap">
168
-                    <h4 class="title"><?php _e( 'How To Use Autoptimize CriticalCSS Power-Up Rules', 'autoptimize' ); ?></h4>
169
-                    <p class="subtitle"><?php _e( 'Click the side arrow to toggle instructions', 'autoptimize' ); ?></p>
168
+                    <h4 class="title"><?php _e('How To Use Autoptimize CriticalCSS Power-Up Rules', 'autoptimize'); ?></h4>
169
+                    <p class="subtitle"><?php _e('Click the side arrow to toggle instructions', 'autoptimize'); ?></p>
170 170
                 </div>
171 171
                 <button type="button" class="toggle-btn">
172 172
                     <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
173 173
                 </button>
174 174
                 <div class="howto-wrap hidden">
175
-                <p><?php _e( "TL;DR:<br />Critical CSS files from <span class='badge auto'>AUTO</span> <strong>rules are updated automatically</strong> while from <span class='badge manual'>MANUAL</span> <strong>rules are not.</strong>", 'autoptimize' ); ?></p>
175
+                <p><?php _e("TL;DR:<br />Critical CSS files from <span class='badge auto'>AUTO</span> <strong>rules are updated automatically</strong> while from <span class='badge manual'>MANUAL</span> <strong>rules are not.</strong>", 'autoptimize'); ?></p>
176 176
                     <ol>
177
-                        <li><?php _e( 'When a valid <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> API key is in place, Autoptimize CriticalCSS Power-Up starts to operate <strong>automatically</strong>.', 'autoptimize' ); ?></li>
178
-                        <li><?php _e( 'Upon a request to any of the frontend pages made by a <strong>not logged in user</strong>, it will <strong>asynchronously</strong> fetch and update the critical CSS from <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for conditional tags you have on your site (e.g. is_page, is_single, is_archive etc.)', 'autoptimize' ); ?></li>
179
-                        <li><?php _e( 'These requests also creates an <span class="badge auto">AUTO</span> rule for you. The critical CSS files from <span class="badge auto">AUTO</span> <strong>rules are updated automatically</strong> when a CSS file in your theme or frontend plugins changes.', 'autoptimize' ); ?></li>
180
-                        <li><?php _e( 'If you want to make any fine tunning in the critical CSS file of an <span class="badge auto">AUTO</span> rule, click on "Edit" button of that rule, change what you need, submit and save it. The rule you\'ve just edited becomes a <span class="badge manual">MANUAL</span> rule then.', 'autoptimize' ); ?></li>
181
-                        <li><?php _e( 'You can create <span class="badge manual">MANUAL</span> rules for specific page paths (URL). Longer, more specific paths have higher priority over shorter ones, which in turn have higher priority over <span class="badge auto">AUTO</span> rules. Also, critical CSS files from <span class="badge manual">MANUAL</span> <strong>rules are NEVER updated automatically.</strong>', 'autoptimize' ); ?></li>
182
-                        <li><?php _e( 'You can also create an <span class="badge auto">AUTO</span> rule for a path by leaving its critical CSS content empty. The critical CSS for that path will be automatically fetched from <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for you and updated whenever it changes.', 'autoptimize' ); ?></li>
183
-                        <li><?php _e( "If you see an <span class='badge auto'>AUTO</span> rule with a <span class='badge review'>R</span> besides it (R is after REVIEW), it means that the fetched critical CSS for that rule is not 100% garanteed to work according to <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> analysis. It's advised that you edit and review that rule to make any required adjustments.", 'autoptimize' ); ?></li>
184
-                        <li><?php _e( 'At any time you can delete an <span class="badge auto">AUTO</span> or <span class="badge manual">MANUAL</span> rule by cliking on "Remove" button of the desired rule and saving your changes.', 'autoptimize' ); ?></li>
177
+                        <li><?php _e('When a valid <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> API key is in place, Autoptimize CriticalCSS Power-Up starts to operate <strong>automatically</strong>.', 'autoptimize'); ?></li>
178
+                        <li><?php _e('Upon a request to any of the frontend pages made by a <strong>not logged in user</strong>, it will <strong>asynchronously</strong> fetch and update the critical CSS from <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for conditional tags you have on your site (e.g. is_page, is_single, is_archive etc.)', 'autoptimize'); ?></li>
179
+                        <li><?php _e('These requests also creates an <span class="badge auto">AUTO</span> rule for you. The critical CSS files from <span class="badge auto">AUTO</span> <strong>rules are updated automatically</strong> when a CSS file in your theme or frontend plugins changes.', 'autoptimize'); ?></li>
180
+                        <li><?php _e('If you want to make any fine tunning in the critical CSS file of an <span class="badge auto">AUTO</span> rule, click on "Edit" button of that rule, change what you need, submit and save it. The rule you\'ve just edited becomes a <span class="badge manual">MANUAL</span> rule then.', 'autoptimize'); ?></li>
181
+                        <li><?php _e('You can create <span class="badge manual">MANUAL</span> rules for specific page paths (URL). Longer, more specific paths have higher priority over shorter ones, which in turn have higher priority over <span class="badge auto">AUTO</span> rules. Also, critical CSS files from <span class="badge manual">MANUAL</span> <strong>rules are NEVER updated automatically.</strong>', 'autoptimize'); ?></li>
182
+                        <li><?php _e('You can also create an <span class="badge auto">AUTO</span> rule for a path by leaving its critical CSS content empty. The critical CSS for that path will be automatically fetched from <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for you and updated whenever it changes.', 'autoptimize'); ?></li>
183
+                        <li><?php _e("If you see an <span class='badge auto'>AUTO</span> rule with a <span class='badge review'>R</span> besides it (R is after REVIEW), it means that the fetched critical CSS for that rule is not 100% garanteed to work according to <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> analysis. It's advised that you edit and review that rule to make any required adjustments.", 'autoptimize'); ?></li>
184
+                        <li><?php _e('At any time you can delete an <span class="badge auto">AUTO</span> or <span class="badge manual">MANUAL</span> rule by cliking on "Remove" button of the desired rule and saving your changes.', 'autoptimize'); ?></li>
185 185
                     </ol>
186 186
                 </div>
187 187
             </div>
188
-            <textarea id="autoptimize_css_defer_inline" name="autoptimize_css_defer_inline" rows="19" cols="10" style="width:100%;"><?php echo get_option( 'autoptimize_css_defer_inline', '' ); ?></textarea>
189
-            <textarea id="autoptimize_ccss_additional" name="autoptimize_ccss_additional" rows="19" cols="10" style="width:100%;"><?php echo get_option( 'autoptimize_ccss_additional', '' ); ?></textarea>
188
+            <textarea id="autoptimize_css_defer_inline" name="autoptimize_css_defer_inline" rows="19" cols="10" style="width:100%;"><?php echo get_option('autoptimize_css_defer_inline', ''); ?></textarea>
189
+            <textarea id="autoptimize_ccss_additional" name="autoptimize_ccss_additional" rows="19" cols="10" style="width:100%;"><?php echo get_option('autoptimize_ccss_additional', ''); ?></textarea>
190 190
             <table class="rules-list" cellspacing="0"><tbody id="rules-list"></tbody></table>
191
-            <input class="hidden" type="text" id="critCssOrigin" name="autoptimize_ccss_rules" value='<?php echo ( json_encode( $ao_ccss_rules, JSON_FORCE_OBJECT ) ); ?>'>
191
+            <input class="hidden" type="text" id="critCssOrigin" name="autoptimize_ccss_rules" value='<?php echo (json_encode($ao_ccss_rules, JSON_FORCE_OBJECT)); ?>'>
192 192
             <div class="submit rules-btn">
193 193
                 <div class="alignleft">
194
-                    <span id="addCritCssButton" class="button-secondary"><?php _e( 'Add New Rule', 'autoptimize' ); ?></span>
195
-                    <span id="editDefaultButton" class="button-secondary"><?php _e( 'Edit Default Rule CSS', 'autoptimize' ); ?></span>
196
-                    <span id="editAdditionalButton" class="button-secondary"><?php _e( 'Add CSS To All Rules', 'autoptimize' ); ?></span>
194
+                    <span id="addCritCssButton" class="button-secondary"><?php _e('Add New Rule', 'autoptimize'); ?></span>
195
+                    <span id="editDefaultButton" class="button-secondary"><?php _e('Edit Default Rule CSS', 'autoptimize'); ?></span>
196
+                    <span id="editAdditionalButton" class="button-secondary"><?php _e('Add CSS To All Rules', 'autoptimize'); ?></span>
197 197
                 </div>
198 198
                 <div class="alignright">
199
-                    <span id="removeAllRules" class="button-secondary" style="color:red;"><?php _e( 'Remove all rules', 'autoptimize' ); ?></span>
199
+                    <span id="removeAllRules" class="button-secondary" style="color:red;"><?php _e('Remove all rules', 'autoptimize'); ?></span>
200 200
                 </div>
201 201
             </div>
202 202
             <!-- END Rules UI -->
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_debug.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $ao_options = $wpdb->get_results('
11 11
   SELECT option_name  AS name,
12 12
          option_value AS value
13
-  FROM ' . $wpdb->options . '
13
+  FROM ' . $wpdb->options.'
14 14
   WHERE option_name LIKE "autoptimize_%%"
15 15
   ORDER BY name
16 16
 ', ARRAY_A);
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
 $ao_trans = $wpdb->get_results('
20 20
   SELECT option_name  AS name,
21 21
          option_value AS value
22
-  FROM ' . $wpdb->options . '
22
+  FROM ' . $wpdb->options.'
23 23
   WHERE option_name LIKE "_transient_autoptimize_%%"
24 24
      OR option_name LIKE "_transient_timeout_autoptimize_%%"
25 25
 ', ARRAY_A);
26 26
 
27 27
 // Render debug panel if there's something to show.
28
-if ( $ao_options || $ao_trans ) {
28
+if ($ao_options || $ao_trans) {
29 29
 ?>
30 30
 <!-- BEGIN: Settings Debug -->
31 31
 <ul>
32 32
     <li class="itemDetail">
33
-        <h2 class="itemTitle"><?php _e( 'Debug Information', 'autoptimize' ); ?></h2>
33
+        <h2 class="itemTitle"><?php _e('Debug Information', 'autoptimize'); ?></h2>
34 34
 
35 35
         <?php
36 36
         // Render options.
37
-        if ( $ao_options ) {
37
+        if ($ao_options) {
38 38
         ?>
39
-            <h4><?php _e( 'Options', 'autoptimize' ); ?>:</h4>
39
+            <h4><?php _e('Options', 'autoptimize'); ?>:</h4>
40 40
             <table class="form-table debug">
41 41
             <?php
42
-            foreach ( $ao_options as $option ) {
42
+            foreach ($ao_options as $option) {
43 43
             ?>
44 44
                 <tr>
45 45
                     <th scope="row">
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
                     </th>
48 48
                     <td>
49 49
                         <?php
50
-                        if ( 'autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name'] ) {
51
-                            $value = print_r( json_decode( $option['value'], true ), true );
52
-                            if ( $value ) {
53
-                                echo "Raw JSON:\n<pre>" . $option['value'] . "</pre>\n\nDecoded JSON:\n<pre>" . $value . '</pre>';
50
+                        if ('autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name']) {
51
+                            $value = print_r(json_decode($option['value'], true), true);
52
+                            if ($value) {
53
+                                echo "Raw JSON:\n<pre>".$option['value']."</pre>\n\nDecoded JSON:\n<pre>".$value.'</pre>';
54 54
                             } else {
55 55
                                 echo 'Empty';
56 56
                             }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         }
70 70
         // Render WP-Cron intervals and scheduled events.
71 71
         ?>
72
-        <h4><?php _e( 'WP-Cron Intervals', 'autoptimize' ); ?>:</h4>
73
-        <pre><?php print_r( wp_get_schedules() ); ?></pre>
72
+        <h4><?php _e('WP-Cron Intervals', 'autoptimize'); ?>:</h4>
73
+        <pre><?php print_r(wp_get_schedules()); ?></pre>
74 74
         <hr />
75
-        <h4><?php _e( 'WP-Cron Scheduled Events', 'autoptimize' ); ?>:</h4>
76
-        <pre><?php print_r( _get_cron_array() ); ?></pre>
75
+        <h4><?php _e('WP-Cron Scheduled Events', 'autoptimize'); ?>:</h4>
76
+        <pre><?php print_r(_get_cron_array()); ?></pre>
77 77
     </li>
78 78
 </ul>
79 79
 <!-- END: Settings Debug -->
Please login to merge, or discard this patch.
classes/autoptimizeCriticalCSSSettings.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Critical CSS Options page.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -17,34 +17,34 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function __construct()
19 19
     {
20
-        $this->settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http );
20
+        $this->settings_screen_do_remote_http = apply_filters('autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http);
21 21
         $this->run();
22 22
     }
23 23
 
24 24
     protected function enabled()
25 25
     {
26
-        return apply_filters( 'autoptimize_filter_show_criticalcss_tabs', true );
26
+        return apply_filters('autoptimize_filter_show_criticalcss_tabs', true);
27 27
     }
28 28
 
29 29
     public function run()
30 30
     {
31
-        if ( $this->enabled() ) {
32
-            add_filter( 'autoptimize_filter_settingsscreen_tabs', array( $this, 'add_critcss_tabs' ), 10, 1 );
33
-            add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
31
+        if ($this->enabled()) {
32
+            add_filter('autoptimize_filter_settingsscreen_tabs', array($this, 'add_critcss_tabs'), 10, 1);
33
+            add_action('admin_enqueue_scripts', array($this, 'admin_assets'));
34 34
 
35
-            if ( $this->is_multisite_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
36
-                add_action( 'network_admin_menu', array( $this, 'add_critcss_admin_menu' ) );
35
+            if ($this->is_multisite_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network()) {
36
+                add_action('network_admin_menu', array($this, 'add_critcss_admin_menu'));
37 37
             } else {
38
-                add_action( 'admin_menu', array( $this, 'add_critcss_admin_menu' ) );
38
+                add_action('admin_menu', array($this, 'add_critcss_admin_menu'));
39 39
             }
40 40
 
41 41
             $criticalcss_ajax = new autoptimizeCriticalCSSSettingsAjax();
42 42
         }
43 43
     }
44 44
 
45
-    public function add_critcss_tabs( $in )
45
+    public function add_critcss_tabs($in)
46 46
     {
47
-        $in = array_merge( $in, array( 'ao_critcss' => '⚡ ' . __( 'Critical CSS', 'autoptimize' ) ) );
47
+        $in = array_merge($in, array('ao_critcss' => '⚡ '.__('Critical CSS', 'autoptimize')));
48 48
 
49 49
         return $in;
50 50
     }
@@ -52,56 +52,56 @@  discard block
 block discarded – undo
52 52
     public function add_critcss_admin_menu()
53 53
     {
54 54
         // Register settings.
55
-        register_setting( 'ao_ccss_options_group', 'autoptimize_css_defer_inline' );
56
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_rules' );
57
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_additional' );
58
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_queue' );
59
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_viewport' );
60
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_finclude' );
61
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_rlimit' );
62
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_noptimize' );
63
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_debug' );
64
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_key' );
65
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_keyst' );
66
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_loggedin' );
67
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_forcepath' );
68
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_deferjquery' );
69
-        register_setting( 'ao_ccss_options_group', 'autoptimize_ccss_domain' );
55
+        register_setting('ao_ccss_options_group', 'autoptimize_css_defer_inline');
56
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_rules');
57
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_additional');
58
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_queue');
59
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_viewport');
60
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_finclude');
61
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_rlimit');
62
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_noptimize');
63
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_debug');
64
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_key');
65
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_keyst');
66
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_loggedin');
67
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_forcepath');
68
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_deferjquery');
69
+        register_setting('ao_ccss_options_group', 'autoptimize_ccss_domain');
70 70
 
71 71
         // And add submenu-page.
72
-        add_submenu_page( null, 'Critical CSS', 'Critical CSS', 'manage_options', 'ao_critcss', array( $this, 'ao_criticalcsssettings_page' ) );
72
+        add_submenu_page(null, 'Critical CSS', 'Critical CSS', 'manage_options', 'ao_critcss', array($this, 'ao_criticalcsssettings_page'));
73 73
     }
74 74
 
75
-    public function admin_assets( $hook ) {
75
+    public function admin_assets($hook) {
76 76
         // Return if plugin is not hooked.
77
-        if ( 'settings_page_ao_critcss' != $hook && 'admin_page_ao_critcss' != $hook ) {
77
+        if ('settings_page_ao_critcss' != $hook && 'admin_page_ao_critcss' != $hook) {
78 78
             return;
79 79
         }
80 80
 
81 81
         // Stylesheets to add.
82
-        wp_enqueue_style( 'wp-jquery-ui-dialog' );
83
-        wp_enqueue_style( 'ao-tablesorter', plugins_url( 'critcss-inc/css/ao-tablesorter/style.css', __FILE__ ) );
84
-        wp_enqueue_style( 'ao-ccss-admin-css', plugins_url( 'critcss-inc/css/admin_styles.css', __FILE__ ) );
82
+        wp_enqueue_style('wp-jquery-ui-dialog');
83
+        wp_enqueue_style('ao-tablesorter', plugins_url('critcss-inc/css/ao-tablesorter/style.css', __FILE__));
84
+        wp_enqueue_style('ao-ccss-admin-css', plugins_url('critcss-inc/css/admin_styles.css', __FILE__));
85 85
 
86 86
         // Scripts to add.
87
-        wp_enqueue_script( 'jquery-ui-dialog', array( 'jquery' ) );
88
-        wp_enqueue_script( 'md5', plugins_url( 'critcss-inc/js/md5.min.js', __FILE__ ), null, null, true );
89
-        wp_enqueue_script( 'tablesorter', plugins_url( 'critcss-inc/js/jquery.tablesorter.min.js', __FILE__ ), array( 'jquery' ), null, true );
90
-        wp_enqueue_script( 'ao-ccss-admin-license', plugins_url( 'critcss-inc/js/admin_settings.js', __FILE__ ), array( 'jquery' ), null, true );
87
+        wp_enqueue_script('jquery-ui-dialog', array('jquery'));
88
+        wp_enqueue_script('md5', plugins_url('critcss-inc/js/md5.min.js', __FILE__), null, null, true);
89
+        wp_enqueue_script('tablesorter', plugins_url('critcss-inc/js/jquery.tablesorter.min.js', __FILE__), array('jquery'), null, true);
90
+        wp_enqueue_script('ao-ccss-admin-license', plugins_url('critcss-inc/js/admin_settings.js', __FILE__), array('jquery'), null, true);
91 91
     }
92 92
 
93 93
     public function ao_criticalcsssettings_page()
94 94
     {
95 95
         // these are not OO yet, simply require for now.
96
-        require_once( 'critcss-inc/admin_settings_rules.php' );
97
-        require_once( 'critcss-inc/admin_settings_queue.php' );
98
-        require_once( 'critcss-inc/admin_settings_key.php' );
99
-        require_once( 'critcss-inc/admin_settings_adv.php' );
100
-        require_once( 'critcss-inc/admin_settings_explain.php' );
96
+        require_once('critcss-inc/admin_settings_rules.php');
97
+        require_once('critcss-inc/admin_settings_queue.php');
98
+        require_once('critcss-inc/admin_settings_key.php');
99
+        require_once('critcss-inc/admin_settings_adv.php');
100
+        require_once('critcss-inc/admin_settings_explain.php');
101 101
 
102 102
         // fetch all options at once and populate them individually explicitely as globals.
103 103
         $all_options = autoptimizeCriticalCSSBase::fetch_options();
104
-        foreach ( $all_options as $_option => $_value ) {
104
+        foreach ($all_options as $_option => $_value) {
105 105
             global ${$_option};
106 106
             ${$_option} = $_value;
107 107
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         <div class="wrap">
110 110
             <div id="autoptimize_main">
111 111
                 <div id="ao_title_and_button">
112
-                    <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
112
+                    <h1><?php _e('Autoptimize Settings', 'autoptimize'); ?></h1>
113 113
                 </div>
114 114
 
115 115
                 <?php
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
                 echo autoptimizeConfig::ao_admin_tabs();
118 118
 
119 119
                 // Make sure dir to write ao_ccss exists and is writable.
120
-                if ( ! is_dir( AO_CCSS_DIR ) ) {
121
-                    $mkdirresp = @mkdir( AO_CCSS_DIR, 0775, true ); // @codingStandardsIgnoreLine
122
-                    $fileresp  = file_put_contents( AO_CCSS_DIR . 'index.html', '<html><head><meta name="robots" content="noindex, nofollow"></head><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/" rel="nofollow">Autoptimize</a></body></html>' );
123
-                    if ( ( ! $mkdirresp ) || ( ! $fileresp ) ) {
120
+                if (!is_dir(AO_CCSS_DIR)) {
121
+                    $mkdirresp = @mkdir(AO_CCSS_DIR, 0775, true); // @codingStandardsIgnoreLine
122
+                    $fileresp  = file_put_contents(AO_CCSS_DIR.'index.html', '<html><head><meta name="robots" content="noindex, nofollow"></head><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/" rel="nofollow">Autoptimize</a></body></html>');
123
+                    if ((!$mkdirresp) || (!$fileresp)) {
124 124
                         ?>
125 125
                         <div class="notice-error notice"><p>
126 126
                         <?php
127
-                        _e( 'Could not create the required directory. Make sure the webserver can write to the wp-content directory.', 'autoptimize' );
127
+                        _e('Could not create the required directory. Make sure the webserver can write to the wp-content directory.', 'autoptimize');
128 128
                         ?>
129 129
                         </p></div>
130 130
                         <?php
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
                 }
133 133
 
134 134
                 // Check for Autoptimize.
135
-                if ( ! empty( $ao_ccss_key ) && ! $ao_css_defer ) {
135
+                if (!empty($ao_ccss_key) && !$ao_css_defer) {
136 136
                     ?>
137 137
                     <div class="notice-error notice"><p>
138 138
                     <?php
139
-                    _e( "Oops! Please <strong>activate the \"Inline and Defer CSS\" option</strong> on Autoptimize's main settings page to use this power-up.", 'autoptimize' );
139
+                    _e("Oops! Please <strong>activate the \"Inline and Defer CSS\" option</strong> on Autoptimize's main settings page to use this power-up.", 'autoptimize');
140 140
                     ?>
141 141
                     </p></div>
142 142
                     <?php
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
                 }
145 145
 
146 146
                 // check if WordPress cron is disabled and warn if so.
147
-                if ( ! empty( $ao_ccss_key ) && defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && PAnD::is_admin_notice_active( 'i-know-about-disable-cron-forever' ) ) {
147
+                if (!empty($ao_ccss_key) && defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && PAnD::is_admin_notice_active('i-know-about-disable-cron-forever')) {
148 148
                     ?>
149 149
                     <div data-dismissible="i-know-about-disable-cron-forever" class="notice-warning notice is-dismissible"><p>
150 150
                     <?php
151
-                    _e( 'WordPress cron (for task scheduling) seems to be disabled. Have a look at <a href="https://wordpress.org/plugins/autoptimize-criticalcss/faq/" target="_blank">the FAQ</a> or the info in the Job Queue instructions if all jobs remain in "N" status and no rules are created.', 'autoptimize' );
151
+                    _e('WordPress cron (for task scheduling) seems to be disabled. Have a look at <a href="https://wordpress.org/plugins/autoptimize-criticalcss/faq/" target="_blank">the FAQ</a> or the info in the Job Queue instructions if all jobs remain in "N" status and no rules are created.', 'autoptimize');
152 152
                     ?>
153 153
                     </p></div>
154 154
                     <?php
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
 
157 157
                 // warn if it looks as though the queue processing job looks isn't running
158 158
                 // but store result in transient as to not to have to go through 2 arrays each and every time.
159
-                $_warn_cron = get_transient( 'ao_ccss_cronwarning' );
160
-                if ( ! empty( $ao_ccss_key ) && false === $_warn_cron ) {
159
+                $_warn_cron = get_transient('ao_ccss_cronwarning');
160
+                if (!empty($ao_ccss_key) && false === $_warn_cron) {
161 161
                     $_jobs_all_new         = true;
162
-                    $_oldest_job_timestamp = microtime( true ); // now.
162
+                    $_oldest_job_timestamp = microtime(true); // now.
163 163
                     $_jobs_too_old         = true;
164 164
 
165 165
                     // go over queue array.
166
-                    if ( empty( $ao_ccss_queue ) ) {
166
+                    if (empty($ao_ccss_queue)) {
167 167
                         // no jobs, then no warning.
168 168
                         $_jobs_all_new = false;
169 169
                     } else {
170
-                        foreach ( $ao_ccss_queue as $job ) {
171
-                            if ( $job['jctime'] < $_oldest_job_timestamp ) {
170
+                        foreach ($ao_ccss_queue as $job) {
171
+                            if ($job['jctime'] < $_oldest_job_timestamp) {
172 172
                                 // we need to catch the oldest job's timestamp.
173 173
                                 $_oldest_job_timestamp = $job['jctime'];
174 174
                             }
175 175
 
176
-                            if ( 'NEW' !== $job['jqstat'] && 'firstrun' !== $job['ljid'] ) {
176
+                            if ('NEW' !== $job['jqstat'] && 'firstrun' !== $job['ljid']) {
177 177
                                 // we have a non-"NEW" job which is not our pending firstrun job either, break the loop.
178 178
                                 $_jobs_all_new = false;
179 179
                                 break;
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
                     }
183 183
 
184 184
                     // is the oldest job too old (4h)?
185
-                    if ( $_oldest_job_timestamp > microtime( true ) - 60 * 60 * 4 ) {
185
+                    if ($_oldest_job_timestamp > microtime(true) - 60*60*4) {
186 186
                         $_jobs_too_old = false;
187 187
                     }
188 188
 
189
-                    if ( $_jobs_all_new && ! $this->ao_ccss_has_autorules() && $_jobs_too_old ) {
189
+                    if ($_jobs_all_new && !$this->ao_ccss_has_autorules() && $_jobs_too_old) {
190 190
                         $_warn_cron            = 'on';
191 191
                         $_transient_multiplier = 1; // store for 1 hour.
192 192
                     } else {
@@ -194,33 +194,33 @@  discard block
 block discarded – undo
194 194
                         $_transient_multiplier = 4; // store for 4 hours.
195 195
                     }
196 196
                     // and set transient.
197
-                    set_transient( 'ao_ccss_cronwarning', $_warn_cron, $_transient_multiplier * HOUR_IN_SECONDS );
197
+                    set_transient('ao_ccss_cronwarning', $_warn_cron, $_transient_multiplier*HOUR_IN_SECONDS);
198 198
                 }
199 199
 
200
-                if ( ! empty( $ao_ccss_key ) && 'on' == $_warn_cron && PAnD::is_admin_notice_active( 'i-know-about-cron-1' ) ) {
200
+                if (!empty($ao_ccss_key) && 'on' == $_warn_cron && PAnD::is_admin_notice_active('i-know-about-cron-1')) {
201 201
                     ?>
202 202
                     <div data-dismissible="i-know-about-cron-1" class="notice-warning notice is-dismissible"><p>
203 203
                     <?php
204
-                    _e( 'It looks like there might be a problem with WordPress cron (task scheduling). Have a look at <a href="https://wordpress.org/plugins/autoptimize-criticalcss/faq/" target="_blank">the FAQ</a> or the info in the Job Queue instructions if all jobs remain in "N" status and no rules are created.', 'autoptimize' );
204
+                    _e('It looks like there might be a problem with WordPress cron (task scheduling). Have a look at <a href="https://wordpress.org/plugins/autoptimize-criticalcss/faq/" target="_blank">the FAQ</a> or the info in the Job Queue instructions if all jobs remain in "N" status and no rules are created.', 'autoptimize');
205 205
                     ?>
206 206
                     </p></div>
207 207
                     <?php
208
-                } elseif ( ! empty( $ao_ccss_key ) && '2' == $ao_ccss_keyst && 'on' != $_warn_cron && ! $this->ao_ccss_has_autorules() ) {
208
+                } elseif (!empty($ao_ccss_key) && '2' == $ao_ccss_keyst && 'on' != $_warn_cron && !$this->ao_ccss_has_autorules()) {
209 209
                     ?>
210 210
                     <div class="notice-success notice"><p>
211 211
                     <?php
212
-                    _e( 'Great, Autoptimize will now automatically start creating new critical CSS rules, you should see those appearing below in the next couple of hours.', 'autoptimize' );
212
+                    _e('Great, Autoptimize will now automatically start creating new critical CSS rules, you should see those appearing below in the next couple of hours.', 'autoptimize');
213 213
                     ?>
214 214
                     </p></div>
215 215
                     <?php
216 216
                 }
217 217
 
218 218
                 // warn if service is down.
219
-                if ( ! empty( $ao_ccss_key ) && ! empty( $ao_ccss_servicestatus ) && is_array( $ao_ccss_servicestatus ) && 'down' === $ao_ccss_servicestatus['critcss']['status'] ) {
219
+                if (!empty($ao_ccss_key) && !empty($ao_ccss_servicestatus) && is_array($ao_ccss_servicestatus) && 'down' === $ao_ccss_servicestatus['critcss']['status']) {
220 220
                     ?>
221 221
                     <div class="notice-warning notice"><p>
222 222
                     <?php
223
-                    _e( 'The critical CSS service has been reported to be down. Although no new rules will be created for now, this does not prevent existing rules from being applied.', 'autoptimize' );
223
+                    _e('The critical CSS service has been reported to be down. Although no new rules will be created for now, this does not prevent existing rules from being applied.', 'autoptimize');
224 224
                     ?>
225 225
                     </p></div>
226 226
                     <?php
@@ -230,24 +230,24 @@  discard block
 block discarded – undo
230 230
                 ?>
231 231
                 <form id="settings" method="post" action="options.php">
232 232
                     <?php
233
-                    settings_fields( 'ao_ccss_options_group' );
233
+                    settings_fields('ao_ccss_options_group');
234 234
 
235 235
                     // Get API key status.
236
-                    $key = autoptimizeCriticalCSSCore::ao_ccss_key_status( true );
236
+                    $key = autoptimizeCriticalCSSCore::ao_ccss_key_status(true);
237 237
 
238
-                    if ( $this->is_multisite_network_admin() ) {
238
+                    if ($this->is_multisite_network_admin()) {
239 239
                         ?>
240 240
                         <ul id="key-panel">
241 241
                             <li class="itemDetail">
242 242
                             <?php
243 243
                                 // translators: the placesholder is for a line of code in wp-config.php.
244
-                                echo sprintf( __( '<p>Critical CSS settings cannot be set at network level as critical CSS is specific to each sub-site.</p><p>You can however provide the critical CSS API key for use by all sites by adding this your wp-config.php as %s</p>', 'autoptimize' ), '<br/><code>define(\'AUTOPTIMIZE_CRITICALCSS_API_KEY\', \'eyJhbGmorestringsherexHa7MkOQFtDFkZgLmBLe-LpcHx4\');</code>' );
244
+                                echo sprintf(__('<p>Critical CSS settings cannot be set at network level as critical CSS is specific to each sub-site.</p><p>You can however provide the critical CSS API key for use by all sites by adding this your wp-config.php as %s</p>', 'autoptimize'), '<br/><code>define(\'AUTOPTIMIZE_CRITICALCSS_API_KEY\', \'eyJhbGmorestringsherexHa7MkOQFtDFkZgLmBLe-LpcHx4\');</code>');
245 245
                             ?>
246 246
                             </li>
247 247
                         </ul>
248 248
                         <?php
249 249
                     } else {
250
-                        if ( 'valid' == $key['status'] ) {
250
+                        if ('valid' == $key['status']) {
251 251
                             // If key status is valid, render other panels.
252 252
                             // Render rules section.
253 253
                             ao_ccss_render_rules();
@@ -264,23 +264,23 @@  discard block
 block discarded – undo
264 264
                             $viewport = autoptimizeCriticalCSSCore::ao_ccss_viewport();
265 265
 
266 266
                             // Add hidden fields.
267
-                            echo "<input class='hidden' name='autoptimize_ccss_rules' value='" . $ao_ccss_rules_raw . "'>";
268
-                            echo "<input class='hidden' name='autoptimize_ccss_queue' value='" . $ao_ccss_queue_raw . "'>";
269
-                            echo '<input class="hidden" name="autoptimize_ccss_viewport[w]" value="' . $viewport['w'] . '">';
270
-                            echo '<input class="hidden" name="autoptimize_ccss_viewport[h]" value="' . $viewport['h'] . '">';
271
-                            echo '<input class="hidden" name="autoptimize_ccss_finclude" value="' . $ao_ccss_finclude . '">';
272
-                            echo '<input class="hidden" name="autoptimize_ccss_rlimit" value="' . $ao_ccss_rlimit . '">';
273
-                            echo '<input class="hidden" name="autoptimize_ccss_debug" value="' . $ao_ccss_debug . '">';
274
-                            echo '<input class="hidden" name="autoptimize_ccss_noptimize" value="' . $ao_ccss_noptimize . '">';
275
-                            echo '<input class="hidden" name="autoptimize_css_defer_inline" value="' . esc_attr( $ao_css_defer_inline ) . '">';
276
-                            echo '<input class="hidden" name="autoptimize_ccss_loggedin" value="' . $ao_ccss_loggedin . '">';
277
-                            echo '<input class="hidden" name="autoptimize_ccss_forcepath" value="' . $ao_ccss_forcepath . '">';
267
+                            echo "<input class='hidden' name='autoptimize_ccss_rules' value='".$ao_ccss_rules_raw."'>";
268
+                            echo "<input class='hidden' name='autoptimize_ccss_queue' value='".$ao_ccss_queue_raw."'>";
269
+                            echo '<input class="hidden" name="autoptimize_ccss_viewport[w]" value="'.$viewport['w'].'">';
270
+                            echo '<input class="hidden" name="autoptimize_ccss_viewport[h]" value="'.$viewport['h'].'">';
271
+                            echo '<input class="hidden" name="autoptimize_ccss_finclude" value="'.$ao_ccss_finclude.'">';
272
+                            echo '<input class="hidden" name="autoptimize_ccss_rlimit" value="'.$ao_ccss_rlimit.'">';
273
+                            echo '<input class="hidden" name="autoptimize_ccss_debug" value="'.$ao_ccss_debug.'">';
274
+                            echo '<input class="hidden" name="autoptimize_ccss_noptimize" value="'.$ao_ccss_noptimize.'">';
275
+                            echo '<input class="hidden" name="autoptimize_css_defer_inline" value="'.esc_attr($ao_css_defer_inline).'">';
276
+                            echo '<input class="hidden" name="autoptimize_ccss_loggedin" value="'.$ao_ccss_loggedin.'">';
277
+                            echo '<input class="hidden" name="autoptimize_ccss_forcepath" value="'.$ao_ccss_forcepath.'">';
278 278
                         }
279 279
                         // Render key panel unconditionally.
280
-                        ao_ccss_render_key( $ao_ccss_key, $key['status'], $key['stmsg'], $key['msg'], $key['color'] );
280
+                        ao_ccss_render_key($ao_ccss_key, $key['status'], $key['stmsg'], $key['msg'], $key['color']);
281 281
                         ?>
282 282
                         <p class="submit left">
283
-                            <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'autoptimize' ); ?>" />
283
+                            <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'autoptimize'); ?>" />
284 284
                         </p>
285 285
                         <?php
286 286
                     }
@@ -298,31 +298,31 @@  discard block
 block discarded – undo
298 298
                     });
299 299
                 }
300 300
                 </script>
301
-                <form id="importSettingsForm"<?php if ( $this->is_multisite_network_admin() ) { echo ' class="hidden"'; } ?>>
302
-                    <span id="exportSettings" class="button-secondary"><?php _e( 'Export Settings', 'autoptimize' ); ?></span>
303
-                    <input class="button-secondary" id="importSettings" type="button" value="<?php _e( 'Import Settings', 'autoptimize' ); ?>" onclick="upload();return false;" />
301
+                <form id="importSettingsForm"<?php if ($this->is_multisite_network_admin()) { echo ' class="hidden"'; } ?>>
302
+                    <span id="exportSettings" class="button-secondary"><?php _e('Export Settings', 'autoptimize'); ?></span>
303
+                    <input class="button-secondary" id="importSettings" type="button" value="<?php _e('Import Settings', 'autoptimize'); ?>" onclick="upload();return false;" />
304 304
                     <input class="button-secondary" id="settingsfile" name="settingsfile" type="file" />
305 305
                 </form>
306 306
                 <div id="importdialog"></div>
307 307
             </div><!-- /#autoptimize_main -->
308 308
         </div><!-- /#wrap -->
309 309
         <?php
310
-        if ( ! $this->is_multisite_network_admin() ) {
310
+        if (!$this->is_multisite_network_admin()) {
311 311
             // Include debug panel if debug mode is enable.
312
-            if ( $ao_ccss_debug ) {
312
+            if ($ao_ccss_debug) {
313 313
             ?>
314 314
                 <div id="debug">
315 315
                     <?php
316 316
                     // Include debug panel.
317
-                    include( 'critcss-inc/admin_settings_debug.php' );
317
+                    include('critcss-inc/admin_settings_debug.php');
318 318
                     ?>
319 319
                 </div><!-- /#debug -->
320 320
             <?php
321 321
             }
322 322
             echo '<script>';
323
-            include( 'critcss-inc/admin_settings_rules.js.php' );
324
-            include( 'critcss-inc/admin_settings_queue.js.php' );
325
-            include( 'critcss-inc/admin_settings_impexp.js.php' );
323
+            include('critcss-inc/admin_settings_rules.js.php');
324
+            include('critcss-inc/admin_settings_queue.js.php');
325
+            include('critcss-inc/admin_settings_impexp.js.php');
326 326
             echo '</script>';
327 327
         }
328 328
     }
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
     public static function ao_ccss_has_autorules() {
331 331
         static $_has_auto_rules = null;
332 332
 
333
-        if ( null === $_has_auto_rules ) {
333
+        if (null === $_has_auto_rules) {
334 334
             global $ao_ccss_rules;
335 335
             $_has_auto_rules = false;
336
-            if ( ! empty( $ao_ccss_rules ) ) {
337
-                foreach ( array( 'types', 'paths' ) as $_typat ) {
338
-                    foreach ( $ao_ccss_rules[ $_typat ] as $rule ) {
339
-                        if ( ! empty( $rule['hash'] ) ) {
336
+            if (!empty($ao_ccss_rules)) {
337
+                foreach (array('types', 'paths') as $_typat) {
338
+                    foreach ($ao_ccss_rules[$_typat] as $rule) {
339
+                        if (!empty($rule['hash'])) {
340 340
                             // we have at least one AUTO job, so all is fine.
341 341
                             $_has_auto_rules = true;
342 342
                             break;
343 343
                         }
344 344
                     }
345
-                    if ( $_has_auto_rules ) {
345
+                    if ($_has_auto_rules) {
346 346
                         break;
347 347
                     }
348 348
                 }
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
     public function is_multisite_network_admin() {
356 356
         static $_multisite_network_admin = null;
357 357
 
358
-        if ( null === $_multisite_network_admin ) {
359
-            if ( is_multisite() && is_network_admin() ) {
358
+        if (null === $_multisite_network_admin) {
359
+            if (is_multisite() && is_network_admin()) {
360 360
                 $_multisite_network_admin = true;
361 361
             } else {
362 362
                 $_multisite_network_admin = false;
Please login to merge, or discard this patch.
classes/autoptimizeCriticalCSSSettingsAjax.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Critical CSS settings AJAX logic.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     {
13 13
         // fetch all options at once and populate them individually explicitely as globals.
14 14
         $all_options = autoptimizeCriticalCSSBase::fetch_options();
15
-        foreach ( $all_options as $_option => $_value ) {
15
+        foreach ($all_options as $_option => $_value) {
16 16
             global ${$_option};
17 17
             ${$_option} = $_value;
18 18
         }
@@ -21,47 +21,47 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function run() {
23 23
         // add filters.
24
-        add_action( 'wp_ajax_fetch_critcss', array( $this, 'critcss_fetch_callback' ) );
25
-        add_action( 'wp_ajax_save_critcss', array( $this, 'critcss_save_callback' ) );
26
-        add_action( 'wp_ajax_rm_critcss', array( $this, 'critcss_rm_callback' ) );
27
-        add_action( 'wp_ajax_rm_critcss_all', array( $this, 'critcss_rm_all_callback' ) );
28
-        add_action( 'wp_ajax_ao_ccss_export', array( $this, 'ao_ccss_export_callback' ) );
29
-        add_action( 'wp_ajax_ao_ccss_import', array( $this, 'ao_ccss_import_callback' ) );
24
+        add_action('wp_ajax_fetch_critcss', array($this, 'critcss_fetch_callback'));
25
+        add_action('wp_ajax_save_critcss', array($this, 'critcss_save_callback'));
26
+        add_action('wp_ajax_rm_critcss', array($this, 'critcss_rm_callback'));
27
+        add_action('wp_ajax_rm_critcss_all', array($this, 'critcss_rm_all_callback'));
28
+        add_action('wp_ajax_ao_ccss_export', array($this, 'ao_ccss_export_callback'));
29
+        add_action('wp_ajax_ao_ccss_import', array($this, 'ao_ccss_import_callback'));
30 30
     }
31 31
 
32 32
     public function critcss_fetch_callback() {
33 33
         // Ajax handler to obtain a critical CSS file from the filesystem.
34 34
         // Check referer.
35
-        check_ajax_referer( 'fetch_critcss_nonce', 'critcss_fetch_nonce' );
35
+        check_ajax_referer('fetch_critcss_nonce', 'critcss_fetch_nonce');
36 36
 
37 37
         // Initialize error flag.
38 38
         $error = true;
39 39
 
40 40
         // Allow no content for MANUAL rules (as they may not exist just yet).
41
-        if ( current_user_can( 'manage_options' ) && empty( $_POST['critcssfile'] ) ) {
41
+        if (current_user_can('manage_options') && empty($_POST['critcssfile'])) {
42 42
             $content = '';
43 43
             $error   = false;
44
-        } elseif ( current_user_can( 'manage_options' ) && $this->critcss_check_filename( $_POST['critcssfile'] ) ) {
44
+        } elseif (current_user_can('manage_options') && $this->critcss_check_filename($_POST['critcssfile'])) {
45 45
             // Or check user permissios and filename.
46 46
             // Set file path and obtain its content.
47
-            $critcssfile = AO_CCSS_DIR . strip_tags( $_POST['critcssfile'] );
48
-            if ( file_exists( $critcssfile ) ) {
49
-                $content = file_get_contents( $critcssfile );
47
+            $critcssfile = AO_CCSS_DIR.strip_tags($_POST['critcssfile']);
48
+            if (file_exists($critcssfile)) {
49
+                $content = file_get_contents($critcssfile);
50 50
                 $error   = false;
51 51
             }
52 52
         }
53 53
 
54 54
         // Prepare response.
55
-        if ( $error ) {
55
+        if ($error) {
56 56
             $response['code']   = '500';
57
-            $response['string'] = 'Error reading file ' . $critcssfile . '.';
57
+            $response['string'] = 'Error reading file '.$critcssfile.'.';
58 58
         } else {
59 59
             $response['code']   = '200';
60 60
             $response['string'] = $content;
61 61
         }
62 62
 
63 63
         // Dispatch respose.
64
-        echo json_encode( $response );
64
+        echo json_encode($response);
65 65
 
66 66
         // Close ajax request.
67 67
         wp_die();
@@ -74,22 +74,22 @@  discard block
 block discarded – undo
74 74
 
75 75
         // Ajax handler to write a critical CSS to the filesystem
76 76
         // Check referer.
77
-        check_ajax_referer( 'save_critcss_nonce', 'critcss_save_nonce' );
77
+        check_ajax_referer('save_critcss_nonce', 'critcss_save_nonce');
78 78
 
79 79
         // Allow empty contents for MANUAL rules (as they are fetched later).
80
-        if ( current_user_can( 'manage_options' ) && empty( $_POST['critcssfile'] ) ) {
80
+        if (current_user_can('manage_options') && empty($_POST['critcssfile'])) {
81 81
             $critcssfile = false;
82 82
             $status      = true;
83
-        } elseif ( current_user_can( 'manage_options' ) && $this->critcss_check_filename( $_POST['critcssfile'] ) ) {
83
+        } elseif (current_user_can('manage_options') && $this->critcss_check_filename($_POST['critcssfile'])) {
84 84
             // Or check user permissios and filename
85 85
             // Set critical CSS content.
86
-            $critcsscontents = stripslashes( $_POST['critcsscontents'] );
86
+            $critcsscontents = stripslashes($_POST['critcsscontents']);
87 87
 
88 88
             // If there is content and it's valid, write the file.
89
-            if ( $critcsscontents && autoptimizeCriticalCSSCore::ao_ccss_check_contents( $critcsscontents ) ) {
89
+            if ($critcsscontents && autoptimizeCriticalCSSCore::ao_ccss_check_contents($critcsscontents)) {
90 90
                 // Set file path and status.
91
-                $critcssfile = AO_CCSS_DIR . strip_tags( $_POST['critcssfile'] );
92
-                $status      = file_put_contents( $critcssfile, $critcsscontents, LOCK_EX );
91
+                $critcssfile = AO_CCSS_DIR.strip_tags($_POST['critcssfile']);
92
+                $status      = file_put_contents($critcssfile, $critcsscontents, LOCK_EX);
93 93
                 // Or set as error.
94 94
             } else {
95 95
                 $error = true;
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         // Prepare response.
103
-        if ( ! $status || $error ) {
103
+        if (!$status || $error) {
104 104
             $response['code']   = '500';
105
-            $response['string'] = 'Error saving file ' . $critcssfile . '.';
105
+            $response['string'] = 'Error saving file '.$critcssfile.'.';
106 106
         } else {
107 107
             $response['code'] = '200';
108
-            if ( $critcssfile ) {
109
-                $response['string'] = 'File ' . $critcssfile . ' saved.';
108
+            if ($critcssfile) {
109
+                $response['string'] = 'File '.$critcssfile.' saved.';
110 110
             } else {
111 111
                 $response['string'] = 'Empty content do not need to be saved.';
112 112
             }
113 113
         }
114 114
 
115 115
         // Dispatch respose.
116
-        echo json_encode( $response );
116
+        echo json_encode($response);
117 117
 
118 118
         // Close ajax request.
119 119
         wp_die();
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
     public function critcss_rm_callback() {
124 124
         // Ajax handler to delete a critical CSS from the filesystem
125 125
         // Check referer.
126
-        check_ajax_referer( 'rm_critcss_nonce', 'critcss_rm_nonce' );
126
+        check_ajax_referer('rm_critcss_nonce', 'critcss_rm_nonce');
127 127
 
128 128
         // Initialize error and status flags.
129 129
         $error  = true;
130 130
         $status = false;
131 131
 
132 132
         // Allow no file for MANUAL rules (as they may not exist just yet).
133
-        if ( current_user_can( 'manage_options' ) && empty( $_POST['critcssfile'] ) ) {
133
+        if (current_user_can('manage_options') && empty($_POST['critcssfile'])) {
134 134
             $error = false;
135
-        } elseif ( current_user_can( 'manage_options' ) && $this->critcss_check_filename( $_POST['critcssfile'] ) ) {
135
+        } elseif (current_user_can('manage_options') && $this->critcss_check_filename($_POST['critcssfile'])) {
136 136
             // Or check user permissios and filename
137 137
             // Set file path and delete it.
138
-            $critcssfile = AO_CCSS_DIR . strip_tags( $_POST['critcssfile'] );
139
-            if ( file_exists( $critcssfile ) ) {
140
-                $status = unlink( $critcssfile );
138
+            $critcssfile = AO_CCSS_DIR.strip_tags($_POST['critcssfile']);
139
+            if (file_exists($critcssfile)) {
140
+                $status = unlink($critcssfile);
141 141
                 $error  = false;
142 142
             }
143 143
         }
144 144
 
145 145
         // Prepare response.
146
-        if ( $error ) {
146
+        if ($error) {
147 147
             $response['code']   = '500';
148
-            $response['string'] = 'Error removing file ' . $critcssfile . '.';
148
+            $response['string'] = 'Error removing file '.$critcssfile.'.';
149 149
         } else {
150 150
             $response['code'] = '200';
151
-            if ( $status ) {
152
-                $response['string'] = 'File ' . $critcssfile . ' removed.';
151
+            if ($status) {
152
+                $response['string'] = 'File '.$critcssfile.' removed.';
153 153
             } else {
154 154
                 $response['string'] = 'No file to be removed.';
155 155
             }
156 156
         }
157 157
 
158 158
         // Dispatch respose.
159
-        echo json_encode( $response );
159
+        echo json_encode($response);
160 160
 
161 161
         // Close ajax request.
162 162
         wp_die();
@@ -165,28 +165,28 @@  discard block
 block discarded – undo
165 165
     public function critcss_rm_all_callback() {
166 166
         // Ajax handler to delete a critical CSS from the filesystem
167 167
         // Check referer.
168
-        check_ajax_referer( 'rm_critcss_all_nonce', 'critcss_rm_all_nonce' );
168
+        check_ajax_referer('rm_critcss_all_nonce', 'critcss_rm_all_nonce');
169 169
 
170 170
         // Initialize error and status flags.
171 171
         $error  = true;
172 172
         $status = false;
173 173
 
174 174
         // Remove all ccss files on filesystem.
175
-        if ( current_user_can( 'manage_options' ) ) {
176
-            if ( file_exists( AO_CCSS_DIR ) && is_dir( AO_CCSS_DIR ) ) {
177
-                array_map( 'unlink', glob( AO_CCSS_DIR . 'ccss_*.css', GLOB_BRACE ) );
175
+        if (current_user_can('manage_options')) {
176
+            if (file_exists(AO_CCSS_DIR) && is_dir(AO_CCSS_DIR)) {
177
+                array_map('unlink', glob(AO_CCSS_DIR.'ccss_*.css', GLOB_BRACE));
178 178
                 $error  = false;
179 179
                 $status = true;
180 180
             }
181 181
         }
182 182
 
183 183
         // Prepare response.
184
-        if ( $error ) {
184
+        if ($error) {
185 185
             $response['code']   = '500';
186 186
             $response['string'] = 'Error removing all critical CSS files.';
187 187
         } else {
188 188
             $response['code'] = '200';
189
-            if ( $status ) {
189
+            if ($status) {
190 190
                 $response['string'] = 'Critical CSS Files removed.';
191 191
             } else {
192 192
                 $response['string'] = 'No file removed.';
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         }
195 195
 
196 196
         // Dispatch respose.
197
-        echo json_encode( $response );
197
+        echo json_encode($response);
198 198
 
199 199
         // Close ajax request.
200 200
         wp_die();
@@ -203,70 +203,70 @@  discard block
 block discarded – undo
203 203
     public function ao_ccss_export_callback() {
204 204
         // Ajax handler export settings
205 205
         // Check referer.
206
-        check_ajax_referer( 'ao_ccss_export_nonce', 'ao_ccss_export_nonce' );
206
+        check_ajax_referer('ao_ccss_export_nonce', 'ao_ccss_export_nonce');
207 207
 
208
-        if ( ! class_exists( 'ZipArchive' ) ) {
208
+        if (!class_exists('ZipArchive')) {
209 209
             $response['code'] = '500';
210 210
             $response['msg']  = 'PHP ZipArchive not present, cannot create zipfile';
211
-            echo json_encode( $response );
211
+            echo json_encode($response);
212 212
             wp_die();
213 213
         }
214 214
 
215 215
         // Init array, get options and prepare the raw object.
216 216
         $settings               = array();
217
-        $settings['rules']      = get_option( 'autoptimize_ccss_rules' );
218
-        $settings['additional'] = get_option( 'autoptimize_ccss_additional' );
219
-        $settings['viewport']   = get_option( 'autoptimize_ccss_viewport' );
220
-        $settings['finclude']   = get_option( 'autoptimize_ccss_finclude' );
221
-        $settings['rlimit']     = get_option( 'autoptimize_ccss_rlimit' );
222
-        $settings['noptimize']  = get_option( 'autoptimize_ccss_noptimize' );
223
-        $settings['debug']      = get_option( 'autoptimize_ccss_debug' );
224
-        $settings['key']        = get_option( 'autoptimize_ccss_key' );
217
+        $settings['rules']      = get_option('autoptimize_ccss_rules');
218
+        $settings['additional'] = get_option('autoptimize_ccss_additional');
219
+        $settings['viewport']   = get_option('autoptimize_ccss_viewport');
220
+        $settings['finclude']   = get_option('autoptimize_ccss_finclude');
221
+        $settings['rlimit']     = get_option('autoptimize_ccss_rlimit');
222
+        $settings['noptimize']  = get_option('autoptimize_ccss_noptimize');
223
+        $settings['debug']      = get_option('autoptimize_ccss_debug');
224
+        $settings['key']        = get_option('autoptimize_ccss_key');
225 225
 
226 226
         // Initialize error flag.
227 227
         $error = true;
228 228
 
229 229
         // Check user permissions.
230
-        if ( current_user_can( 'manage_options' ) ) {
230
+        if (current_user_can('manage_options')) {
231 231
             // Prepare settings file path and content.
232
-            $exportfile = AO_CCSS_DIR . 'settings.json';
233
-            $contents   = json_encode( $settings );
234
-            $status     = file_put_contents( $exportfile, $contents, LOCK_EX );
232
+            $exportfile = AO_CCSS_DIR.'settings.json';
233
+            $contents   = json_encode($settings);
234
+            $status     = file_put_contents($exportfile, $contents, LOCK_EX);
235 235
             $error      = false;
236 236
         }
237 237
 
238 238
         // Prepare archive.
239
-        $zipfile = AO_CCSS_DIR . date( 'Ymd-H\hi' ) . '_ao_ccss_settings.zip';
240
-        $file    = pathinfo( $zipfile, PATHINFO_BASENAME );
239
+        $zipfile = AO_CCSS_DIR.date('Ymd-H\hi').'_ao_ccss_settings.zip';
240
+        $file    = pathinfo($zipfile, PATHINFO_BASENAME);
241 241
         $zip     = new ZipArchive();
242
-        $ret     = $zip->open( $zipfile, ZipArchive::CREATE );
243
-        if ( true !== $ret ) {
242
+        $ret     = $zip->open($zipfile, ZipArchive::CREATE);
243
+        if (true !== $ret) {
244 244
             $error = true;
245 245
         } else {
246
-            $zip->addFile( AO_CCSS_DIR . 'settings.json', 'settings.json' );
247
-            if ( file_exists( AO_CCSS_DIR . 'queue.json' ) ) {
248
-                $zip->addFile( AO_CCSS_DIR . 'queue.json', 'queue.json' );
246
+            $zip->addFile(AO_CCSS_DIR.'settings.json', 'settings.json');
247
+            if (file_exists(AO_CCSS_DIR.'queue.json')) {
248
+                $zip->addFile(AO_CCSS_DIR.'queue.json', 'queue.json');
249 249
             }
250 250
             $options = array(
251 251
                 'add_path'        => './',
252 252
                 'remove_all_path' => true,
253 253
             );
254
-            $zip->addGlob( AO_CCSS_DIR . '*.css', 0, $options );
254
+            $zip->addGlob(AO_CCSS_DIR.'*.css', 0, $options);
255 255
             $zip->close();
256 256
         }
257 257
 
258 258
         // Prepare response.
259
-        if ( ! $status || $error ) {
259
+        if (!$status || $error) {
260 260
             $response['code'] = '500';
261
-            $response['msg']  = 'Error saving file ' . $file . ', code: ' . $ret;
261
+            $response['msg']  = 'Error saving file '.$file.', code: '.$ret;
262 262
         } else {
263 263
             $response['code'] = '200';
264
-            $response['msg']  = 'File ' . $file . ' saved.';
264
+            $response['msg']  = 'File '.$file.' saved.';
265 265
             $response['file'] = $file;
266 266
         }
267 267
 
268 268
         // Dispatch respose.
269
-        echo json_encode( $response );
269
+        echo json_encode($response);
270 270
 
271 271
         // Close ajax request.
272 272
         wp_die();
@@ -275,44 +275,44 @@  discard block
 block discarded – undo
275 275
     public function ao_ccss_import_callback() {
276 276
         // Ajax handler import settings
277 277
         // Check referer.
278
-        check_ajax_referer( 'ao_ccss_import_nonce', 'ao_ccss_import_nonce' );
278
+        check_ajax_referer('ao_ccss_import_nonce', 'ao_ccss_import_nonce');
279 279
 
280 280
         // Initialize error flag.
281 281
         $error = false;
282 282
 
283 283
         // Process an uploaded file with no errors.
284
-        if ( ! $_FILES['file']['error'] ) {
284
+        if (!$_FILES['file']['error']) {
285 285
             // Save file to the cache directory.
286
-            $zipfile = AO_CCSS_DIR . $_FILES['file']['name'];
287
-            move_uploaded_file( $_FILES['file']['tmp_name'], $zipfile );
286
+            $zipfile = AO_CCSS_DIR.$_FILES['file']['name'];
287
+            move_uploaded_file($_FILES['file']['tmp_name'], $zipfile);
288 288
 
289 289
             // Extract archive.
290 290
             $zip = new ZipArchive;
291
-            if ( $zip->open( $zipfile ) === true ) {
292
-                $zip->extractTo( AO_CCSS_DIR );
291
+            if ($zip->open($zipfile) === true) {
292
+                $zip->extractTo(AO_CCSS_DIR);
293 293
                 $zip->close();
294 294
             } else {
295 295
                 $error = 'extracting';
296 296
             }
297 297
 
298
-            if ( ! $error ) {
298
+            if (!$error) {
299 299
                 // Archive extraction ok, continue settings importing
300 300
                 // Settings file.
301
-                $importfile = AO_CCSS_DIR . 'settings.json';
301
+                $importfile = AO_CCSS_DIR.'settings.json';
302 302
 
303
-                if ( file_exists( $importfile ) ) {
303
+                if (file_exists($importfile)) {
304 304
                     // Get settings and turn them into an object.
305
-                    $settings = json_decode( file_get_contents( $importfile ), true );
305
+                    $settings = json_decode(file_get_contents($importfile), true);
306 306
 
307 307
                     // Update options.
308
-                    update_option( 'autoptimize_ccss_rules', $settings['rules'] );
309
-                    update_option( 'autoptimize_ccss_additional', $settings['additional'] );
310
-                    update_option( 'autoptimize_ccss_viewport', $settings['viewport'] );
311
-                    update_option( 'autoptimize_ccss_finclude', $settings['finclude'] );
312
-                    update_option( 'autoptimize_ccss_rlimit', $settings['rlimit'] );
313
-                    update_option( 'autoptimize_ccss_noptimize', $settings['noptimize'] );
314
-                    update_option( 'autoptimize_ccss_debug', $settings['debug'] );
315
-                    update_option( 'autoptimize_ccss_key', $settings['key'] );
308
+                    update_option('autoptimize_ccss_rules', $settings['rules']);
309
+                    update_option('autoptimize_ccss_additional', $settings['additional']);
310
+                    update_option('autoptimize_ccss_viewport', $settings['viewport']);
311
+                    update_option('autoptimize_ccss_finclude', $settings['finclude']);
312
+                    update_option('autoptimize_ccss_rlimit', $settings['rlimit']);
313
+                    update_option('autoptimize_ccss_noptimize', $settings['noptimize']);
314
+                    update_option('autoptimize_ccss_debug', $settings['debug']);
315
+                    update_option('autoptimize_ccss_key', $settings['key']);
316 316
                 } else {
317 317
                     // Settings file doesn't exist, update error flag.
318 318
                     $error = 'settings file does not exist';
@@ -321,28 +321,28 @@  discard block
 block discarded – undo
321 321
         }
322 322
 
323 323
         // Prepare response.
324
-        if ( $error ) {
324
+        if ($error) {
325 325
             $response['code'] = '500';
326
-            $response['msg']  = 'Error importing settings: ' . $error;
326
+            $response['msg']  = 'Error importing settings: '.$error;
327 327
         } else {
328 328
             $response['code'] = '200';
329 329
             $response['msg']  = 'Settings imported successfully';
330 330
         }
331 331
 
332 332
         // Dispatch respose.
333
-        echo json_encode( $response );
333
+        echo json_encode($response);
334 334
 
335 335
         // Close ajax request.
336 336
         wp_die();
337 337
     }
338 338
 
339
-    public function critcss_check_filename( $filename ) {
339
+    public function critcss_check_filename($filename) {
340 340
         // Try to avoid directory traversal when reading/writing/deleting critical CSS files.
341
-        if ( strpos( $filename, 'ccss_' ) !== 0 ) {
341
+        if (strpos($filename, 'ccss_') !== 0) {
342 342
             return false;
343
-        } elseif ( substr( $filename, -4, 4 ) !== '.css' ) {
343
+        } elseif (substr($filename, -4, 4) !== '.css') {
344 344
             return false;
345
-        } elseif ( sanitize_file_name( $filename ) !== $filename ) {
345
+        } elseif (sanitize_file_name($filename) !== $filename) {
346 346
             // Use WordPress core's sanitize_file_name to see if anything fishy is going on.
347 347
             return false;
348 348
         } else {
Please login to merge, or discard this patch.
classes/autoptimizeCriticalCSSBase.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Critical CSS base file (initializes all ccss files).
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
     public function __construct()
20 20
     {
21 21
         // define constant, but only once.
22
-        if ( ! defined( 'AO_CCSS_DIR' ) ) {
22
+        if (!defined('AO_CCSS_DIR')) {
23 23
             // Define plugin version.
24
-            define( 'AO_CCSS_VER', 'AO_' . AUTOPTIMIZE_PLUGIN_VERSION );
24
+            define('AO_CCSS_VER', 'AO_'.AUTOPTIMIZE_PLUGIN_VERSION);
25 25
 
26 26
             // Define a constant with the directory to store critical CSS in.
27
-            if ( is_multisite() ) {
27
+            if (is_multisite()) {
28 28
                 $blog_id = get_current_blog_id();
29
-                define( 'AO_CCSS_DIR', WP_CONTENT_DIR . '/uploads/ao_ccss/' . $blog_id . '/' );
29
+                define('AO_CCSS_DIR', WP_CONTENT_DIR.'/uploads/ao_ccss/'.$blog_id.'/');
30 30
             } else {
31
-                define( 'AO_CCSS_DIR', WP_CONTENT_DIR . '/uploads/ao_ccss/' );
31
+                define('AO_CCSS_DIR', WP_CONTENT_DIR.'/uploads/ao_ccss/');
32 32
             }
33 33
 
34 34
             // Define support files locations.
35
-            define( 'AO_CCSS_LOCK', AO_CCSS_DIR . 'queue.lock' );
36
-            define( 'AO_CCSS_LOG', AO_CCSS_DIR . 'queuelog.html' );
37
-            define( 'AO_CCSS_DEBUG', AO_CCSS_DIR . 'queue.json' );
35
+            define('AO_CCSS_LOCK', AO_CCSS_DIR.'queue.lock');
36
+            define('AO_CCSS_LOG', AO_CCSS_DIR.'queuelog.html');
37
+            define('AO_CCSS_DEBUG', AO_CCSS_DIR.'queue.json');
38 38
 
39 39
             // Define constants for criticalcss.com base path and API endpoints.
40 40
             // fixme: AO_CCSS_URL should be read from the autoptimize availability json stored as option.
41
-            define( 'AO_CCSS_URL', 'https://criticalcss.com' );
42
-            define( 'AO_CCSS_API', AO_CCSS_URL . '/api/premium/' );
41
+            define('AO_CCSS_URL', 'https://criticalcss.com');
42
+            define('AO_CCSS_API', AO_CCSS_URL.'/api/premium/');
43 43
         }
44 44
 
45 45
         $this->filepath = __FILE__;
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
     {
53 53
         // get all options.
54 54
         $all_options = $this->fetch_options();
55
-        foreach ( $all_options as $option => $value ) {
55
+        foreach ($all_options as $option => $value) {
56 56
             ${$option} = $value;
57 57
         }
58 58
 
59 59
         // make sure the 10 minutes cron schedule is added.
60
-        add_filter( 'cron_schedules', array( $this, 'ao_ccss_interval' ) );
60
+        add_filter('cron_schedules', array($this, 'ao_ccss_interval'));
61 61
 
62 62
         // check if we need to upgrade.
63 63
         $this->check_upgrade();
64 64
 
65 65
         // make sure ao_ccss_queue is scheduled OK if an API key is set.
66
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_queue' ) ) {
67
-            wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
66
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_queue')) {
67
+            wp_schedule_event(time(), apply_filters('ao_ccss_queue_schedule', 'ao_ccss'), 'ao_ccss_queue');
68 68
         }
69 69
     }
70 70
 
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
         // Required libs, core is always needed.
73 73
         $criticalcss_core = new autoptimizeCriticalCSSCore();
74 74
 
75
-        if ( defined( 'DOING_CRON' ) || is_admin() ) {
75
+        if (defined('DOING_CRON') || is_admin()) {
76 76
             // TODO: also include if overridden somehow to force queue processing to be executed?
77 77
             $criticalcss_cron = new autoptimizeCriticalCSSCron();
78 78
         }
79 79
 
80
-        if ( is_admin() ) {
80
+        if (is_admin()) {
81 81
             $criticalcss_settings = new autoptimizeCriticalCSSSettings();
82 82
         } else {
83 83
             // enqueuing only done when not wp-admin.
@@ -87,48 +87,48 @@  discard block
 block discarded – undo
87 87
 
88 88
     public static function fetch_options() {
89 89
         // Get options.
90
-        $autoptimize_ccss_options['ao_css_defer']          = autoptimizeOptionWrapper::get_option( 'autoptimize_css_defer' );
91
-        $autoptimize_ccss_options['ao_css_defer_inline']   = autoptimizeOptionWrapper::get_option( 'autoptimize_css_defer_inline' );
92
-        $autoptimize_ccss_options['ao_ccss_rules_raw']     = get_option( 'autoptimize_ccss_rules', false );
93
-        $autoptimize_ccss_options['ao_ccss_additional']    = get_option( 'autoptimize_ccss_additional' );
94
-        $autoptimize_ccss_options['ao_ccss_queue_raw']     = get_option( 'autoptimize_ccss_queue', false );
95
-        $autoptimize_ccss_options['ao_ccss_viewport']      = get_option( 'autoptimize_ccss_viewport', false );
96
-        $autoptimize_ccss_options['ao_ccss_finclude']      = get_option( 'autoptimize_ccss_finclude', false );
97
-        $autoptimize_ccss_options['ao_ccss_rlimit']        = get_option( 'autoptimize_ccss_rlimit', '5' );
98
-        $autoptimize_ccss_options['ao_ccss_noptimize']     = get_option( 'autoptimize_ccss_noptimize', false );
99
-        $autoptimize_ccss_options['ao_ccss_debug']         = get_option( 'autoptimize_ccss_debug', false );
100
-        $autoptimize_ccss_options['ao_ccss_key']           = get_option( 'autoptimize_ccss_key' );
101
-        $autoptimize_ccss_options['ao_ccss_keyst']         = get_option( 'autoptimize_ccss_keyst' );
102
-        $autoptimize_ccss_options['ao_ccss_loggedin']      = get_option( 'autoptimize_ccss_loggedin', '1' );
103
-        $autoptimize_ccss_options['ao_ccss_forcepath']     = get_option( 'autoptimize_ccss_forcepath', '1' );
104
-        $autoptimize_ccss_options['ao_ccss_servicestatus'] = get_option( 'autoptimize_service_availablity' );
105
-        $autoptimize_ccss_options['ao_ccss_deferjquery']   = get_option( 'autoptimize_ccss_deferjquery', false );
106
-        $autoptimize_ccss_options['ao_ccss_domain']        = get_option( 'autoptimize_ccss_domain' );
107
-
108
-        if ( strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'http' ) === false && strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'uggc' ) === 0 ) {
109
-            $autoptimize_ccss_options['ao_ccss_domain'] = str_rot13( $autoptimize_ccss_options['ao_ccss_domain'] );
110
-        } elseif ( strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'http' ) !== false ) {
90
+        $autoptimize_ccss_options['ao_css_defer']          = autoptimizeOptionWrapper::get_option('autoptimize_css_defer');
91
+        $autoptimize_ccss_options['ao_css_defer_inline']   = autoptimizeOptionWrapper::get_option('autoptimize_css_defer_inline');
92
+        $autoptimize_ccss_options['ao_ccss_rules_raw']     = get_option('autoptimize_ccss_rules', false);
93
+        $autoptimize_ccss_options['ao_ccss_additional']    = get_option('autoptimize_ccss_additional');
94
+        $autoptimize_ccss_options['ao_ccss_queue_raw']     = get_option('autoptimize_ccss_queue', false);
95
+        $autoptimize_ccss_options['ao_ccss_viewport']      = get_option('autoptimize_ccss_viewport', false);
96
+        $autoptimize_ccss_options['ao_ccss_finclude']      = get_option('autoptimize_ccss_finclude', false);
97
+        $autoptimize_ccss_options['ao_ccss_rlimit']        = get_option('autoptimize_ccss_rlimit', '5');
98
+        $autoptimize_ccss_options['ao_ccss_noptimize']     = get_option('autoptimize_ccss_noptimize', false);
99
+        $autoptimize_ccss_options['ao_ccss_debug']         = get_option('autoptimize_ccss_debug', false);
100
+        $autoptimize_ccss_options['ao_ccss_key']           = get_option('autoptimize_ccss_key');
101
+        $autoptimize_ccss_options['ao_ccss_keyst']         = get_option('autoptimize_ccss_keyst');
102
+        $autoptimize_ccss_options['ao_ccss_loggedin']      = get_option('autoptimize_ccss_loggedin', '1');
103
+        $autoptimize_ccss_options['ao_ccss_forcepath']     = get_option('autoptimize_ccss_forcepath', '1');
104
+        $autoptimize_ccss_options['ao_ccss_servicestatus'] = get_option('autoptimize_service_availablity');
105
+        $autoptimize_ccss_options['ao_ccss_deferjquery']   = get_option('autoptimize_ccss_deferjquery', false);
106
+        $autoptimize_ccss_options['ao_ccss_domain']        = get_option('autoptimize_ccss_domain');
107
+
108
+        if (strpos($autoptimize_ccss_options['ao_ccss_domain'], 'http') === false && strpos($autoptimize_ccss_options['ao_ccss_domain'], 'uggc') === 0) {
109
+            $autoptimize_ccss_options['ao_ccss_domain'] = str_rot13($autoptimize_ccss_options['ao_ccss_domain']);
110
+        } elseif (strpos($autoptimize_ccss_options['ao_ccss_domain'], 'http') !== false) {
111 111
             // not rot13'ed yet, do so now (goal; avoid migration plugins change the bound domain).
112
-            update_option( 'autoptimize_ccss_domain', str_rot13( $autoptimize_ccss_options['ao_ccss_domain'] ) );
112
+            update_option('autoptimize_ccss_domain', str_rot13($autoptimize_ccss_options['ao_ccss_domain']));
113 113
         }
114 114
 
115 115
         // Setup the rules array.
116
-        if ( empty( $autoptimize_ccss_options['ao_ccss_rules_raw'] ) ) {
116
+        if (empty($autoptimize_ccss_options['ao_ccss_rules_raw'])) {
117 117
             $autoptimize_ccss_options['ao_ccss_rules']['paths'] = array();
118 118
             $autoptimize_ccss_options['ao_ccss_rules']['types'] = array();
119 119
         } else {
120
-            $autoptimize_ccss_options['ao_ccss_rules'] = json_decode( $autoptimize_ccss_options['ao_ccss_rules_raw'], true );
120
+            $autoptimize_ccss_options['ao_ccss_rules'] = json_decode($autoptimize_ccss_options['ao_ccss_rules_raw'], true);
121 121
         }
122 122
 
123 123
         // Setup the queue array.
124
-        if ( empty( $autoptimize_ccss_options['ao_ccss_queue_raw'] ) ) {
124
+        if (empty($autoptimize_ccss_options['ao_ccss_queue_raw'])) {
125 125
             $autoptimize_ccss_options['ao_ccss_queue'] = array();
126 126
         } else {
127
-            $autoptimize_ccss_options['ao_ccss_queue'] = json_decode( $autoptimize_ccss_options['ao_ccss_queue_raw'], true );
127
+            $autoptimize_ccss_options['ao_ccss_queue'] = json_decode($autoptimize_ccss_options['ao_ccss_queue_raw'], true);
128 128
         }
129 129
 
130 130
         // Override API key if constant is defined.
131
-        if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
131
+        if (defined('AUTOPTIMIZE_CRITICALCSS_API_KEY')) {
132 132
             $autoptimize_ccss_options['ao_ccss_key'] = AUTOPTIMIZE_CRITICALCSS_API_KEY;
133 133
         }
134 134
 
@@ -139,49 +139,49 @@  discard block
 block discarded – undo
139 139
         global $ao_ccss_key;
140 140
 
141 141
         // Create the cache directory if it doesn't exist already.
142
-        if ( ! file_exists( AO_CCSS_DIR ) ) {
143
-            mkdir( AO_CCSS_DIR, 0755, true );
142
+        if (!file_exists(AO_CCSS_DIR)) {
143
+            mkdir(AO_CCSS_DIR, 0755, true);
144 144
         }
145 145
 
146 146
         // Create a scheduled event for the queue.
147
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_queue' ) ) {
148
-            wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
147
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_queue')) {
148
+            wp_schedule_event(time(), apply_filters('ao_ccss_queue_schedule', 'ao_ccss'), 'ao_ccss_queue');
149 149
         }
150 150
 
151 151
         // Create a scheduled event for log maintenance.
152
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_maintenance' ) ) {
153
-            wp_schedule_event( time(), 'twicedaily', 'ao_ccss_maintenance' );
152
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_maintenance')) {
153
+            wp_schedule_event(time(), 'twicedaily', 'ao_ccss_maintenance');
154 154
         }
155 155
     }
156 156
 
157 157
     public function check_upgrade() {
158
-        $db_version = get_option( 'autoptimize_ccss_version', '' );
159
-        if ( AO_CCSS_VER !== $db_version ) {
158
+        $db_version = get_option('autoptimize_ccss_version', '');
159
+        if (AO_CCSS_VER !== $db_version) {
160 160
             // check schedules & re-schedule if needed.
161 161
             $this->on_upgrade();
162 162
             // and update db_version.
163
-            update_option( 'autoptimize_ccss_version', AO_CCSS_VER );
163
+            update_option('autoptimize_ccss_version', AO_CCSS_VER);
164 164
         }
165 165
     }
166 166
 
167
-    public function ao_ccss_interval( $schedules ) {
167
+    public function ao_ccss_interval($schedules) {
168 168
         // Let interval be configurable.
169
-        if ( ! defined( 'AO_CCSS_DEBUG_INTERVAL' ) ) {
169
+        if (!defined('AO_CCSS_DEBUG_INTERVAL')) {
170 170
             $intsec = 600;
171 171
         } else {
172 172
             $intsec = AO_CCSS_DEBUG_INTERVAL;
173
-            if ( $intsec >= 120 ) {
174
-                $inttxt = $intsec / 60 . ' minutes';
173
+            if ($intsec >= 120) {
174
+                $inttxt = $intsec/60.' minutes';
175 175
             } else {
176
-                $inttxt = $intsec . ' second(s)';
176
+                $inttxt = $intsec.' second(s)';
177 177
             }
178
-            autoptimizeCriticalCSSCore::ao_ccss_log( 'Using custom WP-Cron interval of ' . $inttxt, 3 );
178
+            autoptimizeCriticalCSSCore::ao_ccss_log('Using custom WP-Cron interval of '.$inttxt, 3);
179 179
         }
180 180
 
181 181
         // Attach interval to schedule.
182 182
         $schedules['ao_ccss'] = array(
183 183
             'interval' => $intsec,
184
-            'display'  => __( 'Autoptimize CriticalCSS' ),
184
+            'display'  => __('Autoptimize CriticalCSS'),
185 185
         );
186 186
         return $schedules;
187 187
     }
Please login to merge, or discard this patch.