Passed
Push — master ( 836585...2607e6 )
by Nirjhar
03:36
created
lib/cron.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 
4 4
 /**
5 5
  *
6 6
  * Add settings page with regarding options
7 7
  *
8 8
  */
9
-if ( ! class_exists( 'PLUGIN_CRON' ) ) {
9
+if ( ! class_exists('PLUGIN_CRON')) {
10 10
 
11 11
 	final class PLUGIN_CRON {
12 12
 
13 13
 		public function __construct() {
14 14
 
15
-			add_filter('cron_schedules', array( $this, 'cron_schedules' ) );
15
+			add_filter('cron_schedules', array($this, 'cron_schedules'));
16 16
 		}
17 17
 
18
-		public function cron_schedules( $schedules ) {
18
+		public function cron_schedules($schedules) {
19 19
 
20 20
 			$prefix = 'prefix_'; // Avoid conflict with other crons. Example Reference: cron_30_mins
21 21
 			// Example schedule options
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 						);
36 36
 
37 37
 			/* Add each custom schedule into the cron job system. */
38
-			foreach($schedule_options as $schedule_key => $schedule){
38
+			foreach ($schedule_options as $schedule_key => $schedule) {
39 39
 
40
-				$schedules[$prefix.$schedule_key] = array(
40
+				$schedules[$prefix . $schedule_key] = array(
41 41
 									'interval' => $schedule['interval'],
42
-									'display' => __('Every '.$schedule['display'])
42
+									'display' => __('Every ' . $schedule['display'])
43 43
 									);
44 44
 			}
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 		public function schedule_task($task) {
50 50
 
51
-			if( ! $task ) {
51
+			if ( ! $task) {
52 52
 				return false;
53 53
 			}
54 54
 
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
 						'hook'
59 59
 					);
60 60
 			$missing_keys = array();
61
-			foreach( $required_keys as $key ){
62
-				if( ! array_key_exists( $key, $task ) ) {
61
+			foreach ($required_keys as $key) {
62
+				if ( ! array_key_exists($key, $task)) {
63 63
 					$missing_keys[] = $key;
64 64
 				}
65 65
 			}
66 66
 
67
-			if( ! empty( $missing_keys ) ){
67
+			if ( ! empty($missing_keys)) {
68 68
 				return false;
69 69
 			}
70 70
 
71
-			if( wp_next_scheduled( $task['hook'] ) ){
71
+			if (wp_next_scheduled($task['hook'])) {
72 72
 				wp_clear_scheduled_hook($task['hook']);
73 73
 			}
74 74
 
Please login to merge, or discard this patch.
lib/api.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * $data = $api->parse();
14 14
  * 
15 15
  */
16
-if ( ! class_exists( 'PLUGIN_API' ) ) {
16
+if ( ! class_exists('PLUGIN_API')) {
17 17
 
18 18
 	class PLUGIN_API {
19 19
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 			$curl = curl_init();
50 50
 
51
-			curl_setopt_array( $curl, $this->build() );
51
+			curl_setopt_array($curl, $this->build());
52 52
 
53 53
 			$result = curl_exec($curl);
54 54
 			$err = curl_error($curl);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		//Check options and tables and output the info to check if db install is successful
68 68
 		public function parse($data) {
69 69
 
70
-			call_user_func( array( $this, $this->data_type ), $data );
70
+			call_user_func(array($this, $this->data_type), $data);
71 71
 		}
72 72
 
73 73
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 		public function xml($data) {
77 77
 
78 78
 			libxml_use_internal_errors(true);
79
-			$parsed = ( ! $data || $data == '' ? false : simplexml_load_string( $data ) );
79
+			$parsed = ( ! $data || $data == '' ? false : simplexml_load_string($data));
80 80
 
81
-			if ( ! $parsed ) {
81
+			if ( ! $parsed) {
82 82
 				return false;
83 83
 				libxml_clear_errors();
84 84
 			} else {
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		//Parse JSON data type
92 92
 		public function json($data) {
93 93
 
94
-			$parsed = ( ! $data || $data == '' ? false : json_decode( $data, 1 ) );
94
+			$parsed = ( ! $data || $data == '' ? false : json_decode($data, 1));
95 95
 			return $parsed;
96 96
 		}
97 97
 	}
Please login to merge, or discard this patch.
src/db.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 
4 4
 /**
5 5
  * DB installation class
6 6
  */
7
-if ( ! class_exists( 'PLUGIN_DB' ) ) {
7
+if ( ! class_exists('PLUGIN_DB')) {
8 8
 
9 9
 	class PLUGIN_DB {
10 10
 
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 			global $wpdb;
30 30
 			$wpdb->hide_errors();
31 31
 			$this->table_name = $wpdb->prefix . $this->table;
32
-			update_option( '_plugin_db_exist', 0 );
33
-			if ( $wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") != $this->table_name ) {
34
-				$execute_sql = $this->execute( $this->table_name, $this->collate(), $this->sql );
35
-				dbDelta( $execute_sql );
32
+			update_option('_plugin_db_exist', 0);
33
+			if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") != $this->table_name) {
34
+				$execute_sql = $this->execute($this->table_name, $this->collate(), $this->sql);
35
+				dbDelta($execute_sql);
36 36
 			}
37 37
 		}
38 38
 
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
 			global $wpdb;
45 45
 			$wpdb->hide_errors();
46 46
 			$collate = "";
47
-		    if ( $wpdb->has_cap( 'collation' ) ) {
48
-				if( ! empty($wpdb->charset ) )
47
+		    if ($wpdb->has_cap('collation')) {
48
+				if ( ! empty($wpdb->charset))
49 49
 					$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
50
-				if( ! empty($wpdb->collate ) )
50
+				if ( ! empty($wpdb->collate))
51 51
 					$collate .= " COLLATE $wpdb->collate";
52 52
 		    }
53
-    		require_once( $this->up_path );
53
+    		require_once($this->up_path);
54 54
 			return $collate;
55 55
 		}
56 56
 
57 57
 
58 58
 
59 59
 		//SQL query to create the main plugin table.
60
-		public function execute( $table_name, $collate, $sql ) {
60
+		public function execute($table_name, $collate, $sql) {
61 61
 			return "CREATE TABLE $table_name ( $sql ) $collate;";
62 62
 		}
63 63
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		public function __destruct() {
68 68
 			global $wpdb;
69 69
 			$this->table_name = $wpdb->prefix . $this->table;
70
-			if ( $wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") == $this->table_name ) {
71
-				update_option( '_plugin_db_exist', 1 );
70
+			if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") == $this->table_name) {
71
+				update_option('_plugin_db_exist', 1);
72 72
 			}
73 73
 		}
74 74
 	}
Please login to merge, or discard this patch.
src/shortcode.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 
4 4
 /**
5 5
  * Shortcode class for rendering in front end
6 6
  */
7
-if ( ! class_exists( 'PLUGIN_SHORTCODE' ) ) {
7
+if ( ! class_exists('PLUGIN_SHORTCODE')) {
8 8
 
9 9
 	class PLUGIN_SHORTCODE {
10 10
 
@@ -12,16 +12,16 @@  discard block
 block discarded – undo
12 12
 
13 13
 		public function __construct() {
14 14
 
15
-			add_shortcode( 'shortcode_name', array( $this, 'cb' ) );
15
+			add_shortcode('shortcode_name', array($this, 'cb'));
16 16
 		}
17 17
 
18 18
 
19 19
 
20 20
 		public function cb($atts) {
21 21
 
22
-			$data = shortcode_atts( array(
22
+			$data = shortcode_atts(array(
23 23
 										'type' => 'zip',
24
-									), $atts );
24
+									), $atts);
25 25
 
26 26
 			return $this->html();
27 27
 		}
Please login to merge, or discard this patch.
src/settings.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  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
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
138 138
 					<form method="post" action="">
139 139
 						<?php settings_fields("addPdfsId");
140 140
 						do_settings_sections("addPdfs");
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
 block discarded – undo
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
 block discarded – undo
177 177
 		//Add different types of settings and corrosponding sections
178 178
 		public function add_settings() {
179 179
 
180
-			add_settings_section( 'SettingsId', __( 'Section Name', 'textdomain' ), array( $this,'SectionCb' ), 'SettingsName' );
181
-			register_setting( 'SettingsId', 'SettingsField' );
182
-			add_settings_field( 'SettingsFieldName', __( 'Field Name', 'textdomain' ), array( $this, 'SettingsFieldCb' ), 'SettingsName', 'SettingsId' );
180
+			add_settings_section('SettingsId', __('Section Name', 'textdomain'), array($this, 'SectionCb'), 'SettingsName');
181
+			register_setting('SettingsId', 'SettingsField');
182
+			add_settings_field('SettingsFieldName', __('Field Name', 'textdomain'), array($this, 'SettingsFieldCb'), 'SettingsName', 'SettingsId');
183 183
 		}
184 184
 
185 185
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		//Section description
188 188
 		public function SectionCb() {
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
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		//Field explanation
196 196
 		public function SettingsFieldCb() {
197 197
 
198
-			echo '<input type="text" class="medium-text" name="SettingsFieldName" id="SettingsFieldName" value="' . get_option('SettingsFieldName') . '" placeholder="' . __( 'Enter Value', 'textdomain' ) . '" required />';
198
+			echo '<input type="text" class="medium-text" name="SettingsFieldName" id="SettingsFieldName" value="' . get_option('SettingsFieldName') . '" placeholder="' . __('Enter Value', 'textdomain') . '" required />';
199 199
 		}
200 200
 	}
201 201
 } ?>
202 202
\ No newline at end of file
Please login to merge, or discard this patch.
src/widget.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 
4 4
 /**
5 5
  * Widget class
6 6
  */
7
-if ( ! class_exists( 'PLUGIN_WIDGET' ) ) {
7
+if ( ! class_exists('PLUGIN_WIDGET')) {
8 8
 
9 9
 	final class PLUGIN_WIDGET extends WP_WIDGET {
10 10
 
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 
16 16
 			$widget_ops = array( 
17 17
 							'classname' => 'plugin_widget',
18
-							'description' => __( 'Plugin widget', 'textdomain' ),
18
+							'description' => __('Plugin widget', 'textdomain'),
19 19
 							);
20
-			parent::__construct( 'my_widget_id', __( 'Plugin widget', 'textdomain' ), $widget_ops );
20
+			parent::__construct('my_widget_id', __('Plugin widget', 'textdomain'), $widget_ops);
21 21
 		}
22 22
 
23 23
 
24 24
 
25 25
 		//Outputs the content of the widget
26
-		public function widget( $args, $instance ) {
26
+		public function widget($args, $instance) {
27 27
 
28 28
 			echo $args['before_widget'];
29
-			if ( ! empty( $instance['title'] ) ) {
30
-				echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
29
+			if ( ! empty($instance['title'])) {
30
+				echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
31 31
 			}
32
-			echo esc_html__( 'Hello, World!', 'textdomain' );
32
+			echo esc_html__('Hello, World!', 'textdomain');
33 33
 			echo $args['after_widget'];
34 34
 		}
35 35
 
36 36
 
37 37
 
38 38
 		//Outputs the options form on admin
39
-		public function form( $instance ) {
39
+		public function form($instance) {
40 40
 
41
-			$title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Internal Link Master', 'textdomain' ); ?>
41
+			$title = ! empty($instance['title']) ? $instance['title'] : esc_html__('Internal Link Master', 'textdomain'); ?>
42 42
 			<p>
43
-				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'textdomain' ); ?></label> 
44
-				<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 ); ?>">
43
+				<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:', 'textdomain'); ?></label> 
44
+				<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); ?>">
45 45
 			</p>
46 46
 		<?php 
47 47
 		}
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 		//Processing widget options on save
52
-		public function update( $new_instance, $old_instance ) {
52
+		public function update($new_instance, $old_instance) {
53 53
 			
54 54
 			$instance = array();
55
-			$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
55
+			$instance['title'] = ( ! empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
56 56
 			return $instance;
57 57
 		}
58 58
 	}
Please login to merge, or discard this patch.
src/metabox.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  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
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
wp-plugin-framework.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
lib/table.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * $myPluginNameTable->display();
8 8
  *
9 9
  */
10
-if ( ! class_exists( 'PLUGIN_TABLE' ) ) {
10
+if ( ! class_exists('PLUGIN_TABLE')) {
11 11
 
12
-if ( ! class_exists( 'WP_List_Table' ) ) {
13
-    require_once( ABSPATH . 'wp-admin/includes/screen.php' );
14
-    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
12
+if ( ! class_exists('WP_List_Table')) {
13
+    require_once(ABSPATH . 'wp-admin/includes/screen.php');
14
+    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
15 15
 }
16 16
 
17 17
 	final class PLUGIN_TABLE extends WP_List_Table {
@@ -20,37 +20,37 @@  discard block
 block discarded – undo
20 20
 
21 21
 		public function __construct() {
22 22
 
23
-			parent::__construct( [
24
-				'singular' => __( 'Name', 'textdomain' ),
25
-				'plural'   => __( 'Names', 'textdomain' ),
23
+			parent::__construct([
24
+				'singular' => __('Name', 'textdomain'),
25
+				'plural'   => __('Names', 'textdomain'),
26 26
 				'ajax'     => false,
27
-			] );
27
+			]);
28 28
 		}
29 29
 
30 30
 
31 31
 
32 32
 		//fetch the data using custom named method function
33
-		public static function get_Table( $per_page = 5, $page_number = 1 ) {
33
+		public static function get_Table($per_page = 5, $page_number = 1) {
34 34
 
35 35
 			global $wpdb;
36 36
 
37 37
 			//Take pivotal from URL
38
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
38
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
39 39
 
40 40
 			//Build the db query base
41 41
 			$sql = "SELECT * FROM {$wpdb->prefix}wordpress_table";
42 42
 			$sql .= " QUERIES with $link'";
43 43
 
44 44
 			//Set filters in the query using $_REQUEST
45
-			if ( ! empty( $_REQUEST['orderby'] ) ) {
46
-				$sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] );
47
-				$sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC';
45
+			if ( ! empty($_REQUEST['orderby'])) {
46
+				$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
47
+				$sql .= ! empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
48 48
 			}
49 49
 			$sql .= " LIMIT $per_page";
50
-			$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
50
+			$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
51 51
 
52 52
 			//get the data from database
53
-			$result = $wpdb->get_results( $sql, 'ARRAY_A' );
53
+			$result = $wpdb->get_results($sql, 'ARRAY_A');
54 54
 
55 55
 			return $result;
56 56
 		}
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
 		//Delete individual data
61
-		public static function delete_url( $id ) {
61
+		public static function delete_url($id) {
62 62
 
63 63
 			global $wpdb;
64
-			$wpdb->delete("{$wpdb->prefix}wordpress_table", array( 'ID' => $id ), array( '%s' ) );
64
+			$wpdb->delete("{$wpdb->prefix}wordpress_table", array('ID' => $id), array('%s'));
65 65
 		}
66 66
 
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		//If there is no data to show
70 70
 		public function no_items() {
71 71
 
72
-			_e( 'No Items Added yet.', 'myPlugintextDomain' );
72
+			_e('No Items Added yet.', 'myPlugintextDomain');
73 73
 		}
74 74
 
75 75
 
@@ -80,58 +80,58 @@  discard block
 block discarded – undo
80 80
 			global $wpdb;
81 81
 
82 82
 			//Take pivotal from URL
83
-			$link = ( isset( $_GET['link'] ) ? $_GET['link'] : 'link' );
83
+			$link = (isset($_GET['link']) ? $_GET['link'] : 'link');
84 84
 
85 85
 			//Build the db query base
86 86
 			$sql = "SELECT COUNT(*) FROM {$wpdb->prefix}wordpress_table";
87 87
 			$sql .= " QUERIES with $link'";
88 88
 
89
-			return $wpdb->get_var( $sql );
89
+			return $wpdb->get_var($sql);
90 90
 		}
91 91
 
92 92
 
93 93
 
94 94
 		//Display columns content
95
-		public function column_name( $item ) {
95
+		public function column_name($item) {
96 96
 
97
-			$delete_nonce = wp_create_nonce( 'delete_url' );
98
-			$title = sprintf( '<strong>%s</strong>', $item['item_name'] );
97
+			$delete_nonce = wp_create_nonce('delete_url');
98
+			$title = sprintf('<strong>%s</strong>', $item['item_name']);
99 99
 
100 100
 			//Change the page instruction where you want to show it
101 101
 			$actions = array(
102
-					'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' ) )
102
+					'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'))
103 103
 					);
104
-			return $title . $this->row_actions( $actions );
104
+			return $title . $this->row_actions($actions);
105 105
 		}
106 106
 
107 107
 
108 108
 
109 109
 		//set coulmns name
110
-		public function column_default( $item, $column_name ) {
110
+		public function column_default($item, $column_name) {
111 111
 
112
-			switch ( $column_name ) {
112
+			switch ($column_name) {
113 113
 
114 114
 				case 'name':
115 115
 					//This is the first column
116
-					return $this->column_name( $item );
116
+					return $this->column_name($item);
117 117
 				case 'caseOne':
118 118
 				case 'caseTwo':
119 119
 				case 'caseThree':
120
-					return $item[ $column_name ];
120
+					return $item[$column_name];
121 121
 
122 122
 				default:
123 123
 
124 124
 					//Show the whole array for troubleshooting purposes
125
-					return print_r( $item, true );
125
+					return print_r($item, true);
126 126
 			}
127 127
 		}
128 128
 
129 129
 
130 130
 
131 131
 		//Set checkboxes to delete
132
-		public function column_cb( $item ) {
132
+		public function column_cb($item) {
133 133
 
134
-			return sprintf( '<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID'] );
134
+			return sprintf('<input type="checkbox" name="bulk-select[]" value="%s" />', $item['ID']);
135 135
 		}
136 136
 
137 137
 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 
142 142
 			$columns = array(
143 143
 							'cb'		=> '<input type="checkbox" />',
144
-							'name'	=> __( 'Name', 'textdomain' ),
145
-							'caseOne'	=> __( 'Case One', 'textdomain' ),
146
-							'caseTwo'	=> __( 'Case Two', 'textdomain' ),
147
-							'caseThree'	=> __( 'Case Three', 'textdomain' ),
144
+							'name'	=> __('Name', 'textdomain'),
145
+							'caseOne'	=> __('Case One', 'textdomain'),
146
+							'caseTwo'	=> __('Case Two', 'textdomain'),
147
+							'caseThree'	=> __('Case Three', 'textdomain'),
148 148
 						);
149 149
 			return $columns;
150 150
 		}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 		public function get_sortable_columns() {
156 156
 
157 157
 			$sortable_columns = array(
158
-				'name' => array( 'name', true ),
159
-				'caseOne' => array( 'caseOne', false ),
160
-				'caseTwo' => array( 'caseTwo', false ),
158
+				'name' => array('name', true),
159
+				'caseOne' => array('caseOne', false),
160
+				'caseTwo' => array('caseTwo', false),
161 161
 			);
162 162
 			return $sortable_columns;
163 163
 		}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		//Determine bulk actions in the table dropdown
168 168
 		public function get_bulk_actions() {
169 169
 
170
-			$actions = array( 'bulk-delete' => 'Delete'	);
170
+			$actions = array('bulk-delete' => 'Delete');
171 171
 			return $actions;
172 172
 		}
173 173
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 
181 181
 			/** Process bulk action */
182 182
 			$this->process_bulk_action();
183
-			$per_page     = $this->get_items_per_page( 'option_name_per_page', 5 );
183
+			$per_page     = $this->get_items_per_page('option_name_per_page', 5);
184 184
 			$current_page = $this->get_pagenum();
185 185
 			$total_items  = self::record_count();
186
-			$this->set_pagination_args( array(
186
+			$this->set_pagination_args(array(
187 187
 				'total_items' => $total_items,
188 188
 				'per_page'    => $per_page,
189
-			) );
189
+			));
190 190
 
191
-			$this->items = self::get_Table( $per_page, $current_page );
191
+			$this->items = self::get_Table($per_page, $current_page);
192 192
 		}
193 193
 
194 194
 
@@ -197,24 +197,24 @@  discard block
 block discarded – undo
197 197
 		public function process_bulk_action() {
198 198
 
199 199
 			//Detect when a bulk action is being triggered...
200
-			if ( 'delete' === $this->current_action() ) {
200
+			if ('delete' === $this->current_action()) {
201 201
 
202 202
 				//In our file that handles the request, verify the nonce.
203
-				$nonce = esc_attr( $_REQUEST['_wpnonce'] );
203
+				$nonce = esc_attr($_REQUEST['_wpnonce']);
204 204
 
205
-				if ( ! wp_verify_nonce( $nonce, 'delete_url' ) ) {
206
-					die( 'Go get a live script kiddies' );
205
+				if ( ! wp_verify_nonce($nonce, 'delete_url')) {
206
+					die('Go get a live script kiddies');
207 207
 				} else {
208
-					self::delete_url( absint( $_GET['instruction'] ) ); //Remember the instruction param from column_name method
208
+					self::delete_url(absint($_GET['instruction'])); //Remember the instruction param from column_name method
209 209
 				}
210 210
 			}
211 211
 
212 212
 			//If the delete bulk action is triggered
213
-			if ( isset( $_POST['action'] ) ) {
214
-				if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' ) ) {
215
-					$delete_ids = esc_sql( $_POST['bulk-select'] );
216
-					foreach ( $delete_ids as $id ) {
217
-						self::delete_url( $id );
213
+			if (isset($_POST['action'])) {
214
+				if ((isset($_POST['action']) && $_POST['action'] == 'bulk-delete')) {
215
+					$delete_ids = esc_sql($_POST['bulk-select']);
216
+					foreach ($delete_ids as $id) {
217
+						self::delete_url($id);
218 218
 					}
219 219
 				}
220 220
 			}
Please login to merge, or discard this patch.