@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Build a sample metabox in editor screen |
6 | 6 | */ |
7 | -if ( ! class_exists( 'PLUGIN_METABOX' ) ) { |
|
7 | +if ( ! class_exists('PLUGIN_METABOX')) { |
|
8 | 8 | |
9 | 9 | final class PLUGIN_METABOX { |
10 | 10 | |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | public function __construct() { |
14 | 14 | |
15 | 15 | //Adding the metabox. For custom post type use "add_meta_boxes_posttype" action |
16 | - add_action( 'add_meta_boxes', array( $this, 'register' ) ); |
|
17 | - add_action( 'save_post', array( $this, 'save' ), 10, 2 ); |
|
16 | + add_action('add_meta_boxes', array($this, 'register')); |
|
17 | + add_action('save_post', array($this, 'save'), 10, 2); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | add_meta_box( |
25 | 25 | 'meta-box-id', |
26 | - esc_html__( 'MetaBox Title', 'textdomain' ), |
|
27 | - array( $this, 'render' ), |
|
26 | + esc_html__('MetaBox Title', 'textdomain'), |
|
27 | + array($this, 'render'), |
|
28 | 28 | // Declare the post type to show meta box |
29 | 29 | 'post_type', |
30 | 30 | 'normal', |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | |
37 | 37 | public function render() { |
38 | 38 | |
39 | - wp_nonce_field( basename( __FILE__ ), 'metaBoxName_nonce' ); ?> |
|
39 | + wp_nonce_field(basename(__FILE__), 'metaBoxName_nonce'); ?> |
|
40 | 40 | |
41 | 41 | <p> |
42 | - <label for="metaBoxName"><?php _e( "Custom Text", 'myPlugintextDomain' ); ?></label> |
|
42 | + <label for="metaBoxName"><?php _e("Custom Text", 'myPlugintextDomain'); ?></label> |
|
43 | 43 | <br /> |
44 | - <input class="widefat" type="text" name="metaBoxFieldName" id="metaBoxFieldName" value="<?php echo esc_attr( get_post_meta( $object->ID, 'metaBoxName', true ) ); ?>" /> |
|
44 | + <input class="widefat" type="text" name="metaBoxFieldName" id="metaBoxFieldName" value="<?php echo esc_attr(get_post_meta($object->ID, 'metaBoxName', true)); ?>" /> |
|
45 | 45 | </p> |
46 | 46 | <?php |
47 | 47 | } |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | //Save the post data |
52 | - function save( $post_id, $post ) { |
|
52 | + function save($post_id, $post) { |
|
53 | 53 | |
54 | 54 | //Verify the nonce before proceeding. |
55 | - if ( !isset( $_POST['metaBoxName_nonce'] ) || !wp_verify_nonce( $_POST['metaBoxName_nonce'], basename( __FILE__ ) ) ) |
|
55 | + if ( ! isset($_POST['metaBoxName_nonce']) || ! wp_verify_nonce($_POST['metaBoxName_nonce'], basename(__FILE__))) |
|
56 | 56 | return $post_id; |
57 | 57 | |
58 | 58 | //Get the post type object. |
59 | - $post_type = get_post_type_object( $post->post_type ); |
|
59 | + $post_type = get_post_type_object($post->post_type); |
|
60 | 60 | |
61 | 61 | //Check if the current user has permission to edit the post. |
62 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) |
|
62 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) |
|
63 | 63 | return $post_id; |
64 | 64 | |
65 | 65 | //Get the posted data and sanitize it for use as an HTML class. |
66 | - $new_meta_value = ( isset( $_POST['metaBoxName'] ) ? sanitize_html_class( $_POST['metaBoxName'] ) : '' ); |
|
66 | + $new_meta_value = (isset($_POST['metaBoxName']) ? sanitize_html_class($_POST['metaBoxName']) : ''); |
|
67 | 67 | |
68 | 68 | //Get the meta key. |
69 | 69 | $meta_key = 'metaBoxName'; |
70 | 70 | |
71 | 71 | //Get the meta value of the custom field key. |
72 | - $meta_value = get_post_meta( $post_id, $meta_key, true ); |
|
72 | + $meta_value = get_post_meta($post_id, $meta_key, true); |
|
73 | 73 | |
74 | 74 | //If a new meta value was added and there was no previous value, add it. |
75 | - if ( $new_meta_value && '' == $meta_value ) { |
|
76 | - add_post_meta( $post_id, $meta_key, $new_meta_value, true ); |
|
77 | - } elseif ( $new_meta_value && $new_meta_value != $meta_value ) { |
|
78 | - update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
79 | - } elseif ( '' == $new_meta_value && $meta_value ) { |
|
80 | - delete_post_meta( $post_id, $meta_key, $meta_value ); |
|
75 | + if ($new_meta_value && '' == $meta_value) { |
|
76 | + add_post_meta($post_id, $meta_key, $new_meta_value, true); |
|
77 | + } elseif ($new_meta_value && $new_meta_value != $meta_value) { |
|
78 | + update_post_meta($post_id, $meta_key, $new_meta_value); |
|
79 | + } elseif ('' == $new_meta_value && $meta_value) { |
|
80 | + delete_post_meta($post_id, $meta_key, $meta_value); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | /** |
5 | 7 | * Build a sample metabox in editor screen |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | function save( $post_id, $post ) { |
53 | 55 | |
54 | 56 | //Verify the nonce before proceeding. |
55 | - if ( !isset( $_POST['metaBoxName_nonce'] ) || !wp_verify_nonce( $_POST['metaBoxName_nonce'], basename( __FILE__ ) ) ) |
|
56 | - return $post_id; |
|
57 | + if ( !isset( $_POST['metaBoxName_nonce'] ) || !wp_verify_nonce( $_POST['metaBoxName_nonce'], basename( __FILE__ ) ) ) { |
|
58 | + return $post_id; |
|
59 | + } |
|
57 | 60 | |
58 | 61 | //Get the post type object. |
59 | 62 | $post_type = get_post_type_object( $post->post_type ); |
60 | 63 | |
61 | 64 | //Check if the current user has permission to edit the post. |
62 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) |
|
63 | - return $post_id; |
|
65 | + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
66 | + return $post_id; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | //Get the posted data and sanitize it for use as an HTML class. |
66 | 70 | $new_meta_value = ( isset( $_POST['metaBoxName'] ) ? sanitize_html_class( $_POST['metaBoxName'] ) : '' ); |
@@ -11,7 +11,7 @@ discard block |
||
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')) exit; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | //Define basic names |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | defined('PLUGIN_PATH') or define('PLUGIN_PATH', plugin_dir_path(__FILE__)); |
22 | 22 | defined('PLUGIN_FILE') or define('PLUGIN_FILE', plugin_basename(__FILE__)); |
23 | 23 | |
24 | -defined('PLUGIN_EXECUTE') or define('PLUGIN_EXECUTE', plugin_dir_path(__FILE__).'src/'); |
|
25 | -defined('PLUGIN_HELPER') or define('PLUGIN_HELPER', plugin_dir_path(__FILE__).'helper/'); |
|
26 | -defined('PLUGIN_TRANSLATE') or define('PLUGIN_TRANSLATE', plugin_basename( plugin_dir_path(__FILE__).'asset/ln/')); |
|
24 | +defined('PLUGIN_EXECUTE') or define('PLUGIN_EXECUTE', plugin_dir_path(__FILE__) . 'src/'); |
|
25 | +defined('PLUGIN_HELPER') or define('PLUGIN_HELPER', plugin_dir_path(__FILE__) . 'helper/'); |
|
26 | +defined('PLUGIN_TRANSLATE') or define('PLUGIN_TRANSLATE', plugin_basename(plugin_dir_path(__FILE__) . 'asset/ln/')); |
|
27 | 27 | |
28 | 28 | //change /wp-plugin-framework/ with your /plugin-name/ |
29 | -defined('PLUGIN_JS') or define('PLUGIN_JS', plugins_url().'/wp-plugin-framework/asset/js/'); |
|
30 | -defined('PLUGIN_CSS') or define('PLUGIN_CSS', plugins_url().'/wp-plugin-framework/asset/css/'); |
|
31 | -defined('PLUGIN_IMAGE') or define('PLUGIN_IMAGE', plugins_url().'/wp-plugin-framework/asset/img/'); |
|
29 | +defined('PLUGIN_JS') or define('PLUGIN_JS', plugins_url() . '/wp-plugin-framework/asset/js/'); |
|
30 | +defined('PLUGIN_CSS') or define('PLUGIN_CSS', plugins_url() . '/wp-plugin-framework/asset/css/'); |
|
31 | +defined('PLUGIN_IMAGE') or define('PLUGIN_IMAGE', plugins_url() . '/wp-plugin-framework/asset/img/'); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | //The Plugin |
35 | 35 | require_once('autoload.php'); |
36 | -if ( class_exists( 'PLUGIN_BUILD' ) ) new PLUGIN_BUILD(); ?> |
|
37 | 36 | \ No newline at end of file |
37 | +if (class_exists('PLUGIN_BUILD')) new PLUGIN_BUILD(); ?> |
|
38 | 38 | \ No newline at end of file |
@@ -11,7 +11,9 @@ discard block |
||
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 |
@@ -33,4 +35,7 @@ discard block |
||
33 | 35 | |
34 | 36 | //The Plugin |
35 | 37 | require_once('autoload.php'); |
36 | -if ( class_exists( 'PLUGIN_BUILD' ) ) new PLUGIN_BUILD(); ?> |
|
37 | 38 | \ No newline at end of file |
39 | +if ( class_exists( 'PLUGIN_BUILD' ) ) { |
|
40 | + new PLUGIN_BUILD(); |
|
41 | +} |
|
42 | +?> |
|
38 | 43 | \ No newline at end of file |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | //Main plugin object to define the plugin |
5 | 7 | if ( ! class_exists( 'PLUGIN_BUILD' ) ) { |
@@ -129,7 +131,9 @@ discard block |
||
129 | 131 | //Include scripts |
130 | 132 | public function scripts() { |
131 | 133 | |
132 | - if ( class_exists( 'PLUGIN_SCRIPT' ) ) new PLUGIN_SCRIPT(); |
|
134 | + if ( class_exists( 'PLUGIN_SCRIPT' ) ) { |
|
135 | + new PLUGIN_SCRIPT(); |
|
136 | + } |
|
133 | 137 | } |
134 | 138 | |
135 | 139 | |
@@ -137,14 +141,18 @@ discard block |
||
137 | 141 | //Include settings pages |
138 | 142 | public function settings() { |
139 | 143 | |
140 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
144 | + if ( class_exists( 'PLUGIN_SETTINGS' ) ) { |
|
145 | + new PLUGIN_SETTINGS(); |
|
146 | + } |
|
141 | 147 | } |
142 | 148 | |
143 | 149 | |
144 | 150 | //Include widget classes |
145 | 151 | public function widgets() { |
146 | 152 | |
147 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
153 | + if ( class_exists( 'PLUGIN_WIDGET' ) ) { |
|
154 | + new PLUGIN_WIDGET(); |
|
155 | + } |
|
148 | 156 | } |
149 | 157 | |
150 | 158 | |
@@ -152,7 +160,9 @@ discard block |
||
152 | 160 | //Include metabox classes |
153 | 161 | public function metabox() { |
154 | 162 | |
155 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
163 | + if ( class_exists( 'PLUGIN_METABOX' ) ) { |
|
164 | + new PLUGIN_METABOX(); |
|
165 | + } |
|
156 | 166 | } |
157 | 167 | |
158 | 168 | |
@@ -160,7 +170,9 @@ discard block |
||
160 | 170 | //Include shortcode classes |
161 | 171 | public function shortcode() { |
162 | 172 | |
163 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
173 | + if ( class_exists( 'PLUGIN_SHORTCODE' ) ) { |
|
174 | + new PLUGIN_SHORTCODE(); |
|
175 | + } |
|
164 | 176 | } |
165 | 177 | |
166 | 178 |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | public function installation() { |
12 | 12 | |
13 | 13 | /** |
14 | - * |
|
15 | - * Plugin installation |
|
16 | - * |
|
14 | + * |
|
15 | + * Plugin installation |
|
16 | + * |
|
17 | 17 | if (class_exists('PLUGIN_INSTALL')) { |
18 | 18 | |
19 | 19 | $install = new PLUGIN_INSTALL(); |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | ); |
28 | 28 | $install->execute(); |
29 | 29 | } |
30 | - * |
|
31 | - */ |
|
30 | + * |
|
31 | + */ |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | public function db_install() { |
55 | 55 | |
56 | 56 | /** |
57 | - * |
|
58 | - * Install database by defining your SQL |
|
59 | - * |
|
57 | + * |
|
58 | + * Install database by defining your SQL |
|
59 | + * |
|
60 | 60 | if ( class_exists( 'PLUGIN_DB' ) ) { |
61 | 61 | $db = new PLUGIN_DB(); |
62 | 62 | $db->table = 'plugin_db_table_name'; |
@@ -65,28 +65,28 @@ discard block |
||
65 | 65 | UNIQUE KEY ID (ID)"; |
66 | 66 | $db->build(); |
67 | 67 | } |
68 | - * |
|
69 | - * |
|
70 | - * Optionally check if the DB table is installed correctly |
|
71 | - * |
|
68 | + * |
|
69 | + * |
|
70 | + * Optionally check if the DB table is installed correctly |
|
71 | + * |
|
72 | 72 | if (get_option('_plugin_db_exist') == '0') { |
73 | 73 | add_action( 'admin_notices', array( $this, 'db_error_msg' ) ); |
74 | 74 | } |
75 | - * |
|
76 | - */ |
|
75 | + * |
|
76 | + */ |
|
77 | 77 | |
78 | 78 | /** |
79 | - * |
|
80 | - * Install DB options |
|
81 | - * |
|
79 | + * |
|
80 | + * Install DB options |
|
81 | + * |
|
82 | 82 | $options = array( |
83 | 83 | array( 'option_name', '__value__' ), |
84 | 84 | ); |
85 | 85 | foreach ($options as $value) { |
86 | 86 | update_option( $value[0], $value[1] ); |
87 | 87 | } |
88 | - * |
|
89 | - */ |
|
88 | + * |
|
89 | + */ |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | public function db_uninstall() { |
106 | 106 | |
107 | 107 | /** |
108 | - * |
|
109 | - * Important table name declarition |
|
110 | - * |
|
108 | + * |
|
109 | + * Important table name declarition |
|
110 | + * |
|
111 | 111 | $tableName = 'plugin_db_table_name'; |
112 | 112 | |
113 | 113 | global $wpdb; |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | foreach ($options as $value) { |
119 | 119 | delete_option($value); |
120 | 120 | } |
121 | - * |
|
122 | - */ |
|
121 | + * |
|
122 | + */ |
|
123 | 123 | } |
124 | 124 | |
125 | 125 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | //Main plugin object to define the plugin |
5 | -if ( ! class_exists( 'PLUGIN_BUILD' ) ) { |
|
5 | +if ( ! class_exists('PLUGIN_BUILD')) { |
|
6 | 6 | |
7 | 7 | final class PLUGIN_BUILD { |
8 | 8 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | //Custom corn class, register it while activation |
37 | 37 | public function cron_activation() { |
38 | 38 | |
39 | - if ( class_exists( 'PLUGIN_CRON' ) ) { |
|
39 | + if (class_exists('PLUGIN_CRON')) { |
|
40 | 40 | $cron = new PLUGIN_CRON(); |
41 | 41 | $schedule = $cron->schedule_task( |
42 | 42 | array( |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function db_error_msg() { ?> |
96 | 96 | |
97 | 97 | <div class="notice notice-error is-dismissible"> |
98 | - <p><?php _e( 'Database table Not installed correctly.', 'textdomain' ); ?></p> |
|
98 | + <p><?php _e('Database table Not installed correctly.', 'textdomain'); ?></p> |
|
99 | 99 | </div> |
100 | 100 | <?php |
101 | 101 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function custom_cron_hook_cb() { |
133 | 133 | |
134 | - add_action('custom_cron_hook', array( $this, 'do_cron_job_function')); |
|
134 | + add_action('custom_cron_hook', array($this, 'do_cron_job_function')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | //Include scripts |
145 | 145 | public function scripts() { |
146 | 146 | |
147 | - if ( class_exists( 'PLUGIN_SCRIPT' ) ) new PLUGIN_SCRIPT(); |
|
147 | + if (class_exists('PLUGIN_SCRIPT')) new PLUGIN_SCRIPT(); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | //Include settings pages |
153 | 153 | public function settings() { |
154 | 154 | |
155 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
155 | + if (class_exists('PLUGIN_SETTINGS')) new PLUGIN_SETTINGS(); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
159 | 159 | //Include widget classes |
160 | 160 | public function widgets() { |
161 | 161 | |
162 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
162 | + if (class_exists('PLUGIN_WIDGET')) new PLUGIN_WIDGET(); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | //Include metabox classes |
168 | 168 | public function metabox() { |
169 | 169 | |
170 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
170 | + if (class_exists('PLUGIN_METABOX')) new PLUGIN_METABOX(); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | //Include shortcode classes |
176 | 176 | public function shortcode() { |
177 | 177 | |
178 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
178 | + if (class_exists('PLUGIN_SHORTCODE')) new PLUGIN_SHORTCODE(); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | $this->helpers(); |
219 | 219 | $this->functionality(); |
220 | 220 | |
221 | - register_activation_hook( PLUGIN_FILE, array( $this, 'db_install' ) ); |
|
222 | - register_activation_hook( PLUGIN_FILE, array($this, 'cron_activation' )); |
|
221 | + register_activation_hook(PLUGIN_FILE, array($this, 'db_install')); |
|
222 | + register_activation_hook(PLUGIN_FILE, array($this, 'cron_activation')); |
|
223 | 223 | |
224 | 224 | //remove the DB upon uninstallation |
225 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'db_uninstall' ) ); //$this won't work here. |
|
226 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'cron_uninstall' ) ); |
|
225 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'db_uninstall')); //$this won't work here. |
|
226 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'cron_uninstall')); |
|
227 | 227 | |
228 | 228 | add_action('init', array($this, 'installation')); |
229 | 229 | add_action('init', array($this, 'custom_cron_hook_cb')); |
@@ -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 | * WP Query class for querying WP database |
@@ -29,12 +29,12 @@ |
||
29 | 29 | /** |
30 | 30 | $user_args = $this->user_args($paged); |
31 | 31 | $the_query = new WP_User_Query( $user_args ); |
32 | - */ |
|
32 | + */ |
|
33 | 33 | |
34 | 34 | // The Loop |
35 | 35 | if ( $the_query->have_posts() ) { |
36 | 36 | while ( $the_query->have_posts() ) { |
37 | - $the_query->the_post(); |
|
37 | + $the_query->the_post(); |
|
38 | 38 | // Do Stuff |
39 | 39 | } // end while |
40 | 40 | } // endif |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * WP Query class for querying WP database |
6 | 6 | * For more reference of arguments visit: https://gist.github.com/nirjharlo/5c6f8ac4cc5271f88376788e599c287b |
7 | 7 | * This class depends on WP pagenavi plugin: https://wordpress.org/plugins/wp-pagenavi/ |
8 | 8 | */ |
9 | -if ( ! class_exists( 'PLUGIN_QUERY' ) ) { |
|
9 | +if ( ! class_exists('PLUGIN_QUERY')) { |
|
10 | 10 | |
11 | 11 | class PLUGIN_QUERY { |
12 | 12 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | get_query_var('page') : 1); |
25 | 25 | |
26 | 26 | $post_args = $this->post_args($paged); |
27 | - $the_query = new WP_Query( $post_args ); |
|
27 | + $the_query = new WP_Query($post_args); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | $user_args = $this->user_args($paged); |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | */ |
33 | 33 | |
34 | 34 | // The Loop |
35 | - if ( $the_query->have_posts() ) { |
|
36 | - while ( $the_query->have_posts() ) { |
|
35 | + if ($the_query->have_posts()) { |
|
36 | + while ($the_query->have_posts()) { |
|
37 | 37 | $the_query->the_post(); |
38 | 38 | // Do Stuff |
39 | 39 | } // end while |
40 | 40 | } // endif |
41 | 41 | |
42 | - if (function_exists('wp_pagenavi')) { |
|
43 | - wp_pagenavi( array( 'query' => $the_query, 'echo' => true ) );//For user query add param 'type' => 'users' |
|
42 | + if (function_exists('wp_pagenavi')) { |
|
43 | + wp_pagenavi(array('query' => $the_query, 'echo' => true)); //For user query add param 'type' => 'users' |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Reset Post Data |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function user_args($paged) { |
55 | 55 | |
56 | - $offset = ( $paged - 1 ) * $this->display_count; |
|
56 | + $offset = ($paged - 1) * $this->display_count; |
|
57 | 57 | |
58 | - $args = array ( |
|
58 | + $args = array( |
|
59 | 59 | 'role' => '', // user role |
60 | 60 | 'order' => '', //ASC or DESC |
61 | 61 | 'fields' => '', // |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'count_total' => true, |
72 | 72 | 'paged' => $paged, |
73 | 73 | 'offset' => $offset, |
74 | - 'search' => '*'.esc_attr( $_GET['search'] ).'*', |
|
74 | + 'search' => '*' . esc_attr($_GET['search']) . '*', |
|
75 | 75 | 'meta_query' => array( // It supports nested meta query |
76 | 76 | 'relation' => 'AND', //or 'OR' |
77 | 77 | array( |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function post_args($paged) { |
98 | 98 | |
99 | - $offset = ( $paged - 1 ) * $this->display_count; |
|
99 | + $offset = ($paged - 1) * $this->display_count; |
|
100 | 100 | |
101 | - $args = array ( |
|
101 | + $args = array( |
|
102 | 102 | 'post_type' => '', // array of type slugs |
103 | 103 | 'order' => 'ASC', |
104 | 104 | 'fields' => '', // |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'count_total' => true, |
113 | 113 | 'paged' => $paged, |
114 | 114 | 'offset' => $offset, |
115 | - 'search' => '*'.esc_attr( $_GET['search'] ).'*', |
|
115 | + 'search' => '*' . esc_attr($_GET['search']) . '*', |
|
116 | 116 | 'meta_query' => array( // It supports nested meta query |
117 | 117 | 'relation' => 'AND', //or 'OR' |
118 | 118 | array( |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | add_action( 'admin_menu', array( $this, 'menu_page' ) ); |
54 | 54 | add_action( 'admin_menu', array( $this, 'sub_menu_page' ) ); |
55 | 55 | add_filter( 'set-screen-option', array( $this, 'set_screen' ), 10, 3 ); |
56 | - * |
|
57 | - */ |
|
56 | + * |
|
57 | + */ |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | //Set screen option |
104 | 104 | public function set_screen($status, $option, $value) { |
105 | 105 | |
106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
107 | - //return $status; |
|
106 | + if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
107 | + //return $status; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | echo '<textarea name="settings_field_name" id="settings_field_name" value="' . get_option('settings_field_name') . '>'. __( 'Enter Value', 'textdomain' ) . '</textarea>'; |
202 | 202 | echo '<select name="settings_field_name" id="settings_field_name"><option value="value" ' . selected( 'value', get_option('settings_field_name'), false) . '>Value</option></select>'; |
203 | 203 | echo '<input type="checkbox" id="settings_field_name" name="settings_field_name" value="1"' . checked( 1, get_option('settings_field_name'), false ) . '/>'; |
204 | - */ |
|
204 | + */ |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } ?> |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Backend settings page class, can have settings fields or data table |
6 | 6 | */ |
7 | -if ( ! class_exists( 'PLUGIN_SETTINGS' ) ) { |
|
7 | +if ( ! class_exists('PLUGIN_SETTINGS')) { |
|
8 | 8 | |
9 | 9 | final class PLUGIN_SETTINGS { |
10 | 10 | |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | public function __construct() { |
21 | 21 | |
22 | 22 | $this->capability = 'manage_options'; |
23 | - $this->menuPage = array( 'name' => '', 'heading' => '', 'slug' => '' ); |
|
23 | + $this->menuPage = array('name' => '', 'heading' => '', 'slug' => ''); |
|
24 | 24 | $this->subMenuPage = array( |
25 | 25 | 'name' => '', |
26 | 26 | 'heading' => '', |
27 | 27 | 'slug' => '', |
28 | 28 | 'parent_slug' => '', |
29 | - 'help' => '',//true/false, |
|
30 | - 'screen' => '',//true/false |
|
29 | + 'help' => '', //true/false, |
|
30 | + 'screen' => '', //true/false |
|
31 | 31 | ); |
32 | 32 | $this->helpData = array( |
33 | 33 | array( |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | 'info' => array( |
37 | 37 | array( |
38 | 38 | 'id' => 'helpId', |
39 | - 'title' => __( 'Title', 'textdomain' ), |
|
40 | - 'content' => __( 'Description', 'textdomain' ), |
|
39 | + 'title' => __('Title', 'textdomain'), |
|
40 | + 'content' => __('Description', 'textdomain'), |
|
41 | 41 | ), |
42 | 42 | ), |
43 | - 'link' => '<p><a href="#">' . __( 'helpLink', 'textdomain' ) . '</a></p>', |
|
43 | + 'link' => '<p><a href="#">' . __('helpLink', 'textdomain') . '</a></p>', |
|
44 | 44 | ) |
45 | 45 | ) |
46 | 46 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->menuPage['heading'], |
69 | 69 | $this->capability, |
70 | 70 | $this->menuPage['slug'], |
71 | - array( $this, 'menu_page_callback' ) |
|
71 | + array($this, 'menu_page_callback') |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | // For the first submenu page, slug should be same as menupage. |
88 | 88 | $this->subMenuPage['slug'], |
89 | 89 | // For the first submenu page, callback should be same as menupage. |
90 | - array( $this, 'menu_page_callback' ) |
|
90 | + array($this, 'menu_page_callback') |
|
91 | 91 | ); |
92 | 92 | if ($this->subMenuPage['help']) { |
93 | - add_action( 'load-' . $hook, array( $this, 'help_tabs' ) ); |
|
93 | + add_action('load-' . $hook, array($this, 'help_tabs')); |
|
94 | 94 | } |
95 | 95 | if ($this->subMenuPage['screen']) { |
96 | - add_action( 'load-' . $hook, array( $this, 'screen_option' ) ); |
|
96 | + add_action('load-' . $hook, array($this, 'screen_option')); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | //Set screen option |
104 | 104 | public function set_screen($status, $option, $value) { |
105 | 105 | |
106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
106 | + if ('option_name_per_page' == $option) return $value; // Related to PLUGIN_TABLE() |
|
107 | 107 | //return $status; |
108 | 108 | } |
109 | 109 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | |
115 | 115 | $option = 'per_page'; |
116 | 116 | $args = array( |
117 | - 'label' => __( 'Show per page', '' ), |
|
117 | + 'label' => __('Show per page', ''), |
|
118 | 118 | 'default' => 10, |
119 | 119 | 'option' => 'option_name_per_page' // Related to PLUGIN_TABLE() |
120 | 120 | ); |
121 | - add_screen_option( $option, $args ); |
|
121 | + add_screen_option($option, $args); |
|
122 | 122 | $this->Table = new PLUGIN_TABLE(); |
123 | 123 | } |
124 | 124 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | <form method="post" action=""> |
139 | 139 | <?php settings_fields("settings_name"); |
140 | 140 | do_settings_sections("settings_name"); |
141 | - submit_button( __( 'Save', 'textdomain' ), 'primary', 'id' ); ?> |
|
141 | + submit_button(__('Save', 'textdomain'), 'primary', 'id'); ?> |
|
142 | 142 | </form> |
143 | 143 | |
144 | 144 | <?php |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | foreach ($this->helpData as $value) { |
165 | 165 | if ($_GET['page'] == $value['slug']) { |
166 | 166 | $this->screen = get_current_screen(); |
167 | - foreach( $value['info'] as $key ) { |
|
168 | - $this->screen->add_help_tab( $key ); |
|
167 | + foreach ($value['info'] as $key) { |
|
168 | + $this->screen->add_help_tab($key); |
|
169 | 169 | } |
170 | - $this->screen->set_help_sidebar( $value['link'] ); |
|
170 | + $this->screen->set_help_sidebar($value['link']); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | //Add different types of settings and corrosponding sections |
178 | 178 | public function add_settings() { |
179 | 179 | |
180 | - add_settings_section( 'settings_id', __( 'Section Name', 'textdomain' ), array( $this,'section_cb' ), 'settings_name' ); |
|
181 | - register_setting( 'settings_name', 'settings_field' ); |
|
182 | - add_settings_field( 'settings_field_name', __( 'Field Name', 'textdomain' ), array( $this, 'settings_field_cb' ), 'settings_name', 'settings_id' ); |
|
180 | + add_settings_section('settings_id', __('Section Name', 'textdomain'), array($this, 'section_cb'), 'settings_name'); |
|
181 | + register_setting('settings_name', 'settings_field'); |
|
182 | + add_settings_field('settings_field_name', __('Field Name', 'textdomain'), array($this, 'settings_field_cb'), 'settings_name', 'settings_id'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | //Section description |
188 | 188 | public function section_cb() { |
189 | 189 | |
190 | - echo '<p class="description">' . __( 'Set up settings', 'textdomain' ) . '</p>'; |
|
190 | + echo '<p class="description">' . __('Set up settings', 'textdomain') . '</p>'; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | /** |
5 | 7 | * Backend settings page class, can have settings fields or data table |
@@ -103,7 +105,10 @@ discard block |
||
103 | 105 | //Set screen option |
104 | 106 | public function set_screen($status, $option, $value) { |
105 | 107 | |
106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
108 | + if ( 'option_name_per_page' == $option ) { |
|
109 | + return $value; |
|
110 | + } |
|
111 | + // Related to PLUGIN_TABLE() |
|
107 | 112 | //return $status; |
108 | 113 | } |
109 | 114 |