@@ -11,7 +11,9 @@ |
||
| 11 | 11 | License: GPLv2 |
| 12 | 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 13 | 13 | */ |
| 14 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 14 | +if ( !defined( 'ABSPATH' ) ) { |
|
| 15 | + exit; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | //Define basic names |
@@ -1,7 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Lib; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | + exit; |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * Plugin upload for WordPress front end or backend |
@@ -7,7 +7,9 @@ |
||
| 7 | 7 | * @author Nirjhar Lo |
| 8 | 8 | * @package wp-plugin-framework |
| 9 | 9 | */ |
| 10 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 10 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + exit; |
|
| 12 | +} |
|
| 11 | 13 | |
| 12 | 14 | if ( ! class_exists( 'Script' ) ) { |
| 13 | 15 | |
@@ -1,7 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Lib; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | + exit; |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * Add Cron schedules and cron task callback |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | * @author Nirjhar Lo |
| 9 | 9 | * @package wp-plugin-framework |
| 10 | 10 | */ |
| 11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | + exit; |
|
| 13 | +} |
|
| 12 | 14 | |
| 13 | 15 | //AJAX helper class |
| 14 | 16 | if ( ! class_exists( 'Ajax' ) ) { |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | use NirjharLo\WP_Plugin_Framework\Lib\Cron as Cron; |
| 14 | 14 | use NirjharLo\WP_Plugin_Framework\Lib\Script as Script; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | + exit; |
|
| 18 | +} |
|
| 17 | 19 | |
| 18 | 20 | /** |
| 19 | 21 | * Main plugin object to define the plugin |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | } |
| 110 | 112 | |
| 111 | 113 | //If CPT exists, include taht and flush the rewrite rules |
| 112 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Cpt' ) ) new Cpt(); |
|
| 114 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Cpt' ) ) { |
|
| 115 | + new Cpt(); |
|
| 116 | + } |
|
| 113 | 117 | flush_rewrite_rules(); |
| 114 | 118 | } |
| 115 | 119 | |
@@ -242,7 +246,9 @@ discard block |
||
| 242 | 246 | */ |
| 243 | 247 | public function cpt() { |
| 244 | 248 | |
| 245 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Cpt' ) ) new Cpt(); |
|
| 249 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Cpt' ) ) { |
|
| 250 | + new Cpt(); |
|
| 251 | + } |
|
| 246 | 252 | } |
| 247 | 253 | |
| 248 | 254 | |
@@ -253,7 +259,9 @@ discard block |
||
| 253 | 259 | */ |
| 254 | 260 | public function scripts() { |
| 255 | 261 | |
| 256 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Lib\\Script' ) ) new Script(); |
|
| 262 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Lib\\Script' ) ) { |
|
| 263 | + new Script(); |
|
| 264 | + } |
|
| 257 | 265 | } |
| 258 | 266 | |
| 259 | 267 | |
@@ -264,7 +272,9 @@ discard block |
||
| 264 | 272 | */ |
| 265 | 273 | public function settings() { |
| 266 | 274 | |
| 267 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Settings' ) ) new Settings(); |
|
| 275 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Settings' ) ) { |
|
| 276 | + new Settings(); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | |
| 270 | 280 | |
@@ -275,7 +285,9 @@ discard block |
||
| 275 | 285 | */ |
| 276 | 286 | public function widgets() { |
| 277 | 287 | |
| 278 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Widget' ) ) new Widget(); |
|
| 288 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Widget' ) ) { |
|
| 289 | + new Widget(); |
|
| 290 | + } |
|
| 279 | 291 | } |
| 280 | 292 | |
| 281 | 293 | |
@@ -286,7 +298,9 @@ discard block |
||
| 286 | 298 | */ |
| 287 | 299 | public function metabox() { |
| 288 | 300 | |
| 289 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Metabox' ) ) new Metabox(); |
|
| 301 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Metabox' ) ) { |
|
| 302 | + new Metabox(); |
|
| 303 | + } |
|
| 290 | 304 | } |
| 291 | 305 | |
| 292 | 306 | |
@@ -297,7 +311,9 @@ discard block |
||
| 297 | 311 | */ |
| 298 | 312 | public function shortcode() { |
| 299 | 313 | |
| 300 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Shortcode' ) ) new Shortcode(); |
|
| 314 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\Shortcode' ) ) { |
|
| 315 | + new Shortcode(); |
|
| 316 | + } |
|
| 301 | 317 | } |
| 302 | 318 | |
| 303 | 319 | |
@@ -308,7 +324,9 @@ discard block |
||
| 308 | 324 | */ |
| 309 | 325 | public function rest_api() { |
| 310 | 326 | |
| 311 | - if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\RestApi' ) ) new RestApi(); |
|
| 327 | + if ( class_exists( 'NirjharLo\\WP_Plugin_Framework\\Src\\RestApi' ) ) { |
|
| 328 | + new RestApi(); |
|
| 329 | + } |
|
| 312 | 330 | } |
| 313 | 331 | |
| 314 | 332 | |
@@ -3,7 +3,9 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use NirjharLo\WP_Plugin_Framework\Lib\Table as Table; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 6 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | + exit; |
|
| 8 | +} |
|
| 7 | 9 | |
| 8 | 10 | /** |
| 9 | 11 | * Backend settings page class, can have settings fields or data table |
@@ -167,7 +169,10 @@ discard block |
||
| 167 | 169 | break; |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | - if ( $output ) return $output; // Related to PLUGIN_TABLE() |
|
| 172 | + if ( $output ) { |
|
| 173 | + return $output; |
|
| 174 | + } |
|
| 175 | + // Related to PLUGIN_TABLE() |
|
| 171 | 176 | } |
| 172 | 177 | |
| 173 | 178 | |
@@ -1,7 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | + exit; |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * Build a sample metabox in editor screen |
@@ -74,16 +76,22 @@ discard block |
||
| 74 | 76 | function save( $post_id, $post ) { |
| 75 | 77 | |
| 76 | 78 | //Check if doing autosave |
| 77 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; |
|
| 79 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 80 | + return; |
|
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | //Verify the nonce before proceeding. |
| 80 | - if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return; |
|
| 84 | + if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 81 | 87 | |
| 82 | 88 | //Get the post type object. |
| 83 | 89 | $post_type = get_post_type_object( $post->post_type ); |
| 84 | 90 | |
| 85 | 91 | //Check if the current user has permission to edit the post. |
| 86 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; |
|
| 92 | + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
| 93 | + return $post_id; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | if ( isset( $_POST['metabox_field_name'] ) ) { |
| 89 | 97 | update_post_meta( $post_id, 'metabox_field_name', sanitize_text_field($_POST['metabox_field_name']) ); |
@@ -1,7 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | + exit; |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * WP Query class for querying WP database |