Completed
Push — master ( 105b4d...0e906a )
by
unknown
17:37
created
modules/wps_product_mass_interface3/wps_product_mass_interface3.php 1 patch
Spacing   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! class_exists( 'WP_List_Table' ) ) {
2
+if (!class_exists('WP_List_Table')) {
3 3
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
4 4
 }
5
-if ( ! class_exists( 'WP_Posts_List_Table' ) ) {
5
+if (!class_exists('WP_Posts_List_Table')) {
6 6
 	include_once ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php';
7 7
 }
8 8
 new mass_interface3();
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
 		'price_behaviour',
28 28
 	);
29 29
 	public function __construct() {
30
-		add_action( 'admin_menu', array( $this, 'mass_init' ), 350 );
31
-		add_action( 'wp_ajax_wps_mass_3_new', array( $this, 'ajax_new' ) );
32
-		add_action( 'wp_ajax_wps_mass_3_save', array( $this, 'ajax_save' ) );
33
-		add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
30
+		add_action('admin_menu', array($this, 'mass_init'), 350);
31
+		add_action('wp_ajax_wps_mass_3_new', array($this, 'ajax_new'));
32
+		add_action('wp_ajax_wps_mass_3_save', array($this, 'ajax_save'));
33
+		add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3);
34 34
 	}
35 35
 	public function mass_init() {
36
-		$this->hook = add_submenu_page( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, __( 'Mass product edit 3', 'wpshop' ), __( 'Mass product edit 3', 'wpshop' ), 'manage_options', ( isset( $_GET['page'] ) && strpos( $_GET['page'], 'mass_edit_interface3_att_set_' ) !== false ) ? $_GET['page'] : 'mass_edit_interface3_att_set_1', array( $this, 'mass_interface' ) );
37
-		add_action( "load-{$this->hook}", array( $this, 'mass_interface_screen_option' ) );
38
-		add_action( "admin_print_scripts-{$this->hook}", array( $this, 'scripts' ) );
39
-		add_action( "admin_print_styles-{$this->hook}", array( $this, 'styles' ) );
36
+		$this->hook = add_submenu_page('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, __('Mass product edit 3', 'wpshop'), __('Mass product edit 3', 'wpshop'), 'manage_options', (isset($_GET['page']) && strpos($_GET['page'], 'mass_edit_interface3_att_set_') !== false) ? $_GET['page'] : 'mass_edit_interface3_att_set_1', array($this, 'mass_interface'));
37
+		add_action("load-{$this->hook}", array($this, 'mass_interface_screen_option'));
38
+		add_action("admin_print_scripts-{$this->hook}", array($this, 'scripts'));
39
+		add_action("admin_print_styles-{$this->hook}", array($this, 'styles'));
40 40
 	}
41 41
 	public function mass_interface() {
42
-		$wp_list_table = $this->wp_list_table( $this->hook );
42
+		$wp_list_table = $this->wp_list_table($this->hook);
43 43
 		$wp_list_table->prepare_items(); ?>
44 44
 		<div class="wrap">
45 45
 		<h1 class="wp-heading-inline"><?php
46
-		echo esc_html( $this->post_type_object->labels->name );
46
+		echo esc_html($this->post_type_object->labels->name);
47 47
 		?></h1>
48 48
 		<?php
49
-		if ( current_user_can( $this->post_type_object->cap->create_posts ) ) {
50
-			echo ' <a href="#" class="page-title-action" onclick="addPost(event, this)">' . esc_html( $this->post_type_object->labels->add_new ) . '</a>';
49
+		if (current_user_can($this->post_type_object->cap->create_posts)) {
50
+			echo ' <a href="#" class="page-title-action" onclick="addPost(event, this)">' . esc_html($this->post_type_object->labels->add_new) . '</a>';
51 51
 		}
52 52
 		?>
53 53
 		<hr class="wp-header-end">
54 54
 		<form id="posts-filter" method="get">
55 55
 		<?php $wp_list_table->views(); ?>
56
-		<?php $wp_list_table->search_box( $this->post_type_object->labels->search_items, 'post' ); ?>
56
+		<?php $wp_list_table->search_box($this->post_type_object->labels->search_items, 'post'); ?>
57 57
 		<input type="hidden" name="page" value="<?php
58 58
 		 echo str_replace(
59 59
 			 "{$wp_list_table->screen->post_type}_page_",
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
 		  <tr id="inline-edit" class="inline-edit-row inline-edit-row-<?php echo "post inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}"; ?>" style="display: none">
69 69
 		   <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
70 70
 			<fieldset class="inline-edit-col">
71
-			 <legend class="inline-edit-legend"><?php echo esc_html( $this->post_type_object->labels->add_new ) ?></legend>
71
+			 <legend class="inline-edit-legend"><?php echo esc_html($this->post_type_object->labels->add_new) ?></legend>
72 72
 			 <div class="inline-edit-col">
73 73
 		   <label>
74
-			<span class="title"><?php _e( 'Title' ); ?></span>
74
+			<span class="title"><?php _e('Title'); ?></span>
75 75
 			<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
76 76
 		   </label>
77 77
 			 </div>
78 78
 			</fieldset>
79 79
 			<p class="submit inline-edit-save">
80
-			 <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
81
-			 <button type="button" class="button button-primary save alignright"><?php echo esc_html( $this->post_type_object->labels->add_new ); ?></button>
80
+			 <button type="button" class="button cancel alignleft"><?php _e('Cancel'); ?></button>
81
+			 <button type="button" class="button button-primary save alignright"><?php echo esc_html($this->post_type_object->labels->add_new); ?></button>
82 82
 			 <span class="spinner"></span>
83 83
 			 <span class="error" style="display:none"></span>
84 84
 			 <br class="clear" />
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 		<?php
92 92
 	}
93 93
 	public function mass_interface_screen_option() {
94
-		add_action( 'admin_notices', array( $this, 'ajax_admin_notice' ) );
95
-		add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 );
96
-		$this->wp_list_table( $this->hook );
94
+		add_action('admin_notices', array($this, 'ajax_admin_notice'));
95
+		add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2);
96
+		$this->wp_list_table($this->hook);
97 97
 	}
