Passed
Push — master ( 2434f2...f94701 )
by Nirjhar
08:29
created
lib/table.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
 if ( ! class_exists( 'PLUGIN_TABLE' ) ) {
14 14
 
15 15
 	if ( ! class_exists( 'WP_List_Table' ) ) {
16
-    	require_once( ABSPATH . 'wp-admin/includes/screen.php' );
17
-    	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
16
+		require_once( ABSPATH . 'wp-admin/includes/screen.php' );
17
+		require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
18 18
 	}
19 19
 
20 20
 	final class PLUGIN_TABLE extends WP_List_Table {
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  * @version    1.2.1
11 11
  * @package    wp-plugin-framework
12 12
  */
13
-if ( ! class_exists( 'PLUGIN_TABLE' ) ) {
13
+if ( ! class_exists('PLUGIN_TABLE')) {
14 14
 
15
-	if ( ! class_exists( 'WP_List_Table' ) ) {
16
-    	require_once( ABSPATH . 'wp-admin/includes/screen.php' );
17
-    	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
15
+	if ( ! class_exists('WP_List_Table')) {
16
+    	require_once(ABSPATH . 'wp-admin/includes/screen.php');
17
+    	require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
18 18
 	}
19 19
 
20 20
 	final class PLUGIN_TABLE extends WP_List_Table {
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 		 */
28 28
 		public function __construct() {
29 29
 
30
-			parent::__construct( [
31
-				'singular' => __( 'Name', 'textdomain' ),
32
-				'plural'   => __( 'Names', 'textdomain' ),
30
+			parent::__construct([
31
+				'singular' => __('Name', 'textdomain'),
32
+				'plural'   => __('Names', 'textdomain'),
33 33
 				'ajax'     => false,
34
-			] );
34
+			]);
35 35
 		}
36 36
 
37 37
 
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @return Array
42 42
 		 */
43
-		public static function get_Table( $per_page = 5, $page_number = 1 ) {
43
+		public static function get_Table($per_page = 5, $page_number = 1) {
44 44
 
45 45
 			global $wpdb;
46 46
 
47 47
 			//Take pivotal from URL
48
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
48
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
49 49
 
50 50
 			//Build the db query base
51 51
 			$sql = "SELECT * FROM {$wpdb->prefix}wordpress_table";
52 52
 			$sql .= " QUERIES with $link'";
53 53
 
54 54
 			//Set filters in the query using $_REQUEST
55
-			if ( ! empty( $_REQUEST['orderby'] ) ) {
56
-				$sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] );
57
-				$sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC';
55
+			if ( ! empty($_REQUEST['orderby'])) {
56
+				$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
57
+				$sql .= ! empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
58 58
 			}
59 59
 			$sql .= " LIMIT $per_page";
60
-			$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
60
+			$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
61 61
 
62 62
 			//get the data from database
63
-			$result = $wpdb->get_results( $sql, 'ARRAY_A' );
63
+			$result = $wpdb->get_results($sql, 'ARRAY_A');
64 64
 
65 65
 			return $result;
66 66
 		}
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 		 *
72 72
 		 * @return Void
73 73
 		 */
74
-		public static function delete_url( $id ) {
74
+		public static function delete_url($id) {
75 75
 
76 76
 			global $wpdb;
77 77
 
78
-			$wpdb->delete( "{$wpdb->prefix}wordpress_table", array( 'ID' => $id ), array( '%s' ) );
78
+			$wpdb->delete("{$wpdb->prefix}wordpress_table", array('ID' => $id), array('%s'));
79 79
 		}
80 80
 
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 */
87 87
 		public function no_items() {
88 88
 
89
-			_e( 'No Items Added yet.', 'textDomain' );
89
+			_e('No Items Added yet.', 'textDomain');
90 90
 		}
91 91
 
92 92
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 			global $wpdb;
101 101
 
102 102
 			//Take pivotal from URL
103
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
103
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
104 104
 
105 105
 			//Build the db query base
106 106
 			$sql = "SELECT COUNT(*) FROM {$wpdb->prefix}wordpress_table";
107 107
 			$sql .= " QUERIES with $link'";
108 108
 
109
-			return $wpdb->get_var( $sql );
109
+			return $wpdb->get_var($sql);
110 110
 		}
111 111
 
112 112
 
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 		 *
116 116
 		 * @return Html
117 117
 		 */
118
-		public function column_name( $item ) {
118
+		public function column_name($item) {
119 119
 
120
-			$delete_nonce = wp_create_nonce( 'delete_url' );
121
-			$title = sprintf( '<strong>%s</strong>', $item['item_name'] );
120
+			$delete_nonce = wp_create_nonce('delete_url');
121
+			$title = sprintf('<strong>%s</strong>', $item['item_name']);
122 122
 
123 123
 			//Change the page instruction where you want to show it
124 124
 			$actions = array(
125
-					'delete' => sprintf( '<a href="?page=%s&action=%s&instruction=%s&_wpnonce=%s">%s</a>', esc_attr( $_REQUEST['page'] ), 'delete', absint( $item['ID'] ), $delete_nonce, __( 'Delete', 'textdomain' ) )
125
+					'delete' => sprintf('<a href="?page=%s&action=%s&instruction=%s&_wpnonce=%s">%s</a>', esc_attr($_REQUEST['page']), 'delete', absint($item['ID']), $delete_nonce, __('Delete', 'textdomain'))
126 126
 					);
127 127
 
128
-			return $title . $this->row_actions( $actions );
128
+			return $title . $this->row_actions($actions);
129 129
 		}
130 130
 
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 		 *
135 135
 		 * @return Html
136 136
 		 */
137
-		public function column_default( $item, $column_name ) {
137
+		public function column_default($item, $column_name) {
138 138
 
139
-			switch ( $column_name ) {
139
+			switch ($column_name) {
140 140
 
141 141
 				case 'name':
142 142
 					//This is the first column
143
-					return $this->column_name( $item );
143
+					return $this->column_name($item);
144 144
 				case 'caseOne':
145 145
 				case 'caseTwo':
146 146
 				case 'caseThree':
147
-					return $item[ $column_name ];
147
+					return $item[$column_name];
148 148
 
149 149
 				default:
150 150
 
151 151
 					//Show the whole array for troubleshooting purposes
152
-					return print_r( $item, true );
152
+					return print_r($item, true);
153 153
 			}
154 154
 		}
155 155
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @return Html
161 161
 		 */
162
-		public function column_cb( $item ) {
162
+		public function column_cb($item) {
163 163
 
164
-			return sprintf( '<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID'] );
164
+			return sprintf('<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID']);
165 165
 		}
166 166
 
167 167
 
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 
175 175
 			$columns = array(
176 176
 							'cb'		=> '<input type="checkbox" />',
177
-							'name'	=> __( 'Name', 'textdomain' ),
178
-							'caseOne'	=> __( 'Case One', 'textdomain' ),
179
-							'caseTwo'	=> __( 'Case Two', 'textdomain' ),
180
-							'caseThree'	=> __( 'Case Three', 'textdomain' ),
177
+							'name'	=> __('Name', 'textdomain'),
178
+							'caseOne'	=> __('Case One', 'textdomain'),
179
+							'caseTwo'	=> __('Case Two', 'textdomain'),
180
+							'caseThree'	=> __('Case Three', 'textdomain'),
181 181
 						);
182 182
 
183 183
 			return $columns;
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 		public function get_sortable_columns() {
193 193
 
194 194
 			$sortable_columns = array(
195
-				'name' => array( 'name', true ),
196
-				'caseOne' => array( 'caseOne', false ),
197
-				'caseTwo' => array( 'caseTwo', false ),
195
+				'name' => array('name', true),
196
+				'caseOne' => array('caseOne', false),
197
+				'caseTwo' => array('caseTwo', false),
198 198
 			);
199 199
 
200 200
 			return $sortable_columns;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		 */
209 209
 		public function get_bulk_actions() {
210 210
 
211
-			$actions = array( 'bulk-delete' => 'Delete'	);
211
+			$actions = array('bulk-delete' => 'Delete');
212 212
 
213 213
 			return $actions;
214 214
 		}
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 
226 226
 			/** Process bulk action */
227 227
 			$this->process_bulk_action();
228
-			$per_page     = $this->get_items_per_page( 'option_name_per_page', 5 );
228
+			$per_page     = $this->get_items_per_page('option_name_per_page', 5);
229 229
 			$current_page = $this->get_pagenum();
230 230
 			$total_items  = self::record_count();
231
-			$this->set_pagination_args( array(
231
+			$this->set_pagination_args(array(
232 232
 				'total_items' => $total_items,
233 233
 				'per_page'    => $per_page,
234
-			) );
234
+			));
235 235
 
236
-			$this->items = self::get_Table( $per_page, $current_page );
236
+			$this->items = self::get_Table($per_page, $current_page);
237 237
 		}
238 238
 
239 239
 
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 		public function process_bulk_action() {
246 246
 
247 247
 			//Detect when a bulk action is being triggered...
248
-			if ( 'delete' === $this->current_action() ) {
248
+			if ('delete' === $this->current_action()) {
249 249
 
250 250
 				//In our file that handles the request, verify the nonce.
251
-				$nonce = esc_attr( $_REQUEST['_wpnonce'] );
251
+				$nonce = esc_attr($_REQUEST['_wpnonce']);
252 252
 
253
-				if ( ! wp_verify_nonce( $nonce, 'delete_url' ) ) {
254
-					die( 'Go get a live script kiddies' );
253
+				if ( ! wp_verify_nonce($nonce, 'delete_url')) {
254
+					die('Go get a live script kiddies');
255 255
 				} else {
256
-					self::delete_url( absint( $_GET['instruction'] ) ); //Remember the instruction param from column_name method
256
+					self::delete_url(absint($_GET['instruction'])); //Remember the instruction param from column_name method
257 257
 				}
258 258
 			}
259 259
 
260 260
 			//If the delete bulk action is triggered
261
-			if ( isset( $_POST['action'] ) ) {
262
-				if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' ) ) {
263
-					$delete_ids = esc_sql( $_POST['bulk-select'] );
264
-					foreach ( $delete_ids as $id ) {
265
-						self::delete_url( $id );
261
+			if (isset($_POST['action'])) {
262
+				if ((isset($_POST['action']) && $_POST['action'] == 'bulk-delete')) {
263
+					$delete_ids = esc_sql($_POST['bulk-select']);
264
+					foreach ($delete_ids as $id) {
265
+						self::delete_url($id);
266 266
 					}
267 267
 				}
268 268
 			}
Please login to merge, or discard this patch.
lib/ajax.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
  * @version    1.2.1
8 8
  * @package    wp-plugin-framework
9 9
  */
10
-if ( ! defined( 'ABSPATH' ) ) exit;
10
+if ( ! defined('ABSPATH')) exit;
11 11
 
12 12
 //AJAX helper class
13
-if ( ! class_exists( 'PLUGIN_AJAX' ) ) {
13
+if ( ! class_exists('PLUGIN_AJAX')) {
14 14
 
15 15
 	final class PLUGIN_AJAX {
16 16
 
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 		 */
23 23
 		public function __construct() {
24 24
 
25
-			add_action( 'wp_footer', array( $this, 'custom_name_js' ) );
26
-			add_action( 'wp_ajax_custom_name', array( $this, 'custom_name' ) );
27
-			add_action( 'wp_ajax_nopriv_custom_name', array( $this, 'custom_name' ) );
25
+			add_action('wp_footer', array($this, 'custom_name_js'));
26
+			add_action('wp_ajax_custom_name', array($this, 'custom_name'));
27
+			add_action('wp_ajax_nopriv_custom_name', array($this, 'custom_name'));
28 28
 		}
29 29
 
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		public function form() { ?>
37 37
 
38 38
 			<form id="add_by_ajax" method="POST" action="">
39
-				<input type="text" name="text_name" placeholder="<?php _e( 'Text', 'textdomain' ); ?>">
39
+				<input type="text" name="text_name" placeholder="<?php _e('Text', 'textdomain'); ?>">
40 40
 				<input id="ajax_submit" type="submit" name="submit" value="Submit">
41 41
 			</form>
42 42
 			<?php
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 
90 90
 			// DO some stuff
91 91
 
92
-			$response = array( 'val' => $value );
93
-			echo json_encode( $response );
92
+			$response = array('val' => $value);
93
+			echo json_encode($response);
94 94
 			wp_die();
95 95
 		}
96 96
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
  * @version    1.2.1
8 8
  * @package    wp-plugin-framework
9 9
  */
10
-if ( ! defined( 'ABSPATH' ) ) exit;
10
+if ( ! defined( 'ABSPATH' ) ) {
11
+	exit;
12
+}
11 13
 
12 14
 //AJAX helper class
13 15
 if ( ! class_exists( 'PLUGIN_AJAX' ) ) {
Please login to merge, or discard this patch.
lib/script.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@  discard block
 block discarded – undo
6 6
  * @version    1.2.1
7 7
  * @package    wp-plugin-framework
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) exit;
9
+if ( ! defined('ABSPATH')) exit;
10 10
 
11
-if ( ! class_exists( 'PLUGIN_SCRIPT' ) ) {
11
+if ( ! class_exists('PLUGIN_SCRIPT')) {
12 12
 
13 13
 	final class PLUGIN_SCRIPT {
14 14
 
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 		 */
21 21
 		public function __construct() {
22 22
 
23
-			add_action( 'admin_head', array( $this, 'data_table_css' ) );
24
-			add_action( 'admin_enqueue_scripts', array( $this, 'backend_scripts' ) );
25
-			add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
23
+			add_action('admin_head', array($this, 'data_table_css'));
24
+			add_action('admin_enqueue_scripts', array($this, 'backend_scripts'));
25
+			add_action('wp_enqueue_scripts', array($this, 'frontend_scripts'));
26 26
 		}
27 27
 
28 28
 
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 			// Set condition to add script
55 55
 			// if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'pageName' ) return;
56 56
 
57
-			wp_enqueue_script( 'jsName', PLUGIN_JS . 'ui.js', array() );
58
-			wp_localize_script( 'jsName', 'ajax', array( 'ajax_url' => admin_url('admin-ajax.php') ) );
57
+			wp_enqueue_script('jsName', PLUGIN_JS . 'ui.js', array());
58
+			wp_localize_script('jsName', 'ajax', array('ajax_url' => admin_url('admin-ajax.php')));
59 59
 
60
-			wp_enqueue_style( 'cssName', PLUGIN_CSS . 'css.css' );
60
+			wp_enqueue_style('cssName', PLUGIN_CSS . 'css.css');
61 61
 		}
62 62
 
63 63
 
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 		 */
69 69
 		public function frontend_scripts() {
70 70
 
71
-			wp_enqueue_script( 'jsName', PLUGIN_JS . 'ui.js', array() );
72
-			wp_localize_script( 'jsName', 'ajax', array( 'ajax_url' => admin_url('admin-ajax.php') ) );
71
+			wp_enqueue_script('jsName', PLUGIN_JS . 'ui.js', array());
72
+			wp_localize_script('jsName', 'ajax', array('ajax_url' => admin_url('admin-ajax.php')));
73 73
 
74
-			wp_enqueue_style( 'cssName', PLUGIN_CSS . 'css.css' );
74
+			wp_enqueue_style('cssName', PLUGIN_CSS . 'css.css');
75 75
 		}
76 76
 	}
77 77
 } ?>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@
 block discarded – undo
6 6
  * @version    1.2.1
7 7
  * @package    wp-plugin-framework
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) exit;
9
+if ( ! defined( 'ABSPATH' ) ) {
10
+	exit;
11
+}
10 12
 
11 13
 if ( ! class_exists( 'PLUGIN_SCRIPT' ) ) {
12 14
 
Please login to merge, or discard this patch.
src/settings.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 					break;
165 165
 			}
166 166
 
167
-    		if ( $output ) return $output; // Related to PLUGIN_TABLE()
167
+			if ( $output ) return $output; // Related to PLUGIN_TABLE()
168 168
 		}
169 169
 
170 170
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			echo '<textarea name="settings_field_name" id="settings_field_name" value="' . get_option('settings_field_name') . '>'. __( 'Enter Value', 'textdomain' ) . '</textarea>';
280 280
 			echo '<select name="settings_field_name" id="settings_field_name"><option value="value" ' . selected( 'value', get_option('settings_field_name'), false) . '>Value</option></select>';
281 281
 			echo '<input type="checkbox" id="settings_field_name" name="settings_field_name" value="1"' . checked( 1, get_option('settings_field_name'), false ) . '/>';
282
-			*/
282
+			 */
283 283
 		}
284 284
 	}
285 285
 } ?>
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version    1.2.1
9 9
  * @package    wp-plugin-framework
10 10
  */
11
-if ( ! class_exists( 'PLUGIN_SETTINGS' ) ) {
11
+if ( ! class_exists('PLUGIN_SETTINGS')) {
12 12
 
13 13
 	final class PLUGIN_SETTINGS {
14 14
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 		public function __construct() {
58 58
 
59 59
 			$this->capability = 'manage_options';
60
-			$this->menu_page = array( 'name' => '', 'heading' => '', 'slug' => '' );
60
+			$this->menu_page = array('name' => '', 'heading' => '', 'slug' => '');
61 61
 			$this->sub_menu_page = array(
62 62
 									'name' => '',
63 63
 									'heading' => '',
64 64
 									'slug' => '',
65 65
 									'parent_slug' => '',
66
-									'help' => '',//true/false,
67
-									'screen' => '',//true/false
66
+									'help' => '', //true/false,
67
+									'screen' => '', //true/false
68 68
 								);
69 69
 			$this->helpData = array(
70 70
 								array(
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 											'info' => array(
74 74
 														array(
75 75
 															'id' => 'helpId',
76
-															'title' => __( 'Title', 'textdomain' ),
77
-															'content' => __( 'Description', 'textdomain' ),
76
+															'title' => __('Title', 'textdomain'),
77
+															'content' => __('Description', 'textdomain'),
78 78
 														),
79 79
 													),
80
-											'link' => '<p><a href="#">' . __( 'helpLink', 'textdomain' ) . '</a></p>',
80
+											'link' => '<p><a href="#">' . __('helpLink', 'textdomain') . '</a></p>',
81 81
 											)
82 82
 								)
83 83
 							);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 					$this->menu_page['heading'],
109 109
 					$this->capability,
110 110
 					$this->menu_page['slug'],
111
-					array( $this, 'menu_page_callback' )
111
+					array($this, 'menu_page_callback')
112 112
 				);
113 113
 			}
114 114
 		}
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 		 */
122 122
 		public function sub_menu_page() {
123 123
 
124
-			if ( $this->sub_menu_page ) {
125
-				foreach ( $this->sub_menu_page as $page ) {
124
+			if ($this->sub_menu_page) {
125
+				foreach ($this->sub_menu_page as $page) {
126 126
 					$hook = add_submenu_page(
127 127
 							$page['parent_slug'],
128 128
 							$page['name'],
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 							// For the first submenu page, slug should be same as menupage.
132 132
 							$page['slug'],
133 133
 							// For the first submenu page, callback should be same as menupage.
134
-							array( $this, 'menu_page_callback' )
134
+							array($this, 'menu_page_callback')
135 135
 						);
136
-					if ( $page['help'] ) {
137
-						add_action( 'load-' . $hook, array( $this, 'help_tabs' ) );
136
+					if ($page['help']) {
137
+						add_action('load-' . $hook, array($this, 'help_tabs'));
138 138
 					}
139
-					if ( $page['screen'] ) {
140
-						add_action( 'load-' . $hook, array( $this, 'screen_option' ) );
139
+					if ($page['screen']) {
140
+						add_action('load-' . $hook, array($this, 'screen_option'));
141 141
 					}
142 142
 				}
143 143
 			}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 					break;
165 165
 			}
166 166
 
167
-    		if ( $output ) return $output; // Related to PLUGIN_TABLE()
167
+    		if ($output) return $output; // Related to PLUGIN_TABLE()
168 168
 		}
169 169
 
170 170
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
 			$option = 'per_page';
179 179
 			$args   = array(
180
-						'label'   => __( 'Show per page', 'textdomain' ),
180
+						'label'   => __('Show per page', 'textdomain'),
181 181
 						'default' => 10,
182 182
 						'option'  => 'option_name_per_page' // Related to PLUGIN_TABLE()
183 183
 						);
184
-			add_screen_option( $option, $args );
184
+			add_screen_option($option, $args);
185 185
 			$this->table = new PLUGIN_TABLE(); // Source /lib/table.php
186 186
 		}
187 187
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 					<form method="post" action="">
205 205
 						<?php settings_fields("settings_id");
206 206
 						do_settings_sections("settings_name");
207
-						submit_button( __( 'Save', 'textdomain' ), 'primary', 'id' ); ?>
207
+						submit_button(__('Save', 'textdomain'), 'primary', 'id'); ?>
208 208
 					</form>
209 209
 
210 210
 					<?php
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 			foreach ($this->helpData as $value) {
233 233
 				if ($_GET['page'] == $value['slug']) {
234 234
 					$this->screen = get_current_screen();
235
-					foreach( $value['info'] as $key ) {
236
-						$this->screen->add_help_tab( $key );
235
+					foreach ($value['info'] as $key) {
236
+						$this->screen->add_help_tab($key);
237 237
 					}
238
-					$this->screen->set_help_sidebar( $value['link'] );
238
+					$this->screen->set_help_sidebar($value['link']);
239 239
 				}
240 240
 			}
241 241
 		}
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 		 */
249 249
 		public function add_settings() {
250 250
 
251
-			add_settings_section( 'settings_id', __( 'Section Name', 'textdomain' ), array( $this,'section_cb' ), 'settings_name' );
251
+			add_settings_section('settings_id', __('Section Name', 'textdomain'), array($this, 'section_cb'), 'settings_name');
252 252
 
253
-			register_setting( 'settings_id', 'settings_field_name' );
254
-			add_settings_field( 'settings_field_name', __( 'Field Name', 'textdomain' ), array( $this, 'settings_field_cb' ), 'settings_name', 'settings_id' );
253
+			register_setting('settings_id', 'settings_field_name');
254
+			add_settings_field('settings_field_name', __('Field Name', 'textdomain'), array($this, 'settings_field_cb'), 'settings_name', 'settings_id');
255 255
 		}
256 256
 
257 257
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		 */
263 263
 		public function section_cb() {
264 264
 
265
-			echo '<p class="description">' . __( 'Set up settings', 'textdomain' ) . '</p>';
265
+			echo '<p class="description">' . __('Set up settings', 'textdomain') . '</p>';
266 266
 		}
267 267
 
268 268
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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
@@ -164,7 +166,10 @@  discard block
 block discarded – undo
164 166
 					break;
165 167
 			}
166 168
 
167
-    		if ( $output ) return $output; // Related to PLUGIN_TABLE()
169
+    		if ( $output ) {
170
+    			return $output;
171
+    		}
172
+    		// Related to PLUGIN_TABLE()
168 173
 		}
169 174
 
170 175
 
Please login to merge, or discard this patch.
src/metabox.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,12 +64,12 @@
 block discarded – undo
64 64
 
65 65
 
66 66
 		/**
67
- 	    * Save the Metabox post data
68
- 		*
69
- 		* @param Array $atts
70
- 		*
71
- 		* @return Html
72
- 		*/
67
+		 * Save the Metabox post data
68
+		 *
69
+		 * @param Array $atts
70
+		 *
71
+		 * @return Html
72
+		 */
73 73
 		function save( $post_id, $post ) {
74 74
 
75 75
 			//Check if doing autosave
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version    1.2.1
9 9
  * @package    wp-plugin-framework
10 10
  */
11
-if ( ! class_exists( 'PLUGIN_METABOX' ) ) {
11
+if ( ! class_exists('PLUGIN_METABOX')) {
12 12
 
13 13
 	final class PLUGIN_METABOX {
14 14
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 		public function __construct() {
22 22
 
23 23
 			//Adding the metabox. For custom post type use "add_meta_boxes_posttype" action
24
-			add_action( 'add_meta_boxes', array( $this, 'register' ) );
25
-			add_action( 'save_post', array( $this, 'save' ), 10, 2 );
24
+			add_action('add_meta_boxes', array($this, 'register'));
25
+			add_action('save_post', array($this, 'save'), 10, 2);
26 26
 		}
27 27
 
28 28
 
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 
36 36
 			add_meta_box(
37 37
 				'meta-box-id',
38
-				esc_html__( 'MetaBox Title', 'textdomain' ),
39
-				array( $this, 'render' ),
38
+				esc_html__('MetaBox Title', 'textdomain'),
39
+				array($this, 'render'),
40 40
 				// Declare the post type to show meta box
41 41
 				'post_type',
42 42
 				'normal',
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 		 */
53 53
 		public function render() {
54 54
 
55
-			wp_nonce_field( basename( __FILE__ ), 'metabox_name_nonce' ); ?>
55
+			wp_nonce_field(basename(__FILE__), 'metabox_name_nonce'); ?>
56 56
 
57 57
 			<p>
58
-				<label for="metabox_name"><?php _e( "Custom Text", 'textdomain' ); ?></label>
58
+				<label for="metabox_name"><?php _e("Custom Text", 'textdomain'); ?></label>
59 59
     			<br />
60
-    			<input class="widefat" type="text" name="metabox_field_name" id="metabox_field_name" value="<?php echo esc_attr( get_post_meta( $object->ID, 'metabox_name', true ) ); ?>" />
60
+    			<input class="widefat" type="text" name="metabox_field_name" id="metabox_field_name" value="<?php echo esc_attr(get_post_meta($object->ID, 'metabox_name', true)); ?>" />
61 61
   			</p>
62 62
   			<?php
63 63
 		}
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
  		*
71 71
  		* @return Html
72 72
  		*/
73
-		function save( $post_id, $post ) {
73
+		function save($post_id, $post) {
74 74
 
75 75
 			//Check if doing autosave
76
-			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
76
+			if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
77 77
 
78 78
 			//Verify the nonce before proceeding.
79
-			if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return;
79
+			if ( ! isset($_POST['metabox_name_nonce']) || ! wp_verify_nonce($_POST['metabox_name_nonce'], basename(__FILE__))) return;
80 80
 
81 81
 			//Get the post type object.
82
-			$post_type = get_post_type_object( $post->post_type );
82
+			$post_type = get_post_type_object($post->post_type);
83 83
 
84 84
 			//Check if the current user has permission to edit the post.
85
-			if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id;
85
+			if ( ! current_user_can($post_type->cap->edit_post, $post_id)) return $post_id;
86 86
 
87
-			if ( isset( $_POST['metabox_field_name'] ) ) {
88
-				update_post_meta( $post_id, 'metabox_field_name', sanitize_text_field($_POST['metabox_field_name']) );
87
+			if (isset($_POST['metabox_field_name'])) {
88
+				update_post_meta($post_id, 'metabox_field_name', sanitize_text_field($_POST['metabox_field_name']));
89 89
 			}
90 90
 		}
91 91
 	}
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
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
@@ -73,16 +75,22 @@  discard block
 block discarded – undo
73 75
 		function save( $post_id, $post ) {
74 76
 
75 77
 			//Check if doing autosave
76
-			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
78
+			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
79
+				return;
80
+			}
77 81
 
78 82
 			//Verify the nonce before proceeding.
79
-			if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return;
83
+			if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) {
84
+				return;
85
+			}
80 86
 
81 87
 			//Get the post type object.
82 88
 			$post_type = get_post_type_object( $post->post_type );
83 89
 
84 90
 			//Check if the current user has permission to edit the post.
85
-			if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id;
91
+			if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
92
+				return $post_id;
93
+			}
86 94
 
87 95
 			if ( isset( $_POST['metabox_field_name'] ) ) {
88 96
 				update_post_meta( $post_id, 'metabox_field_name', sanitize_text_field($_POST['metabox_field_name']) );
Please login to merge, or discard this patch.