@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Main plugin object to define the plugin |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @author Nirjhar Lo |
9 | 9 | * @package wp-plugin-framework |
10 | 10 | */ |
11 | -if ( ! class_exists( 'PLUGIN_BUILD' ) ) { |
|
11 | +if ( ! class_exists('PLUGIN_BUILD')) { |
|
12 | 12 | |
13 | 13 | final class PLUGIN_BUILD { |
14 | 14 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | |
72 | - if ( is_null( self::$_instance ) ) { |
|
72 | + if (is_null(self::$_instance)) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | self::$_instance->init(); |
75 | 75 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | //If CPT exists, include taht and flush the rewrite rules |
98 | - if ( class_exists( 'PLUGIN_CPT' ) ) new PLUGIN_CPT(); |
|
98 | + if (class_exists('PLUGIN_CPT')) new PLUGIN_CPT(); |
|
99 | 99 | flush_rewrite_rules(); |
100 | 100 | } |
101 | 101 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function cron_activation() { |
109 | 109 | |
110 | - if ( class_exists( 'PLUGIN_CRON' ) ) { |
|
110 | + if (class_exists('PLUGIN_CRON')) { |
|
111 | 111 | |
112 | 112 | $cron = new PLUGIN_CRON(); |
113 | 113 | $schedule = $cron->schedule_task( |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function db_install() { |
132 | 132 | |
133 | - if ( class_exists( 'PLUGIN_DB' ) ) { |
|
133 | + if (class_exists('PLUGIN_DB')) { |
|
134 | 134 | |
135 | 135 | $db = new PLUGIN_DB(); |
136 | 136 | $db->table = self::$plugin_table; |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | $db->build(); |
141 | 141 | } |
142 | 142 | |
143 | - if (get_option( '_plugin_db_exist') == '0' ) { |
|
144 | - add_action( 'admin_notices', array( $this, 'db_error_msg' ) ); |
|
143 | + if (get_option('_plugin_db_exist') == '0') { |
|
144 | + add_action('admin_notices', array($this, 'db_error_msg')); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $options = array( |
148 | - array( 'option_name', '__value__' ), |
|
148 | + array('option_name', '__value__'), |
|
149 | 149 | ); |
150 | - foreach ( $options as $value ) { |
|
151 | - update_option( $value[0], $value[1] ); |
|
150 | + foreach ($options as $value) { |
|
151 | + update_option($value[0], $value[1]); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function db_error_msg() { ?> |
162 | 162 | |
163 | 163 | <div class="notice notice-error is-dismissible"> |
164 | - <p><?php _e( 'Database table Not installed correctly.', 'textdomain' ); ?></p> |
|
164 | + <p><?php _e('Database table Not installed correctly.', 'textdomain'); ?></p> |
|
165 | 165 | </div> |
166 | 166 | <?php |
167 | 167 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | $table_name = self::$plugin_table; |
178 | 178 | |
179 | 179 | global $wpdb; |
180 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$table_name" ); |
|
180 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}$table_name"); |
|
181 | 181 | |
182 | 182 | $options = array( |
183 | 183 | '_plugin_db_exist' |
184 | 184 | ); |
185 | - foreach ( $options as $value ) { |
|
186 | - delete_option( $value ); |
|
185 | + foreach ($options as $value) { |
|
186 | + delete_option($value); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function custom_cron_hook_cb() { |
208 | 208 | |
209 | - add_action( 'custom_cron_hook', array( $this, 'do_cron_job_function' ) ); |
|
209 | + add_action('custom_cron_hook', array($this, 'do_cron_job_function')); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function cron_uninstall() { |
219 | 219 | |
220 | - wp_clear_scheduled_hook( 'custom_cron_hook' ); |
|
220 | + wp_clear_scheduled_hook('custom_cron_hook'); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function cpt() { |
230 | 230 | |
231 | - if ( class_exists( 'PLUGIN_CPT' ) ) new PLUGIN_CPT(); |
|
231 | + if (class_exists('PLUGIN_CPT')) new PLUGIN_CPT(); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function scripts() { |
241 | 241 | |
242 | - if ( class_exists( 'PLUGIN_SCRIPT' ) ) new PLUGIN_SCRIPT(); |
|
242 | + if (class_exists('PLUGIN_SCRIPT')) new PLUGIN_SCRIPT(); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function settings() { |
252 | 252 | |
253 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
253 | + if (class_exists('PLUGIN_SETTINGS')) new PLUGIN_SETTINGS(); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function widgets() { |
263 | 263 | |
264 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
264 | + if (class_exists('PLUGIN_WIDGET')) new PLUGIN_WIDGET(); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function metabox() { |
274 | 274 | |
275 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
275 | + if (class_exists('PLUGIN_METABOX')) new PLUGIN_METABOX(); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function shortcode() { |
285 | 285 | |
286 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
286 | + if (class_exists('PLUGIN_SHORTCODE')) new PLUGIN_SHORTCODE(); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function rest_api() { |
296 | 296 | |
297 | - if ( class_exists( 'PLUGIN_CUSTOM_ROUTE' ) ) new PLUGIN_CUSTOM_ROUTE(); |
|
297 | + if (class_exists('PLUGIN_CUSTOM_ROUTE')) new PLUGIN_CUSTOM_ROUTE(); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -303,20 +303,20 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return Void |
305 | 305 | */ |
306 | - public function prevent_unauthorized_rest_access( $result ) { |
|
306 | + public function prevent_unauthorized_rest_access($result) { |
|
307 | 307 | // If a previous authentication check was applied, |
308 | 308 | // pass that result along without modification. |
309 | - if ( true === $result || is_wp_error( $result ) ) { |
|
309 | + if (true === $result || is_wp_error($result)) { |
|
310 | 310 | return $result; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // No authentication has been performed yet. |
314 | 314 | // Return an error if user is not logged in. |
315 | - if ( ! is_user_logged_in() ) { |
|
315 | + if ( ! is_user_logged_in()) { |
|
316 | 316 | return new WP_Error( |
317 | 317 | 'rest_not_logged_in', |
318 | - __( 'You are not currently logged in.' ), |
|
319 | - array( 'status' => 401 ) |
|
318 | + __('You are not currently logged in.'), |
|
319 | + array('status' => 401) |
|
320 | 320 | ); |
321 | 321 | } |
322 | 322 | |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function functionality() { |
334 | 334 | |
335 | - require_once( 'src/class-install.php' ); |
|
336 | - require_once( 'src/class-db.php' ); |
|
337 | - require_once( 'src/class-query.php' ); |
|
338 | - require_once( 'src/class-settings.php' ); |
|
339 | - require_once( 'src/class-widget.php' ); |
|
340 | - require_once( 'src/class-metabox.php' ); |
|
341 | - require_once( 'src/class-shortcode.php' ); |
|
342 | - require_once( 'src/class-cpt.php' ); |
|
343 | - require_once( 'src/class-rest.php' ); |
|
335 | + require_once('src/class-install.php'); |
|
336 | + require_once('src/class-db.php'); |
|
337 | + require_once('src/class-query.php'); |
|
338 | + require_once('src/class-settings.php'); |
|
339 | + require_once('src/class-widget.php'); |
|
340 | + require_once('src/class-metabox.php'); |
|
341 | + require_once('src/class-shortcode.php'); |
|
342 | + require_once('src/class-cpt.php'); |
|
343 | + require_once('src/class-rest.php'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function helpers() { |
354 | 354 | |
355 | - require_once( 'lib/class-cron.php' ); |
|
356 | - require_once( 'lib/class-api.php' ); |
|
357 | - require_once( 'lib/class-table.php' ); |
|
358 | - require_once( 'lib/class-ajax.php' ); |
|
359 | - require_once( 'lib/class-upload.php' ); |
|
360 | - require_once( 'lib/class-script.php' ); |
|
355 | + require_once('lib/class-cron.php'); |
|
356 | + require_once('lib/class-api.php'); |
|
357 | + require_once('lib/class-table.php'); |
|
358 | + require_once('lib/class-ajax.php'); |
|
359 | + require_once('lib/class-upload.php'); |
|
360 | + require_once('lib/class-script.php'); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
@@ -371,18 +371,18 @@ discard block |
||
371 | 371 | $this->helpers(); |
372 | 372 | $this->functionality(); |
373 | 373 | |
374 | - register_activation_hook( PLUGIN_FILE, array( $this, 'db_install' ) ); |
|
375 | - register_activation_hook( PLUGIN_FILE, array( $this, 'cron_activation' ) ); |
|
374 | + register_activation_hook(PLUGIN_FILE, array($this, 'db_install')); |
|
375 | + register_activation_hook(PLUGIN_FILE, array($this, 'cron_activation')); |
|
376 | 376 | |
377 | 377 | //remove the DB and CORN upon uninstallation |
378 | 378 | //using $this won't work here. |
379 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'db_uninstall' ) ); |
|
380 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'cron_uninstall' ) ); |
|
379 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'db_uninstall')); |
|
380 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'cron_uninstall')); |
|
381 | 381 | |
382 | - add_filter( 'rest_authentication_errors', array( $this, 'prevent_unauthorized_rest_access' ) ); |
|
382 | + add_filter('rest_authentication_errors', array($this, 'prevent_unauthorized_rest_access')); |
|
383 | 383 | |
384 | - add_action( 'init', array( $this, 'installation' ) ); |
|
385 | - add_action( 'init', array( $this, 'cpt' ) ); |
|
384 | + add_action('init', array($this, 'installation')); |
|
385 | + add_action('init', array($this, 'cpt')); |
|
386 | 386 | |
387 | 387 | $this->custom_cron_hook_cb(); |
388 | 388 |