98
-	public function wp_list_table( $screen ) {
99
-		$this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
98
+	public function wp_list_table($screen) {
99
+		$this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
100 100
 		$this->wp_list_table = new WPS_Mass_List_Table(
101 101
 			array(
102 102
 				'screen' => $screen,
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 		);
120 120
 		return $this->wp_list_table;
121 121
 	}
122
-	public function hidden_columns( $hidden, $screen ) {
123
-		$wp_list_table = $this->wp_list_table( $this->hook );
124
-		if ( $screen === $wp_list_table->screen ) {
125
-			$hidden = array_diff( array_flip( $wp_list_table->get_columns() ), $this->default_show_columns );
122
+	public function hidden_columns($hidden, $screen) {
123
+		$wp_list_table = $this->wp_list_table($this->hook);
124
+		if ($screen === $wp_list_table->screen) {
125
+			$hidden = array_diff(array_flip($wp_list_table->get_columns()), $this->default_show_columns);
126 126
 		}
127 127
 		return $hidden;
128 128
 	}
129
-	public function set_screen_option( $string, $option, $value ) {
129
+	public function set_screen_option($string, $option, $value) {
130 130
 		$class = get_class();
131
-		if ( "{$class}_per_page" === $option ) {
132
-			$value = (int) $value;
133
-			if ( $value < 1 || $value > 999 ) {
131
+		if ("{$class}_per_page" === $option) {
132
+			$value = (int)$value;
133
+			if ($value < 1 || $value > 999) {
134 134
 				$string = false;
135 135
 			}
136 136
 			return $value;
@@ -138,34 +138,34 @@  discard block
 block discarded – undo
138 138
 		return $string;
139 139
 	}
140 140
 	public function ajax_admin_notice() {
141
-		printf( '<div class="%1$s"><p></p></div>', esc_attr( 'hidden is-dismissible notice' ) );
141
+		printf('<div class="%1$s"><p></p></div>', esc_attr('hidden is-dismissible notice'));
142 142
 	}
143 143
 	public function scripts() {
144 144
 		wp_enqueue_script(
145 145
 			'jquery_chosen_js',
146
-			plugin_dir_url( __FILE__ ) . 'chosen.jquery.min.js',
147
-			array( 'jquery' ),
146
+			plugin_dir_url(__FILE__) . 'chosen.jquery.min.js',
147
+			array('jquery'),
148 148
 			true
149 149
 		);
150 150
 		wp_enqueue_script(
151 151
 			'mass_interface3-ajax',
152
-			plugin_dir_url( __FILE__ ) . 'interface3.js',
153
-			array( 'jquery', 'jquery-form' ),
152
+			plugin_dir_url(__FILE__) . 'interface3.js',
153
+			array('jquery', 'jquery-form'),
154 154
 			true
155 155
 		);
156 156
 	}
157 157
 	public function styles() {
158
-		wp_register_style( 'jquery_chosen_css', plugin_dir_url( __FILE__ ) . 'chosen.min.css' );
159
-		wp_register_style( 'mass_interface3_css', plugin_dir_url( __FILE__ ) . 'interface3.css' );
160
-		wp_enqueue_style( 'jquery_chosen_css' );
161
-		wp_enqueue_style( 'mass_interface3_css' );
162
-		wp_deregister_style( 'wpshop_main_css' );
158
+		wp_register_style('jquery_chosen_css', plugin_dir_url(__FILE__) . 'chosen.min.css');
159
+		wp_register_style('mass_interface3_css', plugin_dir_url(__FILE__) . 'interface3.css');
160
+		wp_enqueue_style('jquery_chosen_css');
161
+		wp_enqueue_style('mass_interface3_css');
162
+		wp_deregister_style('wpshop_main_css');
163 163
 	}
164 164
 	public function ajax_new() {
165
-		$wp_list_table = $this->wp_list_table( $_POST['screen'] );
165
+		$wp_list_table = $this->wp_list_table($_POST['screen']);
166 166
 		$wpshop_product_attribute = array();
167
-		foreach ( $wp_list_table->request_items_columns() as $key_var => $var ) {
168
-			$wpshop_product_attribute[ $var['data'] ][ $key_var ] = null;
167
+		foreach ($wp_list_table->request_items_columns() as $key_var => $var) {
168
+			$wpshop_product_attribute[$var['data']][$key_var] = null;
169 169
 		}
170 170
 		$new_product_id = wp_insert_post(
171 171
 			array(
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 				'post_title' => $_POST['title'],
175 175
 			)
176 176
 		);
177
-		if ( ! empty( $new_product_id ) ) {
178
-			update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view );
177
+		if (!empty($new_product_id)) {
178
+			update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view);
179 179
 			$product_class = new wpshop_products();
180 180
 			$product_class->save_product_custom_informations(
181 181
 				$new_product_id, array(
@@ -187,44 +187,44 @@  discard block
 block discarded – undo
187 187
 				)
188 188
 			);
189 189
 		} else {
190
-			wp_die( 1 );
190
+			wp_die(1);
191 191
 		}
192 192
 		$class = get_class();
193
-		$data = $wp_list_table->request( $new_product_id );
194
-		$per_page = $wp_list_table->screen->get_option( 'per_page', 'option' );
193
+		$data = $wp_list_table->request($new_product_id);
194
+		$per_page = $wp_list_table->screen->get_option('per_page', 'option');
195 195
 		$wp_list_table->column_headers();
196 196
 		$wp_list_table->items = true;
197 197
 		ob_start();
198 198
 		$wp_list_table->views();
199 199
 		$subsubsub = ob_get_clean();
200 200
 		ob_start();
201
-		$wp_list_table->display_tablenav( 'top' );
201
+		$wp_list_table->display_tablenav('top');
202 202
 		$tablenav_top = ob_get_clean();
203 203
 		ob_start();
204
-		$wp_list_table->display_tablenav( 'bottom' );
204
+		$wp_list_table->display_tablenav('bottom');
205 205
 		$tablenav_bottom = ob_get_clean();
206
-		add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 );
206
+		add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2);
207 207
 		ob_start();
208
-		$wp_list_table->single_row( $data[0] );
209
-		wp_send_json_success( array(
208
+		$wp_list_table->single_row($data[0]);
209
+		wp_send_json_success(array(
210 210
 			'row' => ob_get_clean(),
211 211
 			'per_page' => $per_page,
212 212
 			'tablenav_top' => $tablenav_top,
213 213
 			'tablenav_bottom' => $tablenav_bottom,
214 214
 			'subsubsub' => $subsubsub,
215
-		) );
215
+		));
216 216
 	}
217 217
 	public function ajax_save() {
218 218
 		$i = 0;
219 219
 		$product_class = new wpshop_products();
220
-		if ( ! empty( $_REQUEST['cb'] ) ) {
221
-			foreach ( $_REQUEST['cb'] as $id ) {
222
-				$id = intval( $id );
223
-				if ( ! empty( $_REQUEST[ 'row_' . $id ] ) ) {
220
+		if (!empty($_REQUEST['cb'])) {
221
+			foreach ($_REQUEST['cb'] as $id) {
222
+				$id = intval($id);
223
+				if (!empty($_REQUEST['row_' . $id])) {
224 224
 					$product_class->save_product_custom_informations(
225 225
 						$id,
226 226
 						array_merge(
227
-							$_REQUEST[ 'row_' . $id ],
227
+							$_REQUEST['row_' . $id],
228 228
 							array(
229 229
 								'post_ID' => $id,
230 230
 								'product_id' => $id,
@@ -254,96 +254,96 @@  discard block
 block discarded – undo
254 254
 	public $exclude_attribute_codes = array();
255 255
 	public $current_view = null;
256 256
 	private $_views = null;
257
-	public function __construct( $args ) {
258
-		if ( isset( $args['exclude_attribute_codes'] ) ) {
257
+	public function __construct($args) {
258
+		if (isset($args['exclude_attribute_codes'])) {
259 259
 			$this->exclude_attribute_codes = $args['exclude_attribute_codes'];
260 260
 		}
261 261
 		parent::__construct(
262 262
 			array(
263 263
 				'plural' => 'posts',
264 264
 				'ajax' => true,
265
-				'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
265
+				'screen' => isset($args['screen']) ? $args['screen'] : null,
266 266
 			)
267 267
 		);
268
-		$this->current_view = (int) substr( $this->screen->id, strpos( $this->screen->id, '_att_set_' ) + 9 );
269
-		$this->entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
268
+		$this->current_view = (int)substr($this->screen->id, strpos($this->screen->id, '_att_set_') + 9);
269
+		$this->entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
270 270
 	}
271 271
 	public function get_columns() {
272 272
 		$columns = array(
273 273
 			'cb'       => '<input type="checkbox" />',
274
-			'title'    => __( 'Title' ),
274
+			'title'    => __('Title'),
275 275
 		);
276
-		foreach ( $this->request_items_columns() as $column => $data_column ) {
277
-			if ( ! empty( $column ) && ! empty( $data_column ) ) {
278
-				$columns[ $column ] = $data_column['name'];
276
+		foreach ($this->request_items_columns() as $column => $data_column) {
277
+			if (!empty($column) && !empty($data_column)) {
278
+				$columns[$column] = $data_column['name'];
279 279
 			}
280 280
 		}
281 281
 		return $columns;
282 282
 	}
283 283
 	protected function get_sortable_columns() {
284 284
 		$sortable_columns = array(
285
-			'title'    => array( 'title', false ),
285
+			'title'    => array('title', false),
286 286
 		);
287
-		foreach ( $this->request_items_columns() as $column => $data_column ) {
288
-			$sortable_columns[ $column ] = array( $data_column['code'], false );
287
+		foreach ($this->request_items_columns() as $column => $data_column) {
288
+			$sortable_columns[$column] = array($data_column['code'], false);
289 289
 		}
290 290
 		return $sortable_columns;
291 291
 	}
292
-	public function column_default( $item, $column_name ) {
293
-		if ( isset( $this->columns_items[ $column_name ] ) && is_callable( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ) ) ) {
294
-			$callable_ext = str_replace( '-', '_', $this->columns_items[ $column_name ]['type'] );
295
-			$callable = array( $this, "column_data_{$callable_ext}" );
296
-			if ( ! is_callable( $callable ) ) {
297
-				$callable = array( $this, 'column_data_text' );
292
+	public function column_default($item, $column_name) {
293
+		if (isset($this->columns_items[$column_name]) && is_callable(array($this, "column_data_{$this->columns_items[$column_name]['type']}"))) {
294
+			$callable_ext = str_replace('-', '_', $this->columns_items[$column_name]['type']);
295
+			$callable = array($this, "column_data_{$callable_ext}");
296
+			if (!is_callable($callable)) {
297
+				$callable = array($this, 'column_data_text');
298 298
 			}
299 299
 			return call_user_func(
300 300
 				$callable,
301
-				$this->columns_items[ $column_name ]['id'],
302
-				$this->columns_items[ $column_name ]['code'],
303
-				$this->columns_items[ $column_name ]['data'],
301
+				$this->columns_items[$column_name]['id'],
302
+				$this->columns_items[$column_name]['code'],
303
+				$this->columns_items[$column_name]['data'],
304 304
 				$item
305 305
 			);
306 306
 		}
307
-		return print_r( $item[ $column_name ], true );
307
+		return print_r($item[$column_name], true);
308 308
 	}
309
-	public function column_cb( $item ) {
309
+	public function column_cb($item) {
310 310
 		return sprintf(
311 311
 			'<input type="checkbox" name="cb[]" value="%d" />',
312 312
 			$item['ID']
313 313
 		);
314 314
 	}
315
-	public function column_title( $item ) {
316
-		if ( 'private' === $item['status'] ) {
317
-			$post_states['private'] = __( 'Private' );
315
+	public function column_title($item) {
316
+		if ('private' === $item['status']) {
317
+			$post_states['private'] = __('Private');
318 318
 		}
319
-		if ( 'draft' === $item['status'] ) {
320
-			$post_states['draft'] = __( 'Draft' );
319
+		if ('draft' === $item['status']) {
320
+			$post_states['draft'] = __('Draft');
321 321
 		}
322
-		if ( 'pending' === $item['status'] ) {
323
-			$post_states['pending'] = _x( 'Pending', 'post status' );
322
+		if ('pending' === $item['status']) {
323
+			$post_states['pending'] = _x('Pending', 'post status');
324 324
 		}
325
-		if ( 'future' === $item['status'] ) {
326
-			$post_states['scheduled'] = __( 'Scheduled' );
325
+		if ('future' === $item['status']) {
326
+			$post_states['scheduled'] = __('Scheduled');
327 327
 		}
328
-		if ( current_user_can( 'edit_post', $item['ID'] ) && 'trash' !== $item['status'] ) {
328
+		if (current_user_can('edit_post', $item['ID']) && 'trash' !== $item['status']) {
329 329
 			$result = sprintf(
330 330
 				'<a class="row-title" href="%s" aria-label="%s">%s</a>',
331
-				get_edit_post_link( $item['ID'] ),
332
-				esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $item['title'] ) ),
331
+				get_edit_post_link($item['ID']),
332
+				esc_attr(sprintf(__('&#8220;%s&#8221; (Edit)'), $item['title'])),
333 333
 				$item['title']
334 334
 			);
335 335
 		} else {
336 336
 			$result = $item['title'];
337 337
 		}
338
-		if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type'] ) {
339
-			$attr_def = get_post_meta( $item['ID'], '_wpshop_variations_attribute_def', true );
338
+		if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type']) {
339
+			$attr_def = get_post_meta($item['ID'], '_wpshop_variations_attribute_def', true);
340 340
 			$columns_items = $this->request_items_columns();
341 341
 			$first_variation = true;
342
-			$parent = $this->items[ $item['parent'] ];
343
-			foreach ( $attr_def as $key => $value ) {
344
-				foreach ( $this->get_select_items_option( $columns_items[ $key ]['id'] ) as $all_value ) {
345
-					if ( $all_value['id'] === $value ) {
346
-						if ( $first_variation ) {
342
+			$parent = $this->items[$item['parent']];
343
+			foreach ($attr_def as $key => $value) {
344
+				foreach ($this->get_select_items_option($columns_items[$key]['id']) as $all_value) {
345
+					if ($all_value['id'] === $value) {
346
+						if ($first_variation) {
347 347
 							$result = $parent['title'] . ' : ';
348 348
 							$first_variation = false;
349 349
 						} else {
@@ -355,31 +355,31 @@  discard block
 block discarded – undo
355 355
 				}
356 356
 			}
357 357
 		}
358
-		if ( ! empty( $post_states ) ) {
359
-			$state_count = count( $post_states );
358
+		if (!empty($post_states)) {
359
+			$state_count = count($post_states);
360 360
 			$i = 0;
361 361
 			$result .= ' &mdash; ';
362
-			foreach ( $post_states as $state ) {
362
+			foreach ($post_states as $state) {
363 363
 				++$i;
364
-				( $i === $state_count ) ? $sep = '' : $sep = ', ';
364
+				($i === $state_count) ? $sep = '' : $sep = ', ';
365 365
 				$result .= "<span class='post-state'>$state$sep</span>";
366 366
 			}
367 367
 		}
368 368
 		return sprintf(
369 369
 			'<strong>%s</strong>',
370
-			isset( $item['lvl'] ) ? $item['lvl'] . $result : $result
370
+			isset($item['lvl']) ? $item['lvl'] . $result : $result
371 371
 		);
372 372
 	}
373
-	public function column_data_default( $attribute_id, $attribute_code, $attribute_data, $item ) {
373
+	public function column_data_default($attribute_id, $attribute_code, $attribute_data, $item) {
374 374
 		return 'default';
375 375
 	}
376
-	public function column_data_text( $attribute_id, $attribute_code, $attribute_data, $item ) {
376
+	public function column_data_text($attribute_id, $attribute_code, $attribute_data, $item) {
377 377
 		$unit = '';
378
-		if ( is_array( $item[ $attribute_code ] ) ) {
379
-			$unit = ' ' . $item[ $attribute_code ]['unit'];
380
-			$value = $item[ $attribute_code ]['value'];
378
+		if (is_array($item[$attribute_code])) {
379
+			$unit = ' ' . $item[$attribute_code]['unit'];
380
+			$value = $item[$attribute_code]['value'];
381 381
 		} else {
382
-			$value = $item[ $attribute_code ];
382
+			$value = $item[$attribute_code];
383 383
 		}
384 384
 		return sprintf(
385 385
 			'<input type="text" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]" value="%4$s">',
@@ -390,29 +390,29 @@  discard block
 block discarded – undo
390 390
 			$unit
391 391
 		);
392 392
 	}
393
-	public function column_data_select( $attribute_id, $attribute_code, $attribute_data, $item ) {
393
+	public function column_data_select($attribute_id, $attribute_code, $attribute_data, $item) {
394 394
 		$unit = '';
395
-		if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) {
396
-			$unit = ' ' . $item[ $attribute_code ]['unit'];
397
-			$value = $item[ $attribute_code ]['value'];
395
+		if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) {
396
+			$unit = ' ' . $item[$attribute_code]['unit'];
397
+			$value = $item[$attribute_code]['value'];
398 398
 		} else {
399
-			$value = $item[ $attribute_code ];
399
+			$value = $item[$attribute_code];
400 400
 		}
401 401
 		$select_items = array();
402
-		foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) {
403
-			if ( is_array( $value ) ) {
404
-				foreach ( $value as $val ) {
405
-					$selected = selected( $val, $option_item['id'], false );
406
-					if ( ! empty( $selected ) ) {
402
+		foreach ($this->get_select_items_option($attribute_id) as $option_item) {
403
+			if (is_array($value)) {
404
+				foreach ($value as $val) {
405
+					$selected = selected($val, $option_item['id'], false);
406
+					if (!empty($selected)) {
407 407
 						break;
408 408
 					}
409 409
 				}
410 410
 			} else {
411
-				$selected = selected( $value, $option_item['id'], false );
411
+				$selected = selected($value, $option_item['id'], false);
412 412
 			}
413 413
 			$select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>";
414 414
 		}
415
-		$select_items = implode( '', $select_items );
415
+		$select_items = implode('', $select_items);
416 416
 		return sprintf(
417 417
 			'<select name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</select>',
418 418
 			$attribute_code,
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
 			$unit
423 423
 		);
424 424
 	}
425
-	public function column_data_textarea( $attribute_id, $attribute_code, $attribute_data, $item ) {
425
+	public function column_data_textarea($attribute_id, $attribute_code, $attribute_data, $item) {
426 426
 		$unit = '';
427
-		if ( is_array( $item[ $attribute_code ] ) ) {
428
-			$unit = ' ' . $item[ $attribute_code ]['unit'];
429
-			$value = $item[ $attribute_code ]['value'];
427
+		if (is_array($item[$attribute_code])) {
428
+			$unit = ' ' . $item[$attribute_code]['unit'];
429
+			$value = $item[$attribute_code]['value'];
430 430
 		} else {
431
-			$value = $item[ $attribute_code ];
431
+			$value = $item[$attribute_code];
432 432
 		}
433 433
 		return sprintf(
434 434
 			'<textarea name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</textarea>',
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
 			$unit
440 440
 		);
441 441
 	}
442
-	public function column_data_multiple_select( $attribute_id, $attribute_code, $attribute_data, $item ) {
442
+	public function column_data_multiple_select($attribute_id, $attribute_code, $attribute_data, $item) {
443 443
 		$unit = '';
444
-		if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) {
445
-			$unit = ' ' . $item[ $attribute_code ]['unit'];
446
-			$value = $item[ $attribute_code ]['value'];
444
+		if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) {
445
+			$unit = ' ' . $item[$attribute_code]['unit'];
446
+			$value = $item[$attribute_code]['value'];
447 447
 		} else {
448
-			$value = $item[ $attribute_code ];
448
+			$value = $item[$attribute_code];
449 449
 		}
450 450
 		$select_items = array();
451
-		foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) {
452
-			if ( is_array( $value ) ) {
453
-				foreach ( $value as $val ) {
454
-					$selected = selected( $val, $option_item['id'], false );
455
-					if ( ! empty( $selected ) ) {
451
+		foreach ($this->get_select_items_option($attribute_id) as $option_item) {
452
+			if (is_array($value)) {
453
+				foreach ($value as $val) {
454
+					$selected = selected($val, $option_item['id'], false);
455
+					if (!empty($selected)) {
456 456
 						break;
457 457
 					}
458 458
 				}
459 459
 			} else {
460
-				$selected = selected( $value, $option_item['id'], false );
460
+				$selected = selected($value, $option_item['id'], false);
461 461
 			}
462 462
 			$select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>";
463 463
 		}
464
-		$select_items = implode( '', $select_items );
464
+		$select_items = implode('', $select_items);
465 465
 		return sprintf(
466 466
 			'<select class="chosen-select" multiple data-placeholder="%6$s" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s][]">%4$s</select>',
467 467
 			$attribute_code,
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 			'Select some options'
473 473
 		);
474 474
 	}
475
-	public function request( $id_post = null ) {
475
+	public function request($id_post = null) {
476 476
 		global $wpdb;
477
-		$per_page = $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) );
477
+		$per_page = $this->get_items_per_page($this->screen->get_option('per_page', 'option'));
478 478
 		$include_states = array(
479 479
 			'publish',
480 480
 			'future',
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 			'trash',
485 485
 			'scheduled',
486 486
 		);
487
-		$include_states = implode( "','", $include_states );
488
-		$post_types = array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION );
489
-		$post_types = implode( "','", $post_types );
490
-		$orderby = isset( $_REQUEST['orderby'] ) ? esc_sql( $_REQUEST['orderby'] ) : 'p.post_date';
491
-		$order = isset( $_REQUEST['order'] ) ? esc_sql( $_REQUEST['order'] ) : 'DESC';
492
-		$cast = isset( $_REQUEST['cast'] ) ? esc_sql( $_REQUEST['cast'] ) : '';
493
-		$cast = strtoupper( $cast );
494
-		$s = isset( $_REQUEST['s'] ) ? esc_sql( $_REQUEST['s'] ) : '';
495
-		$exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes );
487
+		$include_states = implode("','", $include_states);
488
+		$post_types = array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
489
+		$post_types = implode("','", $post_types);
490
+		$orderby = isset($_REQUEST['orderby']) ? esc_sql($_REQUEST['orderby']) : 'p.post_date';
491
+		$order = isset($_REQUEST['order']) ? esc_sql($_REQUEST['order']) : 'DESC';
492
+		$cast = isset($_REQUEST['cast']) ? esc_sql($_REQUEST['cast']) : '';
493
+		$cast = strtoupper($cast);
494
+		$s = isset($_REQUEST['s']) ? esc_sql($_REQUEST['s']) : '';
495
+		$exclude_attribute_codes = implode("','", $this->exclude_attribute_codes);
496 496
 		$extra = '';
497
-		$items_count = $wpdb->prepare( "SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1 );
498
-		if ( ! is_null( $id_post ) ) {
499
-			$id_post = intval( $id_post );
497
+		$items_count = $wpdb->prepare("SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1);
498
+		if (!is_null($id_post)) {
499
+			$id_post = intval($id_post);
500 500
 			$extra = "
501 501
 			AND p.ID = {$id_post}";
502 502
 			$s = '';
503 503
 		}
504
-		if ( true ) { // FOUND_ROWS incompatibilities ?
504
+		if (true) { // FOUND_ROWS incompatibilities ?
505 505
 			$items_count = $wpdb->prepare(
506 506
 				"SELECT COUNT(*)
507 507
 				FROM {$wpdb->posts} p
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		$wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT;
524 524
 		$wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;
525 525
 		$extra_select = '';
526
-		if ( ! in_array( $orderby, array( 'p.post_date', 'title', 'ID' ), true ) ) {
526
+		if (!in_array($orderby, array('p.post_date', 'title', 'ID'), true)) {
527 527
 			$extra_select = "( SELECT IFNULL( {$wpsdb_values_decimal}.value,
528 528
 				IFNULL( {$wpsdb_values_datetime}.value,
529 529
 					IFNULL( {$wpsdb_values_text}.value,
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
 			LEFT JOIN {$wpsdb_values_varchar} ON {$wpsdb_values_varchar}.attribute_id = {$wpsdb_attribute}.id AND {$wpsdb_values_varchar}.entity_id = p1.ID
545 545
 			LEFT JOIN {$wpsdb_values_options} ON {$wpsdb_values_options}.attribute_id = {$wpsdb_attribute}.id AND {$wpsdb_values_options}.id = {$wpsdb_values_integer}.value
546 546
 			WHERE p1.ID = p.ID )";
547
-			if ( ! empty( $cast ) ) {
547
+			if (!empty($cast)) {
548 548
 				$extra_select = "CAST( {$extra_select} AS {$cast} )";
549 549
 			}
550 550
 			$extra_select = ",
551 551
 			{$extra_select} AS {$orderby}";
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(
@@ -607,49 +607,49 @@  discard block
 block discarded – undo
607 607
 				$this->request_current_view(),
608 608
 				$this->entity_id,
609 609
 				'%' . $s . '%',
610
-				( $this->get_pagenum() -1 ) * $per_page,
610
+				($this->get_pagenum() - 1) * $per_page,
611 611
 				$per_page
612 612
 			),
613 613
 			ARRAY_A
614 614
 		);
615
-		if ( ! is_array( $datas ) ) {
615
+		if (!is_array($datas)) {
616 616
 			$datas = array();
617 617
 		}
618
-		if ( ! isset( $this->_pagination_args['total_items'] ) && ! isset( $this->_pagination_args['per_page'] ) ) {
618
+		if (!isset($this->_pagination_args['total_items']) && !isset($this->_pagination_args['per_page'])) {
619 619
 			$this->set_pagination_args(
620 620
 				array(
621
-					'total_items' => (int) $wpdb->get_var( $items_count ),
622
-					'per_page' => $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ),
621
+					'total_items' => (int)$wpdb->get_var($items_count),
622
+					'per_page' => $this->get_items_per_page($this->screen->get_option('per_page', 'option')),
623 623
 				)
624 624
 			);
625 625
 		}
626
-		return array_map( array( $this, 'data_reorganize' ), $datas );
626
+		return array_map(array($this, 'data_reorganize'), $datas);
627 627
 	}
628 628
 	public function prepare_items() {
629
-		foreach ( $this->request() as $item ) {
630
-			$this->items[ $item['ID'] ] = $item;
629
+		foreach ($this->request() as $item) {
630
+			$this->items[$item['ID']] = $item;
631 631
 		}
632 632
 	}
633
-	public function cast_column( $column_key ) {
633
+	public function cast_column($column_key) {
634 634
 		$columns_items = $this->request_items_columns();
635
-		if ( isset( $columns_items[ $column_key ] ) ) {
636
-			$cast = $columns_items[ $column_key ]['data'];
637
-			if ( 'tx_tva' === $column_key ) {
635
+		if (isset($columns_items[$column_key])) {
636
+			$cast = $columns_items[$column_key]['data'];
637
+			if ('tx_tva' === $column_key) {
638 638
 				return 'decimal';
639 639
 			}
640
-			if ( 'integer' === $cast && 'select' === $columns_items[ $column_key ]['type'] ) {
640
+			if ('integer' === $cast && 'select' === $columns_items[$column_key]['type']) {
641 641
 				return null;
642 642
 			}
643 643
 			return $cast;
644 644
 		}
645 645
 		return null;
646 646
 	}
647
-	public function data_reorganize( $item ) {
648
-		$values = explode( ';', $item['data'] );
649
-		foreach ( $values as $value ) {
650
-			$value = explode( ':', $value );
651
-			if ( ! isset( $this->columns_items[ $value[1] ] ) ) {
652
-				$this->columns_items[ $value[1] ] = array(
647
+	public function data_reorganize($item) {
648
+		$values = explode(';', $item['data']);
649
+		foreach ($values as $value) {
650
+			$value = explode(':', $value);
651
+			if (!isset($this->columns_items[$value[1]])) {
652
+				$this->columns_items[$value[1]] = array(
653 653
 					'id' => $value[0],
654 654
 					'code' => $value[1],
655 655
 					'name' => $value[2],
@@ -657,39 +657,39 @@  discard block
 block discarded – undo
657 657
 					'data' => $value[7],
658 658
 				);
659 659
 			}
660
-			if ( 'yes' === $value[4] ) {
661
-				if ( isset( $item[ $value[1] ]['value'] ) ) {
662
-					if ( is_array( $item[ $value[1] ]['value'] ) ) {
663
-						$item[ $value[1] ]['value'][] = $value[3];
660
+			if ('yes' === $value[4]) {
661
+				if (isset($item[$value[1]]['value'])) {
662
+					if (is_array($item[$value[1]]['value'])) {
663
+						$item[$value[1]]['value'][] = $value[3];
664 664
 					} else {
665
-						$item[ $value[1] ]['value'] = array( $item[ $value[1] ]['value'], $value[3] );
665
+						$item[$value[1]]['value'] = array($item[$value[1]]['value'], $value[3]);
666 666
 					}
667 667
 				} else {
668
-					$item[ $value[1] ] = array(
668
+					$item[$value[1]] = array(
669 669
 						'value' => $value[3],
670 670
 						'unit' => $value[5],
671 671
 					);
672 672
 				}
673 673
 			} else {
674
-				if ( isset( $item[ $value[1] ] ) ) {
675
-					if ( is_array( $item[ $value[1] ] ) ) {
676
-						$item[ $value[1] ][] = $value[3];
674
+				if (isset($item[$value[1]])) {
675
+					if (is_array($item[$value[1]])) {
676
+						$item[$value[1]][] = $value[3];
677 677
 					} else {
678
-						$item[ $value[1] ] = array( $item[ $value[1] ], $value[3] );
678
+						$item[$value[1]] = array($item[$value[1]], $value[3]);
679 679
 					}
680 680
 				} else {
681
-					$item[ $value[1] ] = $value[3];
681
+					$item[$value[1]] = $value[3];
682 682
 				}
683 683
 			}
684 684
 		}// End foreach().
685
-		unset( $item['data'] );
685
+		unset($item['data']);
686 686
 		return $item;
687 687
 	}
688
-	public function get_select_items_option( $attribute_id ) {
689
-		if ( ! isset( self::$wpsdb_values_options[ $attribute_id ] ) ) {
688
+	public function get_select_items_option($attribute_id) {
689
+		if (!isset(self::$wpsdb_values_options[$attribute_id])) {
690 690
 			global $wpdb;
691 691
 			$wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;
692
-			self::$wpsdb_values_options[ $attribute_id ] = $wpdb->get_results(
692
+			self::$wpsdb_values_options[$attribute_id] = $wpdb->get_results(
693 693
 				$wpdb->prepare(
694 694
 					"SELECT *
695 695
 					FROM {$wpsdb_values_options}
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 				ARRAY_A
701 701
 			);
702 702
 		}
703
-		return self::$wpsdb_values_options[ $attribute_id ];
703
+		return self::$wpsdb_values_options[$attribute_id];
704 704
 	}
705 705
 	public function request_views() {
706 706
 		global $wpdb;
707
-		if ( is_null( $this->_views ) ) {
707
+		if (is_null($this->_views)) {
708 708
 			$wpsdb_sets = WPSHOP_DBT_ATTRIBUTE_SET;
709 709
 			$include_states = array(
710 710
 				'publish',
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 				'trash',
716 716
 				'scheduled',
717 717
 			);
718
-			$include_states = implode( "','", $include_states );
718
+			$include_states = implode("','", $include_states);
719 719
 			$this->_views = $wpdb->get_results(
720 720
 				$wpdb->prepare(
721 721
 					"SELECT s.id, name, slug, default_set, COUNT(p.ID) AS count
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
 		return $this->_views;
737 737
 	}
738 738
 	public function request_current_view() {
739
-		if ( is_null( $this->current_view ) ) {
740
-			foreach ( $this->request_views() as $view ) {
741
-				if ( filter_var( $view['default_set'], FILTER_VALIDATE_BOOLEAN ) ) {
739
+		if (is_null($this->current_view)) {
740
+			foreach ($this->request_views() as $view) {
741
+				if (filter_var($view['default_set'], FILTER_VALIDATE_BOOLEAN)) {
742 742
 					$this->current_view = $view['id'];
743 743
 				}
744 744
 			}
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
 		return $this->current_view;
747 747
 	}
748 748
 	public function request_items_columns() {
749
-		if ( empty( $this->columns_items ) ) {
749
+		if (empty($this->columns_items)) {
750 750
 			global $wpdb;
751 751
 			$wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE;
752 752
 			$wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS;
753
-			$exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes );
754
-			foreach ( $wpdb->get_results(
753
+			$exclude_attribute_codes = implode("','", $this->exclude_attribute_codes);
754
+			foreach ($wpdb->get_results(
755 755
 				$wpdb->prepare(
756 756
 					"SELECT {$wpsdb_attribute}.id, {$wpsdb_attribute}.code, {$wpsdb_attribute}.frontend_label AS name, {$wpsdb_attribute}.backend_input AS type, {$wpsdb_attribute}.data_type AS data
757 757
 					FROM {$wpsdb_attribute}
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 					$this->entity_id
766 766
 				),
767 767
 				ARRAY_A
768
-			) as $column ) {
769
-				$this->columns_items[ $column['code'] ] = $column;
768
+			) as $column) {
769
+				$this->columns_items[$column['code']] = $column;
770 770
 			}
771 771
 		}
772
-		ksort( $this->columns_items );
772
+		ksort($this->columns_items);
773 773
 		return $this->columns_items;
774 774
 	}
775 775
 	public function get_views() {
776 776
 		$result = array();
777
-		foreach ( $this->request_views() as $view ) {
777
+		foreach ($this->request_views() as $view) {
778 778
 			$class = '';
779
-			if ( (int) $view['id'] === (int) $this->request_current_view() ) {
779
+			if ((int)$view['id'] === (int)$this->request_current_view()) {
780 780
 				$class = ' class="current"';
781 781
 			}
782 782
 			$link = add_query_arg(
@@ -785,64 +785,64 @@  discard block
 block discarded – undo
785 785
 				str_replace(
786 786
 					"{$this->screen->post_type}_page_",
787 787
 					'',
788
-					substr( $this->screen->id, 0, strpos( $this->screen->id, '_att_set_' ) ) . '_att_set_' . $view['id']
788
+					substr($this->screen->id, 0, strpos($this->screen->id, '_att_set_')) . '_att_set_' . $view['id']
789 789
 				),
790 790
 				)
791 791
 			);
792
-			$link = remove_query_arg( 'paged', $link );
793
-			$result[ $view['id'] ] = sprintf(
792
+			$link = remove_query_arg('paged', $link);
793
+			$result[$view['id']] = sprintf(
794 794
 				'<a href="%s"%s>%s <span class="count">(%s)</span></a>',
795
-				esc_url( $link ),
795
+				esc_url($link),
796 796
 				$class,
797 797
 				$view['name'],
798
-				number_format_i18n( $view['count'] )
798
+				number_format_i18n($view['count'])
799 799
 			);
800 800
 		}
801 801
 		return $result;
802 802
 	}
803
-	public function bulk_actions( $which = '' ) {
804
-		submit_button( __( 'Save changes', 'wpshop' ), 'bulk-save', 'bulk-save', false );
803
+	public function bulk_actions($which = '') {
804
+		submit_button(__('Save changes', 'wpshop'), 'bulk-save', 'bulk-save', false);
805 805
 			?><span class="spinner"></span><?php
806 806
 	}
807
-	private function _display_row( &$lvl, $item_id, $item, &$rows ) {
808
-		if ( array_key_exists( $item_id, $rows ) ) {
807
+	private function _display_row(&$lvl, $item_id, $item, &$rows) {
808
+		if (array_key_exists($item_id, $rows)) {
809 809
 			return;
810 810
 		}
811
-		if ( ! array_key_exists( $item['parent'], $this->items ) && 0 !== (int) $item['parent'] ) {
812
-			$parent_item = $this->request( $item['parent'] );
813
-			$this->items[ $item['parent'] ] = $parent_item[0];
811
+		if (!array_key_exists($item['parent'], $this->items) && 0 !== (int)$item['parent']) {
812
+			$parent_item = $this->request($item['parent']);
813
+			$this->items[$item['parent']] = $parent_item[0];
814 814
 		}
815
-		if ( array_key_exists( $item['parent'], $rows ) ) {
816
-			$offset = array_search( $item['parent'], array_keys( $rows ), true );
817
-			$rows_a = array_slice( $rows, $offset, null, true );
818
-			$rows_a[ $item_id ] = $item;
819
-			$rows_b = array_slice( $rows, 0, $offset, true );
820
-			$rows = array_replace( $rows_a, $rows_b );
815
+		if (array_key_exists($item['parent'], $rows)) {
816
+			$offset = array_search($item['parent'], array_keys($rows), true);
817
+			$rows_a = array_slice($rows, $offset, null, true);
818
+			$rows_a[$item_id] = $item;
819
+			$rows_b = array_slice($rows, 0, $offset, true);
820
+			$rows = array_replace($rows_a, $rows_b);
821 821
 			// $rows = $rows_a + $rows_b; FASTER ?
822 822
 			$lvl++;
823
-		} elseif ( 0 !== (int) $item['parent'] ) {
824
-			$this->_display_row( $lvl, $item['parent'], $this->items[ $item['parent'] ], $rows );
823
+		} elseif (0 !== (int)$item['parent']) {
824
+			$this->_display_row($lvl, $item['parent'], $this->items[$item['parent']], $rows);
825 825
 			$lvl++;
826 826
 		}
827
-		if ( ! empty( $item ) ) {
828
-			$item['lvl'] = str_repeat( '&#8212; ', $lvl );
827
+		if (!empty($item)) {
828
+			$item['lvl'] = str_repeat('&#8212; ', $lvl);
829 829
 		}
830
-		$rows[ $item_id ] = $item;
830
+		$rows[$item_id] = $item;
831 831
 	}
832 832
 	public function display_rows() {
833 833
 		$rows = array();
834
-		foreach ( $this->items as $item_id => $item ) {
834
+		foreach ($this->items as $item_id => $item) {
835 835
 			$lvl = 0;
836
-			$this->_display_row( $lvl, $item_id, $item, $rows );
836
+			$this->_display_row($lvl, $item_id, $item, $rows);
837 837
 		}
838
-		foreach ( $rows as $item ) {
839
-			if ( ! empty( $item ) ) {
840
-				$this->single_row( $item );
838
+		foreach ($rows as $item) {
839
+			if (!empty($item)) {
840
+				$this->single_row($item);
841 841
 			}
842 842
 		}
843 843
 	}
844
-	public function single_row( $item ) {
845
-		parent::single_row( $item );
844
+	public function single_row($item) {
845
+		parent::single_row($item);
846 846
 	}
847 847
 	public function views() {
848 848
 		parent::views();
@@ -850,52 +850,52 @@  discard block
 block discarded – undo
850 850
 		// echo "<input type=\"hidden\" name=\"attribute_set\" value=\"{$current_view}\">";
851 851
 	}
852 852
 	// Duplicate of wp_list_table function
853
-	public function print_column_headers( $with_id = true ) {
854
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
853
+	public function print_column_headers($with_id = true) {
854
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
855 855
 
856
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
857
-		$current_url = remove_query_arg( 'paged', $current_url );
856
+		$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
857
+		$current_url = remove_query_arg('paged', $current_url);
858 858
 
859
-		if ( isset( $_GET['orderby'] ) ) {
859
+		if (isset($_GET['orderby'])) {
860 860
 			$current_orderby = $_GET['orderby'];
861 861
 		} else {
862 862
 			$current_orderby = '';
863 863
 		}
864 864
 
865
-		if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
865
+		if (isset($_GET['order']) && 'desc' === $_GET['order']) {
866 866
 			$current_order = 'desc';
867 867
 		} else {
868 868
 			$current_order = 'asc';
869 869
 		}
870 870
 
871
-		if ( ! empty( $columns['cb'] ) ) {
871
+		if (!empty($columns['cb'])) {
872 872
 			static $cb_counter = 1;
873
-			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
873
+			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>'
874 874
 			 . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
875 875
 			$cb_counter++;
876 876
 		}
877 877
 
878
-		foreach ( $columns as $column_key => $column_display_name ) {
879
-			$class = array( 'manage-column', "column-$column_key" );
878
+		foreach ($columns as $column_key => $column_display_name) {
879
+			$class = array('manage-column', "column-$column_key");
880 880
 
881
-			if ( in_array( $column_key, $hidden, true ) ) {
881
+			if (in_array($column_key, $hidden, true)) {
882 882
 				$class[] = 'hidden';
883 883
 			}
884 884
 
885
-			if ( 'cb' === $column_key ) {
885
+			if ('cb' === $column_key) {
886 886
 				$class[] = 'check-column';
887
-			} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
887
+			} elseif (in_array($column_key, array('posts', 'comments', 'links'), true)) {
888 888
 				$class[] = 'num';
889 889
 			}
890 890
 
891
-			if ( $column_key === $primary ) {
891
+			if ($column_key === $primary) {
892 892
 				$class[] = 'column-primary';
893 893
 			}
894 894
 
895
-			if ( isset( $sortable[ $column_key ] ) ) {
896
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
895
+			if (isset($sortable[$column_key])) {
896
+				list($orderby, $desc_first) = $sortable[$column_key];
897 897
 
898
-				if ( $current_orderby === $orderby ) {
898
+				if ($current_orderby === $orderby) {
899 899
 					$order = 'asc' === $current_order ? 'desc' : 'asc';
900 900
 					$class[] = 'sorted';
901 901
 					$class[] = $current_order;
@@ -905,17 +905,17 @@  discard block
 block discarded – undo
905 905
 					$class[] = $desc_first ? 'asc' : 'desc';
906 906
 				}
907 907
 
908
-				$cast = $this->cast_column( $column_key );
908
+				$cast = $this->cast_column($column_key);
909 909
 
910
-				$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>';
910
+				$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>';
911 911
 			}
912 912
 
913
-			$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
914
-			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
913
+			$tag = ('cb' === $column_key) ? 'td' : 'th';
914
+			$scope = ('th' === $tag) ? 'scope="col"' : '';
915 915
 			$id = $with_id ? "id='$column_key'" : '';
916 916
 
917
-			if ( ! empty( $class ) ) {
918
-				$class = "class='" . join( ' ', $class ) . "'";
917
+			if (!empty($class)) {
918
+				$class = "class='" . join(' ', $class) . "'";
919 919
 			}
920 920
 
921 921
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
Please login to merge, or discard this patch.