@@ -299,28 +299,28 @@ |
||
299 | 299 | |
300 | 300 | |
301 | 301 | /** |
302 | - * Instantiate REST API |
|
303 | - * |
|
304 | - * @return Void |
|
305 | - */ |
|
302 | + * Instantiate REST API |
|
303 | + * |
|
304 | + * @return Void |
|
305 | + */ |
|
306 | 306 | public function prevent_unauthorized_rest_access( $result ) { |
307 | - // If a previous authentication check was applied, |
|
308 | - // pass that result along without modification. |
|
309 | - if ( true === $result || is_wp_error( $result ) ) { |
|
310 | - return $result; |
|
311 | - } |
|
312 | - |
|
313 | - // No authentication has been performed yet. |
|
314 | - // Return an error if user is not logged in. |
|
315 | - if ( ! is_user_logged_in() ) { |
|
316 | - return new WP_Error( |
|
317 | - 'rest_not_logged_in', |
|
318 | - __( 'You are not currently logged in.' ), |
|
319 | - array( 'status' => 401 ) |
|
320 | - ); |
|
321 | - } |
|
322 | - |
|
323 | - return $result; |
|
307 | + // If a previous authentication check was applied, |
|
308 | + // pass that result along without modification. |
|
309 | + if ( true === $result || is_wp_error( $result ) ) { |
|
310 | + return $result; |
|
311 | + } |
|
312 | + |
|
313 | + // No authentication has been performed yet. |
|
314 | + // Return an error if user is not logged in. |
|
315 | + if ( ! is_user_logged_in() ) { |
|
316 | + return new WP_Error( |
|
317 | + 'rest_not_logged_in', |
|
318 | + __( 'You are not currently logged in.' ), |
|
319 | + array( 'status' => 401 ) |
|
320 | + ); |
|
321 | + } |
|
322 | + |
|
323 | + return $result; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 |
@@ -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,19 +371,19 @@ 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, 'custom_cron_hook_cb' ) ); |
|
386 | - add_action( 'init', array( $this, 'cpt' ) ); |
|
384 | + add_action('init', array($this, 'installation')); |
|
385 | + add_action('init', array($this, 'custom_cron_hook_cb')); |
|
386 | + add_action('init', array($this, 'cpt')); |
|
387 | 387 | |
388 | 388 | $this->scripts(); |
389 | 389 | $this->widgets(); |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | public function register_routes() { |
21 | 21 | |
22 | 22 | $version = '1'; |
23 | - $namespace = 'vendor/v' . $version; |
|
24 | - $base = 'route'; |
|
23 | + $namespace = 'vendor/v' . $version; |
|
24 | + $base = 'route'; |
|
25 | 25 | |
26 | 26 | //Available options for methods are CREATABLE, READABLE, EDITABLE, DELETABLE |
27 | 27 | register_rest_route( $namespace, '/' . $base, array( |
28 | - 'methods' => WP_REST_Server::READABLE, |
|
29 | - 'callback' => array( $this, 'callback' ), |
|
30 | - 'permission_callback' => array( $this, 'permission' ), |
|
31 | - 'args' => array('sample', 'list', 'of', 'args') |
|
32 | - )); |
|
28 | + 'methods' => WP_REST_Server::READABLE, |
|
29 | + 'callback' => array( $this, 'callback' ), |
|
30 | + 'permission_callback' => array( $this, 'permission' ), |
|
31 | + 'args' => array('sample', 'list', 'of', 'args') |
|
32 | + )); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function callback() { |
42 | 42 | |
43 | - $params = $request->get_params(); |
|
44 | - $items = array(); |
|
45 | - $data = $this->prepare_item_for_response( $items, $request ); |
|
43 | + $params = $request->get_params(); |
|
44 | + $items = array(); |
|
45 | + $data = $this->prepare_item_for_response( $items, $request ); |
|
46 | 46 | |
47 | - if ( $data ) { |
|
48 | - return new WP_REST_Response( $data, 200 ); |
|
49 | - } else { |
|
47 | + if ( $data ) { |
|
48 | + return new WP_REST_Response( $data, 200 ); |
|
49 | + } else { |
|
50 | 50 | return new WP_Error( 'status_code', __( 'message', 'text-domain' ) ); |
51 | 51 | } |
52 | 52 | } |
@@ -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 | * Extending REST API framework of WordPress |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @author Nirjhar Lo |
8 | 8 | * @package wp-plugin-framework |
9 | 9 | */ |
10 | -if ( ! class_exists( 'PLUGIN_CUSTOM_ROUTE' ) ) { |
|
10 | +if ( ! class_exists('PLUGIN_CUSTOM_ROUTE')) { |
|
11 | 11 | |
12 | 12 | class PLUGIN_CUSTOM_ROUTE extends WP_REST_Controller { |
13 | 13 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | $base = 'route'; |
25 | 25 | |
26 | 26 | //Available options for methods are CREATABLE, READABLE, EDITABLE, DELETABLE |
27 | - register_rest_route( $namespace, '/' . $base, array( |
|
27 | + register_rest_route($namespace, '/' . $base, array( |
|
28 | 28 | 'methods' => WP_REST_Server::READABLE, |
29 | - 'callback' => array( $this, 'callback' ), |
|
30 | - 'permission_callback' => array( $this, 'permission' ), |
|
29 | + 'callback' => array($this, 'callback'), |
|
30 | + 'permission_callback' => array($this, 'permission'), |
|
31 | 31 | 'args' => array('sample', 'list', 'of', 'args') |
32 | 32 | )); |
33 | 33 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | $params = $request->get_params(); |
44 | 44 | $items = array(); |
45 | - $data = $this->prepare_item_for_response( $items, $request ); |
|
45 | + $data = $this->prepare_item_for_response($items, $request); |
|
46 | 46 | |
47 | - if ( $data ) { |
|
48 | - return new WP_REST_Response( $data, 200 ); |
|
47 | + if ($data) { |
|
48 | + return new WP_REST_Response($data, 200); |
|
49 | 49 | } else { |
50 | - return new WP_Error( 'status_code', __( 'message', 'text-domain' ) ); |
|
50 | + return new WP_Error('status_code', __('message', 'text-domain')); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function permission() { |
61 | 61 | |
62 | - return current_user_can( 'manage_options' ); |
|
62 | + return current_user_can('manage_options'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | /** |
5 | 7 | * Extending REST API framework of WordPress |
@@ -54,24 +54,24 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function labels() { |
56 | 56 | |
57 | - $labels = array( |
|
58 | - 'name' => _x( '', 'Post Type General Name', 'textdomain' ), |
|
59 | - 'singular_name' => _x( '', 'Post Type Singular Name', 'textdomain' ), |
|
60 | - 'menu_name' => __( '', 'textdomain' ), |
|
61 | - 'parent_item_colon' => __( '', 'textdomain' ), |
|
62 | - 'all_items' => __( '', 'textdomain' ), |
|
63 | - 'view_item' => __( '', 'textdomain' ), |
|
64 | - 'add_new_item' => __( '', 'textdomain' ), |
|
65 | - 'add_new' => __( '', 'textdomain' ), |
|
66 | - 'edit_item' => __( '', 'textdomain' ), |
|
67 | - 'update_item' => __( '', 'textdomain' ), |
|
68 | - 'search_items' => __( '', 'textdomain' ), |
|
69 | - 'not_found' => __( '', 'textdomain' ), |
|
70 | - 'not_found_in_trash' => __( '', 'textdomain' ), |
|
71 | - ); |
|
72 | - |
|
73 | - return $labels; |
|
74 | - } |
|
57 | + $labels = array( |
|
58 | + 'name' => _x( '', 'Post Type General Name', 'textdomain' ), |
|
59 | + 'singular_name' => _x( '', 'Post Type Singular Name', 'textdomain' ), |
|
60 | + 'menu_name' => __( '', 'textdomain' ), |
|
61 | + 'parent_item_colon' => __( '', 'textdomain' ), |
|
62 | + 'all_items' => __( '', 'textdomain' ), |
|
63 | + 'view_item' => __( '', 'textdomain' ), |
|
64 | + 'add_new_item' => __( '', 'textdomain' ), |
|
65 | + 'add_new' => __( '', 'textdomain' ), |
|
66 | + 'edit_item' => __( '', 'textdomain' ), |
|
67 | + 'update_item' => __( '', 'textdomain' ), |
|
68 | + 'search_items' => __( '', 'textdomain' ), |
|
69 | + 'not_found' => __( '', 'textdomain' ), |
|
70 | + 'not_found_in_trash' => __( '', 'textdomain' ), |
|
71 | + ); |
|
72 | + |
|
73 | + return $labels; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | 77 | /** |
@@ -81,44 +81,44 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return Array |
83 | 83 | */ |
84 | - public function args( $labels ) { |
|
85 | - |
|
86 | - $args = array( |
|
87 | - 'label' => __( '', 'textdomain' ), |
|
88 | - 'description' => __( '', 'textdomain' ), |
|
89 | - 'labels' => $labels, |
|
90 | - 'supports' => array( 'title', 'editor', 'thumbnail' ), |
|
91 | - 'taxonomies' => array( 'custom_tax', 'post_tag' ), |
|
92 | - 'hierarchical' => true, |
|
93 | - 'public' => true, |
|
84 | + public function args( $labels ) { |
|
85 | + |
|
86 | + $args = array( |
|
87 | + 'label' => __( '', 'textdomain' ), |
|
88 | + 'description' => __( '', 'textdomain' ), |
|
89 | + 'labels' => $labels, |
|
90 | + 'supports' => array( 'title', 'editor', 'thumbnail' ), |
|
91 | + 'taxonomies' => array( 'custom_tax', 'post_tag' ), |
|
92 | + 'hierarchical' => true, |
|
93 | + 'public' => true, |
|
94 | 94 | 'rewrite' => array( 'slug' => 'slug_name' ), |
95 | - 'show_ui' => true, |
|
96 | - 'show_in_menu' => true, |
|
95 | + 'show_ui' => true, |
|
96 | + 'show_in_menu' => true, |
|
97 | 97 | 'menu_icon' => 'data:image/svg+xml;base64,' . self::$menu_svg, |
98 | - 'show_in_nav_menus' => true, |
|
99 | - 'show_in_admin_bar' => true, |
|
100 | - 'menu_position' => 5, |
|
101 | - 'can_export' => true, |
|
102 | - 'has_archive' => true, |
|
103 | - 'exclude_from_search' => false, |
|
104 | - 'publicly_queryable' => true, |
|
105 | - 'capability_type' => 'post', |
|
106 | - 'show_in_rest' => true, |
|
98 | + 'show_in_nav_menus' => true, |
|
99 | + 'show_in_admin_bar' => true, |
|
100 | + 'menu_position' => 5, |
|
101 | + 'can_export' => true, |
|
102 | + 'has_archive' => true, |
|
103 | + 'exclude_from_search' => false, |
|
104 | + 'publicly_queryable' => true, |
|
105 | + 'capability_type' => 'post', |
|
106 | + 'show_in_rest' => true, |
|
107 | 107 | //Controls WP REST API behaviour |
108 | 108 | 'rest_controller_class' => 'WP_REST_Posts_Controller', |
109 | - ); |
|
109 | + ); |
|
110 | 110 | |
111 | - return $args; |
|
112 | - } |
|
111 | + return $args; |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
116 | - * Modify the cpt messages |
|
116 | + * Modify the cpt messages |
|
117 | 117 | * |
118 | 118 | * @param Array $messages |
119 | 119 | * |
120 | 120 | * @return Array |
121 | - */ |
|
121 | + */ |
|
122 | 122 | public function cpt_updated_messages( $messages ) { |
123 | 123 | |
124 | 124 | global $post, $post_ID; |
@@ -142,24 +142,24 @@ discard block |
||
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
145 | - * Taxonomy labels |
|
146 | - * |
|
147 | - * @return Array |
|
148 | - */ |
|
145 | + * Taxonomy labels |
|
146 | + * |
|
147 | + * @return Array |
|
148 | + */ |
|
149 | 149 | public function taxonomy_labels() { |
150 | 150 | |
151 | 151 | $labels = array( |
152 | - 'name' => _x( 'Taxonomy', 'taxonomy general name', 'textdomain' ), |
|
153 | - 'singular_name' => _x( 'Taxonomy', 'taxonomy singular name', 'textdomain' ), |
|
154 | - 'search_items' => __( 'Search Taxonomy', 'textdomain' ), |
|
155 | - 'all_items' => __( 'All Taxonomies', 'textdomain' ), |
|
156 | - 'parent_item' => __( 'Parent Taxonomy', 'textdomain' ), |
|
157 | - 'parent_item_colon' => __( 'Parent Taxonomy:', 'textdomain' ), |
|
158 | - 'edit_item' => __( 'Edit Taxonomy', 'textdomain' ), |
|
159 | - 'update_item' => __( 'Update Taxonomy', 'textdomain' ), |
|
160 | - 'add_new_item' => __( 'Add New Taxonomy', 'textdomain' ), |
|
161 | - 'new_item_name' => __( 'New Taxonomy Name', 'textdomain' ), |
|
162 | - 'menu_name' => __( 'Taxonomy', 'textdomain' ), |
|
152 | + 'name' => _x( 'Taxonomy', 'taxonomy general name', 'textdomain' ), |
|
153 | + 'singular_name' => _x( 'Taxonomy', 'taxonomy singular name', 'textdomain' ), |
|
154 | + 'search_items' => __( 'Search Taxonomy', 'textdomain' ), |
|
155 | + 'all_items' => __( 'All Taxonomies', 'textdomain' ), |
|
156 | + 'parent_item' => __( 'Parent Taxonomy', 'textdomain' ), |
|
157 | + 'parent_item_colon' => __( 'Parent Taxonomy:', 'textdomain' ), |
|
158 | + 'edit_item' => __( 'Edit Taxonomy', 'textdomain' ), |
|
159 | + 'update_item' => __( 'Update Taxonomy', 'textdomain' ), |
|
160 | + 'add_new_item' => __( 'Add New Taxonomy', 'textdomain' ), |
|
161 | + 'new_item_name' => __( 'New Taxonomy Name', 'textdomain' ), |
|
162 | + 'menu_name' => __( 'Taxonomy', 'textdomain' ), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | return $labels; |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | |
168 | 168 | |
169 | 169 | /** |
170 | - * Define the arguments for custom taxonomy |
|
171 | - * |
|
172 | - * @param Array $labels |
|
173 | - * |
|
174 | - * @return Array |
|
175 | - */ |
|
176 | - public function taxonomy_args( $labels ) { |
|
177 | - |
|
178 | - $args = array( |
|
170 | + * Define the arguments for custom taxonomy |
|
171 | + * |
|
172 | + * @param Array $labels |
|
173 | + * |
|
174 | + * @return Array |
|
175 | + */ |
|
176 | + public function taxonomy_args( $labels ) { |
|
177 | + |
|
178 | + $args = array( |
|
179 | 179 | 'hierarchical' => true, |
180 | - 'labels' => $labels, |
|
181 | - 'show_ui' => true, |
|
182 | - 'show_admin_column' => true, |
|
183 | - 'query_var' => true, |
|
184 | - 'rewrite' => array( 'slug' => 'custom_tax' ), |
|
185 | - 'show_in_rest' => true, |
|
186 | - 'rest_base' => 'custom_tax', |
|
180 | + 'labels' => $labels, |
|
181 | + 'show_ui' => true, |
|
182 | + 'show_admin_column' => true, |
|
183 | + 'query_var' => true, |
|
184 | + 'rewrite' => array( 'slug' => 'custom_tax' ), |
|
185 | + 'show_in_rest' => true, |
|
186 | + 'rest_base' => 'custom_tax', |
|
187 | 187 | //Controls WP REST API behaviour |
188 | - 'rest_controller_class' => 'WP_REST_Terms_Controller', |
|
189 | - ); |
|
188 | + 'rest_controller_class' => 'WP_REST_Terms_Controller', |
|
189 | + ); |
|
190 | 190 | |
191 | - return $args; |
|
192 | - } |
|
191 | + return $args; |
|
192 | + } |
|
193 | 193 | } |
194 | 194 | } |
@@ -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 | * Custom post type class |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @author Nirjhar Lo |
8 | 8 | * @package wp-plugin-framework |
9 | 9 | */ |
10 | -if ( ! class_exists( 'PLUGIN_CPT' ) ) { |
|
10 | +if ( ! class_exists('PLUGIN_CPT')) { |
|
11 | 11 | |
12 | 12 | class PLUGIN_CPT { |
13 | 13 | |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | public function __construct() { |
36 | 36 | |
37 | 37 | $this->labels = $this->labels(); |
38 | - $this->args = $this->args( $this->labels ); |
|
38 | + $this->args = $this->args($this->labels); |
|
39 | 39 | |
40 | 40 | $this->taxonomy_labels = $this->taxonomy_labels(); |
41 | - $this->taxonomy_args = $this->taxonomy_args( $this->taxonomy_labels ); |
|
41 | + $this->taxonomy_args = $this->taxonomy_args($this->taxonomy_labels); |
|
42 | 42 | |
43 | 43 | //register_post_type( 'cpt_name', $this->args ); |
44 | 44 | //add_filter( 'post_updated_messages', array( $this, 'group_updated_messages' ) ); |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | public function labels() { |
56 | 56 | |
57 | 57 | $labels = array( |
58 | - 'name' => _x( '', 'Post Type General Name', 'textdomain' ), |
|
59 | - 'singular_name' => _x( '', 'Post Type Singular Name', 'textdomain' ), |
|
60 | - 'menu_name' => __( '', 'textdomain' ), |
|
61 | - 'parent_item_colon' => __( '', 'textdomain' ), |
|
62 | - 'all_items' => __( '', 'textdomain' ), |
|
63 | - 'view_item' => __( '', 'textdomain' ), |
|
64 | - 'add_new_item' => __( '', 'textdomain' ), |
|
65 | - 'add_new' => __( '', 'textdomain' ), |
|
66 | - 'edit_item' => __( '', 'textdomain' ), |
|
67 | - 'update_item' => __( '', 'textdomain' ), |
|
68 | - 'search_items' => __( '', 'textdomain' ), |
|
69 | - 'not_found' => __( '', 'textdomain' ), |
|
70 | - 'not_found_in_trash' => __( '', 'textdomain' ), |
|
58 | + 'name' => _x('', 'Post Type General Name', 'textdomain'), |
|
59 | + 'singular_name' => _x('', 'Post Type Singular Name', 'textdomain'), |
|
60 | + 'menu_name' => __('', 'textdomain'), |
|
61 | + 'parent_item_colon' => __('', 'textdomain'), |
|
62 | + 'all_items' => __('', 'textdomain'), |
|
63 | + 'view_item' => __('', 'textdomain'), |
|
64 | + 'add_new_item' => __('', 'textdomain'), |
|
65 | + 'add_new' => __('', 'textdomain'), |
|
66 | + 'edit_item' => __('', 'textdomain'), |
|
67 | + 'update_item' => __('', 'textdomain'), |
|
68 | + 'search_items' => __('', 'textdomain'), |
|
69 | + 'not_found' => __('', 'textdomain'), |
|
70 | + 'not_found_in_trash' => __('', 'textdomain'), |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | return $labels; |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return Array |
83 | 83 | */ |
84 | - public function args( $labels ) { |
|
84 | + public function args($labels) { |
|
85 | 85 | |
86 | 86 | $args = array( |
87 | - 'label' => __( '', 'textdomain' ), |
|
88 | - 'description' => __( '', 'textdomain' ), |
|
87 | + 'label' => __('', 'textdomain'), |
|
88 | + 'description' => __('', 'textdomain'), |
|
89 | 89 | 'labels' => $labels, |
90 | - 'supports' => array( 'title', 'editor', 'thumbnail' ), |
|
91 | - 'taxonomies' => array( 'custom_tax', 'post_tag' ), |
|
90 | + 'supports' => array('title', 'editor', 'thumbnail'), |
|
91 | + 'taxonomies' => array('custom_tax', 'post_tag'), |
|
92 | 92 | 'hierarchical' => true, |
93 | 93 | 'public' => true, |
94 | - 'rewrite' => array( 'slug' => 'slug_name' ), |
|
94 | + 'rewrite' => array('slug' => 'slug_name'), |
|
95 | 95 | 'show_ui' => true, |
96 | 96 | 'show_in_menu' => true, |
97 | 97 | 'menu_icon' => 'data:image/svg+xml;base64,' . self::$menu_svg, |
@@ -119,22 +119,22 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return Array |
121 | 121 | */ |
122 | - public function cpt_updated_messages( $messages ) { |
|
122 | + public function cpt_updated_messages($messages) { |
|
123 | 123 | |
124 | 124 | global $post, $post_ID; |
125 | 125 | |
126 | 126 | $messages['cpt_name'] = array( |
127 | 127 | 0 => '', |
128 | - 1 => sprintf( __( 'CPT updated. <a href="%s">View CPT</a>', 'textdomain' ), esc_url( get_permalink( $post_ID ) ) ), |
|
129 | - 2 => __( 'field updated.', 'textdomain' ), |
|
130 | - 3 => __( 'field deleted.', 'textdomain' ), |
|
131 | - 4 => __( 'CPT updated.', 'textdomain' ), |
|
132 | - 5 => ( isset( $_GET['revision'] ) ? sprintf( __( 'CPT restored to revision from %s', 'textdomain' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false ), |
|
133 | - 6 => sprintf( __( 'CPT published. <a href="%s">View Cpt</a>', 'textdomain' ), esc_url( get_permalink( $post_ID ) ) ), |
|
134 | - 7 => __( 'CPT saved.', 'textdomain' ), |
|
135 | - 8 => sprintf( __( 'CPT submitted. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), |
|
136 | - 9 => sprintf( __( 'CPT scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview cpt</a>', 'textdomain' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), |
|
137 | - 10 => sprintf( __( 'CPT draft updated. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), |
|
128 | + 1 => sprintf(__('CPT updated. <a href="%s">View CPT</a>', 'textdomain'), esc_url(get_permalink($post_ID))), |
|
129 | + 2 => __('field updated.', 'textdomain'), |
|
130 | + 3 => __('field deleted.', 'textdomain'), |
|
131 | + 4 => __('CPT updated.', 'textdomain'), |
|
132 | + 5 => (isset($_GET['revision']) ? sprintf(__('CPT restored to revision from %s', 'textdomain'), wp_post_revision_title((int) $_GET['revision'], false)) : false), |
|
133 | + 6 => sprintf(__('CPT published. <a href="%s">View Cpt</a>', 'textdomain'), esc_url(get_permalink($post_ID))), |
|
134 | + 7 => __('CPT saved.', 'textdomain'), |
|
135 | + 8 => sprintf(__('CPT submitted. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), |
|
136 | + 9 => sprintf(__('CPT scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview cpt</a>', 'textdomain'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), |
|
137 | + 10 => sprintf(__('CPT draft updated. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), |
|
138 | 138 | ); |
139 | 139 | |
140 | 140 | return $messages; |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | public function taxonomy_labels() { |
150 | 150 | |
151 | 151 | $labels = array( |
152 | - 'name' => _x( 'Taxonomy', 'taxonomy general name', 'textdomain' ), |
|
153 | - 'singular_name' => _x( 'Taxonomy', 'taxonomy singular name', 'textdomain' ), |
|
154 | - 'search_items' => __( 'Search Taxonomy', 'textdomain' ), |
|
155 | - 'all_items' => __( 'All Taxonomies', 'textdomain' ), |
|
156 | - 'parent_item' => __( 'Parent Taxonomy', 'textdomain' ), |
|
157 | - 'parent_item_colon' => __( 'Parent Taxonomy:', 'textdomain' ), |
|
158 | - 'edit_item' => __( 'Edit Taxonomy', 'textdomain' ), |
|
159 | - 'update_item' => __( 'Update Taxonomy', 'textdomain' ), |
|
160 | - 'add_new_item' => __( 'Add New Taxonomy', 'textdomain' ), |
|
161 | - 'new_item_name' => __( 'New Taxonomy Name', 'textdomain' ), |
|
162 | - 'menu_name' => __( 'Taxonomy', 'textdomain' ), |
|
152 | + 'name' => _x('Taxonomy', 'taxonomy general name', 'textdomain'), |
|
153 | + 'singular_name' => _x('Taxonomy', 'taxonomy singular name', 'textdomain'), |
|
154 | + 'search_items' => __('Search Taxonomy', 'textdomain'), |
|
155 | + 'all_items' => __('All Taxonomies', 'textdomain'), |
|
156 | + 'parent_item' => __('Parent Taxonomy', 'textdomain'), |
|
157 | + 'parent_item_colon' => __('Parent Taxonomy:', 'textdomain'), |
|
158 | + 'edit_item' => __('Edit Taxonomy', 'textdomain'), |
|
159 | + 'update_item' => __('Update Taxonomy', 'textdomain'), |
|
160 | + 'add_new_item' => __('Add New Taxonomy', 'textdomain'), |
|
161 | + 'new_item_name' => __('New Taxonomy Name', 'textdomain'), |
|
162 | + 'menu_name' => __('Taxonomy', 'textdomain'), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | return $labels; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return Array |
175 | 175 | */ |
176 | - public function taxonomy_args( $labels ) { |
|
176 | + public function taxonomy_args($labels) { |
|
177 | 177 | |
178 | 178 | $args = array( |
179 | 179 | 'hierarchical' => true, |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | 'show_ui' => true, |
182 | 182 | 'show_admin_column' => true, |
183 | 183 | 'query_var' => true, |
184 | - 'rewrite' => array( 'slug' => 'custom_tax' ), |
|
184 | + 'rewrite' => array('slug' => 'custom_tax'), |
|
185 | 185 | 'show_in_rest' => true, |
186 | 186 | 'rest_base' => 'custom_tax', |
187 | 187 | //Controls WP REST API behaviour |