@@ -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 | * Implimentation of WordPress inbuilt functions for plugin activation. |
6 | 6 | */ |
7 | -if ( ! class_exists( 'PLUGGIN_INSTALL' ) ) { |
|
7 | +if ( ! class_exists('PLUGGIN_INSTALL')) { |
|
8 | 8 | |
9 | 9 | final class PLUGIN_INSTALL { |
10 | 10 | |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | |
27 | 27 | public function execute() { |
28 | - add_action( 'plugins_loaded', array( $this, 'text_domain_cb' ) ); |
|
29 | - add_action( 'admin_notices', array( $this, 'php_ver_incompatible' ) ); |
|
30 | - add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 ); |
|
28 | + add_action('plugins_loaded', array($this, 'text_domain_cb')); |
|
29 | + add_action('admin_notices', array($this, 'php_ver_incompatible')); |
|
30 | + add_filter('plugin_action_links', array($this, 'menu_page_link'), 10, 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | //Load plugin textdomain |
36 | 36 | public function text_domain_cb() { |
37 | 37 | |
38 | - load_plugin_textdomain( $this->textDomin, false, PLUGIN_LN ); |
|
38 | + load_plugin_textdomain($this->textDomin, false, PLUGIN_LN); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | //Define low php verson errors |
44 | 44 | public function php_ver_incompatible() { |
45 | 45 | |
46 | - if ( version_compare( phpversion(), $this->phpVerAllowed, '<' ) ) : |
|
47 | - $text = __( 'The Plugin can\'t be activated because your PHP version', 'textdomain' ); |
|
48 | - $text_last = __( 'is less than required 5.3. See more information', 'textdomain' ); |
|
46 | + if (version_compare(phpversion(), $this->phpVerAllowed, '<')) : |
|
47 | + $text = __('The Plugin can\'t be activated because your PHP version', 'textdomain'); |
|
48 | + $text_last = __('is less than required 5.3. See more information', 'textdomain'); |
|
49 | 49 | $text_link = 'php.net/eol.php'; ?> |
50 | 50 | |
51 | 51 | <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $text . ' ' . phpversion() . ' ' . $text_last . ': '; ?><a href="http://php.net/eol.php/" target="_blank"><?php echo $text_link; ?></a></p></div> |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | |
56 | 56 | |
57 | 57 | // Add settings link to plugin page |
58 | - public function menu_page_link( $links, $file ) { |
|
58 | + public function menu_page_link($links, $file) { |
|
59 | 59 | |
60 | 60 | if ($this->pluginPageLinks) { |
61 | 61 | static $this_plugin; |
62 | - if ( ! $this_plugin ) { |
|
62 | + if ( ! $this_plugin) { |
|
63 | 63 | $this_plugin = PLUGIN_FILE; |
64 | 64 | } |
65 | - if ( $file == $this_plugin ) { |
|
65 | + if ($file == $this_plugin) { |
|
66 | 66 | $shift_link = array(); |
67 | 67 | foreach ($this->pluginPageLinks as $value) { |
68 | - $shift_link[] = '<a href="'.$value['slug'].'">'.$value['label'].'</a>'; |
|
68 | + $shift_link[] = '<a href="' . $value['slug'] . '">' . $value['label'] . '</a>'; |
|
69 | 69 | } |
70 | - foreach( $shift_link as $val ) { |
|
71 | - array_unshift( $links, $val ); |
|
70 | + foreach ($shift_link as $val) { |
|
71 | + array_unshift($links, $val); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | return $links; |
@@ -7,11 +7,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -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 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | //Custom corn class, register it while activation |
39 | 39 | public function corn() { |
40 | 40 | |
41 | - if ( class_exists( 'PLUGIN_CRON' ) ) { |
|
41 | + if (class_exists('PLUGIN_CRON')) { |
|
42 | 42 | $cron = new PLUGIN_CRON(); |
43 | 43 | $schedule = $cron->schedule_task( |
44 | 44 | array( |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function db_error_msg() { ?> |
98 | 98 | |
99 | 99 | <div class="notice notice-error is-dismissible"> |
100 | - <p><?php _e( 'Database table Not installed correctly.', 'textdomain' ); ?></p> |
|
100 | + <p><?php _e('Database table Not installed correctly.', 'textdomain'); ?></p> |
|
101 | 101 | </div> |
102 | 102 | <?php |
103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | //Include scripts |
130 | 130 | public function scripts() { |
131 | 131 | |
132 | - if ( class_exists( 'CGSS_SCRIPT' ) ) new CGSS_SCRIPT(); |
|
132 | + if (class_exists('CGSS_SCRIPT')) new CGSS_SCRIPT(); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | //Include settings pages |
138 | 138 | public function settings() { |
139 | 139 | |
140 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
140 | + if (class_exists('PLUGIN_SETTINGS')) new PLUGIN_SETTINGS(); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
144 | 144 | //Include widget classes |
145 | 145 | public function widgets() { |
146 | 146 | |
147 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
147 | + if (class_exists('PLUGIN_WIDGET')) new PLUGIN_WIDGET(); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | //Include metabox classes |
153 | 153 | public function metabox() { |
154 | 154 | |
155 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
155 | + if (class_exists('PLUGIN_METABOX')) new PLUGIN_METABOX(); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | //Include shortcode classes |
161 | 161 | public function shortcode() { |
162 | 162 | |
163 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
163 | + if (class_exists('PLUGIN_SHORTCODE')) new PLUGIN_SHORTCODE(); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | $this->helpers(); |
203 | 203 | $this->functionality(); |
204 | 204 | |
205 | - register_activation_hook( PLUGIN_FILE, array( $this, 'db_install' ) ); |
|
205 | + register_activation_hook(PLUGIN_FILE, array($this, 'db_install')); |
|
206 | 206 | |
207 | 207 | //remove the DB upon uninstallation |
208 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'db_uninstall' ) ); //$this won't work here. |
|
208 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'db_uninstall')); //$this won't work here. |
|
209 | 209 | |
210 | 210 | add_action('init', array($this, 'installation')); |
211 | 211 |