Passed
Push — master ( 6f98fc...d232f0 )
by Nirjhar
09:26
created
plugin/Src/Widget.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 use WP_WIDGET as WP_WIDGET;
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if ( ! defined('ABSPATH')) exit;
7 7
 
8 8
 /**
9 9
  * Widget class
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author     Nirjhar Lo
12 12
  * @package    wp-plugin-framework
13 13
  */
14
-if ( ! class_exists( 'Widget' ) ) {
14
+if ( ! class_exists('Widget')) {
15 15
 
16 16
 	final class Widget extends WP_WIDGET {
17 17
 
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 			$widget_ops = array(
27 27
 							'classname' => 'plugin_widget',
28
-							'description' => __( 'Plugin widget', 'textdomain' ),
28
+							'description' => __('Plugin widget', 'textdomain'),
29 29
 							);
30
-			parent::__construct( 'my_widget_id', __( 'Plugin widget', 'textdomain' ), $widget_ops );
30
+			parent::__construct('my_widget_id', __('Plugin widget', 'textdomain'), $widget_ops);
31 31
 		}
32 32
 
33 33
 
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		 *
40 40
 		 * @return Html
41 41
 		 */
42
-		public function widget( $args, $instance ) {
42
+		public function widget($args, $instance) {
43 43
 
44 44
 			echo $args['before_widget'];
45
-			if ( ! empty( $instance['title'] ) ) {
46
-				echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
45
+			if ( ! empty($instance['title'])) {
46
+				echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
47 47
 			}
48
-			echo esc_html__( 'Hello, World!', 'textdomain' );
48
+			echo esc_html__('Hello, World!', 'textdomain');
49 49
 			echo $args['after_widget'];
50 50
 		}
51 51
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 		 *
58 58
 		 * @return Html
59 59
 		 */
60
-		public function form( $instance ) {
60
+		public function form($instance) {
61 61
 
62
-			$title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Internal Link Master', 'textdomain' ); ?>
62
+			$title = ! empty($instance['title']) ? $instance['title'] : esc_html__('Internal Link Master', 'textdomain'); ?>
63 63
 			<p>
64
-				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'textdomain' ); ?></label>
65
-				<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
64
+				<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:', 'textdomain'); ?></label>
65
+				<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>">
66 66
 			</p>
67 67
 		<?php
68 68
 		}
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 		 *
77 77
 		 * @return Array
78 78
 		 */
79
-		public function update( $new_instance, $old_instance ) {
79
+		public function update($new_instance, $old_instance) {
80 80
 
81 81
 			$instance = array();
82
-			$instance['title'] = ( ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '' );
82
+			$instance['title'] = ( ! empty($new_instance['title']) ? sanitize_text_field($new_instance['title']) : '');
83 83
 			return $instance;
84 84
 		}
85 85
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,9 @@
 block discarded – undo
3 3
 
4 4
 use WP_WIDGET as WP_WIDGET;
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if ( ! defined( 'ABSPATH' ) ) {
7
+	exit;
8
+}
7 9
 
8 10
 /**
9 11
  * Widget class
Please login to merge, or discard this patch.
plugin/Src/Db.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@
 block discarded – undo
44 44
 			global $wpdb;
45 45
 			$wpdb->hide_errors();
46 46
 			$collate = "";
47
-		    if ( $wpdb->has_cap( 'collation' ) ) {
47
+			if ( $wpdb->has_cap( 'collation' ) ) {
48 48
 				if( ! empty($wpdb->charset ) )
49 49
 					$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
50 50
 				if( ! empty($wpdb->collate ) )
51 51
 					$collate .= " COLLATE $wpdb->collate";
52
-		    }
53
-    		require_once( $this->up_path );
52
+			}
53
+			require_once( $this->up_path );
54 54
 			return $collate;
55 55
 		}
56 56
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace NirjharLo\WP_Plugin_Framework\Src;
3 3
 
4
-if ( ! defined( 'ABSPATH' ) ) exit;
4
+if ( ! defined('ABSPATH')) exit;
5 5
 
6 6
 /**
7 7
  * DB installation class
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @author     Nirjhar Lo
10 10
  * @package    wp-plugin-framework
11 11
  */
12
-if ( ! class_exists( 'Db' ) ) {
12
+if ( ! class_exists('Db')) {
13 13
 
14 14
 	class Db {
15 15
 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 			global $wpdb;
47 47
 			$wpdb->hide_errors();
48 48
 			$this->table_name = $wpdb->prefix . $this->table;
49
-			update_option( '_plugin_db_exist', 0 );
50
-			if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->table_name'" ) != $this->table_name ) {
51
-				$execute_sql = $this->execute( $this->table_name, $this->collate(), $this->sql );
52
-				dbDelta( $execute_sql );
49
+			update_option('_plugin_db_exist', 0);
50
+			if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") != $this->table_name) {
51
+				$execute_sql = $this->execute($this->table_name, $this->collate(), $this->sql);
52
+				dbDelta($execute_sql);
53 53
 			}
54 54
 		}
55 55
 
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
 			global $wpdb;
65 65
 			$wpdb->hide_errors();
66 66
 			$collate = "";
67
-		    if ( $wpdb->has_cap( 'collation' ) ) {
68
-				if( ! empty($wpdb->charset ) )
67
+		    if ($wpdb->has_cap('collation')) {
68
+				if ( ! empty($wpdb->charset))
69 69
 					$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
70
-				if( ! empty($wpdb->collate ) )
70
+				if ( ! empty($wpdb->collate))
71 71
 					$collate .= " COLLATE $wpdb->collate";
72 72
 		    }
73
-    		require_once( $this->up_path );
73
+    		require_once($this->up_path);
74 74
 			return $collate;
75 75
 		}
76 76
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		 *
85 85
 		 * @return String
86 86
 		 */
87
-		public function execute( $table_name, $collate, $sql ) {
87
+		public function execute($table_name, $collate, $sql) {
88 88
 
89 89
 			return "CREATE TABLE $table_name ( $sql ) $collate;";
90 90
 		}
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 			global $wpdb;
101 101
 
102 102
 			$this->table_name = $wpdb->prefix . $this->table;
103
-			if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->table_name'" ) == $this->table_name ) {
103
+			if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") == $this->table_name) {
104 104
 
105
-				update_option( '_plugin_db_exist', 1 );
105
+				update_option('_plugin_db_exist', 1);
106 106
 			}
107 107
 		}
108 108
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace NirjharLo\WP_Plugin_Framework\Src;
3 3
 
4
-if ( ! defined( 'ABSPATH' ) ) exit;
4
+if ( ! defined( 'ABSPATH' ) ) {
5
+	exit;
6
+}
5 7
 
6 8
 /**
7 9
  * DB installation class
@@ -65,10 +67,12 @@  discard block
 block discarded – undo
65 67
 			$wpdb->hide_errors();
66 68
 			$collate = "";
67 69
 		    if ( $wpdb->has_cap( 'collation' ) ) {
68
-				if( ! empty($wpdb->charset ) )
69
-					$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
70
-				if( ! empty($wpdb->collate ) )
71
-					$collate .= " COLLATE $wpdb->collate";
70
+				if( ! empty($wpdb->charset ) ) {
71
+									$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
72
+				}
73
+				if( ! empty($wpdb->collate ) ) {
74
+									$collate .= " COLLATE $wpdb->collate";
75
+				}
72 76
 		    }
73 77
     		require_once( $this->up_path );
74 78
 			return $collate;
Please login to merge, or discard this patch.
plugin/Lib/Table.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 if ( ! class_exists( 'Table' ) ) {
15 15
 
16 16
 	if ( ! class_exists( 'WP_List_Table' ) ) {
17
-    	require_once( ABSPATH . 'wp-admin/includes/screen.php' );
18
-    	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
17
+		require_once( ABSPATH . 'wp-admin/includes/screen.php' );
18
+		require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
19 19
 	}
20 20
 
21 21
 	final class Table extends WP_List_Table {
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 			$current_page = $this->get_pagenum();
231 231
 			$total_items  = self::record_count();
232 232
 			$this->_column_headers = [
233
-    			$this->get_columns(),
234
-    			[], // hidden columns
235
-    			$this->get_sortable_columns(),
236
-    			$this->get_primary_column_name(),
233
+				$this->get_columns(),
234
+				[], // hidden columns
235
+				$this->get_sortable_columns(),
236
+				$this->get_primary_column_name(),
237 237
 			];
238 238
 			$this->set_pagination_args( array(
239 239
 				'total_items' => $total_items,
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  * @author     Nirjhar Lo
12 12
  * @package    wp-plugin-framework
13 13
  */
14
-if ( ! class_exists( 'Table' ) ) {
14
+if ( ! class_exists('Table')) {
15 15
 
16
-	if ( ! class_exists( 'WP_List_Table' ) ) {
17
-    	require_once( ABSPATH . 'wp-admin/includes/screen.php' );
18
-    	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
16
+	if ( ! class_exists('WP_List_Table')) {
17
+    	require_once(ABSPATH . 'wp-admin/includes/screen.php');
18
+    	require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
19 19
 	}
20 20
 
21 21
 	final class Table extends WP_List_Table {
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 		 */
29 29
 		public function __construct() {
30 30
 
31
-			parent::__construct( [
32
-				'singular' => __( 'Name', 'textdomain' ),
33
-				'plural'   => __( 'Names', 'textdomain' ),
31
+			parent::__construct([
32
+				'singular' => __('Name', 'textdomain'),
33
+				'plural'   => __('Names', 'textdomain'),
34 34
 				'ajax'     => false,
35
-			] );
35
+			]);
36 36
 		}
37 37
 
38 38
 
@@ -41,27 +41,27 @@  discard block
 block discarded – undo
41 41
 		 *
42 42
 		 * @return Array
43 43
 		 */
44
-		public static function get_Table( $per_page = 5, $page_number = 1 ) {
44
+		public static function get_Table($per_page = 5, $page_number = 1) {
45 45
 
46 46
 			global $wpdb;
47 47
 
48 48
 			//Take pivotal from URL
49
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
49
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
50 50
 
51 51
 			//Build the db query base
52 52
 			$sql = "SELECT * FROM {$wpdb->prefix}wordpress_table";
53 53
 			$sql .= " QUERIES with $link'";
54 54
 
55 55
 			//Set filters in the query using $_REQUEST
56
-			if ( ! empty( $_REQUEST['orderby'] ) ) {
57
-				$sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] );
58
-				$sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC';
56
+			if ( ! empty($_REQUEST['orderby'])) {
57
+				$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
58
+				$sql .= ! empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
59 59
 			}
60 60
 			$sql .= " LIMIT $per_page";
61
-			$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
61
+			$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
62 62
 
63 63
 			//get the data from database
64
-			$result = $wpdb->get_results( $sql, 'ARRAY_A' );
64
+			$result = $wpdb->get_results($sql, 'ARRAY_A');
65 65
 
66 66
 			return $result;
67 67
 		}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 		 *
73 73
 		 * @return Void
74 74
 		 */
75
-		public static function delete_url( $id ) {
75
+		public static function delete_url($id) {
76 76
 
77 77
 			global $wpdb;
78 78
 
79
-			$wpdb->delete( "{$wpdb->prefix}wordpress_table", array( 'ID' => $id ), array( '%s' ) );
79
+			$wpdb->delete("{$wpdb->prefix}wordpress_table", array('ID' => $id), array('%s'));
80 80
 		}
81 81
 
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		 */
88 88
 		public function no_items() {
89 89
 
90
-			_e( 'No Items Added yet.', 'textDomain' );
90
+			_e('No Items Added yet.', 'textDomain');
91 91
 		}
92 92
 
93 93
 
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 			global $wpdb;
102 102
 
103 103
 			//Take pivotal from URL
104
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
104
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
105 105
 
106 106
 			//Build the db query base
107 107
 			$sql = "SELECT COUNT(*) FROM {$wpdb->prefix}wordpress_table";
108 108
 			$sql .= " QUERIES with $link'";
109 109
 
110
-			return $wpdb->get_var( $sql );
110
+			return $wpdb->get_var($sql);
111 111
 		}
112 112
 
113 113
 
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 		 *
117 117
 		 * @return Html
118 118
 		 */
119
-		public function column_name( $item ) {
119
+		public function column_name($item) {
120 120
 
121
-			$delete_nonce = wp_create_nonce( 'delete_url' );
122
-			$title = sprintf( '<strong>%s</strong>', $item['item_name'] );
121
+			$delete_nonce = wp_create_nonce('delete_url');
122
+			$title = sprintf('<strong>%s</strong>', $item['item_name']);
123 123
 
124 124
 			//Change the page instruction where you want to show it
125 125
 			$actions = array(
126
-					'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
+					'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'))
127 127
 					);
128 128
 
129
-			return $title . $this->row_actions( $actions );
129
+			return $title . $this->row_actions($actions);
130 130
 		}
131 131
 
132 132
 
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @return Html
137 137
 		 */
138
-		public function column_default( $item, $column_name ) {
138
+		public function column_default($item, $column_name) {
139 139
 
140
-			switch ( $column_name ) {
140
+			switch ($column_name) {
141 141
 
142 142
 				case 'name':
143 143
 					//This is the first column
144
-					return $this->column_name( $item );
144
+					return $this->column_name($item);
145 145
 				case 'caseOne':
146 146
 				case 'caseTwo':
147 147
 				case 'caseThree':
148
-					return $item[ $column_name ];
148
+					return $item[$column_name];
149 149
 
150 150
 				default:
151 151
 
152 152
 					//Show the whole array for troubleshooting purposes
153
-					return print_r( $item, true );
153
+					return print_r($item, true);
154 154
 			}
155 155
 		}
156 156
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 		 *
161 161
 		 * @return Html
162 162
 		 */
163
-		public function column_cb( $item ) {
163
+		public function column_cb($item) {
164 164
 
165
-			return sprintf( '<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID'] );
165
+			return sprintf('<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID']);
166 166
 		}
167 167
 
168 168
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 
176 176
 			$columns = array(
177 177
 							'cb'		=> '<input type="checkbox" />',
178
-							'name'	=> __( 'Name', 'textdomain' ),
179
-							'caseOne'	=> __( 'Case One', 'textdomain' ),
180
-							'caseTwo'	=> __( 'Case Two', 'textdomain' ),
181
-							'caseThree'	=> __( 'Case Three', 'textdomain' ),
178
+							'name'	=> __('Name', 'textdomain'),
179
+							'caseOne'	=> __('Case One', 'textdomain'),
180
+							'caseTwo'	=> __('Case Two', 'textdomain'),
181
+							'caseThree'	=> __('Case Three', 'textdomain'),
182 182
 						);
183 183
 
184 184
 			return $columns;
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 		public function get_sortable_columns() {
194 194
 
195 195
 			$sortable_columns = array(
196
-				'name' => array( 'name', true ),
197
-				'caseOne' => array( 'caseOne', false ),
198
-				'caseTwo' => array( 'caseTwo', false ),
196
+				'name' => array('name', true),
197
+				'caseOne' => array('caseOne', false),
198
+				'caseTwo' => array('caseTwo', false),
199 199
 			);
200 200
 
201 201
 			return $sortable_columns;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		 */
210 210
 		public function get_bulk_actions() {
211 211
 
212
-			$actions = array( 'bulk-delete' => 'Delete'	);
212
+			$actions = array('bulk-delete' => 'Delete');
213 213
 
214 214
 			return $actions;
215 215
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 			/** Process bulk action */
228 228
 			$this->process_bulk_action();
229
-			$per_page     = $this->get_items_per_page( 'option_name_per_page', 5 );
229
+			$per_page     = $this->get_items_per_page('option_name_per_page', 5);
230 230
 			$current_page = $this->get_pagenum();
231 231
 			$total_items  = self::record_count();
232 232
 			$this->_column_headers = [
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
     			$this->get_sortable_columns(),
236 236
     			$this->get_primary_column_name(),
237 237
 			];
238
-			$this->set_pagination_args( array(
238
+			$this->set_pagination_args(array(
239 239
 				'total_items' => $total_items,
240 240
 				'per_page'    => $per_page,
241
-			) );
241
+			));
242 242
 
243
-			$this->items = self::get_Table( $per_page, $current_page );
243
+			$this->items = self::get_Table($per_page, $current_page);
244 244
 		}
245 245
 
246 246
 
@@ -252,24 +252,24 @@  discard block
 block discarded – undo
252 252
 		public function process_bulk_action() {
253 253
 
254 254
 			//Detect when a bulk action is being triggered...
255
-			if ( 'delete' === $this->current_action() ) {
255
+			if ('delete' === $this->current_action()) {
256 256
 
257 257
 				//In our file that handles the request, verify the nonce.
258
-				$nonce = esc_attr( $_REQUEST['_wpnonce'] );
258
+				$nonce = esc_attr($_REQUEST['_wpnonce']);
259 259
 
260
-				if ( ! wp_verify_nonce( $nonce, 'delete_url' ) ) {
261
-					die( 'Go get a live script kiddies' );
260
+				if ( ! wp_verify_nonce($nonce, 'delete_url')) {
261
+					die('Go get a live script kiddies');
262 262
 				} else {
263
-					self::delete_url( absint( $_GET['instruction'] ) ); //Remember the instruction param from column_name method
263
+					self::delete_url(absint($_GET['instruction'])); //Remember the instruction param from column_name method
264 264
 				}
265 265
 			}
266 266
 
267 267
 			//If the delete bulk action is triggered
268
-			if ( isset( $_POST['action'] ) ) {
269
-				if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' ) ) {
270
-					$delete_ids = esc_sql( $_POST['bulk-select'] );
271
-					foreach ( $delete_ids as $id ) {
272
-						self::delete_url( $id );
268
+			if (isset($_POST['action'])) {
269
+				if ((isset($_POST['action']) && $_POST['action'] == 'bulk-delete')) {
270
+					$delete_ids = esc_sql($_POST['bulk-select']);
271
+					foreach ($delete_ids as $id) {
272
+						self::delete_url($id);
273 273
 					}
274 274
 				}
275 275
 			}
Please login to merge, or discard this patch.