@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | * @package wps-mass-interface3 |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
15 | - exit( 'class-wp-list-table.php not found.' ); |
|
14 | +if (!class_exists('WP_List_Table')) { |
|
15 | + exit('class-wp-list-table.php not found.'); |
|
16 | 16 | } |
17 | 17 | /** |
18 | 18 | * Custom WP_List_Table to edit attributes from WPShop EAV. |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | * @method __construct |
79 | 79 | * @param array $args New key : exclude_attribute_codes. |
80 | 80 | */ |
81 | - public function __construct( $args ) { |
|
82 | - if ( isset( $args['exclude_attribute_codes'] ) ) { |
|
81 | + public function __construct($args) { |
|
82 | + if (isset($args['exclude_attribute_codes'])) { |
|
83 | 83 | $this->exclude_attribute_codes = $args['exclude_attribute_codes']; |
84 | 84 | } |
85 | 85 | parent::__construct( |
86 | 86 | array( |
87 | 87 | 'plural' => 'posts', |
88 | 88 | 'ajax' => true, |
89 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
89 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
90 | 90 | ) |
91 | 91 | ); |
92 | - $this->current_view = (int) substr( $this->screen->id, strpos( $this->screen->id, '_att_set_' ) + 9 ); |
|
93 | - $this->entity_id = (int) wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
94 | - $this->_post_types = array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ); |
|
92 | + $this->current_view = (int)substr($this->screen->id, strpos($this->screen->id, '_att_set_') + 9); |
|
93 | + $this->entity_id = (int)wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
94 | + $this->_post_types = array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION); |
|
95 | 95 | } |
96 | 96 | /** |
97 | 97 | * List columns. |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | public function get_columns() { |
103 | 103 | $columns = array( |
104 | 104 | 'cb' => '<input type="checkbox" />', |
105 | - 'title' => __( 'Title' ), |
|
106 | - 'thumbnail' => __( 'Thumbnail' ), |
|
105 | + 'title' => __('Title'), |
|
106 | + 'thumbnail' => __('Thumbnail'), |
|
107 | 107 | ); |
108 | - foreach ( $this->request_items_columns() as $column => $data_column ) { |
|
109 | - if ( ! empty( $column ) && ! empty( $data_column ) ) { |
|
110 | - $columns[ $column ] = $data_column['name']; |
|
108 | + foreach ($this->request_items_columns() as $column => $data_column) { |
|
109 | + if (!empty($column) && !empty($data_column)) { |
|
110 | + $columns[$column] = $data_column['name']; |
|
111 | 111 | } |
112 | 112 | } |
113 | - $columns['date'] = __( 'Date' ); |
|
113 | + $columns['date'] = __('Date'); |
|
114 | 114 | return $columns; |
115 | 115 | } |
116 | 116 | /** |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function get_sortable_columns() { |
123 | 123 | $sortable_columns = array( |
124 | - 'title' => array( 'title', false ), |
|
125 | - 'thumbnail' => array( 'thumbnail', false ), |
|
126 | - 'date' => array( 'p.post_date', false ), |
|
124 | + 'title' => array('title', false), |
|
125 | + 'thumbnail' => array('thumbnail', false), |
|
126 | + 'date' => array('p.post_date', false), |
|
127 | 127 | ); |
128 | - foreach ( $this->request_items_columns() as $column => $data_column ) { |
|
129 | - $sortable_columns[ $column ] = array( $data_column['code'], false ); |
|
128 | + foreach ($this->request_items_columns() as $column => $data_column) { |
|
129 | + $sortable_columns[$column] = array($data_column['code'], false); |
|
130 | 130 | } |
131 | 131 | return $sortable_columns; |
132 | 132 | } |
@@ -138,22 +138,22 @@ discard block |
||
138 | 138 | * @param string $column_name Current column. |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function column_default( $item, $column_name ) { |
|
142 | - if ( isset( $this->columns_items[ $column_name ] ) && is_callable( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ) ) ) { |
|
143 | - $callable_ext = str_replace( '-', '_', $this->columns_items[ $column_name ]['type'] ); |
|
144 | - if ( ! method_exists( $this, "column_data_{$callable_ext}" ) ) { |
|
141 | + public function column_default($item, $column_name) { |
|
142 | + if (isset($this->columns_items[$column_name]) && is_callable(array($this, "column_data_{$this->columns_items[$column_name]['type']}"))) { |
|
143 | + $callable_ext = str_replace('-', '_', $this->columns_items[$column_name]['type']); |
|
144 | + if (!method_exists($this, "column_data_{$callable_ext}")) { |
|
145 | 145 | $callable_ext = 'text'; |
146 | 146 | } |
147 | - $callable = array( $this, "column_data_{$callable_ext}" ); |
|
147 | + $callable = array($this, "column_data_{$callable_ext}"); |
|
148 | 148 | return call_user_func( |
149 | 149 | $callable, |
150 | - (int) $this->columns_items[ $column_name ]['id'], |
|
151 | - $this->columns_items[ $column_name ]['code'], |
|
152 | - $this->columns_items[ $column_name ]['data'], |
|
150 | + (int)$this->columns_items[$column_name]['id'], |
|
151 | + $this->columns_items[$column_name]['code'], |
|
152 | + $this->columns_items[$column_name]['data'], |
|
153 | 153 | $item |
154 | 154 | ); |
155 | 155 | } |
156 | - return print_r( $item[ $column_name ], true ); |
|
156 | + return print_r($item[$column_name], true); |
|
157 | 157 | } |
158 | 158 | /** |
159 | 159 | * Column content for checkbox. |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array $item Result of sql query. |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function column_cb( $item ) { |
|
165 | + public function column_cb($item) { |
|
166 | 166 | return sprintf( |
167 | 167 | '<input type="checkbox" name="cb[]" value="%d" />', |
168 | 168 | $item['ID'] |
@@ -175,52 +175,52 @@ discard block |
||
175 | 175 | * @param array $item Result of sql query. |
176 | 176 | * @return string |
177 | 177 | */ |
178 | - public function column_thumbnail( $item ) { |
|
178 | + public function column_thumbnail($item) { |
|
179 | 179 | $thumbnail_id = ''; |
180 | - $link_content = get_the_post_thumbnail( $item['ID'], array( 25, 25 ) ); |
|
181 | - if ( ! empty( $link_content ) ) { |
|
180 | + $link_content = get_the_post_thumbnail($item['ID'], array(25, 25)); |
|
181 | + if (!empty($link_content)) { |
|
182 | 182 | $link_content = "<span class=\"img\">{$link_content}</span>"; |
183 | - $thumbnail_id = get_post_thumbnail_id( $item['ID'] ); |
|
183 | + $thumbnail_id = get_post_thumbnail_id($item['ID']); |
|
184 | 184 | } |
185 | - $popup_title = __( 'Choose Image' ); |
|
185 | + $popup_title = __('Choose Image'); |
|
186 | 186 | return sprintf( |
187 | 187 | '<input type="hidden" name="row_%1$s[thumbnail]" value="%2$s"><a href="#thumbnail" data-media-title="%3$s">%4$s<span class="text">%3$s</span></a>', |
188 | 188 | $item['ID'], |
189 | 189 | $thumbnail_id, |
190 | - __( 'Choose Image' ), |
|
190 | + __('Choose Image'), |
|
191 | 191 | $link_content |
192 | 192 | ); |
193 | 193 | } |
194 | - public function column_date( $item ) { |
|
194 | + public function column_date($item) { |
|
195 | 195 | global $mode; |
196 | 196 | |
197 | - if ( '0000-00-00 00:00:00' === $item['pdate'] ) { |
|
198 | - $t_time = $h_time = __( 'Unpublished' ); |
|
197 | + if ('0000-00-00 00:00:00' === $item['pdate']) { |
|
198 | + $t_time = $h_time = __('Unpublished'); |
|
199 | 199 | $time_diff = 0; |
200 | 200 | } else { |
201 | - $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
201 | + $t_time = get_the_time(__('Y/m/d g:i:s a')); |
|
202 | 202 | $m_time = $item['pdate']; |
203 | - $time = get_post_time( 'G', true, $item['ID'] ); |
|
203 | + $time = get_post_time('G', true, $item['ID']); |
|
204 | 204 | |
205 | 205 | $time_diff = time() - $time; |
206 | 206 | |
207 | - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
208 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
207 | + if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { |
|
208 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
209 | 209 | } else { |
210 | - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
210 | + $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - if ( 'publish' === $item['status'] ) { |
|
215 | - _e( 'Published' ); |
|
216 | - } elseif ( 'future' === $item['status'] ) { |
|
217 | - if ( $time_diff > 0 ) { |
|
218 | - echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
214 | + if ('publish' === $item['status']) { |
|
215 | + _e('Published'); |
|
216 | + } elseif ('future' === $item['status']) { |
|
217 | + if ($time_diff > 0) { |
|
218 | + echo '<strong class="error-message">' . __('Missed schedule') . '</strong>'; |
|
219 | 219 | } else { |
220 | - _e( 'Scheduled' ); |
|
220 | + _e('Scheduled'); |
|
221 | 221 | } |
222 | 222 | } else { |
223 | - _e( 'Last Modified' ); |
|
223 | + _e('Last Modified'); |
|
224 | 224 | } |
225 | 225 | echo '<br />'; |
226 | 226 | echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
@@ -232,39 +232,39 @@ discard block |
||
232 | 232 | * @param array $item Result of sql query. |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - public function column_title( $item ) { |
|
236 | - if ( 'private' === $item['status'] ) { |
|
237 | - $post_states['private'] = __( 'Private' ); |
|
235 | + public function column_title($item) { |
|
236 | + if ('private' === $item['status']) { |
|
237 | + $post_states['private'] = __('Private'); |
|
238 | 238 | } |
239 | - if ( 'draft' === $item['status'] ) { |
|
240 | - $post_states['draft'] = __( 'Draft' ); |
|
239 | + if ('draft' === $item['status']) { |
|
240 | + $post_states['draft'] = __('Draft'); |
|
241 | 241 | } |
242 | - if ( 'pending' === $item['status'] ) { |
|
243 | - $post_states['pending'] = _x( 'Pending', 'post status' ); |
|
242 | + if ('pending' === $item['status']) { |
|
243 | + $post_states['pending'] = _x('Pending', 'post status'); |
|
244 | 244 | } |
245 | - if ( 'future' === $item['status'] ) { |
|
246 | - $post_states['scheduled'] = __( 'Scheduled' ); |
|
245 | + if ('future' === $item['status']) { |
|
246 | + $post_states['scheduled'] = __('Scheduled'); |
|
247 | 247 | } |
248 | - if ( current_user_can( 'edit_post', $item['ID'] ) && 'trash' !== $item['status'] ) { |
|
248 | + if (current_user_can('edit_post', $item['ID']) && 'trash' !== $item['status']) { |
|
249 | 249 | $result = sprintf( |
250 | 250 | '<a class="row-title" href="%s" aria-label="%s">%s</a>', |
251 | - get_edit_post_link( $item['ID'] ), |
|
251 | + get_edit_post_link($item['ID']), |
|
252 | 252 | // translators: WordPress translate. |
253 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $item['title'] ) ), |
|
253 | + esc_attr(sprintf(__('“%s” (Edit)'), $item['title'])), |
|
254 | 254 | $item['title'] |
255 | 255 | ); |
256 | 256 | } else { |
257 | 257 | $result = $item['title']; |
258 | 258 | } |
259 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type'] ) { |
|
260 | - $attr_def = get_post_meta( $item['ID'], '_wpshop_variations_attribute_def', true ); |
|
259 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type']) { |
|
260 | + $attr_def = get_post_meta($item['ID'], '_wpshop_variations_attribute_def', true); |
|
261 | 261 | $columns_items = $this->request_items_columns(); |
262 | 262 | $first_variation = true; |
263 | - $parent = $this->items[ $item['parent'] ]; |
|
264 | - foreach ( $attr_def as $key => $value ) { |
|
265 | - foreach ( $this->get_select_items_option( $columns_items[ $key ]['id'] ) as $all_value ) { |
|
266 | - if ( $all_value['id'] === $value ) { |
|
267 | - if ( $first_variation ) { |
|
263 | + $parent = $this->items[$item['parent']]; |
|
264 | + foreach ($attr_def as $key => $value) { |
|
265 | + foreach ($this->get_select_items_option($columns_items[$key]['id']) as $all_value) { |
|
266 | + if ($all_value['id'] === $value) { |
|
267 | + if ($first_variation) { |
|
268 | 268 | $result = $parent['title'] . ' : '; |
269 | 269 | $first_variation = false; |
270 | 270 | } else { |
@@ -276,19 +276,19 @@ discard block |
||
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | - if ( ! empty( $post_states ) ) { |
|
280 | - $state_count = count( $post_states ); |
|
279 | + if (!empty($post_states)) { |
|
280 | + $state_count = count($post_states); |
|
281 | 281 | $i = 0; |
282 | 282 | $result .= ' — '; |
283 | - foreach ( $post_states as $state ) { |
|
283 | + foreach ($post_states as $state) { |
|
284 | 284 | ++$i; |
285 | - ( $i === $state_count ) ? $sep = '' : $sep = ', '; |
|
285 | + ($i === $state_count) ? $sep = '' : $sep = ', '; |
|
286 | 286 | $result .= "<span class='post-state'>$state$sep</span>"; |
287 | 287 | } |
288 | 288 | } |
289 | 289 | return sprintf( |
290 | 290 | '<strong>%s</strong>', |
291 | - isset( $item['lvl'] ) ? $item['lvl'] . $result : $result |
|
291 | + isset($item['lvl']) ? $item['lvl'] . $result : $result |
|
292 | 292 | ); |
293 | 293 | } |
294 | 294 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param array $item Result of sql query. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function column_data_default( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
304 | + public function column_data_default($attribute_id, $attribute_code, $attribute_data, $item) { |
|
305 | 305 | return 'default'; |
306 | 306 | } |
307 | 307 | /** |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | * @param array $item Result of sql query. |
315 | 315 | * @return string |
316 | 316 | */ |
317 | - public function column_data_text( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
317 | + public function column_data_text($attribute_id, $attribute_code, $attribute_data, $item) { |
|
318 | 318 | $unit = ''; |
319 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
320 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
321 | - $value = $item[ $attribute_code ]['value']; |
|
319 | + if (is_array($item[$attribute_code])) { |
|
320 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
321 | + $value = $item[$attribute_code]['value']; |
|
322 | 322 | } else { |
323 | - $value = $item[ $attribute_code ]; |
|
323 | + $value = $item[$attribute_code]; |
|
324 | 324 | } |
325 | 325 | return sprintf( |
326 | 326 | '<input type="text" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]" value="%4$s">', |
@@ -341,34 +341,34 @@ discard block |
||
341 | 341 | * @param array $item Result of sql query. |
342 | 342 | * @return string |
343 | 343 | */ |
344 | - public function column_data_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
344 | + public function column_data_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
345 | 345 | $unit = ''; |
346 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
347 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
348 | - $value = $item[ $attribute_code ]['value']; |
|
346 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
347 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
348 | + $value = $item[$attribute_code]['value']; |
|
349 | 349 | } else { |
350 | - $value = $item[ $attribute_code ]; |
|
350 | + $value = $item[$attribute_code]; |
|
351 | 351 | } |
352 | 352 | $has_selected = false; |
353 | 353 | $select_items = array(); |
354 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
355 | - if ( is_array( $value ) ) { |
|
356 | - foreach ( $value as $val ) { |
|
357 | - $selected = selected( $val, $option_item['id'], false ); |
|
358 | - if ( ! empty( $selected ) ) { |
|
354 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
355 | + if (is_array($value)) { |
|
356 | + foreach ($value as $val) { |
|
357 | + $selected = selected($val, $option_item['id'], false); |
|
358 | + if (!empty($selected)) { |
|
359 | 359 | break; |
360 | 360 | } |
361 | 361 | } |
362 | 362 | } else { |
363 | - $selected = selected( $value, $option_item['id'], false ); |
|
363 | + $selected = selected($value, $option_item['id'], false); |
|
364 | 364 | } |
365 | - $has_selected = empty( $selected ) ? $has_selected : true; |
|
365 | + $has_selected = empty($selected) ? $has_selected : true; |
|
366 | 366 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
367 | 367 | } |
368 | - if ( ! $has_selected ) { |
|
369 | - array_unshift( $select_items, '<option selected disabled>' . __( 'None' ) . '</option>' ); |
|
368 | + if (!$has_selected) { |
|
369 | + array_unshift($select_items, '<option selected disabled>' . __('None') . '</option>'); |
|
370 | 370 | } |
371 | - $select_items = implode( '', $select_items ); |
|
371 | + $select_items = implode('', $select_items); |
|
372 | 372 | return sprintf( |
373 | 373 | '<select name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</select>', |
374 | 374 | $attribute_code, |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | * @param array $item Result of sql query. |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public function column_data_textarea( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
391 | + public function column_data_textarea($attribute_id, $attribute_code, $attribute_data, $item) { |
|
392 | 392 | $unit = ''; |
393 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
394 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
395 | - $value = $item[ $attribute_code ]['value']; |
|
393 | + if (is_array($item[$attribute_code])) { |
|
394 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
395 | + $value = $item[$attribute_code]['value']; |
|
396 | 396 | } else { |
397 | - $value = $item[ $attribute_code ]; |
|
397 | + $value = $item[$attribute_code]; |
|
398 | 398 | } |
399 | 399 | return sprintf( |
400 | 400 | '<textarea name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</textarea>', |
@@ -415,29 +415,29 @@ discard block |
||
415 | 415 | * @param array $item Result of sql query. |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function column_data_multiple_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
418 | + public function column_data_multiple_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
419 | 419 | $unit = ''; |
420 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
421 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
422 | - $value = $item[ $attribute_code ]['value']; |
|
420 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
421 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
422 | + $value = $item[$attribute_code]['value']; |
|
423 | 423 | } else { |
424 | - $value = $item[ $attribute_code ]; |
|
424 | + $value = $item[$attribute_code]; |
|
425 | 425 | } |
426 | 426 | $select_items = array(); |
427 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
428 | - if ( is_array( $value ) ) { |
|
429 | - foreach ( $value as $val ) { |
|
430 | - $selected = selected( $val, $option_item['id'], false ); |
|
431 | - if ( ! empty( $selected ) ) { |
|
427 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
428 | + if (is_array($value)) { |
|
429 | + foreach ($value as $val) { |
|
430 | + $selected = selected($val, $option_item['id'], false); |
|
431 | + if (!empty($selected)) { |
|
432 | 432 | break; |
433 | 433 | } |
434 | 434 | } |
435 | 435 | } else { |
436 | - $selected = selected( $value, $option_item['id'], false ); |
|
436 | + $selected = selected($value, $option_item['id'], false); |
|
437 | 437 | } |
438 | 438 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
439 | 439 | } |
440 | - $select_items = implode( '', $select_items ); |
|
440 | + $select_items = implode('', $select_items); |
|
441 | 441 | return sprintf( |
442 | 442 | '<select class="chosen-select" multiple data-placeholder="%6$s" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s][]">%4$s</select>', |
443 | 443 | $attribute_code, |
@@ -455,9 +455,9 @@ discard block |
||
455 | 455 | * @param Mixed $id_post Null = all / Int = single. |
456 | 456 | * @return array Return all values with ARRAY_A. |
457 | 457 | */ |
458 | - public function request( $id_post = null ) { |
|
458 | + public function request($id_post = null) { |
|
459 | 459 | global $wpdb; |
460 | - $per_page = $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ); |
|
460 | + $per_page = $this->get_items_per_page($this->screen->get_option('per_page', 'option')); |
|
461 | 461 | $include_states = array( |
462 | 462 | 'publish', |
463 | 463 | 'future', |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | 'trash', |
468 | 468 | 'scheduled', |
469 | 469 | ); |
470 | - $include_states = implode( "','", $include_states ); |
|
471 | - $post_types = implode( "','", $this->_post_types ); |
|
472 | - $orderby = isset( $_REQUEST['orderby'] ) ? esc_sql( $_REQUEST['orderby'] ) : 'p.post_date'; // WPCS: CSRF ok. |
|
473 | - $order = isset( $_REQUEST['order'] ) ? esc_sql( strtoupper( $_REQUEST['order'] ) ) : 'DESC'; // WPCS: CSRF ok. |
|
474 | - $cast = isset( $_REQUEST['cast'] ) ? esc_sql( $_REQUEST['cast'] ) : ''; // WPCS: CSRF ok. |
|
475 | - $cast = strtoupper( $cast ); |
|
476 | - $s = isset( $_REQUEST['s'] ) ? esc_sql( $_REQUEST['s'] ) : ''; // WPCS: CSRF ok. |
|
477 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
478 | - $items_count = $wpdb->prepare( "SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1 ); |
|
470 | + $include_states = implode("','", $include_states); |
|
471 | + $post_types = implode("','", $this->_post_types); |
|
472 | + $orderby = isset($_REQUEST['orderby']) ? esc_sql($_REQUEST['orderby']) : 'p.post_date'; // WPCS: CSRF ok. |
|
473 | + $order = isset($_REQUEST['order']) ? esc_sql(strtoupper($_REQUEST['order'])) : 'DESC'; // WPCS: CSRF ok. |
|
474 | + $cast = isset($_REQUEST['cast']) ? esc_sql($_REQUEST['cast']) : ''; // WPCS: CSRF ok. |
|
475 | + $cast = strtoupper($cast); |
|
476 | + $s = isset($_REQUEST['s']) ? esc_sql($_REQUEST['s']) : ''; // WPCS: CSRF ok. |
|
477 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
478 | + $items_count = $wpdb->prepare("SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1); |
|
479 | 479 | $true = true; |
480 | - if ( $true ) { // FOUND_ROWS incompatibilities ? |
|
480 | + if ($true) { // FOUND_ROWS incompatibilities ? |
|
481 | 481 | $items_count = $wpdb->prepare( |
482 | 482 | "SELECT COUNT(*) |
483 | 483 | FROM {$wpdb->posts} p |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; |
500 | 500 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
501 | 501 | $extra_select = ''; |
502 | - if ( ! in_array( $orderby, apply_filters( 'wps_mass_list_custom_orderby', array( 'title', 'ID', 'thumbnail', 'p.post_date' ) ), true ) ) { |
|
502 | + if (!in_array($orderby, apply_filters('wps_mass_list_custom_orderby', array('title', 'ID', 'thumbnail', 'p.post_date')), true)) { |
|
503 | 503 | $extra_select = "SELECT GROUP_CONCAT( IFNULL( val_dec1.value, |
504 | 504 | IFNULL( val_dat1.value, |
505 | 505 | IFNULL( val_tex1.value, |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | LEFT JOIN {$wpsdb_values_options} val_opt1 ON val_opt1.attribute_id = attr1.id AND val_opt1.id = val_int1.value |
522 | 522 | WHERE p1.ID = p.ID"; |
523 | 523 | $extra_select = "( {$extra_select} )"; |
524 | - if ( ! empty( $cast ) ) { |
|
524 | + if (!empty($cast)) { |
|
525 | 525 | $extra_select = "CAST( {$extra_select} AS {$cast} )"; |
526 | 526 | } |
527 | 527 | $extra_select = ", |
528 | 528 | {$extra_select} AS {$orderby}"; |
529 | 529 | } |
530 | - if ( 'thumbnail' === $orderby ) { |
|
531 | - $ids = $wpdb->get_col( $wpdb->prepare( |
|
530 | + if ('thumbnail' === $orderby) { |
|
531 | + $ids = $wpdb->get_col($wpdb->prepare( |
|
532 | 532 | "SELECT CAST( pm.post_id AS SIGNED INTEGER ) as col |
533 | 533 | FROM {$wpdb->postmeta} pm |
534 | 534 | JOIN {$wpdb->posts} p ON pm.post_id = p.ID AND p.post_type IN ( '{$post_types}' ) |
@@ -537,21 +537,21 @@ discard block |
||
537 | 537 | ORDER BY pm.meta_value {$order}", |
538 | 538 | '_thumbnail_id', |
539 | 539 | 0 |
540 | - ) ); |
|
541 | - $ids = implode( ', ', $ids ); |
|
540 | + )); |
|
541 | + $ids = implode(', ', $ids); |
|
542 | 542 | $orderby = "FIELD( p.ID, {$ids} )"; |
543 | 543 | } |
544 | - $orderby = apply_filters( 'wps_mass_list_custom_orderby_query', $orderby ); |
|
544 | + $orderby = apply_filters('wps_mass_list_custom_orderby_query', $orderby); |
|
545 | 545 | $extra = "GROUP BY p.ID |
546 | 546 | ORDER BY {$orderby} {$order} |
547 | 547 | LIMIT %d, %d"; |
548 | - if ( ! is_null( $id_post ) ) { |
|
549 | - $id_post = intval( $id_post ); |
|
548 | + if (!is_null($id_post)) { |
|
549 | + $id_post = intval($id_post); |
|
550 | 550 | $extra = "AND p.ID = {$id_post}"; |
551 | 551 | $s = ''; |
552 | 552 | } |
553 | 553 | $wpdb->query( |
554 | - $wpdb->prepare( 'SET SESSION group_concat_max_len = %d', 1000000 ) |
|
554 | + $wpdb->prepare('SET SESSION group_concat_max_len = %d', 1000000) |
|
555 | 555 | ); |
556 | 556 | $datas = $wpdb->get_results( |
557 | 557 | $wpdb->prepare( |
@@ -606,23 +606,23 @@ discard block |
||
606 | 606 | $this->request_current_view(), |
607 | 607 | $this->entity_id, |
608 | 608 | '%' . $s . '%', |
609 | - ( $this->get_pagenum() -1 ) * $per_page, |
|
609 | + ($this->get_pagenum() - 1) * $per_page, |
|
610 | 610 | $per_page |
611 | 611 | ), |
612 | 612 | ARRAY_A |
613 | 613 | ); |
614 | - if ( ! is_array( $datas ) ) { |
|
614 | + if (!is_array($datas)) { |
|
615 | 615 | $datas = array(); |
616 | 616 | } |
617 | - if ( ! isset( $this->_pagination_args['total_items'] ) && ! isset( $this->_pagination_args['per_page'] ) ) { |
|
617 | + if (!isset($this->_pagination_args['total_items']) && !isset($this->_pagination_args['per_page'])) { |
|
618 | 618 | $this->set_pagination_args( |
619 | 619 | array( |
620 | - 'total_items' => (int) $wpdb->get_var( $items_count ), |
|
621 | - 'per_page' => $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ), |
|
620 | + 'total_items' => (int)$wpdb->get_var($items_count), |
|
621 | + 'per_page' => $this->get_items_per_page($this->screen->get_option('per_page', 'option')), |
|
622 | 622 | ) |
623 | 623 | ); |
624 | 624 | } |
625 | - return array_map( array( $this, 'data_reorganize' ), $datas ); |
|
625 | + return array_map(array($this, 'data_reorganize'), $datas); |
|
626 | 626 | } |
627 | 627 | /** |
628 | 628 | * Main function to call before display WP_List_Table. See parent class. |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | * @return void Same results as request() but id as key. |
632 | 632 | */ |
633 | 633 | public function prepare_items() { |
634 | - foreach ( $this->request() as $item ) { |
|
635 | - $this->items[ $item['ID'] ] = $item; |
|
634 | + foreach ($this->request() as $item) { |
|
635 | + $this->items[$item['ID']] = $item; |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 | /** |
@@ -642,20 +642,20 @@ discard block |
||
642 | 642 | * @param string $column_key Current column. |
643 | 643 | * @return string |
644 | 644 | */ |
645 | - public function cast_column( $column_key ) { |
|
645 | + public function cast_column($column_key) { |
|
646 | 646 | $columns_items = $this->request_items_columns(); |
647 | - if ( isset( $columns_items[ $column_key ] ) ) { |
|
648 | - $cast = $columns_items[ $column_key ]['data']; |
|
649 | - if ( in_array( $cast, array( 'varchar', 'text' ), true ) ) { |
|
647 | + if (isset($columns_items[$column_key])) { |
|
648 | + $cast = $columns_items[$column_key]['data']; |
|
649 | + if (in_array($cast, array('varchar', 'text'), true)) { |
|
650 | 650 | $cast = 'char'; |
651 | 651 | } |
652 | - if ( 'tx_tva' === $column_key ) { |
|
652 | + if ('tx_tva' === $column_key) { |
|
653 | 653 | return 'decimal'; |
654 | 654 | } |
655 | - if ( 'integer' === $cast && 'select' === $columns_items[ $column_key ]['type'] ) { |
|
655 | + if ('integer' === $cast && 'select' === $columns_items[$column_key]['type']) { |
|
656 | 656 | return null; |
657 | 657 | } |
658 | - if ( 'integer' === $cast && 'multiple-select' === $columns_items[ $column_key ]['type'] ) { |
|
658 | + if ('integer' === $cast && 'multiple-select' === $columns_items[$column_key]['type']) { |
|
659 | 659 | return null; |
660 | 660 | } |
661 | 661 | return $cast; |
@@ -669,12 +669,12 @@ discard block |
||
669 | 669 | * @param array $item Result of sql query. |
670 | 670 | * @return array Item reorganized. |
671 | 671 | */ |
672 | - public function data_reorganize( $item ) { |
|
673 | - $values = explode( '&data;', $item['data'] ); |
|
674 | - foreach ( $values as $value ) { |
|
675 | - $value = explode( '&', $value ); |
|
676 | - if ( ! isset( $this->columns_items[ $value[1] ] ) ) { |
|
677 | - $this->columns_items[ $value[1] ] = array( |
|
672 | + public function data_reorganize($item) { |
|
673 | + $values = explode('&data;', $item['data']); |
|
674 | + foreach ($values as $value) { |
|
675 | + $value = explode('&', $value); |
|
676 | + if (!isset($this->columns_items[$value[1]])) { |
|
677 | + $this->columns_items[$value[1]] = array( |
|
678 | 678 | 'id' => $value[0], |
679 | 679 | 'code' => $value[1], |
680 | 680 | 'name' => $value[2], |
@@ -682,32 +682,32 @@ discard block |
||
682 | 682 | 'data' => $value[7], |
683 | 683 | ); |
684 | 684 | } |
685 | - if ( 'yes' === $value[4] ) { |
|
686 | - if ( isset( $item[ $value[1] ]['value'] ) ) { |
|
687 | - if ( is_array( $item[ $value[1] ]['value'] ) ) { |
|
688 | - $item[ $value[1] ]['value'][] = $value[3]; |
|
685 | + if ('yes' === $value[4]) { |
|
686 | + if (isset($item[$value[1]]['value'])) { |
|
687 | + if (is_array($item[$value[1]]['value'])) { |
|
688 | + $item[$value[1]]['value'][] = $value[3]; |
|
689 | 689 | } else { |
690 | - $item[ $value[1] ]['value'] = array( $item[ $value[1] ]['value'], $value[3] ); |
|
690 | + $item[$value[1]]['value'] = array($item[$value[1]]['value'], $value[3]); |
|
691 | 691 | } |
692 | 692 | } else { |
693 | - $item[ $value[1] ] = array( |
|
693 | + $item[$value[1]] = array( |
|
694 | 694 | 'value' => $value[3], |
695 | 695 | 'unit' => $value[5], |
696 | 696 | ); |
697 | 697 | } |
698 | 698 | } else { |
699 | - if ( isset( $item[ $value[1] ] ) ) { |
|
700 | - if ( is_array( $item[ $value[1] ] ) ) { |
|
701 | - $item[ $value[1] ][] = $value[3]; |
|
702 | - } elseif ( $item[ $value[1] ] !== $value[3] ) { |
|
703 | - $item[ $value[1] ] = array( $item[ $value[1] ], $value[3] ); |
|
699 | + if (isset($item[$value[1]])) { |
|
700 | + if (is_array($item[$value[1]])) { |
|
701 | + $item[$value[1]][] = $value[3]; |
|
702 | + } elseif ($item[$value[1]] !== $value[3]) { |
|
703 | + $item[$value[1]] = array($item[$value[1]], $value[3]); |
|
704 | 704 | } |
705 | 705 | } else { |
706 | - $item[ $value[1] ] = $value[3]; |
|
706 | + $item[$value[1]] = $value[3]; |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | }// End foreach(). |
710 | - unset( $item['data'] ); |
|
710 | + unset($item['data']); |
|
711 | 711 | return $item; |
712 | 712 | } |
713 | 713 | /** |
@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | * @param int $attribute_id Attribute ID. |
718 | 718 | * @return array |
719 | 719 | */ |
720 | - public function get_select_items_option( $attribute_id ) { |
|
721 | - if ( ! isset( self::$wpsdb_values_options[ $attribute_id ] ) ) { |
|
720 | + public function get_select_items_option($attribute_id) { |
|
721 | + if (!isset(self::$wpsdb_values_options[$attribute_id])) { |
|
722 | 722 | global $wpdb; |
723 | 723 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
724 | - self::$wpsdb_values_options[ $attribute_id ] = $wpdb->get_results( |
|
724 | + self::$wpsdb_values_options[$attribute_id] = $wpdb->get_results( |
|
725 | 725 | $wpdb->prepare( |
726 | 726 | "SELECT * |
727 | 727 | FROM {$wpsdb_values_options} |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | ARRAY_A |
733 | 733 | ); |
734 | 734 | } |
735 | - return self::$wpsdb_values_options[ $attribute_id ]; |
|
735 | + return self::$wpsdb_values_options[$attribute_id]; |
|
736 | 736 | } |
737 | 737 | /** |
738 | 738 | * Get all views available. |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | */ |
743 | 743 | public function request_views() { |
744 | 744 | global $wpdb; |
745 | - if ( is_null( $this->_views ) ) { |
|
745 | + if (is_null($this->_views)) { |
|
746 | 746 | $wpsdb_sets = WPSHOP_DBT_ATTRIBUTE_SET; |
747 | 747 | $include_states = array( |
748 | 748 | 'publish', |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | 'trash', |
754 | 754 | 'scheduled', |
755 | 755 | ); |
756 | - $include_states = implode( "','", $include_states ); |
|
757 | - $post_types = implode( "','", $this->_post_types ); |
|
756 | + $include_states = implode("','", $include_states); |
|
757 | + $post_types = implode("','", $this->_post_types); |
|
758 | 758 | $this->_views = $wpdb->get_results( |
759 | 759 | $wpdb->prepare( |
760 | 760 | "SELECT s.id, name, slug, default_set, COUNT(p.ID) AS count |
@@ -780,9 +780,9 @@ discard block |
||
780 | 780 | * @return [type] [description] |
781 | 781 | */ |
782 | 782 | public function request_current_view() { |
783 | - if ( is_null( $this->current_view ) ) { |
|
784 | - foreach ( $this->request_views() as $view ) { |
|
785 | - if ( filter_var( $view['default_set'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
783 | + if (is_null($this->current_view)) { |
|
784 | + foreach ($this->request_views() as $view) { |
|
785 | + if (filter_var($view['default_set'], FILTER_VALIDATE_BOOLEAN)) { |
|
786 | 786 | $this->current_view = $view['id']; |
787 | 787 | } |
788 | 788 | } |
@@ -796,12 +796,12 @@ discard block |
||
796 | 796 | * @return array See :754 order columns. |
797 | 797 | */ |
798 | 798 | public function request_items_columns() { |
799 | - if ( empty( $this->columns_items ) ) { |
|
799 | + if (empty($this->columns_items)) { |
|
800 | 800 | global $wpdb; |
801 | 801 | $wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE; |
802 | 802 | $wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS; |
803 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
804 | - foreach ( $wpdb->get_results( |
|
803 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
804 | + foreach ($wpdb->get_results( |
|
805 | 805 | $wpdb->prepare( |
806 | 806 | "SELECT attr.id, attr.code, attr.frontend_label AS name, attr.backend_input AS type, attr.data_type AS data |
807 | 807 | FROM {$wpsdb_attribute} attr |
@@ -815,11 +815,11 @@ discard block |
||
815 | 815 | $this->entity_id |
816 | 816 | ), |
817 | 817 | ARRAY_A |
818 | - ) as $column ) { |
|
819 | - $this->columns_items[ $column['code'] ] = $column; |
|
818 | + ) as $column) { |
|
819 | + $this->columns_items[$column['code']] = $column; |
|
820 | 820 | } |
821 | 821 | } |
822 | - ksort( $this->columns_items ); |
|
822 | + ksort($this->columns_items); |
|
823 | 823 | return $this->columns_items; |
824 | 824 | } |
825 | 825 | /** |
@@ -830,30 +830,30 @@ discard block |
||
830 | 830 | */ |
831 | 831 | public function get_views() { |
832 | 832 | $result = array(); |
833 | - foreach ( $this->request_views() as $view ) { |
|
833 | + foreach ($this->request_views() as $view) { |
|
834 | 834 | $class = ''; |
835 | - if ( (int) $view['id'] === (int) $this->request_current_view() ) { |
|
835 | + if ((int)$view['id'] === (int)$this->request_current_view()) { |
|
836 | 836 | $class = ' class="current"'; |
837 | 837 | } |
838 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
838 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
839 | 839 | $link = add_query_arg( |
840 | 840 | array( |
841 | 841 | 'page' => |
842 | 842 | str_replace( |
843 | 843 | "{$this->screen->post_type}_page_", |
844 | 844 | '', |
845 | - substr( $this->screen->id, 0, strpos( $this->screen->id, '_att_set_' ) ) . '_att_set_' . $view['id'] |
|
845 | + substr($this->screen->id, 0, strpos($this->screen->id, '_att_set_')) . '_att_set_' . $view['id'] |
|
846 | 846 | ), |
847 | 847 | ), |
848 | 848 | $current_url |
849 | 849 | ); |
850 | - $link = remove_query_arg( 'paged', $link ); |
|
851 | - $result[ $view['id'] ] = sprintf( |
|
850 | + $link = remove_query_arg('paged', $link); |
|
851 | + $result[$view['id']] = sprintf( |
|
852 | 852 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
853 | - esc_url( $link ), |
|
853 | + esc_url($link), |
|
854 | 854 | $class, |
855 | 855 | $view['name'], |
856 | - number_format_i18n( $view['count'] ) |
|
856 | + number_format_i18n($view['count']) |
|
857 | 857 | ); |
858 | 858 | } |
859 | 859 | return $result; |
@@ -865,10 +865,10 @@ discard block |
||
865 | 865 | * @param string $which Can be top or bottom. |
866 | 866 | * @return void Direct display. |
867 | 867 | */ |
868 | - public function bulk_actions( $which = '' ) { |
|
869 | - submit_button( __( 'Save changes', 'wpshop' ), 'bulk-save', 'bulk-save', false, array( |
|
870 | - 'data-nonce' => wp_create_nonce( 'bulk-save-mass-edit-interface-3' ), |
|
871 | - ) ); |
|
868 | + public function bulk_actions($which = '') { |
|
869 | + submit_button(__('Save changes', 'wpshop'), 'bulk-save', 'bulk-save', false, array( |
|
870 | + 'data-nonce' => wp_create_nonce('bulk-save-mass-edit-interface-3'), |
|
871 | + )); |
|
872 | 872 | ?><span class="spinner"></span><?php |
873 | 873 | } |
874 | 874 | /** |
@@ -882,34 +882,34 @@ discard block |
||
882 | 882 | * @param array $rows List of rows always traited. |
883 | 883 | * @return void |
884 | 884 | */ |
885 | - private function _display_row( &$lvl, $item_id, $item, &$rows ) { |
|
886 | - if ( array_key_exists( $item_id, $rows ) ) { |
|
885 | + private function _display_row(&$lvl, $item_id, $item, &$rows) { |
|
886 | + if (array_key_exists($item_id, $rows)) { |
|
887 | 887 | return; |
888 | 888 | } |
889 | - if ( ! array_key_exists( $item['parent'], $this->items ) && 0 !== (int) $item['parent'] ) { |
|
890 | - $parent_item = $this->request( $item['parent'] ); |
|
891 | - if ( isset( $parent_item[0] ) ) { |
|
892 | - $this->items[ $item['parent'] ] = $parent_item[0]; |
|
889 | + if (!array_key_exists($item['parent'], $this->items) && 0 !== (int)$item['parent']) { |
|
890 | + $parent_item = $this->request($item['parent']); |
|
891 | + if (isset($parent_item[0])) { |
|
892 | + $this->items[$item['parent']] = $parent_item[0]; |
|
893 | 893 | } else { |
894 | - $this->items[ $item['parent'] ] = null; |
|
894 | + $this->items[$item['parent']] = null; |
|
895 | 895 | } |
896 | 896 | } |
897 | - if ( array_key_exists( $item['parent'], $rows ) ) { |
|
898 | - $offset = array_search( $item['parent'], array_keys( $rows ), true ); |
|
899 | - $rows_a = array_slice( $rows, $offset, null, true ); |
|
900 | - $rows_a[ $item_id ] = $item; |
|
901 | - $rows_b = array_slice( $rows, 0, $offset, true ); |
|
902 | - $rows = array_replace( $rows_a, $rows_b ); |
|
897 | + if (array_key_exists($item['parent'], $rows)) { |
|
898 | + $offset = array_search($item['parent'], array_keys($rows), true); |
|
899 | + $rows_a = array_slice($rows, $offset, null, true); |
|
900 | + $rows_a[$item_id] = $item; |
|
901 | + $rows_b = array_slice($rows, 0, $offset, true); |
|
902 | + $rows = array_replace($rows_a, $rows_b); |
|
903 | 903 | // $rows = $rows_a + $rows_b; FASTER ? |
904 | 904 | $lvl++; |
905 | - } elseif ( 0 !== (int) $item['parent'] ) { |
|
906 | - $this->_display_row( $lvl, $item['parent'], $this->items[ $item['parent'] ], $rows ); |
|
905 | + } elseif (0 !== (int)$item['parent']) { |
|
906 | + $this->_display_row($lvl, $item['parent'], $this->items[$item['parent']], $rows); |
|
907 | 907 | $lvl++; |
908 | 908 | } |
909 | - if ( ! empty( $item ) ) { |
|
910 | - $item['lvl'] = str_repeat( '— ', $lvl ); |
|
909 | + if (!empty($item)) { |
|
910 | + $item['lvl'] = str_repeat('— ', $lvl); |
|
911 | 911 | } |
912 | - $rows[ $item_id ] = $item; |
|
912 | + $rows[$item_id] = $item; |
|
913 | 913 | } |
914 | 914 | /** |
915 | 915 | * See WP_List_Table. |
@@ -919,13 +919,13 @@ discard block |
||
919 | 919 | */ |
920 | 920 | public function display_rows() { |
921 | 921 | $rows = array(); |
922 | - foreach ( $this->items as $item_id => $item ) { |
|
922 | + foreach ($this->items as $item_id => $item) { |
|
923 | 923 | $lvl = 0; |
924 | - $this->_display_row( $lvl, $item_id, $item, $rows ); |
|
924 | + $this->_display_row($lvl, $item_id, $item, $rows); |
|
925 | 925 | } |
926 | - foreach ( $rows as $item ) { |
|
927 | - if ( ! empty( $item ) ) { |
|
928 | - $this->single_row( $item ); |
|
926 | + foreach ($rows as $item) { |
|
927 | + if (!empty($item)) { |
|
928 | + $this->single_row($item); |
|
929 | 929 | } |
930 | 930 | } |
931 | 931 | } |
@@ -946,52 +946,52 @@ discard block |
||
946 | 946 | * @param boolean $with_id See wp_list_table::print_column_headers. |
947 | 947 | * @return void Direct display. |
948 | 948 | */ |
949 | - public function print_column_headers( $with_id = true ) { |
|
950 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
949 | + public function print_column_headers($with_id = true) { |
|
950 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
951 | 951 | |
952 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
953 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
952 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
953 | + $current_url = remove_query_arg('paged', $current_url); |
|
954 | 954 | |
955 | - if ( isset( $_GET['orderby'] ) ) { // WPCS: CSRF ok. |
|
955 | + if (isset($_GET['orderby'])) { // WPCS: CSRF ok. |
|
956 | 956 | $current_orderby = $_GET['orderby']; // WPCS: CSRF ok. |
957 | 957 | } else { |
958 | 958 | $current_orderby = ''; |
959 | 959 | } |
960 | 960 | |
961 | - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { // WPCS: CSRF ok. |
|
961 | + if (isset($_GET['order']) && 'desc' === $_GET['order']) { // WPCS: CSRF ok. |
|
962 | 962 | $current_order = 'desc'; |
963 | 963 | } else { |
964 | 964 | $current_order = 'asc'; |
965 | 965 | } |
966 | 966 | |
967 | - if ( ! empty( $columns['cb'] ) ) { |
|
967 | + if (!empty($columns['cb'])) { |
|
968 | 968 | static $cb_counter = 1; |
969 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
969 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>' |
|
970 | 970 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
971 | 971 | $cb_counter++; |
972 | 972 | } |
973 | 973 | |
974 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
975 | - $class = array( 'manage-column', "column-$column_key" ); |
|
974 | + foreach ($columns as $column_key => $column_display_name) { |
|
975 | + $class = array('manage-column', "column-$column_key"); |
|
976 | 976 | |
977 | - if ( in_array( $column_key, $hidden, true ) ) { |
|
977 | + if (in_array($column_key, $hidden, true)) { |
|
978 | 978 | $class[] = 'hidden'; |
979 | 979 | } |
980 | 980 | |
981 | - if ( 'cb' === $column_key ) { |
|
981 | + if ('cb' === $column_key) { |
|
982 | 982 | $class[] = 'check-column'; |
983 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { |
|
983 | + } elseif (in_array($column_key, array('posts', 'comments', 'links'), true)) { |
|
984 | 984 | $class[] = 'num'; |
985 | 985 | } |
986 | 986 | |
987 | - if ( $column_key === $primary ) { |
|
987 | + if ($column_key === $primary) { |
|
988 | 988 | $class[] = 'column-primary'; |
989 | 989 | } |
990 | 990 | |
991 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
992 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
991 | + if (isset($sortable[$column_key])) { |
|
992 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
993 | 993 | |
994 | - if ( $current_orderby === $orderby ) { |
|
994 | + if ($current_orderby === $orderby) { |
|
995 | 995 | $order = 'asc' === $current_order ? 'desc' : 'asc'; |
996 | 996 | $class[] = 'sorted'; |
997 | 997 | $class[] = $current_order; |
@@ -1001,17 +1001,17 @@ discard block |
||
1001 | 1001 | $class[] = $desc_first ? 'asc' : 'desc'; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - $cast = $this->cast_column( $column_key ); |
|
1004 | + $cast = $this->cast_column($column_key); |
|
1005 | 1005 | |
1006 | - $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order', 'cast' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
1006 | + $column_display_name = '<a href="' . esc_url(add_query_arg(compact('orderby', 'order', 'cast'), $current_url)) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
1010 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
1009 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
1010 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
1011 | 1011 | $id = $with_id ? "id='$column_key'" : ''; |
1012 | 1012 | |
1013 | - if ( ! empty( $class ) ) { |
|
1014 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
1013 | + if (!empty($class)) { |
|
1014 | + $class = "class='" . join(' ', $class) . "'"; |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; // WPCS: XSS ok. |