Completed
Push — master ( da5a66...8cd4be )
by frank
03:29
created
classes/autoptimizeCriticalCSSBase.php 1 patch
Spacing   +67 added lines, -67 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,35 +19,35 @@  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 a constant with the directory to store critical CSS in.
24
-            if ( is_multisite() ) {
24
+            if (is_multisite()) {
25 25
                 $blog_id = get_current_blog_id();
26
-                define( 'AO_CCSS_DIR', WP_CONTENT_DIR . '/uploads/ao_ccss/' . $blog_id . '/' );
26
+                define('AO_CCSS_DIR', WP_CONTENT_DIR.'/uploads/ao_ccss/'.$blog_id.'/');
27 27
             } else {
28
-                define( 'AO_CCSS_DIR', WP_CONTENT_DIR . '/uploads/ao_ccss/' );
28
+                define('AO_CCSS_DIR', WP_CONTENT_DIR.'/uploads/ao_ccss/');
29 29
             }
30 30
         }
31
-        if ( ! defined( 'AO_CCSS_VER' ) ) {
31
+        if (!defined('AO_CCSS_VER')) {
32 32
             // Define plugin version.
33
-            define( 'AO_CCSS_VER', 'AO_' . AUTOPTIMIZE_PLUGIN_VERSION );
33
+            define('AO_CCSS_VER', 'AO_'.AUTOPTIMIZE_PLUGIN_VERSION);
34 34
 
35 35
             // Define constants for criticalcss.com base path and API endpoints.
36 36
             // fixme: AO_CCSS_URL should be read from the autoptimize availability json stored as option.
37
-            define( 'AO_CCSS_URL', 'https://criticalcss.com' );
38
-            define( 'AO_CCSS_API', AO_CCSS_URL . '/api/premium/' );
39
-            define( 'AO_CCSS_SLEEP', 10 );
37
+            define('AO_CCSS_URL', 'https://criticalcss.com');
38
+            define('AO_CCSS_API', AO_CCSS_URL.'/api/premium/');
39
+            define('AO_CCSS_SLEEP', 10);
40 40
         }
41 41
 
42 42
         // Define support files locations, in case they are not already defined.
43
-        if ( ! defined( 'AO_CCSS_LOCK' ) ) {
44
-            define( 'AO_CCSS_LOCK', AO_CCSS_DIR . 'queue.lock' );
43
+        if (!defined('AO_CCSS_LOCK')) {
44
+            define('AO_CCSS_LOCK', AO_CCSS_DIR.'queue.lock');
45 45
         }
46
-        if ( ! defined( 'AO_CCSS_LOG' ) ) {
47
-            define( 'AO_CCSS_LOG', AO_CCSS_DIR . 'queuelog.html' );
46
+        if (!defined('AO_CCSS_LOG')) {
47
+            define('AO_CCSS_LOG', AO_CCSS_DIR.'queuelog.html');
48 48
         }
49
-        if ( ! defined( 'AO_CCSS_DEBUG' ) ) {
50
-            define( 'AO_CCSS_DEBUG', AO_CCSS_DIR . 'queue.json' );
49
+        if (!defined('AO_CCSS_DEBUG')) {
50
+            define('AO_CCSS_DEBUG', AO_CCSS_DIR.'queue.json');
51 51
         }
52 52
 
53 53
         $this->filepath = __FILE__;
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
     {
61 61
         // get all options.
62 62
         $all_options = $this->fetch_options();
63
-        foreach ( $all_options as $option => $value ) {
63
+        foreach ($all_options as $option => $value) {
64 64
             ${$option} = $value;
65 65
         }
66 66
 
67 67
         // make sure the 10 minutes cron schedule is added.
68
-        add_filter( 'cron_schedules', array( $this, 'ao_ccss_interval' ) );
68
+        add_filter('cron_schedules', array($this, 'ao_ccss_interval'));
69 69
 
70 70
         // check if we need to upgrade.
71 71
         $this->check_upgrade();
72 72
 
73 73
         // make sure ao_ccss_queue is scheduled OK if an API key is set.
74
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_queue' ) ) {
75
-            wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
74
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_queue')) {
75
+            wp_schedule_event(time(), apply_filters('ao_ccss_queue_schedule', 'ao_ccss'), 'ao_ccss_queue');
76 76
         }
77 77
     }
78 78
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
         // Required libs, core is always needed.
81 81
         $criticalcss_core = new autoptimizeCriticalCSSCore();
82 82
 
83
-        if ( defined( 'WP_CLI' ) || defined( 'DOING_CRON' ) || is_admin() ) {
83
+        if (defined('WP_CLI') || defined('DOING_CRON') || is_admin()) {
84 84
             // TODO: also include if overridden somehow to force queue processing to be executed?
85 85
             $criticalcss_cron = new autoptimizeCriticalCSSCron();
86 86
         }
87 87
 
88
-        if ( is_admin() ) {
88
+        if (is_admin()) {
89 89
             $criticalcss_settings = new autoptimizeCriticalCSSSettings();
90 90
         } else {
91 91
             // enqueuing only done when not wp-admin.
@@ -96,51 +96,51 @@  discard block
 block discarded – undo
96 96
     public static function fetch_options() {
97 97
         static $autoptimize_ccss_options = null;
98 98
 
99
-        if ( null === $autoptimize_ccss_options ) {
99
+        if (null === $autoptimize_ccss_options) {
100 100
             // not cached yet, fetching from WordPress options.
101
-            $autoptimize_ccss_options['ao_css_defer']          = autoptimizeOptionWrapper::get_option( 'autoptimize_css_defer' );
102
-            $autoptimize_ccss_options['ao_css_defer_inline']   = autoptimizeOptionWrapper::get_option( 'autoptimize_css_defer_inline' );
103
-            $autoptimize_ccss_options['ao_ccss_rules_raw']     = get_option( 'autoptimize_ccss_rules', false );
104
-            $autoptimize_ccss_options['ao_ccss_additional']    = get_option( 'autoptimize_ccss_additional' );
105
-            $autoptimize_ccss_options['ao_ccss_queue_raw']     = get_option( 'autoptimize_ccss_queue', false );
106
-            $autoptimize_ccss_options['ao_ccss_viewport']      = get_option( 'autoptimize_ccss_viewport', false );
107
-            $autoptimize_ccss_options['ao_ccss_finclude']      = get_option( 'autoptimize_ccss_finclude', false );
108
-            $autoptimize_ccss_options['ao_ccss_rtimelimit']    = get_option( 'autoptimize_ccss_rtimelimit', '30' );
109
-            $autoptimize_ccss_options['ao_ccss_noptimize']     = get_option( 'autoptimize_ccss_noptimize', false );
110
-            $autoptimize_ccss_options['ao_ccss_debug']         = get_option( 'autoptimize_ccss_debug', false );
111
-            $autoptimize_ccss_options['ao_ccss_key']           = get_option( 'autoptimize_ccss_key' );
112
-            $autoptimize_ccss_options['ao_ccss_keyst']         = get_option( 'autoptimize_ccss_keyst' );
113
-            $autoptimize_ccss_options['ao_ccss_loggedin']      = get_option( 'autoptimize_ccss_loggedin', '1' );
114
-            $autoptimize_ccss_options['ao_ccss_forcepath']     = get_option( 'autoptimize_ccss_forcepath', '1' );
115
-            $autoptimize_ccss_options['ao_ccss_servicestatus'] = get_option( 'autoptimize_service_availablity' );
116
-            $autoptimize_ccss_options['ao_ccss_deferjquery']   = get_option( 'autoptimize_ccss_deferjquery', false );
117
-            $autoptimize_ccss_options['ao_ccss_domain']        = get_option( 'autoptimize_ccss_domain' );
118
-            $autoptimize_ccss_options['ao_ccss_unloadccss']    = get_option( 'autoptimize_ccss_unloadccss', false );
119
-
120
-            if ( strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'http' ) === false && strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'uggc' ) === 0 ) {
121
-                $autoptimize_ccss_options['ao_ccss_domain'] = str_rot13( $autoptimize_ccss_options['ao_ccss_domain'] );
122
-            } elseif ( strpos( $autoptimize_ccss_options['ao_ccss_domain'], 'http' ) !== false ) {
101
+            $autoptimize_ccss_options['ao_css_defer']          = autoptimizeOptionWrapper::get_option('autoptimize_css_defer');
102
+            $autoptimize_ccss_options['ao_css_defer_inline']   = autoptimizeOptionWrapper::get_option('autoptimize_css_defer_inline');
103
+            $autoptimize_ccss_options['ao_ccss_rules_raw']     = get_option('autoptimize_ccss_rules', false);
104
+            $autoptimize_ccss_options['ao_ccss_additional']    = get_option('autoptimize_ccss_additional');
105
+            $autoptimize_ccss_options['ao_ccss_queue_raw']     = get_option('autoptimize_ccss_queue', false);
106
+            $autoptimize_ccss_options['ao_ccss_viewport']      = get_option('autoptimize_ccss_viewport', false);
107
+            $autoptimize_ccss_options['ao_ccss_finclude']      = get_option('autoptimize_ccss_finclude', false);
108
+            $autoptimize_ccss_options['ao_ccss_rtimelimit']    = get_option('autoptimize_ccss_rtimelimit', '30');
109
+            $autoptimize_ccss_options['ao_ccss_noptimize']     = get_option('autoptimize_ccss_noptimize', false);
110
+            $autoptimize_ccss_options['ao_ccss_debug']         = get_option('autoptimize_ccss_debug', false);
111
+            $autoptimize_ccss_options['ao_ccss_key']           = get_option('autoptimize_ccss_key');
112
+            $autoptimize_ccss_options['ao_ccss_keyst']         = get_option('autoptimize_ccss_keyst');
113
+            $autoptimize_ccss_options['ao_ccss_loggedin']      = get_option('autoptimize_ccss_loggedin', '1');
114
+            $autoptimize_ccss_options['ao_ccss_forcepath']     = get_option('autoptimize_ccss_forcepath', '1');
115
+            $autoptimize_ccss_options['ao_ccss_servicestatus'] = get_option('autoptimize_service_availablity');
116
+            $autoptimize_ccss_options['ao_ccss_deferjquery']   = get_option('autoptimize_ccss_deferjquery', false);
117
+            $autoptimize_ccss_options['ao_ccss_domain']        = get_option('autoptimize_ccss_domain');
118
+            $autoptimize_ccss_options['ao_ccss_unloadccss']    = get_option('autoptimize_ccss_unloadccss', false);
119
+
120
+            if (strpos($autoptimize_ccss_options['ao_ccss_domain'], 'http') === false && strpos($autoptimize_ccss_options['ao_ccss_domain'], 'uggc') === 0) {
121
+                $autoptimize_ccss_options['ao_ccss_domain'] = str_rot13($autoptimize_ccss_options['ao_ccss_domain']);
122
+            } elseif (strpos($autoptimize_ccss_options['ao_ccss_domain'], 'http') !== false) {
123 123
                 // not rot13'ed yet, do so now (goal; avoid migration plugins change the bound domain).
124
-                update_option( 'autoptimize_ccss_domain', str_rot13( $autoptimize_ccss_options['ao_ccss_domain'] ) );
124
+                update_option('autoptimize_ccss_domain', str_rot13($autoptimize_ccss_options['ao_ccss_domain']));
125 125
             }
126 126
 
127 127
             // Setup the rules array.
128
-            if ( empty( $autoptimize_ccss_options['ao_ccss_rules_raw'] ) ) {
128
+            if (empty($autoptimize_ccss_options['ao_ccss_rules_raw'])) {
129 129
                 $autoptimize_ccss_options['ao_ccss_rules']['paths'] = array();
130 130
                 $autoptimize_ccss_options['ao_ccss_rules']['types'] = array();
131 131
             } else {
132
-                $autoptimize_ccss_options['ao_ccss_rules'] = json_decode( $autoptimize_ccss_options['ao_ccss_rules_raw'], true );
132
+                $autoptimize_ccss_options['ao_ccss_rules'] = json_decode($autoptimize_ccss_options['ao_ccss_rules_raw'], true);
133 133
             }
134 134
 
135 135
             // Setup the queue array.
136
-            if ( empty( $autoptimize_ccss_options['ao_ccss_queue_raw'] ) ) {
136
+            if (empty($autoptimize_ccss_options['ao_ccss_queue_raw'])) {
137 137
                 $autoptimize_ccss_options['ao_ccss_queue'] = array();
138 138
             } else {
139
-                $autoptimize_ccss_options['ao_ccss_queue'] = json_decode( $autoptimize_ccss_options['ao_ccss_queue_raw'], true );
139
+                $autoptimize_ccss_options['ao_ccss_queue'] = json_decode($autoptimize_ccss_options['ao_ccss_queue_raw'], true);
140 140
             }
141 141
 
142 142
             // Override API key if constant is defined.
143
-            if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
143
+            if (defined('AUTOPTIMIZE_CRITICALCSS_API_KEY')) {
144 144
                 $autoptimize_ccss_options['ao_ccss_key'] = AUTOPTIMIZE_CRITICALCSS_API_KEY;
145 145
             }
146 146
         }
@@ -152,49 +152,49 @@  discard block
 block discarded – undo
152 152
         global $ao_ccss_key;
153 153
 
154 154
         // Create the cache directory if it doesn't exist already.
155
-        if ( ! file_exists( AO_CCSS_DIR ) ) {
156
-            mkdir( AO_CCSS_DIR, 0755, true );
155
+        if (!file_exists(AO_CCSS_DIR)) {
156
+            mkdir(AO_CCSS_DIR, 0755, true);
157 157
         }
158 158
 
159 159
         // Create a scheduled event for the queue.
160
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_queue' ) ) {
161
-            wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
160
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_queue')) {
161
+            wp_schedule_event(time(), apply_filters('ao_ccss_queue_schedule', 'ao_ccss'), 'ao_ccss_queue');
162 162
         }
163 163
 
164 164
         // Create a scheduled event for log maintenance.
165
-        if ( isset( $ao_ccss_key ) && ! empty( $ao_ccss_key ) && ! wp_next_scheduled( 'ao_ccss_maintenance' ) ) {
166
-            wp_schedule_event( time(), 'twicedaily', 'ao_ccss_maintenance' );
165
+        if (isset($ao_ccss_key) && !empty($ao_ccss_key) && !wp_next_scheduled('ao_ccss_maintenance')) {
166
+            wp_schedule_event(time(), 'twicedaily', 'ao_ccss_maintenance');
167 167
         }
168 168
     }
169 169
 
170 170
     public function check_upgrade() {
171
-        $db_version = get_option( 'autoptimize_ccss_version', '' );
172
-        if ( AO_CCSS_VER !== $db_version ) {
171
+        $db_version = get_option('autoptimize_ccss_version', '');
172
+        if (AO_CCSS_VER !== $db_version) {
173 173
             // check schedules & re-schedule if needed.
174 174
             $this->on_upgrade();
175 175
             // and update db_version.
176
-            update_option( 'autoptimize_ccss_version', AO_CCSS_VER );
176
+            update_option('autoptimize_ccss_version', AO_CCSS_VER);
177 177
         }
178 178
     }
179 179
 
180
-    public function ao_ccss_interval( $schedules ) {
180
+    public function ao_ccss_interval($schedules) {
181 181
         // Let interval be configurable.
182
-        if ( ! defined( 'AO_CCSS_DEBUG_INTERVAL' ) ) {
182
+        if (!defined('AO_CCSS_DEBUG_INTERVAL')) {
183 183
             $intsec = 600;
184 184
         } else {
185 185
             $intsec = AO_CCSS_DEBUG_INTERVAL;
186
-            if ( $intsec >= 120 ) {
187
-                $inttxt = $intsec / 60 . ' minutes';
186
+            if ($intsec >= 120) {
187
+                $inttxt = $intsec/60.' minutes';
188 188
             } else {
189
-                $inttxt = $intsec . ' second(s)';
189
+                $inttxt = $intsec.' second(s)';
190 190
             }
191
-            autoptimizeCriticalCSSCore::ao_ccss_log( 'Using custom WP-Cron interval of ' . $inttxt, 3 );
191
+            autoptimizeCriticalCSSCore::ao_ccss_log('Using custom WP-Cron interval of '.$inttxt, 3);
192 192
         }
193 193
 
194 194
         // Attach interval to schedule.
195 195
         $schedules['ao_ccss'] = array(
196 196
             'interval' => $intsec,
197
-            'display'  => __( 'Autoptimize CriticalCSS' ),
197
+            'display'  => __('Autoptimize CriticalCSS'),
198 198
         );
199 199
         return $schedules;
200 200
     }
Please login to merge, or discard this patch.
classes/autoptimizeCriticalCSSSettingsAjax.php 1 patch
Spacing   +109 added lines, -109 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['rtimelimit'] = get_option( 'autoptimize_ccss_rtimelimit' );
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['rtimelimit'] = get_option('autoptimize_ccss_rtimelimit');
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,30 +275,30 @@  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 ( current_user_can( 'manage_options' ) && ! $_FILES['file']['error'] && $_FILES['file']['size'] < 500001 && strpos( $_FILES['file']['name'], '.zip' ) === strlen( $_FILES['file']['name'] ) - 4 ) {
284
+        if (current_user_can('manage_options') && !$_FILES['file']['error'] && $_FILES['file']['size'] < 500001 && strpos($_FILES['file']['name'], '.zip') === strlen($_FILES['file']['name']) - 4) {
285 285
             // create tmp dir with hard guess name in AO_CCSS_DIR.
286
-            $_secret_dir     = wp_hash( uniqid( md5( AUTOPTIMIZE_CACHE_URL ), true ) );
287
-            $_import_tmp_dir = trailingslashit( AO_CCSS_DIR . $_secret_dir );
288
-            mkdir( $_import_tmp_dir );
286
+            $_secret_dir     = wp_hash(uniqid(md5(AUTOPTIMIZE_CACHE_URL), true));
287
+            $_import_tmp_dir = trailingslashit(AO_CCSS_DIR.$_secret_dir);
288
+            mkdir($_import_tmp_dir);
289 289
 
290 290
             // Save file to that tmp directory but give it our own name to prevent directory traversal risks when using original name.
291
-            $zipfile = $_import_tmp_dir . uniqid( 'import_settings-', true ) . '.zip';
292
-            move_uploaded_file( $_FILES['file']['tmp_name'], $zipfile );
291
+            $zipfile = $_import_tmp_dir.uniqid('import_settings-', true).'.zip';
292
+            move_uploaded_file($_FILES['file']['tmp_name'], $zipfile);
293 293
 
294 294
             // Extract archive in the tmp directory.
295 295
             $zip = new ZipArchive;
296
-            if ( $zip->open( $zipfile ) === true ) {
296
+            if ($zip->open($zipfile) === true) {
297 297
                 // loop through all files in the zipfile.
298 298
                 for ($i = 0; $i < $zip->numFiles; $i++) {
299 299
                     // but only extract known good files.
300
-                    if ( preg_match('/^settings\.json$|^ccss_[a-z0-9]{32}\.css$/', $zip->getNameIndex( $i ) ) > 0 ) {
301
-                        $zip->extractTo( AO_CCSS_DIR, $zip->getNameIndex( $i ) );
300
+                    if (preg_match('/^settings\.json$|^ccss_[a-z0-9]{32}\.css$/', $zip->getNameIndex($i)) > 0) {
301
+                        $zip->extractTo(AO_CCSS_DIR, $zip->getNameIndex($i));
302 302
                     }
303 303
                 }
304 304
                 $zip->close();
@@ -307,26 +307,26 @@  discard block
 block discarded – undo
307 307
             }
308 308
             
309 309
             // and remove temp. dir with all contents (the import-zipfile).
310
-            $this->rrmdir( $_import_tmp_dir );
310
+            $this->rrmdir($_import_tmp_dir);
311 311
 
312
-            if ( ! $error ) {
312
+            if (!$error) {
313 313
                 // Archive extraction ok, continue importing settings from AO_CCSS_DIR.
314 314
                 // Settings file.
315
-                $importfile = AO_CCSS_DIR . 'settings.json';
315
+                $importfile = AO_CCSS_DIR.'settings.json';
316 316
 
317
-                if ( file_exists( $importfile ) ) {
317
+                if (file_exists($importfile)) {
318 318
                     // Get settings and turn them into an object.
319
-                    $settings = json_decode( file_get_contents( $importfile ), true );
319
+                    $settings = json_decode(file_get_contents($importfile), true);
320 320
 
321 321
                     // Update options.
322
-                    update_option( 'autoptimize_ccss_rules', $settings['rules'] );
323
-                    update_option( 'autoptimize_ccss_additional', $settings['additional'] );
324
-                    update_option( 'autoptimize_ccss_viewport', $settings['viewport'] );
325
-                    update_option( 'autoptimize_ccss_finclude', $settings['finclude'] );
326
-                    update_option( 'autoptimize_ccss_rtimelimit', $settings['rtimelimit'] );
327
-                    update_option( 'autoptimize_ccss_noptimize', $settings['noptimize'] );
328
-                    update_option( 'autoptimize_ccss_debug', $settings['debug'] );
329
-                    update_option( 'autoptimize_ccss_key', $settings['key'] );
322
+                    update_option('autoptimize_ccss_rules', $settings['rules']);
323
+                    update_option('autoptimize_ccss_additional', $settings['additional']);
324
+                    update_option('autoptimize_ccss_viewport', $settings['viewport']);
325
+                    update_option('autoptimize_ccss_finclude', $settings['finclude']);
326
+                    update_option('autoptimize_ccss_rtimelimit', $settings['rtimelimit']);
327
+                    update_option('autoptimize_ccss_noptimize', $settings['noptimize']);
328
+                    update_option('autoptimize_ccss_debug', $settings['debug']);
329
+                    update_option('autoptimize_ccss_key', $settings['key']);
330 330
                 } else {
331 331
                     // Settings file doesn't exist, update error flag.
332 332
                     $error = 'settings file does not exist';
@@ -337,28 +337,28 @@  discard block
 block discarded – undo
337 337
         }
338 338
 
339 339
         // Prepare response.
340
-        if ( $error ) {
340
+        if ($error) {
341 341
             $response['code'] = '500';
342
-            $response['msg']  = 'Error importing settings: ' . $error;
342
+            $response['msg']  = 'Error importing settings: '.$error;
343 343
         } else {
344 344
             $response['code'] = '200';
345 345
             $response['msg']  = 'Settings imported successfully';
346 346
         }
347 347
 
348 348
         // Dispatch respose.
349
-        echo json_encode( $response );
349
+        echo json_encode($response);
350 350
 
351 351
         // Close ajax request.
352 352
         wp_die();
353 353
     }
354 354
 
355
-    public function critcss_check_filename( $filename ) {
355
+    public function critcss_check_filename($filename) {
356 356
         // Try to avoid directory traversal when reading/writing/deleting critical CSS files.
357
-        if ( strpos( $filename, 'ccss_' ) !== 0 ) {
357
+        if (strpos($filename, 'ccss_') !== 0) {
358 358
             return false;
359
-        } elseif ( substr( $filename, -4, 4 ) !== '.css' ) {
359
+        } elseif (substr($filename, -4, 4) !== '.css') {
360 360
             return false;
361
-        } elseif ( sanitize_file_name( $filename ) !== $filename ) {
361
+        } elseif (sanitize_file_name($filename) !== $filename) {
362 362
             // Use WordPress core's sanitize_file_name to see if anything fishy is going on.
363 363
             return false;
364 364
         } else {
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
         }
367 367
     }
368 368
     
369
-    public function rrmdir( $path ) {
369
+    public function rrmdir($path) {
370 370
         // recursively remove a directory as found on
371 371
         // https://andy-carter.com/blog/recursively-remove-a-directory-in-php.
372
-        $files = glob($path . '/*');
373
-        foreach ( $files as $file ) {
374
-            is_dir( $file ) ? $this->rrmdir( $file ) : unlink( $file );
372
+        $files = glob($path.'/*');
373
+        foreach ($files as $file) {
374
+            is_dir($file) ? $this->rrmdir($file) : unlink($file);
375 375
         }
376
-        rmdir( $path );
376
+        rmdir($path);
377 377
 
378 378
         return;
379 379
     }
Please login to merge, or discard this patch.
autoptimize.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,66 +17,66 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 
20
-if ( ! defined( 'ABSPATH' ) ) {
20
+if (!defined('ABSPATH')) {
21 21
     exit;
22 22
 }
23 23
 
24
-define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.8.0' );
24
+define('AUTOPTIMIZE_PLUGIN_VERSION', '2.8.0');
25 25
 
26 26
 // plugin_dir_path() returns the trailing slash!
27
-define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
28
-define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ );
27
+define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__));
28
+define('AUTOPTIMIZE_PLUGIN_FILE', __FILE__);
29 29
 
30 30
 // Bail early if attempting to run on non-supported php versions.
31
-if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
31
+if (version_compare(PHP_VERSION, '5.6', '<')) {
32 32
     function autoptimize_incompatible_admin_notice() {
33
-        echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>';
34
-        if ( isset( $_GET['activate'] ) ) {
35
-            unset( $_GET['activate'] );
33
+        echo '<div class="error"><p>'.__('Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize').'</p></div>';
34
+        if (isset($_GET['activate'])) {
35
+            unset($_GET['activate']);
36 36
         }
37 37
     }
38 38
     function autoptimize_deactivate_self() {
39
-        deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) );
39
+        deactivate_plugins(plugin_basename(AUTOPTIMIZE_PLUGIN_FILE));
40 40
     }
41
-    add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' );
42
-    add_action( 'admin_init', 'autoptimize_deactivate_self' );
41
+    add_action('admin_notices', 'autoptimize_incompatible_admin_notice');
42
+    add_action('admin_init', 'autoptimize_deactivate_self');
43 43
     return;
44 44
 }
45 45
 
46
-function autoptimize_autoload( $class_name ) {
47
-    if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) {
48
-        $file     = strtolower( $class_name );
49
-        $file     = str_replace( '_', '-', $file );
50
-        $path     = dirname( __FILE__ ) . '/classes/external/php/';
51
-        $filepath = $path . $file . '.php';
52
-    } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) {
53
-        $file     = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name );
54
-        $path     = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/';
55
-        $filepath = $path . $file . '.php';
56
-    } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) {
46
+function autoptimize_autoload($class_name) {
47
+    if (in_array($class_name, array('Minify_HTML', 'JSMin'))) {
48
+        $file     = strtolower($class_name);
49
+        $file     = str_replace('_', '-', $file);
50
+        $path     = dirname(__FILE__).'/classes/external/php/';
51
+        $filepath = $path.$file.'.php';
52
+    } elseif (false !== strpos($class_name, 'Autoptimize\\tubalmartin\\CssMin')) {
53
+        $file     = str_replace('Autoptimize\\tubalmartin\\CssMin\\', '', $class_name);
54
+        $path     = dirname(__FILE__).'/classes/external/php/yui-php-cssmin-bundled/';
55
+        $filepath = $path.$file.'.php';
56
+    } elseif ('autoptimize' === substr($class_name, 0, 11)) {
57 57
         // One of our "old" classes.
58 58
         $file     = $class_name;
59
-        $path     = dirname( __FILE__ ) . '/classes/';
60
-        $filepath = $path . $file . '.php';
61
-    } elseif ( 'PAnD' === $class_name ) {
59
+        $path     = dirname(__FILE__).'/classes/';
60
+        $filepath = $path.$file.'.php';
61
+    } elseif ('PAnD' === $class_name) {
62 62
         $file     = 'persist-admin-notices-dismissal';
63
-        $path     = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/';
64
-        $filepath = $path . $file . '.php';
63
+        $path     = dirname(__FILE__).'/classes/external/php/persist-admin-notices-dismissal/';
64
+        $filepath = $path.$file.'.php';
65 65
     }
66 66
 
67 67
     // If we didn't match one of our rules, bail!
68
-    if ( ! isset( $filepath ) ) {
68
+    if (!isset($filepath)) {
69 69
         return;
70 70
     }
71 71
 
72 72
     require $filepath;
73 73
 }
74 74
 
75
-spl_autoload_register( 'autoptimize_autoload' );
75
+spl_autoload_register('autoptimize_autoload');
76 76
 
77 77
 // Load WP CLI command(s) on demand.
78
-if ( defined( 'WP_CLI' ) && WP_CLI ) {
79
-    require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php';
78
+if (defined('WP_CLI') && WP_CLI) {
79
+    require AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php';
80 80
 }
81 81
 
82 82
 /**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 function autoptimize() {
88 88
     static $plugin = null;
89 89
 
90
-    if ( null === $plugin ) {
91
-        $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE );
90
+    if (null === $plugin) {
91
+        $plugin = new autoptimizeMain(AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE);
92 92
     }
93 93
 
94 94
     return $plugin;
Please login to merge, or discard this patch.