Completed
Push — master ( 5987fc...959a28 )
by
unknown
13:59
created
includes/modules/wps_message/controller/wps_message_ctr.php 2 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,6 +139,9 @@  discard block
 block discarded – undo
139 139
 		return $output;
140 140
 	}
141 141
 
142
+	/**
143
+	 * @param string $code
144
+	 */
142 145
 	public static function get_xml_messages( $code = null ) {
143 146
 		if ( is_null( self::$xml_messages ) ) {
144 147
 			$xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' );
@@ -328,7 +331,11 @@  discard block
 block discarded – undo
328 331
 
329 332
 	/** Store a new message
330 333
 	 *
331
-	 * @return boolean
334
+	 * @param string $email
335
+	 * @param string $title
336
+	 * @param string $message
337
+	 * @param integer $model_id
338
+	 * @return boolean|null
332 339
 	 */
333 340
 	function add_message( $recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null ) {
334 341
 
Please login to merge, or discard this patch.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) { exit;
1
+<?php if (!defined('ABSPATH')) { exit;
2 2
 }
3 3
 class wps_message_ctr {
4 4
 
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 	function __construct() {
19 19
 
20 20
 		/** Js */
21
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
21
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
22 22
 		// End if().
23 23
 		$this->template_dir = WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/';
24 24
 		// WP General actions
25
-		add_action( 'admin_init', array( $this, 'wps_messages_init_actions' ) );
26
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
27
-		add_action( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column',  array( $this, 'messages_custom_columns' ) );
28
-		add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array( $this, 'messages_edit_columns' ) );
25
+		add_action('admin_init', array($this, 'wps_messages_init_actions'));
26
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
27
+		add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column', array($this, 'messages_custom_columns'));
28
+		add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array($this, 'messages_edit_columns'));
29 29
 		// Shortcodes
30
-		add_shortcode( 'wps_message_histo', array( $this, 'display_message_histo_per_customer' ) );
31
-		add_shortcode( 'order_customer_personnal_informations', array( $this, 'order_personnal_informations' ) );
30
+		add_shortcode('wps_message_histo', array($this, 'display_message_histo_per_customer'));
31
+		add_shortcode('order_customer_personnal_informations', array($this, 'order_personnal_informations'));
32 32
 		/** Ajax */
33
-		add_action( 'wp_ajax_get_content_message', array( $this, 'get_content_message' ) );
33
+		add_action('wp_ajax_get_content_message', array($this, 'get_content_message'));
34 34
 	}
35 35
 
36 36
 	/**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
 		/** Css */
42 42
 		add_thickbox();
43
-		wp_register_style( 'wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION );
44
-		wp_enqueue_style( 'wpeo-message-css' );
43
+		wp_register_style('wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION);
44
+		wp_enqueue_style('wpeo-message-css');
45 45
 		/** My js */
46
-		wp_enqueue_script( 'wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array( 'jquery', 'thickbox' ), WPS_MESSAGE_VERSION );
46
+		wp_enqueue_script('wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array('jquery', 'thickbox'), WPS_MESSAGE_VERSION);
47 47
 	}
48 48
 
49 49
 	/**
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	function create_message_type() {
61 61
 
62
-		register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array(
62
+		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array(
63 63
 			'labels' => array(
64
-				'name' => __( 'Message', 'wpshop' ),
65
-				'singular_name' => __( 'message', 'wpshop' ),
66
-				'add_new' => __( 'Add message', 'wpshop' ),
67
-				'add_new_item' => __( 'Add New message', 'wpshop' ),
68
-				'edit' => __( 'Edit', 'wpshop' ),
69
-				'edit_item' => __( 'Edit message', 'wpshop' ),
70
-				'new_item' => __( 'New message', 'wpshop' ),
71
-				'view' => __( 'View message', 'wpshop' ),
72
-				'view_item' => __( 'View message', 'wpshop' ),
73
-				'search_items' => __( 'Search messages', 'wpshop' ),
74
-				'not_found' => __( 'No message found', 'wpshop' ),
75
-				'not_found_in_trash' => __( 'No message found in trash', 'wpshop' ),
64
+				'name' => __('Message', 'wpshop'),
65
+				'singular_name' => __('message', 'wpshop'),
66
+				'add_new' => __('Add message', 'wpshop'),
67
+				'add_new_item' => __('Add New message', 'wpshop'),
68
+				'edit' => __('Edit', 'wpshop'),
69
+				'edit_item' => __('Edit message', 'wpshop'),
70
+				'new_item' => __('New message', 'wpshop'),
71
+				'view' => __('View message', 'wpshop'),
72
+				'view_item' => __('View message', 'wpshop'),
73
+				'search_items' => __('Search messages', 'wpshop'),
74
+				'not_found' => __('No message found', 'wpshop'),
75
+				'not_found_in_trash' => __('No message found in trash', 'wpshop'),
76 76
 				'parent-item-colon' => '',
77 77
 			),
78
-			'description' => __( 'This is where store messages are stored.', 'wpshop' ),
78
+			'description' => __('This is where store messages are stored.', 'wpshop'),
79 79
 			'public' => true,
80 80
 			'show_ui' => true,
81 81
 			'capability_type' => 'post',
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 			'show_in_nav_menus' => false,
87 87
 			'rewrite' => false,
88 88
 			'query_var' => true,
89
-			'supports' => array( 'title', 'editor' ),
89
+			'supports' => array('title', 'editor'),
90 90
 			'has_archive' => false,
91
-		) );
91
+		));
92 92
 	}
93 93
 
94 94
 	/**
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	function add_meta_boxes() {
98 98
 
99 99
 		// Add message sending historic meta box
100
-		add_meta_box( 'wpshop_message_histo',
101
-			__( 'Message historic', 'wpshop' ),
102
-			array( $this, 'message_histo_box' ),
103
-		WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high' );
100
+		add_meta_box('wpshop_message_histo',
101
+			__('Message historic', 'wpshop'),
102
+			array($this, 'message_histo_box'),
103
+		WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high');
104 104
 	}
105 105
 
106 106
 	/**
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	 * @param unknown_type $post
110 110
 	 * @param unknown_type $params
111 111
 	 */
112
-	function message_histo_box( $post, $params ) {
112
+	function message_histo_box($post, $params) {
113 113
 
114 114
 		$output  = '<div id="message_histo_container">';
115
-		$output .= $this->get_historic_message_by_type( $post->ID );
115
+		$output .= $this->get_historic_message_by_type($post->ID);
116 116
 		$output .= '</div>';
117 117
 		echo $output;
118 118
 	}
@@ -123,39 +123,39 @@  discard block
 block discarded – undo
123 123
 	 * @param  integer $message_type_id : Message type ID
124 124
 	 * @return string
125 125
 	 */
126
-	function get_historic_message_by_type( $message_type_id ) {
126
+	function get_historic_message_by_type($message_type_id) {
127 127
 
128 128
 		global $wpdb;
129 129
 		$output = '';
130
-		if ( ! empty( $message_type_id ) ) {
130
+		if (!empty($message_type_id)) {
131 131
 			// Recover all sended messages
132 132
 			$wps_message_mdl = new wps_message_mdl();
133
-			$messages = $wps_message_mdl->get_messages_histo( $message_type_id );
133
+			$messages = $wps_message_mdl->get_messages_histo($message_type_id);
134 134
 			ob_start();
135
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic' ) );
135
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic'));
136 136
 			$output .= ob_get_contents();
137 137
 			ob_end_clean();
138 138
 		}
139 139
 		return $output;
140 140
 	}
141 141
 
142
-	public static function get_xml_messages( $code = null ) {
143
-		if ( is_null( self::$xml_messages ) ) {
144
-			$xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' );
145
-			$default_emails = new SimpleXMLElement( $xml_default_emails );
142
+	public static function get_xml_messages($code = null) {
143
+		if (is_null(self::$xml_messages)) {
144
+			$xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml');
145
+			$default_emails = new SimpleXMLElement($xml_default_emails);
146 146
 			self::$xml_messages = array();
147
-			foreach ( $default_emails->xpath( '//emails/email' ) as $email ) {
148
-				self::$xml_messages[ (string) $email->attributes()->code ] = array(
149
-					'shop_type' => (string) $email->attributes()->shop_type,
150
-					'object' => (string) $email->subject,
151
-					'message' => (string) $email->content,
147
+			foreach ($default_emails->xpath('//emails/email') as $email) {
148
+				self::$xml_messages[(string)$email->attributes()->code] = array(
149
+					'shop_type' => (string)$email->attributes()->shop_type,
150
+					'object' => (string)$email->subject,
151
+					'message' => (string)$email->content,
152 152
 				);
153 153
 			}
154 154
 		}
155
-		if ( is_null( $code ) ) {
155
+		if (is_null($code)) {
156 156
 			return self::$xml_messages;
157
-		} elseif ( isset( self::$xml_messages[ $code ] ) ) {
158
-			return self::$xml_messages[ $code ];
157
+		} elseif (isset(self::$xml_messages[$code])) {
158
+			return self::$xml_messages[$code];
159 159
 		} else {
160 160
 			return false;
161 161
 		}
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public static function create_default_message() {
167 167
 		// Read default emails for options creation
168
-		foreach ( self::get_xml_messages() as $code => $email ) {
169
-			if ( ( WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type'] ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) {
170
-				self::createMessage( $code, $email['object'], $email['message'] );
168
+		foreach (self::get_xml_messages() as $code => $email) {
169
+			if ((WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type']) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) {
170
+				self::createMessage($code, $email['object'], $email['message']);
171 171
 			}
172 172
 		}
173 173
 	}
@@ -180,23 +180,23 @@  discard block
 block discarded – undo
180 180
 	 * @param string $message : Message content
181 181
 	 * @return integer message ID
182 182
 	 */
183
-	public static function createMessage( $code, $object = '', $message = '' ) {
183
+	public static function createMessage($code, $object = '', $message = '') {
184 184
 
185 185
 		$id = 0;
186
-		$xml_message = self::get_xml_messages( $code );
187
-		$object = empty( $object ) ? $xml_message['object'] : $object;
188
-		$message = empty( $message ) ? $xml_message['message'] : $message;
189
-		$message_option = get_option( $code, null );
190
-		if ( empty( $message_option ) && ! empty( $object ) && ! empty( $message ) ) {
186
+		$xml_message = self::get_xml_messages($code);
187
+		$object = empty($object) ? $xml_message['object'] : $object;
188
+		$message = empty($message) ? $xml_message['message'] : $message;
189
+		$message_option = get_option($code, null);
190
+		if (empty($message_option) && !empty($object) && !empty($message)) {
191 191
 			$new_message = array(
192
-				'post_title' => __( $object , 'wpshop' ),
193
-				'post_content' => self::customize_message( __( $message, 'wpshop' ) ),
192
+				'post_title' => __($object, 'wpshop'),
193
+				'post_content' => self::customize_message(__($message, 'wpshop')),
194 194
 				'post_status' => 'publish',
195 195
 				'post_author' => 1,
196 196
 				'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE,
197 197
 			);
198
-			$id = wp_insert_post( $new_message );
199
-			update_option( $code, $id );
198
+			$id = wp_insert_post($new_message);
199
+			update_option($code, $id);
200 200
 		} else {
201 201
 			$id = $message_option;
202 202
 		}
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @return array
211 211
 	 */
212
-	function messages_custom_columns( $column ) {
212
+	function messages_custom_columns($column) {
213 213
 
214 214
 		global $post;
215 215
 		$metadata = get_post_custom();
216
-		switch ( $column ) {
216
+		switch ($column) {
217 217
 			case 'extract':
218
-				echo wp_trim_words( $post->post_content, 55 );
218
+				echo wp_trim_words($post->post_content, 55);
219 219
 		break;
220 220
 			case 'last_dispatch_date':
221
-				if ( ! empty( $metadata['wpshop_message_last_dispatch_date'][0] ) ) {
222
-					echo mysql2date( 'd F Y, H:i:s',$metadata['wpshop_message_last_dispatch_date'][0], true );
221
+				if (!empty($metadata['wpshop_message_last_dispatch_date'][0])) {
222
+					echo mysql2date('d F Y, H:i:s', $metadata['wpshop_message_last_dispatch_date'][0], true);
223 223
 				} else { echo '-';
224 224
 				}
225 225
 		break;
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return array
233 233
 	 */
234
-	function messages_edit_columns( $columns ) {
234
+	function messages_edit_columns($columns) {
235 235
 
236 236
 		$columns = array(
237 237
 			'cb' => '<input type="checkbox" />',
238
-			'title' => __( 'Name', 'wpshop' ),
239
-			'extract' => __( 'Extract from the message','wpshop' ),
240
-			'date' => __( 'Creation date','wpshop' ),
241
-			'last_dispatch_date' => __( 'Last dispatch date','wpshop' ),
238
+			'title' => __('Name', 'wpshop'),
239
+			'extract' => __('Extract from the message', 'wpshop'),
240
+			'date' => __('Creation date', 'wpshop'),
241
+			'last_dispatch_date' => __('Last dispatch date', 'wpshop'),
242 242
 		);
243 243
 		return $columns;
244 244
 	}
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 	 * @param integer $current
250 250
 	 * @return string
251 251
 	 */
252
-	function getMessageListOption( $current = 0 ) {
252
+	function getMessageListOption($current = 0) {
253 253
 
254
-		$posts = query_posts( array(
254
+		$posts = query_posts(array(
255 255
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE,
256 256
 			'posts_per_page' => '-1',
257
-		) );
257
+		));
258 258
 		$options = '';
259
-		if ( ! empty( $posts ) ) {
260
-			$options = '<option value="0">' . __( 'Select values from list', 'wpshop' ) . '</option>';
261
-			foreach ( $posts as $p ) {
262
-				$selected = $p->ID == $current ? ' selected="selected"': '';
259
+		if (!empty($posts)) {
260
+			$options = '<option value="0">' . __('Select values from list', 'wpshop') . '</option>';
261
+			foreach ($posts as $p) {
262
+				$selected = $p->ID == $current ? ' selected="selected"' : '';
263 263
 				$options .= '<option value="' . $p->ID . '"' . $selected . '>' . $p->post_title . '</option>';
264 264
 			}
265 265
 		}
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 	 * @param integer $customer_id : ID to identifiate the customer
275 275
 	 * @return string
276 276
 	 */
277
-	function display_message_histo_per_customer( $args, $customer_id = '' ) {
277
+	function display_message_histo_per_customer($args, $customer_id = '') {
278 278
 
279
-		$customer_id = ( ! empty( $customer_id ) ) ? $customer_id : get_current_user_id();
280
-		$message_id = ( ! empty( $args ) && ! empty( $args['message_id'] ) ) ? $args['message_id'] : '';
279
+		$customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id();
280
+		$message_id = (!empty($args) && !empty($args['message_id'])) ? $args['message_id'] : '';
281 281
 		$message_elements = '';
282 282
 		$wps_message_mdl = new wps_message_mdl();
283
-		$messages_data = $wps_message_mdl->get_messages_histo( $message_id, $customer_id );
283
+		$messages_data = $wps_message_mdl->get_messages_histo($message_id, $customer_id);
284 284
 
285 285
 		// ob_start();
286 286
 		// require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, "frontend", "messages") );
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
 		// ob_end_clean();
289 289
 		/**	Order emails	*/
290 290
 		$messages_histo = array();
291
-		foreach ( $messages_data as $meta_id => $messages ) :
291
+		foreach ($messages_data as $meta_id => $messages) :
292 292
 			$i = 0;
293
-			foreach ( $messages as $message ) :
294
-				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['title'] = $message['mess_title'];
295
-				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['message'] = $message['mess_message'];
296
-				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['dates'] = $message['mess_dispatch_date'];
297
-				if ( ! empty( $message['mess_object_id'] ) ) {
298
-					$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['object'] = $message['mess_object_id'];
293
+			foreach ($messages as $message) :
294
+				$messages_histo[$message['mess_dispatch_date'][0]][$i]['title'] = $message['mess_title'];
295
+				$messages_histo[$message['mess_dispatch_date'][0]][$i]['message'] = $message['mess_message'];
296
+				$messages_histo[$message['mess_dispatch_date'][0]][$i]['dates'] = $message['mess_dispatch_date'];
297
+				if (!empty($message['mess_object_id'])) {
298
+					$messages_histo[$message['mess_dispatch_date'][0]][$i]['object'] = $message['mess_object_id'];
299 299
 				}
300 300
 				$i++;
301 301
 		endforeach;
302 302
 endforeach;
303
-		ksort( $messages_histo );
304
-		$messages_histo = array_reverse( $messages_histo );
303
+		ksort($messages_histo);
304
+		$messages_histo = array_reverse($messages_histo);
305 305
 		ob_start();
306
-		require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages' ) );
306
+		require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages'));
307 307
 		$output = ob_get_contents();
308 308
 		ob_end_clean();
309 309
 		return $output;
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	 * @param string $message : message content
316 316
 	 * @return string
317 317
 	 */
318
-	public static function customize_message( $message ) {
318
+	public static function customize_message($message) {
319 319
 
320
-		if ( ! empty( $message ) ) {
320
+		if (!empty($message)) {
321 321
 			ob_start();
322
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure' ) );
322
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure'));
323 323
 			$message = ob_get_contents();
324 324
 			ob_end_clean();
325 325
 		}
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return boolean
332 332
 	 */
333
-	function add_message( $recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null ) {
333
+	function add_message($recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null) {
334 334
 
335
-		$date = empty( $date ) ? current_time( 'mysql', 0 ) : $date;
335
+		$date = empty($date) ? current_time('mysql', 0) : $date;
336 336
 		$object_empty = array(
337 337
 			'object_type' => '',
338 338
 			'object_id' => 0,
339 339
 		);
340
-		$object = array_merge( $object_empty, $object );
341
-		$historic = get_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), true );
340
+		$object = array_merge($object_empty, $object);
341
+		$historic = get_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), true);
342 342
 		$data_to_insert = array(
343 343
 			'mess_user_id' => $recipient_id,
344 344
 			'mess_user_email' => $email,
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 			'mess_object_id' => $object['object_id'],
347 347
 			'mess_title' => $title,
348 348
 			'mess_message' => $message,
349
-			'mess_dispatch_date' => array( $date ),
349
+			'mess_dispatch_date' => array($date),
350 350
 		);
351 351
 		$historic[] = $data_to_insert;
352
-		update_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), $historic );
352
+		update_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), $historic);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,49 +361,49 @@  discard block
 block discarded – undo
361 361
 	 * @param boolean $duplicate_message : Duplicate a light message for historic storage
362 362
 	 * @return string
363 363
 	 */
364
-	function customMessage( $string, $data, $model_name = '', $duplicate_message = false ) {
364
+	function customMessage($string, $data, $model_name = '', $duplicate_message = false) {
365 365
 
366 366
 		$avant = array();
367 367
 		$apres = array();
368
-		$logo_option = get_option( 'wpshop_logo' );
368
+		$logo_option = get_option('wpshop_logo');
369 369
 
370
-		$data['your_shop_logo'] = ( ! empty( $logo_option ) ) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo( 'name' ) . '" />' : '';
370
+		$data['your_shop_logo'] = (!empty($logo_option)) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo('name') . '" />' : '';
371 371
 
372
-		foreach ( $data as $key => $value ) {
372
+		foreach ($data as $key => $value) {
373 373
 			$avant[] = '[' . $key . ']';
374
-			switch ( $key ) {
374
+			switch ($key) {
375 375
 				case 'order_content' :
376
-					$apres[] = ( $duplicate_message ) ? '[order_content]' : $this->order_content_template_for_mail( $data['order_id'] );
376
+					$apres[] = ($duplicate_message) ? '[order_content]' : $this->order_content_template_for_mail($data['order_id']);
377 377
 					break;
378 378
 				case 'order_addresses' :
379
-					$apres[] = ( $duplicate_message ) ? '[order_addresses]' : $this->order_addresses_template_for_mail( $data['order_id'] );
379
+					$apres[] = ($duplicate_message) ? '[order_addresses]' : $this->order_addresses_template_for_mail($data['order_id']);
380 380
 					break;
381 381
 
382 382
 				case 'order_billing_address' :
383
-					$apres[] = ( $duplicate_message ) ? '[order_billing_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'billing' );
383
+					$apres[] = ($duplicate_message) ? '[order_billing_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'billing');
384 384
 					break;
385 385
 
386 386
 				case 'order_shipping_address' :
387
-					$apres[] = ( $duplicate_message ) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'shipping' );
387
+					$apres[] = ($duplicate_message) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'shipping');
388 388
 					break;
389 389
 
390 390
 				case 'order_customer_comments' :
391
-					$apres[] = ( $duplicate_message ) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail( $data['order_id'] );
391
+					$apres[] = ($duplicate_message) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail($data['order_id']);
392 392
 					break;
393 393
 				case 'order_personnal_informations' :
394
-					$apres[] = ( $duplicate_message ) ? '[order_personnal_informations]' : $this->order_personnal_informations();
394
+					$apres[] = ($duplicate_message) ? '[order_personnal_informations]' : $this->order_personnal_informations();
395 395
 					break;
396 396
 				default :
397 397
 					$apres[] = $value;
398 398
 					break;
399 399
 			}
400 400
 		}
401
-		$string = str_replace( $avant, $apres, $string );
401
+		$string = str_replace($avant, $apres, $string);
402 402
 
403
-		$string = apply_filters( 'wps_more_customized_message', $string, $data, $duplicate_message );
403
+		$string = apply_filters('wps_more_customized_message', $string, $data, $duplicate_message);
404 404
 
405
-		if ( ($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE') ) {
406
-			$string = preg_replace( '/\[(.*)\]/Usi', '', $string );
405
+		if (($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE')) {
406
+			$string = preg_replace('/\[(.*)\]/Usi', '', $string);
407 407
 		}
408 408
 
409 409
 		return $string;
@@ -418,22 +418,22 @@  discard block
 block discarded – undo
418 418
 	 * @param string $object : message object
419 419
 	 * @param file   $attached_file : File to attached to e-mail
420 420
 	 */
421
-	function wpshop_prepared_email( $email, $model_name, $data = array(), $object = array(), $attached_file = '' ) {
421
+	function wpshop_prepared_email($email, $model_name, $data = array(), $object = array(), $attached_file = '') {
422 422
 		global $wpdb;
423
-		$data = apply_filters( 'wps_extra_data_to_send_in_email', $data );
424
-		$model_id = get_option( $model_name, 0 );
425
-		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id );
426
-		$post_message = $wpdb->get_row( $query );
423
+		$data = apply_filters('wps_extra_data_to_send_in_email', $data);
424
+		$model_id = get_option($model_name, 0);
425
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id);
426
+		$post_message = $wpdb->get_row($query);
427 427
 		$duplicate_message = '';
428
-		if ( ! empty( $post_message ) ) {
429
-			$title = $this->customMessage( $post_message->post_title, $data, $model_name );
430
-			$message = $this->customMessage( $post_message->post_content, $data, $model_name );
428
+		if (!empty($post_message)) {
429
+			$title = $this->customMessage($post_message->post_title, $data, $model_name);
430
+			$message = $this->customMessage($post_message->post_content, $data, $model_name);
431 431
 			// End if().
432
-			if ( array_key_exists( 'order_content', $data ) || array_key_exists( 'order_addresses', $data ) || array_key_exists( 'order_customer_comments', $data ) ) {
433
-				$duplicate_message = $this->customMessage( $post_message->post_content, $data, $model_name, true );
432
+			if (array_key_exists('order_content', $data) || array_key_exists('order_addresses', $data) || array_key_exists('order_customer_comments', $data)) {
433
+				$duplicate_message = $this->customMessage($post_message->post_content, $data, $model_name, true);
434 434
 			}
435
-			if ( ! empty( $email ) ) {
436
-				$this->wpshop_email( $email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message );
435
+			if (!empty($email)) {
436
+				$this->wpshop_email($email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message);
437 437
 			}
438 438
 		}
439 439
 	}
@@ -450,37 +450,37 @@  discard block
 block discarded – undo
450 450
 	 * @param file    $attachments : File to attached to e-mail
451 451
 	 * @param string  $duplicate_message : lighter message to store
452 452
 	 */
453
-	function wpshop_email( $email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '' ) {
453
+	function wpshop_email($email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '') {
454 454
 		global $wpdb;
455 455
 		// Sauvegarde
456
-		if ( $save ) {
457
-			$user = $wpdb->get_row( 'SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";' );
456
+		if ($save) {
457
+			$user = $wpdb->get_row('SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";');
458 458
 			$user_id = $user ? $user->ID : get_current_user_id();
459
-			$query = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
460
-			$user_post_id = $wpdb->get_var( $query );
459
+			$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
460
+			$user_post_id = $wpdb->get_var($query);
461 461
 
462
-			if ( ! empty( $duplicate_message ) ) {
463
-				$this->add_message( $user_post_id, $email, $title, $duplicate_message, $model_id, $object );
462
+			if (!empty($duplicate_message)) {
463
+				$this->add_message($user_post_id, $email, $title, $duplicate_message, $model_id, $object);
464 464
 			} else {
465
-				$this->add_message( $user_post_id, $email, $title, $message, $model_id, $object );
465
+				$this->add_message($user_post_id, $email, $title, $message, $model_id, $object);
466 466
 			}
467 467
 		}
468 468
 
469
-		$emails = get_option( 'wpshop_emails', array() );
469
+		$emails = get_option('wpshop_emails', array());
470 470
 		$noreply_email = $emails['noreply_email'];
471 471
 		// Split the email to get the name
472
-		$vers_nom = substr( $email, 0, strpos( $email,'@' ) );
472
+		$vers_nom = substr($email, 0, strpos($email, '@'));
473 473
 
474 474
 		// Headers du mail
475 475
 		$headers = "MIME-Version: 1.0\r\n";
476 476
 		$headers .= "Content-type: text/html; charset=UTF-8\r\n";
477
-		$headers .= 'From: ' . get_bloginfo( 'name' ) . ' <' . $noreply_email . '>' . "\r\n";
477
+		$headers .= 'From: ' . get_bloginfo('name') . ' <' . $noreply_email . '>' . "\r\n";
478 478
 
479 479
 		// Mail en HTML
480
-		@wp_mail( $email, $title, $message, $headers, $attachments );
480
+		@wp_mail($email, $title, $message, $headers, $attachments);
481 481
 
482
-		if ( ! empty( $attachments ) ) {
483
-			unlink( $attachments );
482
+		if (!empty($attachments)) {
483
+			unlink($attachments);
484 484
 		}
485 485
 	}
486 486
 
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
 	 * @param integer $order_id : Order ID
491 491
 	 * @return string
492 492
 	 */
493
-	function order_content_template_for_mail( $order_id ) {
493
+	function order_content_template_for_mail($order_id) {
494 494
 		$message = '';
495
-		if ( ! empty( $order_id ) ) {
496
-			$currency_code = wpshop_tools::wpshop_get_currency( false );
497
-			$orders_infos = get_post_meta( $order_id, '_order_postmeta', true );
495
+		if (!empty($order_id)) {
496
+			$currency_code = wpshop_tools::wpshop_get_currency(false);
497
+			$orders_infos = get_post_meta($order_id, '_order_postmeta', true);
498 498
 			ob_start();
499
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template' ) );
499
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template'));
500 500
 			$message .= ob_get_contents();
501 501
 			ob_end_clean();
502 502
 		}
@@ -510,44 +510,44 @@  discard block
 block discarded – undo
510 510
 	 * @param integer $address_type : Address type ID
511 511
 	 * @return string
512 512
 	 */
513
-	function order_addresses_template_for_mail( $order_id, $address_type = '' ) {
513
+	function order_addresses_template_for_mail($order_id, $address_type = '') {
514 514
 		global $wpdb;
515
-		$shipping_option = get_option( 'wpshop_shipping_address_choice' );
516
-		$display_shipping = ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) ? true : false;
515
+		$shipping_option = get_option('wpshop_shipping_address_choice');
516
+		$display_shipping = (!empty($shipping_option) && !empty($shipping_option['activate'])) ? true : false;
517 517
 		$message = '';
518
-		if ( ! empty( $order_id ) ) {
519
-			$order_addresses = get_post_meta( $order_id, '_order_info', true );
520
-			if ( ! empty( $order_addresses ) ) {
521
-				foreach ( $order_addresses as $key => $order_address ) {
522
-					if ( ! empty( $order_address ) && ( empty( $address_type ) || $address_type == $key ) ) {
523
-
524
-						if ( $key != 'shipping' || ($key == 'shipping' && $display_shipping) ) {
525
-							$address_type_title = ( ! empty( $key ) && $key == 'billing' ) ? __( 'Billing address', 'wpshop' ) : __( 'Shipping address', 'wpshop' );
518
+		if (!empty($order_id)) {
519
+			$order_addresses = get_post_meta($order_id, '_order_info', true);
520
+			if (!empty($order_addresses)) {
521
+				foreach ($order_addresses as $key => $order_address) {
522
+					if (!empty($order_address) && (empty($address_type) || $address_type == $key)) {
523
+
524
+						if ($key != 'shipping' || ($key == 'shipping' && $display_shipping)) {
525
+							$address_type_title = (!empty($key) && $key == 'billing') ? __('Billing address', 'wpshop') : __('Shipping address', 'wpshop');
526 526
 							$civility = '';
527
-							if ( ! empty( $order_address['address']['civility'] ) ) {
528
-								$query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility'] );
529
-								$civility = $wpdb->get_var( $query );
527
+							if (!empty($order_address['address']['civility'])) {
528
+								$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility']);
529
+								$civility = $wpdb->get_var($query);
530 530
 							}
531 531
 
532 532
 							// Address informations
533
-							$customer_last_name = ( ! empty( $order_address['address']['address_last_name'] ) ) ? $order_address['address']['address_last_name'] : '';
534
-							$customer_firtsname = ( ! empty( $order_address['address']['address_first_name'] ) ) ? $order_address['address']['address_first_name'] : '';
535
-							$customer_company = ( ! empty( $order_address['address']['company'] ) ) ? $order_address['address']['company'] : '';
536
-							$customer_address = ( ! empty( $order_address['address']['address'] ) ) ? $order_address['address']['address'] : '';
537
-							$customer_zip_code = ( ! empty( $order_address['address']['postcode'] ) ) ? $order_address['address']['postcode'] : '';
538
-							$customer_city = ( ! empty( $order_address['address']['city'] ) ) ? $order_address['address']['city'] : '';
539
-							$customer_state = ( ! empty( $order_address['address']['state'] ) ) ? $order_address['address']['state'] : '';
540
-							$customer_phone = ( ! empty( $order_address['address']['phone'] ) ) ? ' Tel. : ' . $order_address['address']['phone'] : '';
533
+							$customer_last_name = (!empty($order_address['address']['address_last_name'])) ? $order_address['address']['address_last_name'] : '';
534
+							$customer_firtsname = (!empty($order_address['address']['address_first_name'])) ? $order_address['address']['address_first_name'] : '';
535
+							$customer_company = (!empty($order_address['address']['company'])) ? $order_address['address']['company'] : '';
536
+							$customer_address = (!empty($order_address['address']['address'])) ? $order_address['address']['address'] : '';
537
+							$customer_zip_code = (!empty($order_address['address']['postcode'])) ? $order_address['address']['postcode'] : '';
538
+							$customer_city = (!empty($order_address['address']['city'])) ? $order_address['address']['city'] : '';
539
+							$customer_state = (!empty($order_address['address']['state'])) ? $order_address['address']['state'] : '';
540
+							$customer_phone = (!empty($order_address['address']['phone'])) ? ' Tel. : ' . $order_address['address']['phone'] : '';
541 541
 							$country = '';
542
-							foreach ( unserialize( WPSHOP_COUNTRY_LIST ) as $key => $value ) {
543
-								if ( ! empty( $order_address['address']['country'] ) && $key == $order_address['address']['country'] ) {
542
+							foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key => $value) {
543
+								if (!empty($order_address['address']['country']) && $key == $order_address['address']['country']) {
544 544
 									$country = $value;
545 545
 								}
546 546
 							}
547 547
 							$customer_country = $country;
548 548
 
549 549
 							ob_start();
550
-							require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail' ) );
550
+							require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail'));
551 551
 							$message .= ob_get_contents();
552 552
 							ob_end_clean();
553 553
 						}
@@ -564,20 +564,20 @@  discard block
 block discarded – undo
564 564
 	 * @param integer $order_id : Order ID
565 565
 	 * @return string
566 566
 	 */
567
-	function order_customer_comment_template_for_mail( $order_id ) {
567
+	function order_customer_comment_template_for_mail($order_id) {
568 568
 		global $wpdb;
569 569
 		$message = '';
570
-		if ( ! empty( $order_id ) ) {
571
-			$query = $wpdb->prepare( 'SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id );
572
-			$comment = $wpdb->get_var( $query );
573
-			$order_infos = get_post_meta( $order_id, '_order_postmeta', true );
574
-			if ( ! empty( $order_infos['order_key'] ) ) {
575
-				$comment_title = __( 'Comments about the order', 'wpshop' );
570
+		if (!empty($order_id)) {
571
+			$query = $wpdb->prepare('SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id);
572
+			$comment = $wpdb->get_var($query);
573
+			$order_infos = get_post_meta($order_id, '_order_postmeta', true);
574
+			if (!empty($order_infos['order_key'])) {
575
+				$comment_title = __('Comments about the order', 'wpshop');
576 576
 			} else {
577
-				$comment_title = __( 'Comments about the quotation', 'wpshop' );
577
+				$comment_title = __('Comments about the quotation', 'wpshop');
578 578
 			}
579 579
 			ob_start();
580
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments' ) );
580
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments'));
581 581
 			$message .= ob_get_contents();
582 582
 			ob_end_clean();
583 583
 		}
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 		global $wpdb;
594 594
 		$user_id = get_current_user_id();
595 595
 		$message = '';
596
-		$customer_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
597
-		if ( ! empty( $customer_entity ) ) {
596
+		$customer_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
597
+		if (!empty($customer_entity)) {
598 598
 
599
-			$query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid' );
600
-			$attributes_sets = $wpdb->get_results( $query );
599
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid');
600
+			$attributes_sets = $wpdb->get_results($query);
601 601
 
602
-			if ( ! empty( $attributes_sets ) ) {
602
+			if (!empty($attributes_sets)) {
603 603
 				ob_start();
604
-				require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail' ) );
604
+				require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail'));
605 605
 				$message .= ob_get_contents();
606 606
 				ob_end_clean();
607 607
 			}
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	function wpshop_messages_historic_correction() {
616 616
 		global $wpdb;
617
-		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%' );
618
-		$messages_histo = $wpdb->get_results( $query );
617
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%');
618
+		$messages_histo = $wpdb->get_results($query);
619 619
 
620
-		foreach ( $messages_histo as $message ) {
621
-			$query_user = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s',  $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
622
-			$user_post_id = $wpdb->get_var( $query_user );
623
-			$wpdb->update( $wpdb->postmeta, array(
620
+		foreach ($messages_histo as $message) {
621
+			$query_user = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
622
+			$user_post_id = $wpdb->get_var($query_user);
623
+			$wpdb->update($wpdb->postmeta, array(
624 624
 				'post_id' => $user_post_id,
625 625
 				), array(
626 626
 				'meta_id' => $message->meta_id,
627
-			) );
627
+			));
628 628
 		}
629 629
 	}
630 630
 
@@ -633,20 +633,20 @@  discard block
 block discarded – undo
633 633
 	 * Récupères le contenu du message
634 634
 	 */
635 635
 	public function get_content_message() {
636
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
636
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
637 637
 
638
-		if ( ! wp_verify_nonce( $_wpnonce, 'get_content_message' ) ) {
638
+		if (!wp_verify_nonce($_wpnonce, 'get_content_message')) {
639 639
 			wp_die();
640 640
 		}
641 641
 
642 642
 		global $wpdb;
643
-		$meta_id = (int) $_GET['meta_id'];
643
+		$meta_id = (int)$_GET['meta_id'];
644 644
 
645
-		$result = $wpdb->get_results( $wpdb->prepare( 'SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array( ($meta_id) ) ) );
646
-		$result = unserialize( $result[0]->meta_value );
645
+		$result = $wpdb->get_results($wpdb->prepare('SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array(($meta_id))));
646
+		$result = unserialize($result[0]->meta_value);
647 647
 		$result = $result[0]['mess_message'];
648 648
 
649
-		wp_die( $result );
649
+		wp_die($result);
650 650
 	}
651 651
 
652 652
 }
Please login to merge, or discard this patch.
includes/wpshop_ajax.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -547,6 +547,10 @@  discard block
 block discarded – undo
547 547
 
548 548
 
549 549
 	/* Send a confirmation e-mail to the customer */
550
+
551
+	/**
552
+	 * @param integer $order_id
553
+	 */
550 554
 	function wpshop_send_confirmation_shipping_email($order_id){
551 555
 		$wps_message = new wps_message_ctr();
552 556
 		if ( !empty($order_id) ) {
@@ -2787,6 +2791,10 @@  discard block
 block discarded – undo
2787 2791
 		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2788 2792
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2789 2793
 	}
2794
+
2795
+	/**
2796
+	 * @param integer $product_id
2797
+	 */
2790 2798
 	function ajax_wpshop_fill_the_downloadable_dialog_exec( $product_id ) {
2791 2799
 		$output  = '<form method="post" action="' .admin_url('admin-ajax.php') .'" id="upload_downloadable_file" enctype="multipart/form-data" >';
2792 2800
 		$output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>';
Please login to merge, or discard this patch.
Spacing   +983 added lines, -983 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
 * Ajax request management file
4 4
 *
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 */
10 10
 
11 11
 /*	Check if file is include. No direct access possible with file url	*/
12
-if ( !defined( 'WPSHOP_VERSION' ) ) {
13
-	die( __('Access is not allowed by this way', 'wpshop') );
12
+if (!defined('WPSHOP_VERSION')) {
13
+	die(__('Access is not allowed by this way', 'wpshop'));
14 14
 }
15 15
 
16 16
 /*	Products	*/
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function ajax_duplicate_product() {
21 21
 
22
-		check_ajax_referer( 'wpshop_product_duplication', 'wpshop_ajax_nonce' );
22
+		check_ajax_referer('wpshop_product_duplication', 'wpshop_ajax_nonce');
23 23
 
24 24
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
25 25
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	 * Delete an attachmant from a product
35 35
 	 */
36 36
 	function ajax_delete_product_thumbnail() {
37
-		check_ajax_referer( 'wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce' );
37
+		check_ajax_referer('wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce');
38 38
 
39 39
 		$bool = false;
40
-		$attachement_id = isset($_POST['attachement_id']) ? (int) $_POST['attachement_id'] : null;
40
+		$attachement_id = isset($_POST['attachement_id']) ? (int)$_POST['attachement_id'] : null;
41 41
 
42
-		if ( !empty($attachement_id) ) {
42
+		if (!empty($attachement_id)) {
43 43
 			$deletion_result = wp_delete_attachment($attachement_id, false);
44 44
 			$bool = !empty($deletion_result);
45 45
 		}
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 * Reload attachment container
53 53
 	 */
54 54
 	function ajax_reload_attachment_boxes() {
55
-		check_ajax_referer( 'wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce' );
55
+		check_ajax_referer('wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce');
56 56
 
57 57
 		$bool = false;
58
-		$current_post_id = isset($_POST['current_post_id']) ? (int) $_POST['current_post_id'] : null;
58
+		$current_post_id = isset($_POST['current_post_id']) ? (int)$_POST['current_post_id'] : null;
59 59
 		$attachement_type_list = array('reload_box_document' => 'application/pdf', 'reload_box_picture' => 'image/');
60
-		$part_to_reload = isset($_POST['part_to_reload']) ? sanitize_text_field( $_POST['part_to_reload']) : null;
60
+		$part_to_reload = isset($_POST['part_to_reload']) ? sanitize_text_field($_POST['part_to_reload']) : null;
61 61
 		$attachement_type = $attachement_type_list[$part_to_reload];
62 62
 
63 63
 		echo json_encode(array(wpshop_products::product_attachement_by_type($current_post_id, $attachement_type, 'media-upload.php?post_id=' . $current_post_id . '&amp;tab=library&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=566'), $part_to_reload));
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	function ajax_product_bulk_edit_save() {
72 72
 		global $wpdb;
73
-		check_ajax_referer( 'product_bulk_edit_save', 'wpshop_ajax_nonce' );
73
+		check_ajax_referer('product_bulk_edit_save', 'wpshop_ajax_nonce');
74 74
 
75
-		$post_ids = ( isset( $_POST[ 'post_ids' ] ) && !empty( $_POST[ 'post_ids' ] ) ) ? (array) $_POST[ 'post_ids' ] : array();
76
-		$post_attributes = ( isset( $_POST[ 'attribute' ] ) && !empty( $_POST[ 'attribute' ] ) ) ? (array) $_POST[ 'attribute' ] : array();
75
+		$post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? (array)$_POST['post_ids'] : array();
76
+		$post_attributes = (isset($_POST['attribute']) && !empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array();
77 77
 
78
-		if ( !empty( $post_ids ) && is_array( $post_ids ) && !empty( $post_attributes ) && is_array( $post_attributes ) ) {
78
+		if (!empty($post_ids) && is_array($post_ids) && !empty($post_attributes) && is_array($post_attributes)) {
79 79
 			$attribute_to_save = array();
80
-			foreach ( $post_attributes as $attribute ) {
80
+			foreach ($post_attributes as $attribute) {
81 81
 				$attribute_component = explode('_-val-_', $attribute);
82 82
 				$attribute_definition = explode('[', $attribute_component[0]);
83 83
 				$attribute_data_type = substr($attribute_definition[1], 0, -1);
84 84
 				$attribute_code = substr($attribute_definition[2], 0, -1);
85 85
 
86
-				if ( !empty($attribute_component[1]) ) {
86
+				if (!empty($attribute_component[1])) {
87 87
 					$attribute_to_save[$attribute_data_type][$attribute_code] = $attribute_component[1];
88 88
 				}
89 89
 			}
90 90
 
91
-			foreach ( $post_ids as $post_id ) {
91
+			foreach ($post_ids as $post_id) {
92 92
 				$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = (SELECT language_code FROM " . $wpdb->prefix . "icl_translations WHERE element_id = %d )", $post_id);
93 93
 				$lang_wpml = $wpdb->get_var($query);
94 94
 				$lang = !empty($lang_wpml) ? $lang_wpml : WPSHOP_CURRENT_LOCALE;
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
 
101 101
 				/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
102 102
 				$productMetaDatas = get_post_meta($post_id, '_wpshop_product_metadata', true);
103
-				if ( !empty($productMetaDatas) ) {
103
+				if (!empty($productMetaDatas)) {
104 104
 					$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $post_id);
105
-					if ( !empty($attributes_list)) {
105
+					if (!empty($attributes_list)) {
106 106
 						foreach ($attributes_list as $attribute) {
107
-							$value_key = 'attribute_value_'.$attribute->data_type;
107
+							$value_key = 'attribute_value_' . $attribute->data_type;
108 108
 							$productMetaDatas[$attribute->code] = $attribute->$value_key;
109 109
 						}
110 110
 					}
111 111
 				}
112
-				foreach($attribute_to_save as $attributeType => $attributeValues){
113
-					foreach($attributeValues as $attributeCode => $attributeValue){
114
-						if ( $attributeCode == 'product_attribute_set_id' ) {
112
+				foreach ($attribute_to_save as $attributeType => $attributeValues) {
113
+					foreach ($attributeValues as $attributeCode => $attributeValue) {
114
+						if ($attributeCode == 'product_attribute_set_id') {
115 115
 							/*	Update the attribute set id for the current product	*/
116 116
 							update_post_meta($post_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue);
117 117
 						}
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 
124 124
 
125 125
 				/* If the product have some variations */
126
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
126
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
127 127
 				$product_variations = $wpdb->get_results($query);
128
-				if ( !empty($product_variations) ) {
129
-					foreach( $product_variations as $product_variation ) {
128
+				if (!empty($product_variations)) {
129
+					foreach ($product_variations as $product_variation) {
130 130
 						$variation_post_meta = get_post_meta($product_variation->ID, '_wpshop_product_metadata', true);
131 131
 						$common_attributes = unserialize(WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT);
132
-						if ( !empty($common_attributes) ) {
133
-							if ( !empty($parent_product_metadata) ) {
134
-								foreach( $parent_product_metadata as $key => $value ) {
135
-									if ( in_array($key, $common_attributes) ) {
132
+						if (!empty($common_attributes)) {
133
+							if (!empty($parent_product_metadata)) {
134
+								foreach ($parent_product_metadata as $key => $value) {
135
+									if (in_array($key, $common_attributes)) {
136 136
 										$variation_post_meta[$key] = $value;
137
-										update_post_meta($product_variation->ID, '_'.$key, $value);
137
+										update_post_meta($product_variation->ID, '_' . $key, $value);
138 138
 									}
139 139
 								}
140 140
 								update_post_meta($product_variation->ID, '_wpshop_product_metadata', $variation_post_meta);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 		die();
152 152
 	}
153
-	add_action( 'wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save' );
153
+	add_action('wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save');
154 154
 /*	Products	*/
155 155
 
156 156
 /*	Variations	*/
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
 	 * Variation list creation
159 159
 	 */
160 160
 	function ajax_add_new_variation_list() {
161
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
161
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
162 162
 		global $wpdb;
163 163
 
164
-		$attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? (array) $_POST['wpshop_attribute_to_use_for_variation'] : null;
164
+		$attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? (array)$_POST['wpshop_attribute_to_use_for_variation'] : null;
165 165
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
166 166
 
167 167
 		/** Get the list of values of the attribute to affect to a variation	*/
168 168
 		$var = array();
169 169
 
170
-		foreach ( $attributes_for_variation as $attribute_code ) {
170
+		foreach ($attributes_for_variation as $attribute_code) {
171 171
 			$query = $wpdb->prepare("SELECT data_type_to_use FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code);
172
-			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list( $attribute_code, $current_post_id, $wpdb->get_var($query));
172
+			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list($attribute_code, $current_post_id, $wpdb->get_var($query));
173 173
 		}
174 174
 
175
-		$possible_variations = wpshop_tools::search_all_possibilities( $var );
175
+		$possible_variations = wpshop_tools::search_all_possibilities($var);
176 176
 
177
-		wpshop_products::creation_variation_callback( $possible_variations, $current_post_id );
177
+		wpshop_products::creation_variation_callback($possible_variations, $current_post_id);
178 178
 
179
-		$output = wpshop_products::display_variation_admin( $current_post_id );
179
+		$output = wpshop_products::display_variation_admin($current_post_id);
180 180
 
181 181
 		echo $output;
182 182
 		die();
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 * Variation uniq item creation
188 188
 	 */
189 189
 	function ajax_new_single_variation_definition() {
190
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
190
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
191 191
 		$output = '';
192 192
 
193 193
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
194 194
 
195 195
 		/*	Get the list of values of the attribute to affect to a variation	*/
196
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id, 'single' );
196
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id, 'single');
197 197
 		$output = $attribute_for_variation[0];
198 198
 
199 199
 		/**	Display specific element for variation	*/
200 200
 		$tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = '';
201 201
 		$tpl_component['VARIATION_IDENTIFIER'] = 'new';
202
-		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']','page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => '') );
202
+		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']', 'page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => ''));
203 203
 		$output .= wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $current_post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $tpl_component['VARIATION_IDENTIFIER']), 'admin');
204 204
 
205 205
 		$tpl_component = array();
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	 * Combined variation list creation
218 218
 	 */
219 219
 	function ajax_new_combined_variation_list_definition() {
220
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
220
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
221 221
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
222 222
 		$output = '';
223 223
 
224
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id );
224
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id);
225 225
 		$output = $attribute_for_variation[0];
226 226
 
227 227
 		echo $output;
@@ -233,43 +233,43 @@  discard block
 block discarded – undo
233 233
 	 * Product variaitons parameters
234 234
 	 */
235 235
 	function wpshop_ajax_admin_variation_parameters() {
236
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
236
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
237 237
 
238 238
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
239 239
 		$output = '';
240 240
 
241 241
 		/*	Display variation options	*/
242 242
 		$options_tpl_component = array();
243
-		$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
244
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single')) ) ? ' checked="checked"' : '';
245
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined')) ) ? ' checked="checked"' : '';
246
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition')) ) ? ' checked="checked"' : '';
247
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement')) ) ? ' checked="checked"' : '';
243
+		$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
244
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single'))) ? ' checked="checked"' : '';
245
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined'))) ? ' checked="checked"' : '';
246
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition'))) ? ' checked="checked"' : '';
247
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement'))) ? ' checked="checked"' : '';
248 248
 
249
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ( ( empty($head_wpshop_variation_definition['options']) ) || ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')) ) ) ? ' checked="checked"' : '';
250
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ( (empty($head_wpshop_variation_definition['options']) ) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')) ) ) ? ' checked="checked"' : '';
249
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')))) ? ' checked="checked"' : '';
250
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')))) ? ' checked="checked"' : '';
251 251
 
252 252
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_PRODUCT_ID'] = $current_post_id;
253 253
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_NOUNCE'] = wp_create_nonce("wpshop_variation_parameters");
254 254
 
255 255
 		$options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] = '';
256 256
 
257
-		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute( $current_post_id );
257
+		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute($current_post_id);
258 258
 
259 259
 		$default_value_for_attributes = $required_attributes = '';
260 260
 
261
-		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => get_post_type($current_post_id)) );
262
-		if ( !empty($attribute_user_defined) ) {
263
-			foreach ( $attribute_user_defined as $attribute_def ) {
261
+		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => get_post_type($current_post_id)));
262
+		if (!empty($attribute_user_defined)) {
263
+			foreach ($attribute_user_defined as $attribute_def) {
264 264
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
265 265
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
266 266
 
267 267
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_def->code;
268 268
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_def->code;
269
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_def->frontend_label, 'wpshop' );
269
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_def->frontend_label, 'wpshop');
270 270
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
271 271
 
272
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
272
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
273 273
 
274 274
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_def->code;
275 275
 
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 		}
279 279
 
280
-		if ( !empty($attribute_list_for_variations['available']) ) {
281
-			$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
282
-			foreach ( $attribute_list_for_variations['available'] as $attribute_code => $attribute_definition ) {
280
+		if (!empty($attribute_list_for_variations['available'])) {
281
+			$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
282
+			foreach ($attribute_list_for_variations['available'] as $attribute_code => $attribute_definition) {
283 283
 				/** Default value for attribute	*/
284 284
 				$tpl_component = array();
285 285
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ' variation_attribute_container_default_value_' . $attribute_code;
286 286
 
287 287
 				$attribute_for_default_value = wpshop_attributes::get_attribute_field_definition($attribute_definition['attribute_complete_def'], (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : 'none'), array('from' => 'frontend', 'field_custom_name_prefix' => 'empty'));
288
-				switch ( $attribute_for_default_value['type'] ) {
288
+				switch ($attribute_for_default_value['type']) {
289 289
 					case 'select':
290 290
 					case 'multiple-select':
291 291
 					case 'radio':
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 						break;
298 298
 				}
299 299
 
300
-				if ( !empty($attribute_for_default_value['possible_value']) ) {
300
+				if (!empty($attribute_for_default_value['possible_value'])) {
301 301
 					$attribute_for_default_value['possible_value']['none'] = __('No default value', 'wpshop');
302
-					foreach( $attribute_for_default_value['possible_value'] as $value_id => $value ){
303
-						if ( !empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values']) ) {
302
+					foreach ($attribute_for_default_value['possible_value'] as $value_id => $value) {
303
+						if (!empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values'])) {
304 304
 							unset($attribute_for_default_value['possible_value'][$value_id]);
305 305
 						}
306 306
 					}
307 307
 					ksort($attribute_for_default_value['possible_value']);
308 308
 
309 309
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = $attribute_for_default_value['id'];
310
-					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf( __('Default value for %s', 'wpshop'), $attribute_for_default_value['label'] );
310
+					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf(__('Default value for %s', 'wpshop'), $attribute_for_default_value['label']);
311 311
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_INPUT'] = wpshop_form::check_input_type($attribute_for_default_value, 'wps_pdt_variations[options][attributes_default_value]');
312 312
 					$default_value_for_attributes .= wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item_for_default', $tpl_component, array(), 'admin');
313 313
 				}
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 
319 319
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_code;
320 320
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code;
321
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_definition['label'], 'wpshop' );
321
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_definition['label'], 'wpshop');
322 322
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
323 323
 
324
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
324
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
325 325
 
326 326
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_code;
327 327
 				$required_attributes .= str_replace('wpshop_attribute_to_use_for_variation', 'wps_pdt_variations[options][required_attributes]', str_replace('variation_attribute_usable', 'variation_attribute_required', wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item', $tpl_component, array(), 'admin')));
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 * Save product variation paramters
345 345
 	 */
346 346
 	function wpshop_ajax_admin_variation_parameters_save() {
347
-		check_ajax_referer( 'wpshop_variation_parameters', 'wpshop_ajax_nonce' );
347
+		check_ajax_referer('wpshop_variation_parameters', 'wpshop_ajax_nonce');
348 348
 
349 349
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
350
-		$options = !empty( $_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] ) ? (array)$_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] : array();
350
+		$options = !empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options']) ? (array)$_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] : array();
351 351
 
352
-		if ( !empty($options) ) {
353
-			wpshop_products::variation_parameters_save( $post_id, $options );
352
+		if (!empty($options)) {
353
+			wpshop_products::variation_parameters_save($post_id, $options);
354 354
 		}
355 355
 
356 356
 		die();
@@ -361,41 +361,41 @@  discard block
 block discarded – undo
361 361
 	 * Variation uniq item creation
362 362
 	 */
363 363
 	function ajax_add_new_single_variation() {
364
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
364
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
365 365
 		$output = '';
366 366
 
367
-		$attributes_for_variation = isset($_POST['variation_attr']) ? (array) $_POST['variation_attr'] : null;
368
-		$wpshop_admin_use_attribute_for_single_variation_checkbox = isset($_POST['wpshop_admin_use_attribute_for_single_variation_checkbox']) ? (array) $_POST['wpshop_admin_use_attribute_for_single_variation_checkbox'] : null;
369
-		$variation_specific_definition = isset($_POST['wps_pdt_variations']['new']['attribute']) ? (array) $_POST['wps_pdt_variations']['new']['attribute'] : null;
367
+		$attributes_for_variation = isset($_POST['variation_attr']) ? (array)$_POST['variation_attr'] : null;
368
+		$wpshop_admin_use_attribute_for_single_variation_checkbox = isset($_POST['wpshop_admin_use_attribute_for_single_variation_checkbox']) ? (array)$_POST['wpshop_admin_use_attribute_for_single_variation_checkbox'] : null;
369
+		$variation_specific_definition = isset($_POST['wps_pdt_variations']['new']['attribute']) ? (array)$_POST['wps_pdt_variations']['new']['attribute'] : null;
370 370
 		$current_post_id = isset($_POST['wpshop_head_product_id']) ? sanitize_key($_POST['wpshop_head_product_id']) : null;
371
-		$display = isset( $_POST['data'] ) ? (bool) $_POST['data'] : false;
371
+		$display = isset($_POST['data']) ? (bool)$_POST['data'] : false;
372 372
 
373 373
 		$attribute_to_use_for_creation = array();
374
-		foreach ( $attributes_for_variation as $attribute_code => $attribute_value) {
375
-			if ( array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox) ) {
374
+		foreach ($attributes_for_variation as $attribute_code => $attribute_value) {
375
+			if (array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox)) {
376 376
 				$attribute_to_use_for_creation[0][$attribute_code] = $attributes_for_variation[$attribute_code];
377 377
 				$attr_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
378 378
 				$variation_specific_definition[$attr_def->data_type][$attribute_code] = $attributes_for_variation[$attribute_code];
379 379
 			}
380 380
 		}
381
-		$new_variation_identifier = wpshop_products::creation_variation_callback( $attribute_to_use_for_creation, $current_post_id );
381
+		$new_variation_identifier = wpshop_products::creation_variation_callback($attribute_to_use_for_creation, $current_post_id);
382 382
 
383 383
 		/*	Save variation specific element	*/
384
-		foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
384
+		foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
385 385
 			$head_product_price_attribute_value = wpshop_attributes::get_attribute_value_content($price_attribute_code, $current_post_id, wpshop_products::currentPageCode);
386 386
 			$price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code');
387
-			if ( !empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
387
+			if (!empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
388 388
 				$variation_specific_definition[$price_attr_def->data_type][$price_attribute_code] = !empty($head_product_price_attribute_value->value) ? $head_product_price_attribute_value->value : 1;
389 389
 			}
390 390
 		}
391 391
 
392 392
 		wpshop_attributes::saveAttributeForEntity($variation_specific_definition, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $new_variation_identifier, WPSHOP_CURRENT_LOCALE);
393
-		wpshop_products::calculate_price( $new_variation_identifier );
393
+		wpshop_products::calculate_price($new_variation_identifier);
394 394
 
395
-		if( $display ) {
396
-			$output = json_encode( array( 'ID' => $new_variation_identifier ) );
395
+		if ($display) {
396
+			$output = json_encode(array('ID' => $new_variation_identifier));
397 397
 		} else {
398
-			$output = wpshop_products::display_variation_admin( $current_post_id );
398
+			$output = wpshop_products::display_variation_admin($current_post_id);
399 399
 		}
400 400
 
401 401
 		echo $output;
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 	 * Delete a variation
408 408
 	*/
409 409
 	function ajax_delete_variation() {
410
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
410
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
411 411
 		$result = false;
412 412
 		$list_to_remove = '';
413 413
 
414
-		$current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? (array) $_POST['current_post_id'] : null;
415
-		foreach ( $current_post_id as $variation_id) {
414
+		$current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? (array)$_POST['current_post_id'] : null;
415
+		foreach ($current_post_id as $variation_id) {
416 416
 			$result = wp_delete_post($variation_id, false);
417
-			if ( $result ) {
417
+			if ($result) {
418 418
 				$list_to_remove[] = $variation_id;
419 419
 			}
420 420
 		}
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 /*	Orders	*/
443 443
 	/* Validate the payment transaction number */
444 444
 	function wpshop_ajax_validate_payment_method() {
445
-		check_ajax_referer( 'wpshop_validate_payment_method', 'wpshop_ajax_nonce' );
446
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int) $_POST[ 'order_id' ] : null;
447
-		$payment_method = ( isset( $_POST[ 'payment_method' ] ) && !empty( $_POST[ 'payment_method' ] ) ) ? sanitize_text_field( $_POST[ 'payment_method' ] ) : null;
448
-		$transaction_id = ( isset( $_POST[ 'transaction_id' ] ) && !empty( $_POST[ 'transaction_id' ] ) ) ? (int) $_POST[ 'transaction_id' ] : null;
445
+		check_ajax_referer('wpshop_validate_payment_method', 'wpshop_ajax_nonce');
446
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
447
+		$payment_method = (isset($_POST['payment_method']) && !empty($_POST['payment_method'])) ? sanitize_text_field($_POST['payment_method']) : null;
448
+		$transaction_id = (isset($_POST['transaction_id']) && !empty($_POST['transaction_id'])) ? (int)$_POST['transaction_id'] : null;
449 449
 
450
-		if ( !empty($order_id) ) {
451
-			if( !empty($payment_method) && !empty($transaction_id) ) {
450
+		if (!empty($order_id)) {
451
+			if (!empty($payment_method) && !empty($transaction_id)) {
452 452
 				/* Update he payment method */
453 453
 				$order = get_post_meta($order_id, '_order_postmeta', true);
454 454
 				$order['payment_method'] = $payment_method;
455 455
 				update_post_meta($order_id, '_order_postmeta', $order);
456 456
 
457 457
 				// Update Transaction identifier regarding the payment method
458
-				if ( !empty($transaction_id) ) {
458
+				if (!empty($transaction_id)) {
459 459
 // 					$transaction_key = '';
460 460
 // 					switch($payment_method) {
461 461
 // 						case 'check':
@@ -465,28 +465,28 @@  discard block
 block discarded – undo
465 465
 // 					if ( !empty($transaction_key) ) update_post_meta($order_id, $transaction_key, $transaction_id);
466 466
 					wpshop_payment::set_payment_transaction_number($order_id, $transaction_id);
467 467
 				}
468
-				$result = json_encode(array(true,''));
468
+				$result = json_encode(array(true, ''));
469 469
 			}
470 470
 			else {
471
-				$result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop')));
471
+				$result = json_encode(array(false, __('Choose a payment method and/or type a transaction number', 'wpshop')));
472 472
 			}
473 473
 		}
474 474
 		else {
475
-			$result = json_encode(array(false,__('Bad order identifier', 'wpshop')));
475
+			$result = json_encode(array(false, __('Bad order identifier', 'wpshop')));
476 476
 		}
477 477
 		echo json_encode($result);
478 478
 		die();
479 479
 	}
480
-	add_action( 'wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method' );
480
+	add_action('wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method');
481 481
 
482 482
 
483 483
 	/* Display a dialog box to inform a shipping tracking number */
484 484
 	function wpshop_ajax_dialog_inform_shipping_number() {
485
-		check_ajax_referer( 'wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce' );
486
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int)$_POST[ 'order_id' ] : null;
485
+		check_ajax_referer('wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce');
486
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
487 487
 
488
-		if ( !empty($order_id) ) {
489
-			$result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />'));
488
+		if (!empty($order_id)) {
489
+			$result = (array(true, '<h1>' . __('Tracking number', 'wpshop') . '</h1><p>' . __('Enter a tracking number, or leave blank:', 'wpshop') . '</p><input type="hidden" value="' . $order_id . '" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>' . __('Enter a tracking link, or leave blank: (http included)', 'wpshop') . '</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="' . __('Send', 'wpshop') . '" /> <input type="button" class="button-secondary closeAlert" value="' . __('Cancel', 'wpshop') . '" />'));
490 490
 
491 491
 		}
492 492
 		else {
@@ -495,23 +495,23 @@  discard block
 block discarded – undo
495 495
 		echo json_encode($result);
496 496
 		die();
497 497
 	}
498
-	add_action( 'wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number' );
498
+	add_action('wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number');
499 499
 
500 500
 	function wpshop_ajax_change_order_state() {
501 501
 		global $order_status;
502
-		check_ajax_referer( 'wpshop_change_order_state', 'wpshop_ajax_nonce' );
502
+		check_ajax_referer('wpshop_change_order_state', 'wpshop_ajax_nonce');
503 503
 
504
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int)$_POST[ 'order_id' ] : null;
505
-		$order_state = ( isset( $_POST[ 'order_state' ] ) && !empty( $_POST[ 'order_state' ] ) ) ? sanitize_text_field( $_POST[ 'order_state' ] ) : null;
506
-		$order_shipped_number = ( isset( $_POST[ 'order_shipped_number' ] ) && !empty( $_POST[ 'order_shipped_number' ] ) ) ? sanitize_text_field( $_POST[ 'order_shipped_number' ] ) : null;
507
-		$order_shipped_link = ( isset( $_POST[ 'order_shipped_link' ] ) && !empty( $_POST[ 'order_shipped_link' ] ) ) ? sanitize_text_field( $_POST[ 'order_shipped_link' ] ) : null;
504
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
505
+		$order_state = (isset($_POST['order_state']) && !empty($_POST['order_state'])) ? sanitize_text_field($_POST['order_state']) : null;
506
+		$order_shipped_number = (isset($_POST['order_shipped_number']) && !empty($_POST['order_shipped_number'])) ? sanitize_text_field($_POST['order_shipped_number']) : null;
507
+		$order_shipped_link = (isset($_POST['order_shipped_link']) && !empty($_POST['order_shipped_link'])) ? sanitize_text_field($_POST['order_shipped_link']) : null;
508 508
 
509
-		if ( !empty($order_id) ) {
509
+		if (!empty($order_id)) {
510 510
 			/* Update the oder state */
511 511
 			$order = get_post_meta($order_id, '_order_postmeta', true);
512 512
 			$order['order_status'] = $order_state;
513 513
 
514
-			if ( $order_state == 'shipped' ) {
514
+			if ($order_state == 'shipped') {
515 515
 				$order['order_shipping_date'] = current_time('mysql', 0);
516 516
 				$order['order_trackingNumber'] = $order_shipped_number;
517 517
 				$order['order_trackingLink'] = $order_shipped_link;
@@ -522,11 +522,11 @@  discard block
 block discarded – undo
522 522
 				$output_payment_box_class = 'wpshop_order_status_shipped';
523 523
 				$output_payment_box_content = __('Shipped', 'wpshop');
524 524
 
525
-				$output_shipping_box  = '<li><strong>'.__('Order shipping date','wpshop').' :</strong>'.$order['order_shipping_date'].'</li>';
526
-				$output_shipping_box .= '<li><strong>'.__('Tracking number','wpshop').' :</strong> '.$order['order_trackingNumber'].'</li>';
527
-				$output_shipping_box .= '<li><strong>'.__('Tracking link','wpshop').' :</strong> '.$order['order_trackingLink'].'</li>';
525
+				$output_shipping_box  = '<li><strong>' . __('Order shipping date', 'wpshop') . ' :</strong>' . $order['order_shipping_date'] . '</li>';
526
+				$output_shipping_box .= '<li><strong>' . __('Tracking number', 'wpshop') . ' :</strong> ' . $order['order_trackingNumber'] . '</li>';
527
+				$output_shipping_box .= '<li><strong>' . __('Tracking link', 'wpshop') . ' :</strong> ' . $order['order_trackingLink'] . '</li>';
528 528
 
529
-				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
529
+				$result = array(true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content);
530 530
 			}
531 531
 			else {
532 532
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
@@ -543,39 +543,39 @@  discard block
 block discarded – undo
543 543
 		echo json_encode($result);
544 544
 		die();
545 545
 	}
546
-	add_action( 'wp_ajax_change_order_state', 'wpshop_ajax_change_order_state' );
546
+	add_action('wp_ajax_change_order_state', 'wpshop_ajax_change_order_state');
547 547
 
548 548
 
549 549
 	/* Send a confirmation e-mail to the customer */
550
-	function wpshop_send_confirmation_shipping_email($order_id){
550
+	function wpshop_send_confirmation_shipping_email($order_id) {
551 551
 		$wps_message = new wps_message_ctr();
552
-		if ( !empty($order_id) ) {
552
+		if (!empty($order_id)) {
553 553
 			$order_info = get_post_meta($order_id, '_order_info', true);
554 554
 			$order = get_post_meta($order_id, '_order_postmeta', true);
555
-			$email = ( !empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
555
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
556 556
 			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
557
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
557
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
558 558
 
559
-			if( empty($email) && !empty($order['customer_id']) ) {
560
-				$user_data = get_userdata( $order['customer_id'] );
559
+			if (empty($email) && !empty($order['customer_id'])) {
560
+				$user_data = get_userdata($order['customer_id']);
561 561
 				$email = $user_data->user_email;
562 562
 			}
563 563
 
564
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
565
-			$shipping_method = ( !empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order['order_payment']['shipping_method'] : '' );
564
+			$shipping_mode_option = get_option('wps_shipping_mode');
565
+			$shipping_method = (!empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order['order_payment']['shipping_method'] : '');
566 566
 
567 567
 
568
-			$wps_message->wpshop_prepared_email (
568
+			$wps_message->wpshop_prepared_email(
569 569
 				$email,
570 570
 				'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE',
571 571
 				array(
572 572
 					'order_id' => $order_id,
573
-					'order_key' => ( !empty($order['order_key']) ? $order['order_key'] : '' ),
573
+					'order_key' => (!empty($order['order_key']) ? $order['order_key'] : ''),
574 574
 					'customer_first_name' => $first_name,
575 575
 					'customer_last_name' => $last_name,
576
-					'order_date' => ( !empty($order['order_date']) ? $order['order_date'] : '' ),
577
-					'order_trackingNumber' => ( !empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : '' ),
578
-					'order_trackingLink' => ( !empty($order['order_trackingLink']) ? $order['order_trackingLink'] : '' ),
576
+					'order_date' => (!empty($order['order_date']) ? $order['order_date'] : ''),
577
+					'order_trackingNumber' => (!empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : ''),
578
+					'order_trackingLink' => (!empty($order['order_trackingLink']) ? $order['order_trackingLink'] : ''),
579 579
 					'order_addresses' => '',
580 580
 					'order_billing_address' => '',
581 581
 					'order_shipping_address' => '',
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
 	 * @return string The html output for the new value
595 595
 	 */
596 596
 	function ajax_new_option_for_select_callback() {
597
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
597
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
598 598
 		global $wpdb;
599 599
 
600
-		$option_id=$option_default_value=$option_value_id=$options_value='';
601
-		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int) $_GET['attribute_identifier'] : '0';
602
-		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field( $_REQUEST['attribute_new_label'] ) : '');
600
+		$option_id = $option_default_value = $option_value_id = $options_value = '';
601
+		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int)$_GET['attribute_identifier'] : '0';
602
+		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field($_REQUEST['attribute_new_label']) : '');
603 603
 		$options_value = sanitize_title($option_name);
604 604
 
605 605
 		/*	Check if given value does not exist before continuing	*/
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		$existing_values = $wpdb->get_results($query);
608 608
 
609 609
 		/*	If given value does not exist: display result. If value exist alert a error message	*/
610
-		if( empty($existing_values) ) {
610
+		if (empty($existing_values)) {
611 611
 			$tpl_component = array();
612 612
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_ID'] = $option_id;
613 613
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_NAME'] = stripslashes($option_name);
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", stripslashes($options_value));
616 616
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = '';
617 617
 			$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
618
-			if ( current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0) ) :
618
+			if (current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0)) :
619 619
 				$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
620 620
 			endif;
621 621
 			$output = wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	 * Add a new value to an attribute from select type directly from an entity element edition interface
635 635
 	 */
636 636
 	function ajax_new_option_for_select_from_product_edition_callback() {
637
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
637
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
638 638
 
639 639
 		global $wpdb;
640 640
 		$result = '';
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 		$attribute_options_label = isset($_POST['attribute_new_label']) ? wpshop_tools::varSanitizer($_POST['attribute_new_label']) : null;
652 652
 		$attribute_options_value = sanitize_title($attribute_options_label);
653 653
 
654
-		if ( $type == 'internal' ) {
654
+		if ($type == 'internal') {
655 655
 			/**	Check if the given value does not exist	*/
656 656
 			$query = $wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_status = 'publish'", $attribute_options_label);
657 657
 			$existing_values = $wpdb->get_results($query);
658 658
 
659 659
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
660
-			if ( count($existing_values) <= 0 ) {
660
+			if (count($existing_values) <= 0) {
661 661
 				$result_status = true;
662 662
 				/**	Create the new value as an entity into post database	*/
663 663
 				$new_post = array(
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 			$existing_values = $wpdb->get_results($query);
681 681
 
682 682
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
683
-			if( count($existing_values) <= 0 ) {
683
+			if (count($existing_values) <= 0) {
684 684
 				$result_status = true;
685 685
 				$position = 1;
686 686
 				/**	Get the last value position for adding the new at the end	*/
@@ -699,15 +699,15 @@  discard block
 block discarded – undo
699 699
 
700 700
 		if ($result_status) {
701 701
 			$tmp_selection_for_output = array();
702
-			foreach ( $attribute_selected_values as $value ) {
702
+			foreach ($attribute_selected_values as $value) {
703 703
 				$tmp_selection_for_output[]['value'] = $value;
704 704
 			}
705 705
 			$tmp_selection_for_output[]['value'] = $new_option_id;
706
-			foreach ( $tmp_selection_for_output as $tmp_value ) {
706
+			foreach ($tmp_selection_for_output as $tmp_value) {
707 707
 				$selection_for_output[] = (object)$tmp_value;
708 708
 			}
709 709
 			$attribute_selected_values[] = $new_option_id;
710
-			$input = wpshop_attributes::get_attribute_field_definition( $attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display) );
710
+			$input = wpshop_attributes::get_attribute_field_definition($attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display));
711 711
 			$result = $input['output'] . $input['options'];
712 712
 		}
713 713
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	 * Delete a value for a select list attribute
721 721
 	 */
722 722
 	function ajax_delete_option_for_select_callback() {
723
-		check_ajax_referer( 'wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce' );
723
+		check_ajax_referer('wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce');
724 724
 
725 725
 		$attribute_value_id = isset($_POST['attribute_value_id']) ? wpshop_tools::varSanitizer($_POST['attribute_value_id']) : '0';
726 726
 
@@ -744,18 +744,18 @@  discard block
 block discarded – undo
744 744
 	 * Display the field for the selected attribute type
745 745
 	 */
746 746
 	function ajax_attribute_output_type_callback() {
747
-		check_ajax_referer( 'wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce' );
747
+		check_ajax_referer('wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce');
748 748
 
749 749
 		$data_type_to_use = isset($_POST['data_type_to_use']) ? str_replace('_data', '', wpshop_tools::varSanitizer($_POST['data_type_to_use'], '')) : 'custom';
750 750
 		$current_type = isset($_POST['current_type']) ? wpshop_tools::varSanitizer($_POST['current_type']) : 'short_text';
751
-		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval( wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
751
+		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval(wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
752 752
 		$the_input = __('An error occured while getting field type', 'wpshop');
753 753
 		$input_def = array();
754 754
 		$input_def['name'] = 'default_value';
755 755
 		$input_def['id'] = 'wpshop_attributes_edition_table_field_id_default_value';
756 756
 		$input_label = __('Default value', 'wpshop');
757 757
 
758
-		switch($current_type){
758
+		switch ($current_type) {
759 759
 			case 'short_text':
760 760
 			case 'float_field':
761 761
 				$input_def['type'] = 'text';
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
 			case 'multiple-select':
767 767
 			case 'radio':
768 768
 			case 'checkbox':
769
-				$input_label=__('Options list for attribute', 'wpshop');
769
+				$input_label = __('Options list for attribute', 'wpshop');
770 770
 				$the_input = wpshop_attributes::get_select_options_list($elementIdentifier, $data_type_to_use);
771 771
 				break;
772 772
 			case 'date_field':
773
-				$input_label=__('Date field configuration', 'wpshop');
773
+				$input_label = __('Date field configuration', 'wpshop');
774 774
 
775
-				$the_input = wpshop_attributes::attribute_type_date_config( array() );
775
+				$the_input = wpshop_attributes::attribute_type_date_config(array());
776 776
 				break;
777 777
 			case 'textarea':
778 778
 				$input_def['type'] = 'textarea';
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 	 * Get the attribute set list when creating a new attribute for direct affectation
791 791
 	 */
792 792
 	function ajax_attribute_entity_set_selection_callback() {
793
-		check_ajax_referer( 'wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce' );
793
+		check_ajax_referer('wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce');
794 794
 
795 795
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
796 796
 
797
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
797
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
798 798
 
799 799
 		echo json_encode($the_input);
800 800
 		die();
@@ -804,11 +804,11 @@  discard block
 block discarded – undo
804 804
 	 * Get the attribute set list when creating a new attribute for direct affectation
805 805
 	 */
806 806
 	function ajax_attribute_set_entity_selection_callback() {
807
-		check_ajax_referer( 'wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce' );
807
+		check_ajax_referer('wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce');
808 808
 
809 809
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
810 810
 
811
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
811
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
812 812
 
813 813
 		echo json_encode($the_input);
814 814
 		die();
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 	 * Dialog box allowing to change attribute data type from custom to internal
820 820
 	 */
821 821
 	function ajax_attribute_select_data_type_callback() {
822
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce' );
822
+		check_ajax_referer('wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce');
823 823
 		$result = '';
824 824
 
825 825
 		$current_attribute = isset($_POST['current_attribute']) ? intval(wpshop_tools::varSanitizer($_POST['current_attribute'])) : null;
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 
828 828
 		$types_toggled = unserialize(WPSHOP_ATTR_SELECT_TYPE_TOGGLED);
829 829
 		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_current_attribute" >' . sprintf(__('Selected attribute %s', 'wpshop'), $attribute->frontend_label) . '</p>';
830
-		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use.'_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
830
+		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use . '_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
831 831
 
832
-		if ( $attribute->data_type_to_use == 'custom' ) {
833
-			$sub_output='';
832
+		if ($attribute->data_type_to_use == 'custom') {
833
+			$sub_output = '';
834 834
 			$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
835
-			unset($input_def);$input_def=array();
835
+			unset($input_def); $input_def = array();
836 836
 			$input_def['label'] = __('Type of data for list', 'wpshop');
837 837
 			$input_def['type'] = 'select';
838 838
 			$input_def['name'] = 'internal_data';
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 			$input_def['possible_value'] = $wp_types;
841 841
 			$input_def['value'] = !empty($attribute_select_options[0]->default_value) ? $attribute_select_options[0]->default_value : null;
842 842
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
843
-			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>';
843
+			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="' . sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')) . '" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">' . $combo_wp_type . '</div>';
844 844
 			$result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />';
845 845
 		}
846 846
 		else {
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 	 */
874 874
 	function ajax_attribute_select_data_type_change_callback() {
875 875
 		global $wpdb;
876
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce' );
876
+		check_ajax_referer('wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce');
877 877
 		$result = '';
878 878
 
879 879
 		$current_attribute = isset($_POST['attribute_id']) ? intval(wpshop_tools::varSanitizer($_POST['attribute_id'])) : null;
@@ -883,10 +883,10 @@  discard block
 block discarded – undo
883 883
 		$delete_entity = isset($_POST['delete_entity']) ? wpshop_tools::varSanitizer($_POST['delete_entity']) : false;
884 884
 
885 885
 
886
-		if ( $data_type == 'internal' ) {
886
+		if ($data_type == 'internal') {
887 887
 			$options_list = wpshop_attributes::get_select_option_list_($current_attribute);
888
-			if(!empty($options_list)){
889
-				foreach($options_list as $option){
888
+			if (!empty($options_list)) {
889
+				foreach ($options_list as $option) {
890 890
 					/*	Creat the new entity	*/
891 891
 					$new_post = array(
892 892
 							'post_title' 	=> $option->name,
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 							'post_type' 	=> $internal_data_type
896 896
 					);
897 897
 					$new_option_id = wp_insert_post($new_post);
898
-					if(!empty($new_option_id)){
898
+					if (!empty($new_option_id)) {
899 899
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'deleted'), array('attribute_id'=>$current_attribute));
900 900
 					}
901 901
 				}
@@ -904,19 +904,19 @@  discard block
 block discarded – undo
904 904
 		else {
905 905
 			$post_list = query_posts(array('post_type' => $internal_data_type));
906 906
 			if (!empty($post_list)) {
907
-				$p=1;
907
+				$p = 1;
908 908
 				$error = false;
909 909
 				foreach ($post_list as $post) {
910
-					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
911
-					if(is_int($last_insert) && $delete_items_of_entity){
910
+					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
911
+					if (is_int($last_insert) && $delete_items_of_entity) {
912 912
 						wp_delete_post($post->ID, true);
913 913
 					}
914
-					else{
914
+					else {
915 915
 						$error = true;
916 916
 					}
917 917
 					$p++;
918 918
 				}
919
-				if(!$error && $delete_entity){
919
+				if (!$error && $delete_entity) {
920 920
 					$post = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_name=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, $internal_data_type);
921 921
 					wp_delete_post($wpdb->get_var($post), true);
922 922
 				}
@@ -936,8 +936,8 @@  discard block
 block discarded – undo
936 936
 	/**
937 937
 	 * Duplicate an existing attribute from an entity to another
938 938
 	 */
939
-	function ajax_wpshop_duplicate_attribute_callback (){
940
-		check_ajax_referer( 'wpshop_duplicate_attribute', 'wpshop_ajax_nonce' );
939
+	function ajax_wpshop_duplicate_attribute_callback() {
940
+		check_ajax_referer('wpshop_duplicate_attribute', 'wpshop_ajax_nonce');
941 941
 		global $wpdb;
942 942
 
943 943
 		$result = '';
@@ -957,16 +957,16 @@  discard block
 block discarded – undo
957 957
 		/*	Check if the attribute to duplicate does not exist for the selected entity	*/
958 958
 		$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']);
959 959
 		$check_existing_attribute = $wpdb->get_var($query);
960
-		if ( empty($check_existing_attribute) ) {
960
+		if (empty($check_existing_attribute)) {
961 961
 			/*	Save new attribut for the selected entity	*/
962 962
 			$new_attribute = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE, $attribute_def);
963 963
 			$new_attribute_id = $wpdb->insert_id;
964 964
 
965 965
 			if ($new_attribute) {
966
-				if ( in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom') ) {
966
+				if (in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom')) {
967 967
 					$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d", $current_attribute);
968 968
 					$attribute_options_list = $wpdb->get_results($query, ARRAY_A);
969
-					foreach ( $attribute_options_list as $option ) {
969
+					foreach ($attribute_options_list as $option) {
970 970
 						$option['id'] = '';
971 971
 						$option['creation_date'] = current_time('mysql', 0);
972 972
 						$option['attribute_id'] = $new_attribute_id;
@@ -997,27 +997,27 @@  discard block
 block discarded – undo
997 997
 	/**
998 998
 	 * Load comboBox of unit or group of unit
999 999
 	 */
1000
-	function wpshop_ajax_load_attribute_unit_list(){
1001
-		check_ajax_referer( 'wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce' );
1000
+	function wpshop_ajax_load_attribute_unit_list() {
1001
+		check_ajax_referer('wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce');
1002 1002
 		$response = '';
1003 1003
 
1004
-		$current_group = ( isset( $_POST[ 'current_group' ] ) && !empty( $_POST[ 'current_group' ] ) ) ? sanitize_text_field( $_POST[ 'current_group' ] ) : null;
1005
-		$selected_list = ( isset( $_POST[ 'selected_list' ] ) && !empty( $_POST[ 'selected_list' ] ) ) ? sanitize_text_field( $_POST[ 'selected_list' ] ) : null;
1004
+		$current_group = (isset($_POST['current_group']) && !empty($_POST['current_group'])) ? sanitize_text_field($_POST['current_group']) : null;
1005
+		$selected_list = (isset($_POST['selected_list']) && !empty($_POST['selected_list'])) ? sanitize_text_field($_POST['selected_list']) : null;
1006 1006
 
1007 1007
 		$group = wpshop_tools::varSanitizer($current_group);
1008 1008
 		$selected_list = wpshop_tools::varSanitizer($selected_list);
1009 1009
 
1010
-		if ( !empty($group) && !empty($selected_list)) {
1010
+		if (!empty($group) && !empty($selected_list)) {
1011 1011
 			/* Test if we want display the group unit list OR the unit list */
1012
-			if ( $selected_list == 'group unit' ) {
1012
+			if ($selected_list == 'group unit') {
1013 1013
 				$list = wpshop_attributes_unit::get_unit_group();
1014 1014
 			}
1015 1015
 			else {
1016 1016
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1017 1017
 			}
1018 1018
 
1019
-			foreach( $list as $unit ) {
1020
-				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1019
+			foreach ($list as $unit) {
1020
+				$response .= '<option value="' . $unit->id . '" ' . (($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '') . '>' . $unit->name . '</option>';
1021 1021
 			}
1022 1022
 			$result = array(true, $response);
1023 1023
 		}
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 
1034 1034
 /**	Tools page	*/
1035 1035
 	function wpshop_ajax_db_check_tool() {
1036
-		check_ajax_referer( 'wpshop_ajax_db_check_tool', '_wpnonce' );
1036
+		check_ajax_referer('wpshop_ajax_db_check_tool', '_wpnonce');
1037 1037
 
1038 1038
 		global $wpdb, $wpshop_db_table_operation_list, $wpshop_db_table, $wpshop_update_way;
1039 1039
 		$current_db_version = get_option('wpshop_db_options', 0);
@@ -1049,22 +1049,22 @@  discard block
 block discarded – undo
1049 1049
 </div>
1050 1050
 <div class="tools_db_modif_list_version_details" >
1051 1051
 	<ul>';
1052
-			foreach($plugin_db_modification as $modif_name => $modif_list){
1053
-				switch($modif_name){
1052
+			foreach ($plugin_db_modification as $modif_name => $modif_list) {
1053
+				switch ($modif_name) {
1054 1054
 					case 'FIELD_ADD':{
1055
-						foreach($modif_list as $table_name => $field_list){
1055
+						foreach ($modif_list as $table_name => $field_list) {
1056 1056
 							$sub_modif = '  ';
1057
-							foreach($field_list as $column_name){
1058
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1057
+							foreach ($field_list as $column_name) {
1058
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1059 1059
 								$columns = $wpdb->get_row($query);
1060 1060
 								$sub_modif .= $column_name;
1061
-								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1061
+								if (!empty($columns->Field) && ($columns->Field == $column_name)) {
1062 1062
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1063 1063
 								}
1064
-								else{
1064
+								else {
1065 1065
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1066 1066
 									$error_nb++;
1067
-									if ( !empty($error_list[$plugin_db_version]) ) {
1067
+									if (!empty($error_list[$plugin_db_version])) {
1068 1068
 										$error_list[$plugin_db_version] += 1;
1069 1069
 									}
1070 1070
 									else {
@@ -1073,56 +1073,56 @@  discard block
 block discarded – undo
1073 1073
 								}
1074 1074
 								$sub_modif .= ' / ';
1075 1075
 							}
1076
-							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1076
+							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1077 1077
 						}
1078 1078
 					}break;
1079 1079
 					case 'FIELD_DROP':{
1080
-						foreach($modif_list as $table_name => $field_list){
1080
+						foreach ($modif_list as $table_name => $field_list) {
1081 1081
 							$sub_modif = '  ';
1082
-							foreach($field_list as $column_name){
1083
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1082
+							foreach ($field_list as $column_name) {
1083
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1084 1084
 								$columns = $wpdb->get_row($query);
1085 1085
 								$sub_modif .= $column_name;
1086
-								if(empty($columns) || ($columns->Field != $column_name)){
1086
+								if (empty($columns) || ($columns->Field != $column_name)) {
1087 1087
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />';
1088 1088
 								}
1089
-								else{
1089
+								else {
1090 1090
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1091 1091
 									$error_nb++;
1092 1092
 									$error_list[$plugin_db_version] += 1;
1093 1093
 								}
1094 1094
 								$sub_modif .= ' / ';
1095 1095
 							}
1096
-							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1096
+							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1097 1097
 						}
1098 1098
 					}break;
1099 1099
 					case 'FIELD_CHANGE':{
1100
-						foreach($modif_list as $table_name => $field_list){
1100
+						foreach ($modif_list as $table_name => $field_list) {
1101 1101
 							$sub_modif = '  ';
1102
-							foreach($field_list as $field_infos){
1103
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_infos['field']);
1102
+							foreach ($field_list as $field_infos) {
1103
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_infos['field']);
1104 1104
 								$columns = $wpdb->get_row($query);
1105 1105
 								$what_is_changed = '';
1106
-								if(isset($field_infos['type'])){
1106
+								if (isset($field_infos['type'])) {
1107 1107
 									$what_is_changed = __('field type', 'wpshop');
1108 1108
 									$changed_key = 'type';
1109
-									if($columns->Type == $field_infos['type']){
1109
+									if ($columns->Type == $field_infos['type']) {
1110 1110
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1111 1111
 									}
1112
-									else{
1112
+									else {
1113 1113
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1114 1114
 										$error_nb++;
1115 1115
 										$error_list[$plugin_db_version] += 1;
1116 1116
 									}
1117 1117
 									$sub_modif .= sprintf(__('Change %s for field %s to %s', 'wpshop'), $what_is_changed, $field_infos['field'], $field_infos[$changed_key]);
1118 1118
 								}
1119
-								if(isset($field_infos['original_name'])){
1119
+								if (isset($field_infos['original_name'])) {
1120 1120
 									$what_is_changed = __('field name', 'wpshop');
1121 1121
 									$changed_key = 'original_name';
1122
-									if($columns->Field == $field_infos['field']){
1122
+									if ($columns->Field == $field_infos['field']) {
1123 1123
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1124 1124
 									}
1125
-									else{
1125
+									else {
1126 1126
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1127 1127
 										$error_nb++;
1128 1128
 										$error_list[$plugin_db_version] += 1;
@@ -1137,59 +1137,59 @@  discard block
 block discarded – undo
1137 1137
 					}break;
1138 1138
 
1139 1139
 					case 'DROP_INDEX':{
1140
-						foreach($modif_list as $table_name => $field_list){
1140
+						foreach ($modif_list as $table_name => $field_list) {
1141 1141
 							$sub_modif = '   ';
1142
-							foreach($field_list as $column_name){
1143
-								$query = $wpdb->prepare("SHOW INDEX FROM " .$table_name . " WHERE Column_name = %s", $column_name);
1142
+							foreach ($field_list as $column_name) {
1143
+								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s", $column_name);
1144 1144
 								$columns = $wpdb->get_row($query);
1145 1145
 								$sub_modif .= $column_name;
1146
-								if((empty($columns)) || ($columns->Column_name != $column_name)){
1146
+								if ((empty($columns)) || ($columns->Column_name != $column_name)) {
1147 1147
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />';
1148 1148
 								}
1149
-								else{
1149
+								else {
1150 1150
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />';
1151 1151
 									$error_nb++;
1152 1152
 									$error_list[$plugin_db_version] += 1;
1153 1153
 								}
1154 1154
 								$sub_modif .= ' / ';
1155 1155
 							}
1156
-							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1156
+							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1157 1157
 						}
1158 1158
 					}break;
1159 1159
 					case 'ADD_INDEX':{
1160
-						foreach($modif_list as $table_name => $field_list){
1160
+						foreach ($modif_list as $table_name => $field_list) {
1161 1161
 							$sub_modif = '   ';
1162
-							foreach($field_list as $column_name){
1162
+							foreach ($field_list as $column_name) {
1163 1163
 								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s OR Key_name = %s", $column_name, $column_name);
1164 1164
 								$columns = $wpdb->get_row($query);
1165 1165
 								$sub_modif .= $column_name;
1166
-								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1166
+								if (($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)) {
1167 1167
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />';
1168 1168
 								}
1169
-								else{
1169
+								else {
1170 1170
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />';
1171 1171
 									$error_nb++;
1172 1172
 									$error_list[$plugin_db_version] += 1;
1173 1173
 								}
1174 1174
 								$sub_modif .= ' / ';
1175 1175
 							}
1176
-							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1176
+							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1177 1177
 						}
1178 1178
 					}break;
1179 1179
 
1180 1180
 					case 'ADD_TABLE':{
1181 1181
 						$sub_modif = '  ';
1182
-						foreach($modif_list as $table_name){
1182
+						foreach ($modif_list as $table_name) {
1183 1183
 							$sub_modif .= $table_name;
1184 1184
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table_name);
1185 1185
 							$table_exists = $wpdb->query($query);
1186
-							if($table_exists == 1){
1186
+							if ($table_exists == 1) {
1187 1187
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />';
1188 1188
 							}
1189
-							else{
1189
+							else {
1190 1190
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />';
1191 1191
 								$error_nb++;
1192
-								if ( !empty($error_list[$plugin_db_version]) ) {
1192
+								if (!empty($error_list[$plugin_db_version])) {
1193 1193
 									$error_list[$plugin_db_version] += 1;
1194 1194
 								}
1195 1195
 								else {
@@ -1202,29 +1202,29 @@  discard block
 block discarded – undo
1202 1202
 					}break;
1203 1203
 					case 'TABLE_RENAME':{
1204 1204
 						$sub_modif = '  ';
1205
-						foreach($modif_list as $table){
1205
+						foreach ($modif_list as $table) {
1206 1206
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1207 1207
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1208 1208
 							$table_exists = $wpdb->query($query);
1209 1209
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1210 1210
 							$old_table_exists = $wpdb->query($query);
1211
-							if(($table_exists == 1) && ($old_table_exists == 1)){
1211
+							if (($table_exists == 1) && ($old_table_exists == 1)) {
1212 1212
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Both database table are still present', 'wpshop') . '" title="' . __('Both database table are still present', 'wpshop') . '" class="db_rename_table_check" />';
1213 1213
 								$error_nb++;
1214
-								if ( !empty($error_list[$plugin_db_version]) ) {
1214
+								if (!empty($error_list[$plugin_db_version])) {
1215 1215
 									$error_list[$plugin_db_version] += 1;
1216 1216
 								}
1217 1217
 								else {
1218 1218
 									$error_list[$plugin_db_version] = 1;
1219 1219
 								}
1220 1220
 							}
1221
-							elseif($table_exists == 1){
1221
+							elseif ($table_exists == 1) {
1222 1222
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1223 1223
 							}
1224
-							else{
1224
+							else {
1225 1225
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1226 1226
 								$error_nb++;
1227
-								if ( !empty($error_list[$plugin_db_version]) ) {
1227
+								if (!empty($error_list[$plugin_db_version])) {
1228 1228
 									$error_list[$plugin_db_version] += 1;
1229 1229
 								}
1230 1230
 								else {
@@ -1237,27 +1237,27 @@  discard block
 block discarded – undo
1237 1237
 					}break;
1238 1238
 					case 'TABLE_RENAME_FOR_DELETION':{
1239 1239
 						$sub_modif = '  ';
1240
-						foreach($modif_list as $table){
1240
+						foreach ($modif_list as $table) {
1241 1241
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1242 1242
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1243 1243
 							$table_delete_exists = $wpdb->query($query);
1244 1244
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1245 1245
 							$old_table_exists = $wpdb->query($query);
1246
-							if(($table_delete_exists == 1) || ($old_table_exists == 1)){
1247
-								if($old_table_exists == 1){
1246
+							if (($table_delete_exists == 1) || ($old_table_exists == 1)) {
1247
+								if ($old_table_exists == 1) {
1248 1248
 									$deleted_table_result = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1249 1249
 									$error_nb++;
1250
-									if ( !empty($error_list[$plugin_db_version]) ) {
1250
+									if (!empty($error_list[$plugin_db_version])) {
1251 1251
 										$error_list[$plugin_db_version] += 1;
1252 1252
 									}
1253 1253
 									else {
1254 1254
 										$error_list[$plugin_db_version] = 1;
1255 1255
 									}
1256 1256
 								}
1257
-								else{
1257
+								else {
1258 1258
 									$deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1259 1259
 									$warning_nb++;
1260
-									if ( !empty($warning_list[$plugin_db_version]) ) {
1260
+									if (!empty($warning_list[$plugin_db_version])) {
1261 1261
 										$warning_list[$plugin_db_version] += 1;
1262 1262
 									}
1263 1263
 									else {
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 								}
1267 1267
 								$sub_modif .= $deleted_table_result;
1268 1268
 							}
1269
-							else{
1269
+							else {
1270 1270
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />';
1271 1271
 							}
1272 1272
 							$sub_modif .= ' / ';
@@ -1281,57 +1281,57 @@  discard block
 block discarded – undo
1281 1281
 		}
1282 1282
 
1283 1283
 		$db_table_field_error = '';
1284
-		foreach($wpshop_db_table as $table_name => $table_definition){
1285
-			if(!empty($table_definition)){
1284
+		foreach ($wpshop_db_table as $table_name => $table_definition) {
1285
+			if (!empty($table_definition)) {
1286 1286
 				$table_line = explode("
1287 1287
 ", $table_definition);
1288 1288
 
1289 1289
 				$sub_db_table_field_error = '  ';
1290
-				foreach($table_line as $table_definition_line){
1290
+				foreach ($table_line as $table_definition_line) {
1291 1291
 					$def_line = trim($table_definition_line);
1292
-					if(substr($def_line, 0, 1) == "`"){
1292
+					if (substr($def_line, 0, 1) == "`") {
1293 1293
 						$line_element = explode(" ", $def_line);
1294 1294
 						$field_name = str_replace("`", "", $line_element[0]);
1295
-						$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_name);
1295
+						$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_name);
1296 1296
 						$columns = $wpdb->get_row($query);
1297
-						if ( !empty($columns->Field) && ($columns->Field != $field_name)) {
1297
+						if (!empty($columns->Field) && ($columns->Field != $field_name)) {
1298 1298
 							$sub_db_table_field_error .= $field_name . ', '/*  . ' : <img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />' */;
1299 1299
 							$error_nb++;
1300 1300
 						}
1301 1301
 					}
1302 1302
 				}
1303 1303
 				$sub_db_table_field_error = trim(substr($sub_db_table_field_error, 0, -2));
1304
-				if(!empty($sub_db_table_field_error)){
1304
+				if (!empty($sub_db_table_field_error)) {
1305 1305
 					$db_table_field_error .= sprintf(__('Following fields of %s don\'t exists: %s', 'wpshop'), '<span class="bold" >' . $table_name . '</span>', $sub_db_table_field_error) . '<br/>';
1306 1306
 				}
1307 1307
 			}
1308 1308
 		}
1309
-		if(!empty($db_table_field_error)){
1309
+		if (!empty($db_table_field_error)) {
1310 1310
 			$db_table_field_error = '<hr class="clear" />' . $db_table_field_error . '<hr/>';
1311 1311
 		}
1312 1312
 
1313 1313
 		/*	Start display	*/
1314 1314
 		$plugin_install_error = '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Wpshop install is ok', 'wpshop') . '" title="' . __('Wpshop install is ok', 'wpshop') . '" />&nbsp;' . __('There is no error in your wpshop installation. Please find details below', 'wpshop') . '<hr/>';
1315
-		if($error_nb > 0){
1315
+		if ($error_nb > 0) {
1316 1316
 			$plugin_install_error = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Error in wpshop install', 'wpshop') . '" title="' . __('Error in wpshop install', 'wpshop') . '" />&nbsp;' . __('There are ne or more errors into your wpshop installation. Please find details below', 'wpshop') . '<br/>
1317 1317
 							<ul>';
1318
-			foreach($error_list as $version => $element_nb){
1319
-				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version  . '" data-nonce="' . wp_create_nonce( 'wpshop_ajax_db_repair_tool ' ) .'" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1318
+			foreach ($error_list as $version => $element_nb) {
1319
+				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version . '" data-nonce="' . wp_create_nonce('wpshop_ajax_db_repair_tool ') . '" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1320 1320
 			}
1321 1321
 			$plugin_install_error .= '
1322 1322
 							</ul>';
1323 1323
 		}
1324
-		if($warning_nb > 0){
1324
+		if ($warning_nb > 0) {
1325 1325
 			$plugin_install_error .= '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Warning in wpshop install', 'wpshop') . '" title="' . __('Warning in wpshop install', 'wpshop') . '" />&nbsp;' . __('Some element need your attention. They have no consequences on wpshop operation. Please find details below', 'wpshop') . '<br/>';
1326
-			foreach($warning_list as $version => $element_nb){
1326
+			foreach ($warning_list as $version => $element_nb) {
1327 1327
 				$plugin_install_error .= '&nbsp;&nbsp;' . sprintf(__('There are %d warning into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - ';
1328 1328
 			}
1329 1329
 			$plugin_install_error = substr($plugin_install_error, 0, -3) . '<hr/>';
1330 1330
 		}
1331 1331
 
1332 1332
 		$max_number = 0;
1333
-		foreach($wpshop_update_way as $number => $operation){
1334
-			if($number > $max_number){
1333
+		foreach ($wpshop_update_way as $number => $operation) {
1334
+			if ($number > $max_number) {
1335 1335
 				$max_number = $number;
1336 1336
 			}
1337 1337
 		}
@@ -1341,30 +1341,30 @@  discard block
 block discarded – undo
1341 1341
 	add_action('wp_ajax_wpshop_tool_db_check', 'wpshop_ajax_db_check_tool');
1342 1342
 
1343 1343
 	function wpshop_tool_default_datas_check() {
1344
-		check_ajax_referer( 'wpshop_tool_default_datas_check' );
1344
+		check_ajax_referer('wpshop_tool_default_datas_check');
1345 1345
 
1346 1346
 		$output_ok = $output_error = '';
1347 1347
 
1348 1348
 		/**	Get defined default datas type	*/
1349
-		$default_custom_post_type = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES );
1349
+		$default_custom_post_type = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES);
1350 1350
 
1351 1351
 		/**	Read the default data saved to check	*/
1352
-		if ( !empty($default_custom_post_type) ) {
1353
-			foreach ( $default_custom_post_type as $type ) {
1352
+		if (!empty($default_custom_post_type)) {
1353
+			foreach ($default_custom_post_type as $type) {
1354 1354
 				$has_error = false;
1355 1355
 				$file_uri = WPSHOP_TEMPLATES_DIR . 'default_datas/' . $type . '.csv';
1356
-				if ( is_file( $file_uri ) ) {
1356
+				if (is_file($file_uri)) {
1357 1357
 					unset($tpl_component);
1358 1358
 					$tpl_component = array();
1359 1359
 					$tpl_component['CUSTOM_POST_TYPE_NAME'] = 'wpshop_cpt_' . $type;
1360 1360
 
1361 1361
 					/**	Launch check on custom post type	*/
1362
-					$check_cpt = wpshop_entities::check_default_custom_post_type( $type, $tpl_component );
1362
+					$check_cpt = wpshop_entities::check_default_custom_post_type($type, $tpl_component);
1363 1363
 					$has_error = $check_cpt[0];
1364 1364
 					$tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER'] = $check_cpt[1];
1365
-					$tpl_component = array_merge( $tpl_component, $check_cpt[2] );
1365
+					$tpl_component = array_merge($tpl_component, $check_cpt[2]);
1366 1366
 
1367
-					if ( $has_error ) {
1367
+					if ($has_error) {
1368 1368
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1369 1369
 					}
1370 1370
 					else {
@@ -1380,77 +1380,77 @@  discard block
 block discarded – undo
1380 1380
 	add_action('wp_ajax_wpshop_tool_default_datas_check', 'wpshop_tool_default_datas_check');
1381 1381
 
1382 1382
 	function wpshop_ajax_repair_default_datas() {
1383
-		check_ajax_referer( 'wpshop_ajax_repair_default_datas' );
1383
+		check_ajax_referer('wpshop_ajax_repair_default_datas');
1384 1384
 
1385 1385
 		global $wpdb;
1386 1386
 		$output = '';
1387 1387
 		$container = '';
1388 1388
 		$result = '';
1389 1389
 
1390
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1391
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1390
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1391
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1392 1392
 
1393
-		switch ( $selected_type ) {
1393
+		switch ($selected_type) {
1394 1394
 			case WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES:
1395
-				$result = wpshop_entities::create_cpt_from_csv_file( $identifier );
1395
+				$result = wpshop_entities::create_cpt_from_csv_file($identifier);
1396 1396
 			break;
1397 1397
 			case WPSHOP_DBT_ATTRIBUTE:
1398
-				$result = wpshop_entities::create_cpt_attributes_from_csv_file( $identifier );
1398
+				$result = wpshop_entities::create_cpt_attributes_from_csv_file($identifier);
1399 1399
 			break;
1400 1400
 		}
1401 1401
 
1402
-		echo json_encode( $result );
1402
+		echo json_encode($result);
1403 1403
 		die();
1404 1404
 	}
1405 1405
 	add_action('wp_ajax_wpshop_ajax_repair_default_datas', 'wpshop_ajax_repair_default_datas');
1406 1406
 
1407 1407
 	function wpshop_ajax_translate_default_datas() {
1408
-		check_ajax_referer( 'wpshop_ajax_translate_default_datas' );
1408
+		check_ajax_referer('wpshop_ajax_translate_default_datas');
1409 1409
 		global $wpdb;
1410 1410
 		$result = array('status' => true);
1411 1411
 
1412
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1413
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1412
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1413
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1414 1414
 
1415
-		$entity_id = wpshop_entities::get_entity_identifier_from_code( $identifier );
1415
+		$entity_id = wpshop_entities::get_entity_identifier_from_code($identifier);
1416 1416
 		$query = $wpdb->prepare("SELECT id, frontend_label FROM " . $selected_type . " WHERE entity_id = %d", $entity_id);
1417
-		$attribute_list = $wpdb->get_results( $query );
1418
-		if ( !empty($attribute_list) ) {
1419
-			foreach ( $attribute_list as $attribute) {
1420
-				$update_result = $wpdb->update( $selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id) );
1421
-				if ( $update_result === false ) {
1417
+		$attribute_list = $wpdb->get_results($query);
1418
+		if (!empty($attribute_list)) {
1419
+			foreach ($attribute_list as $attribute) {
1420
+				$update_result = $wpdb->update($selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id));
1421
+				if ($update_result === false) {
1422 1422
 					$result['status'] = false;
1423 1423
 				}
1424 1424
 			}
1425 1425
 		}
1426 1426
 
1427
-		echo json_encode( $result );
1427
+		echo json_encode($result);
1428 1428
 		die();
1429 1429
 	}
1430 1430
 	add_action('wp_ajax_wpshop_ajax_translate_default_datas', 'wpshop_ajax_translate_default_datas');
1431 1431
 
1432 1432
 	function wpshop_ajax_db_repair_tool() {
1433
-		check_ajax_referer( 'wpshop_ajax_db_repair_tool' );
1433
+		check_ajax_referer('wpshop_ajax_db_repair_tool');
1434 1434
 
1435 1435
 		$version_id = isset($_POST['version_id']) ? wpshop_tools::varSanitizer($_POST['version_id']) : null;
1436 1436
 
1437
-		echo wpshop_install::alter_db_structure_on_update( $version_id );
1437
+		echo wpshop_install::alter_db_structure_on_update($version_id);
1438 1438
 
1439 1439
 		die();
1440 1440
 	}
1441 1441
 	add_action('wp_ajax_wpshop_ajax_db_repair_tool', 'wpshop_ajax_db_repair_tool');
1442 1442
 
1443 1443
 	function wps_mass_action_main_interface() {
1444
-		check_ajax_referer( 'wps_mass_action_main_interface' );
1444
+		check_ajax_referer('wps_mass_action_main_interface');
1445 1445
 		$tpl_component = array();
1446 1446
 
1447 1447
 		/**	Copy an attribute content to another	*/
1448
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ), "'valid'", 'entity_id', true);
1448
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), "'valid'", 'entity_id', true);
1449 1449
 		$possible_values = array('' => __('Choose an attribute', 'wpshop'));
1450 1450
 		$possible_values_for_variation = array('' => __('Choose an attribute', 'wpshop'));
1451
-		foreach ( $attribute_list as $attribute ) {
1451
+		foreach ($attribute_list as $attribute) {
1452 1452
 			$possible_values[$attribute->id] = $attribute->frontend_label;
1453
-			if ( $attribute->is_used_for_variation == 'yes' ) {
1453
+			if ($attribute->is_used_for_variation == 'yes') {
1454 1454
 				$possible_values_for_variation[$attribute->id] = $attribute->frontend_label;
1455 1455
 			}
1456 1456
 		}
@@ -1481,22 +1481,22 @@  discard block
 block discarded – undo
1481 1481
 	add_action('wp_ajax_wps_mass_action', 'wps_mass_action_main_interface');
1482 1482
 
1483 1483
 	function wps_mass_action_update_attribute_value() {
1484
-		check_ajax_referer( 'wps_mass_action_update_attribute_value' );
1484
+		check_ajax_referer('wps_mass_action_update_attribute_value');
1485 1485
 		global $wpdb;
1486 1486
 		$response = array();
1487 1487
 
1488
-		$from = !empty( $_POST['wps_update_att_values']['from'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['from'] ) : '';
1489
-		$to = !empty( $_POST['wps_update_att_values']['to'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['to'] ) : '';
1490
-		$entity_to_transfert = !empty( $_POST['wps_entity_to_transfert'] ) ? sanitize_text_field( $_POST['wps_entity_to_transfert'] ) : '';
1488
+		$from = !empty($_POST['wps_update_att_values']['from']) ? sanitize_text_field($_POST['wps_update_att_values']['from']) : '';
1489
+		$to = !empty($_POST['wps_update_att_values']['to']) ? sanitize_text_field($_POST['wps_update_att_values']['to']) : '';
1490
+		$entity_to_transfert = !empty($_POST['wps_entity_to_transfert']) ? sanitize_text_field($_POST['wps_entity_to_transfert']) : '';
1491 1491
 
1492
-		if ( $from != $to ) {
1492
+		if ($from != $to) {
1493 1493
 			$from_attribute = wpshop_attributes::getElement($from, "'valid'");
1494 1494
 			$to_attribute = wpshop_attributes::getElement($to, "'valid'");
1495
-			if ( $from_attribute->data_type == $to_attribute->data_type ) {
1495
+			if ($from_attribute->data_type == $to_attribute->data_type) {
1496 1496
 
1497 1497
 				/**	Manage specific case	*/
1498 1498
 				$query_more_args = array();
1499
-				switch( $to_attribute->code ){
1499
+				switch ($to_attribute->code) {
1500 1500
 					case "barcode":
1501 1501
 							$more_query = "
1502 1502
 						AND VAL.value NOT LIKE %s";
@@ -1512,22 +1512,22 @@  discard block
 block discarded – undo
1512 1512
 					WHERE VAL.attribute_id = %d
1513 1513
 						AND P.post_type = %s
1514 1514
 						AND VAL.value != ''" . $more_query,
1515
-					array_merge( array( $from, $entity_to_transfert ), $query_more_args )
1515
+					array_merge(array($from, $entity_to_transfert), $query_more_args)
1516 1516
 				);
1517
-				$element_list_to_update = $wpdb->get_results( $query );
1517
+				$element_list_to_update = $wpdb->get_results($query);
1518 1518
 
1519
-				if ( !empty($element_list_to_update) ) {
1519
+				if (!empty($element_list_to_update)) {
1520 1520
 					$has_error = false;
1521 1521
 					$error_count = 0;
1522
-					foreach ( $element_list_to_update as $element ) {
1522
+					foreach ($element_list_to_update as $element) {
1523 1523
 
1524 1524
 						/**	Historicize the old value of recevier attribute	*/
1525
-						if (  $to_attribute->is_historisable == 'yes' ) {
1525
+						if ($to_attribute->is_historisable == 'yes') {
1526 1526
 							$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $to_attribute->id, $element->ID);
1527
-							$attribute_histos = $wpdb->get_results( $query );
1528
-							if ( !empty( $attribute_histos ) ) {
1529
-								foreach ( $attribute_histos as $attribute_histo ) {
1530
-									if ( !empty( $attribute_histo->value ) ) {
1527
+							$attribute_histos = $wpdb->get_results($query);
1528
+							if (!empty($attribute_histos)) {
1529
+								foreach ($attribute_histos as $attribute_histo) {
1530
+									if (!empty($attribute_histo->value)) {
1531 1531
 										$attribute_histo_content['status'] = 'valid';
1532 1532
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1533 1533
 										$attribute_histo_content['creation_date_value'] = $attribute_histo->creation_date_value;
@@ -1540,12 +1540,12 @@  discard block
 block discarded – undo
1540 1540
 										$attribute_histo_content['value'] = $attribute_histo->value;
1541 1541
 										$attribute_histo_content['value_type'] = WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType;
1542 1542
 										$last_histo = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO, $attribute_histo_content);
1543
-										if ( $last_histo === false ) {
1543
+										if ($last_histo === false) {
1544 1544
 											$has_error = true;
1545 1545
 											$error_count++;
1546 1546
 										}
1547 1547
 										else {
1548
-											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1548
+											$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array('value_id' => $attribute_histo->value_id));
1549 1549
 										}
1550 1550
 									}
1551 1551
 								}
@@ -1554,36 +1554,36 @@  discard block
 block discarded – undo
1554 1554
 
1555 1555
 						/**		*/
1556 1556
 						$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $from_attribute->id, $element->ID);
1557
-						$attribute_to_save = $wpdb->get_row( $query, ARRAY_A );
1557
+						$attribute_to_save = $wpdb->get_row($query, ARRAY_A);
1558 1558
 						unset($attribute_to_save['value_id']);
1559 1559
 						$attribute_to_save['attribute_id'] = $to_attribute->id;
1560 1560
 						$attribute_to_save['creation_date_value'] = current_time('mysql', 0);
1561 1561
 						$attribute_to_save['user_id'] = get_current_user_id();
1562
-						$new_value = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save );
1563
-						if ( $new_value === false ) {
1562
+						$new_value = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save);
1563
+						if ($new_value === false) {
1564 1564
 							$has_error = true;
1565 1565
 							$error_count++;
1566 1566
 						}
1567 1567
 						else {
1568 1568
 							/**	Save new atribute values in product metadata	*/
1569
-							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1569
+							$current_product_metadata = get_post_meta($element->ID, '_wpshop_product_metadata', true);
1570 1570
 							$current_product_metadata[$to_attribute->code] = $element->value;
1571
-							update_post_meta( $element->ID, '_wpshop_product_metadata', $current_product_metadata );
1571
+							update_post_meta($element->ID, '_wpshop_product_metadata', $current_product_metadata);
1572 1572
 
1573 1573
 							/**	Save a single meta for attribute in case it will be used in specific case where meta needs to be alone	*/
1574
-							if ( ( ($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes'))  || ( $to_attribute->is_filterable == 'yes') && !empty($element->value) ) :
1575
-								update_post_meta( $element->ID, '_' . $to_attribute->code, $element->value );
1574
+							if ((($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ($to_attribute->is_filterable == 'yes') && !empty($element->value)) :
1575
+								update_post_meta($element->ID, '_' . $to_attribute->code, $element->value);
1576 1576
 							endif;
1577 1577
 						}
1578 1578
 					}
1579 1579
 
1580
-					if ( !$has_error ) {
1580
+					if (!$has_error) {
1581 1581
 						$response['status'] = true;
1582 1582
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1583 1583
 					}
1584 1584
 					else {
1585 1585
 						$response['status'] = false;
1586
-						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1586
+						$response['error'] = sprinttf(__('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1587 1587
 					}
1588 1588
 				}
1589 1589
 				else {
@@ -1601,20 +1601,20 @@  discard block
 block discarded – undo
1601 1601
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1602 1602
 		}
1603 1603
 
1604
-		echo json_encode( $response );
1604
+		echo json_encode($response);
1605 1605
 		die();
1606 1606
 	}
1607 1607
 	add_action('wp_ajax_wps_mass_action_update_attribute', 'wps_mass_action_update_attribute_value');
1608 1608
 
1609 1609
 	function wps_tools_mass_action_load_possible_options_for_variations_attributes() {
1610 1610
 		// @TODO attribute_id est introuvable
1611
-		check_ajax_referer( 'wps_tools_mass_action_load_possible_options_for_variations_attributes' );
1611
+		check_ajax_referer('wps_tools_mass_action_load_possible_options_for_variations_attributes');
1612 1612
 		$output = '';
1613
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1614
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1613
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1614
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1615 1615
 
1616 1616
 		/**	Define new default value	*/
1617
-		$attribute_possible_values_output = wpshop_attributes::get_select_output( $attribute, array() );
1617
+		$attribute_possible_values_output = wpshop_attributes::get_select_output($attribute, array());
1618 1618
 		$attribute_possible_values_output['possible_value']['no_changes'] = __('No changes', 'wpshop');
1619 1619
 		$attribute_possible_values_output['possible_value']['none'] = __('No default value', 'wpshop');
1620 1620
 		ksort($attribute_possible_values_output['possible_value']);
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 		$input_def['valueToPut'] = 'index';
1624 1624
 		$input_def['name'] = 'wps_update_att_for_variation_options_values';
1625 1625
 		$input_def['id'] = 'wps_update_att_for_variation_options_values';
1626
-		$output .= __( 'Default value to affect for this attribute to all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1626
+		$output .= __('Default value to affect for this attribute to all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1627 1627
 
1628 1628
 		/**	Define if attribute is required for adding product to cart	*/
1629 1629
 		$input_def = array();
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 		$input_def['valueToPut'] = 'index';
1633 1633
 		$input_def['name'] = 'wps_update_att_for_variation_required_state';
1634 1634
 		$input_def['id'] = 'wps_update_att_for_variation_required_state';
1635
-		$output .= '<br/>' . __( 'Put this attribute as required for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1635
+		$output .= '<br/>' . __('Put this attribute as required for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1636 1636
 
1637 1637
 
1638 1638
 		$input_def = array();
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 		$input_def['valueToPut'] = 'index';
1642 1642
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][text_from]';
1643 1643
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_text_from';
1644
-		$output .= '<br/>' . __( 'Display "Price from" text before price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1644
+		$output .= '<br/>' . __('Display "Price from" text before price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1645 1645
 
1646 1646
 		$input_def = array();
1647 1647
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'no' => __('No', 'wpshop'), 'yes' => __('Yes', 'wpshop'));
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 		$input_def['valueToPut'] = 'index';
1650 1650
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][lower_price]';
1651 1651
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_lower_price';
1652
-		$output .= '<br/>' . __( 'Display lower price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1652
+		$output .= '<br/>' . __('Display lower price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1653 1653
 
1654 1654
 		$input_def = array();
1655 1655
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'replacement' => __('Replace product price with option price', 'wpshop'), 'addition' => __('Add option price to product price', 'wpshop'));
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 		$input_def['valueToPut'] = 'index';
1658 1658
 		$input_def['name'] = 'wps_update_att_for_variation[price_behaviour]';
1659 1659
 		$input_def['id'] = 'wps_update_att_for_variation_price_behaviour';
1660
-		$output .= '<br/>' . __( 'Price calculation behaviour', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1660
+		$output .= '<br/>' . __('Price calculation behaviour', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1661 1661
 
1662 1662
 		$input_def = array();
1663 1663
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'single' => __('Priority to single options', 'wpshop'), 'combined' => __('Priority to combined options', 'wpshop'));
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
 		$input_def['valueToPut'] = 'index';
1666 1666
 		$input_def['name'] = 'wps_update_att_for_variation[priority]';
1667 1667
 		$input_def['id'] = 'wps_update_att_for_variation_priority';
1668
-		$output .= '<br/>' . __( 'Choose priority combination for calculating options', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1668
+		$output .= '<br/>' . __('Choose priority combination for calculating options', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1669 1669
 
1670 1670
 		echo $output;
1671 1671
 		die();
@@ -1673,69 +1673,69 @@  discard block
 block discarded – undo
1673 1673
 	add_action('wp_ajax_wps_tools_mass_action_load_possible_options_for_variations_attributes', 'wps_tools_mass_action_load_possible_options_for_variations_attributes');
1674 1674
 
1675 1675
 	function wps_mass_action_change_variation_option() {
1676
-		check_ajax_referer( 'wps_mass_action_change_variation_option' );
1676
+		check_ajax_referer('wps_mass_action_change_variation_option');
1677 1677
 		global $wpdb;
1678 1678
 
1679
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1680
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1681
-		$query = $wpdb->prepare( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code );
1682
-		$meta_to_update = $wpdb->get_results( $query );
1679
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1680
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1681
+		$query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code);
1682
+		$meta_to_update = $wpdb->get_results($query);
1683 1683
 		$has_error = false;
1684
-		if ( !empty($meta_to_update) ) {
1685
-			foreach ( $meta_to_update as $meta_def ) {
1686
-				$meta_value = unserialize( $meta_def->meta_value );
1687
-				if ( !empty($meta_value) && !empty( $meta_value['attributes'] ) && in_array( $attribute->code, $meta_value['attributes']) ) {
1684
+		if (!empty($meta_to_update)) {
1685
+			foreach ($meta_to_update as $meta_def) {
1686
+				$meta_value = unserialize($meta_def->meta_value);
1687
+				if (!empty($meta_value) && !empty($meta_value['attributes']) && in_array($attribute->code, $meta_value['attributes'])) {
1688 1688
 
1689
-					$update_att_for_variation_options_values = !empty( $_POST['wps_update_att_for_variation_options_values'] ) ? sanitize_text_field( $_POST['wps_update_att_for_variation_options_values'] ) : '';
1690
-					if ( $update_att_for_variation_options_values != 'no_changes' ) {
1689
+					$update_att_for_variation_options_values = !empty($_POST['wps_update_att_for_variation_options_values']) ? sanitize_text_field($_POST['wps_update_att_for_variation_options_values']) : '';
1690
+					if ($update_att_for_variation_options_values != 'no_changes') {
1691 1691
 						$meta_value['options']['attributes_default_value'][$attribute->code] = $update_att_for_variation_options_values;
1692 1692
 					}
1693 1693
 
1694
-					$wps_update_att_for_variation_required_state = !empty( $_POST['wps_update_att_for_variation_required_state'] ) ? sanitize_text_field( $_POST['wps_update_att_for_variation_required_state'] ) : '';
1695
-					if ( !empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes') ) {
1696
-						if ( $wps_update_att_for_variation_required_state == 'yes') {
1694
+					$wps_update_att_for_variation_required_state = !empty($_POST['wps_update_att_for_variation_required_state']) ? sanitize_text_field($_POST['wps_update_att_for_variation_required_state']) : '';
1695
+					if (!empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes')) {
1696
+						if ($wps_update_att_for_variation_required_state == 'yes') {
1697 1697
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1698 1698
 						}
1699
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1699
+						else if (!empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code])) {
1700 1700
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1701 1701
 						}
1702 1702
 					}
1703 1703
 
1704
-					$update_att_for_variation = !empty( $_POST['wps_update_att_for_variation'] ) ? (array) $_POST['wps_update_att_for_variation'] : array();
1705
-					$text_from = !empty( $update_att_for_variation['text_from'] ) ? sanitize_text_field( $update_att_for_variation['text_from'] ) : '';
1706
-					if ( !empty( $update_att_for_variation ) ) {
1707
-						if ( !empty($text_from) && ($text_from != 'no_changes') ) {
1708
-							if ( $text_from == 'yes' ) {
1704
+					$update_att_for_variation = !empty($_POST['wps_update_att_for_variation']) ? (array)$_POST['wps_update_att_for_variation'] : array();
1705
+					$text_from = !empty($update_att_for_variation['text_from']) ? sanitize_text_field($update_att_for_variation['text_from']) : '';
1706
+					if (!empty($update_att_for_variation)) {
1707
+						if (!empty($text_from) && ($text_from != 'no_changes')) {
1708
+							if ($text_from == 'yes') {
1709 1709
 								$meta_value['options']['price_display']['text_from'] = 'on';
1710 1710
 							}
1711
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1711
+							else if (!empty($meta_value['options']['price_display']['text_from'])) {
1712 1712
 								unset($meta_value['options']['price_display']['text_from']);
1713 1713
 							}
1714 1714
 						}
1715 1715
 
1716
-						$lower_price = !empty( $update_att_for_variation['lower_price'] ) ? sanitize_text_field( $update_att_for_variation['lower_price'] ) : '';
1717
-						if ( !empty($lower_price) && ($lower_price != 'no_changes') ) {
1718
-							if ( $lower_price == 'yes' ) {
1716
+						$lower_price = !empty($update_att_for_variation['lower_price']) ? sanitize_text_field($update_att_for_variation['lower_price']) : '';
1717
+						if (!empty($lower_price) && ($lower_price != 'no_changes')) {
1718
+							if ($lower_price == 'yes') {
1719 1719
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1720 1720
 							}
1721
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1721
+							else if (!empty($meta_value['options']['price_display']['lower_price'])) {
1722 1722
 								unset($meta_value['options']['price_display']['lower_price']);
1723 1723
 							}
1724 1724
 						}
1725 1725
 
1726
-						$price_behaviour = !empty( $update_att_for_variation['price_behaviour'] ) ? sanitize_text_field( $update_att_for_variation['price_behaviour'] ) : '';
1727
-						if ( !empty($price_behaviour) && ($price_behaviour != 'no_changes') ) {
1726
+						$price_behaviour = !empty($update_att_for_variation['price_behaviour']) ? sanitize_text_field($update_att_for_variation['price_behaviour']) : '';
1727
+						if (!empty($price_behaviour) && ($price_behaviour != 'no_changes')) {
1728 1728
 							$meta_value['options']['price_behaviour'][0] = $price_behaviour;
1729 1729
 						}
1730 1730
 
1731
-						$priority = !empty( $update_att_for_variation['priority'] ) ? sanitize_text_field( $update_att_for_variation['priority'] ) : '';
1732
-						if ( !empty($priority) && ($priority != 'no_changes') ) {
1731
+						$priority = !empty($update_att_for_variation['priority']) ? sanitize_text_field($update_att_for_variation['priority']) : '';
1732
+						if (!empty($priority) && ($priority != 'no_changes')) {
1733 1733
 							$meta_value['options']['priority'][0] = $priority;
1734 1734
 						}
1735 1735
 					}
1736 1736
 
1737
-					$meta_save = update_meta( $meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1738
-					if ( $meta_save === false ) {
1737
+					$meta_save = update_meta($meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1738
+					if ($meta_save === false) {
1739 1739
 						$has_error = true;
1740 1740
 					}
1741 1741
 
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
 			}
1744 1744
 		}
1745 1745
 
1746
-		echo json_encode( array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))) );
1746
+		echo json_encode(array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))));
1747 1747
 		die();
1748 1748
 	}
1749 1749
 	add_action('wp_ajax_wps_mass_action_change_variation_option', 'wps_mass_action_change_variation_option');
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 	 */
1756 1756
 	function ajax_activate_addons() {
1757 1757
 		global $wpdb;
1758
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1758
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1759 1759
 
1760 1760
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1761 1761
 		$addon_code = isset($_POST['code']) ? wpshop_tools::varSanitizer($_POST['code']) : null;
@@ -1764,56 +1764,56 @@  discard block
 block discarded – undo
1764 1764
 		if (!empty($addon_name) && !empty($addon_code)) {
1765 1765
 			$addons_list = (unserialize(WPSHOP_ADDONS_LIST));
1766 1766
 			if (in_array($addon_name, array_keys($addons_list))) {
1767
-				$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
1767
+				$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
1768 1768
 				$code_part = array();
1769
-				$code_part[] = substr(hash ( "sha256" , $addons_list[$addon_name][0] ),  $addons_list[$addon_name][1], 5);
1770
-				$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
1771
-				$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
1769
+				$code_part[] = substr(hash("sha256", $addons_list[$addon_name][0]), $addons_list[$addon_name][1], 5);
1770
+				$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
1771
+				$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
1772 1772
 				$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
1773 1773
 
1774 1774
 				$current_web_site = site_url('/');
1775 1775
 
1776
-				if ( $addons_list[$addon_name][2] == 'per_site') {
1777
-					$code .= '-' . substr(hash ( "sha256" , $current_web_site ),  $addons_list[$addon_name][1], 5);
1776
+				if ($addons_list[$addon_name][2] == 'per_site') {
1777
+					$code .= '-' . substr(hash("sha256", $current_web_site), $addons_list[$addon_name][1], 5);
1778 1778
 				}
1779 1779
 
1780
-				if ( !empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1781
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1782
-					if ( empty($admin_new_quotation_message) ) {
1783
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1780
+				if (!empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1781
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1782
+					if (empty($admin_new_quotation_message)) {
1783
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1784 1784
 					}
1785
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1786
-					if ( empty($admin_new_quotation_confirm_message) ) {
1787
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1785
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1786
+					if (empty($admin_new_quotation_confirm_message)) {
1787
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1788 1788
 					}
1789 1789
 				}
1790 1790
 
1791 1791
 				if ($code == $addon_code) {
1792
-					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array() );
1792
+					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1793 1793
 					$extra_options[$addon_name]['activate'] = true;
1794 1794
 					$extra_options[$addon_name]['activation_date'] = current_time('mysql', 0);
1795 1795
 					$extra_options[$addon_name]['activation_code'] = $addon_code;
1796
-					if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1797
-						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated','wpshop'));
1798
-						if( !empty($addons_list[$addon_name][3]) ) {
1796
+					if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1797
+						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated', 'wpshop'));
1798
+						if (!empty($addons_list[$addon_name][3])) {
1799 1799
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1800 1800
 						}
1801 1801
 						$state = true;
1802 1802
 					}
1803 1803
 					else {
1804
-						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1804
+						$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1805 1805
 					}
1806 1806
 				}
1807 1807
 				else {
1808
-					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1808
+					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1809 1809
 				}
1810 1810
 			}
1811 1811
 			else {
1812
-				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1812
+				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1813 1813
 			}
1814 1814
 		}
1815 1815
 		else {
1816
-			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1816
+			$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1817 1817
 		}
1818 1818
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
1819 1819
 
@@ -1826,27 +1826,27 @@  discard block
 block discarded – undo
1826 1826
 	 * Addons desactivate
1827 1827
 	 */
1828 1828
 	function ajax_desactivate_wpshop_addons() {
1829
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1829
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1830 1830
 
1831 1831
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1832 1832
 		$state = true;
1833 1833
 
1834
-		if ( !empty($addon_name) ) {
1834
+		if (!empty($addon_name)) {
1835 1835
 			$addons_list = array_keys(unserialize(WPSHOP_ADDONS_LIST));
1836 1836
 			if (in_array($addon_name, $addons_list)) {
1837 1837
 				$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1838 1838
 				$extra_options[$addon_name]['activate'] = false;
1839 1839
 				$extra_options[$addon_name]['deactivation_date'] = current_time('mysql', 0);
1840
-				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1841
-					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1840
+				if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1841
+					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated', 'wpshop'));
1842 1842
 					$state = false;
1843 1843
 				}
1844 1844
 				else {
1845
-					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1845
+					$result = array(false, __('An error occured', 'wpshop'), __('Activated', 'wpshop'));
1846 1846
 				}
1847 1847
 			}
1848 1848
 			else {
1849
-				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1849
+				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated', 'wpshop'));
1850 1850
 			}
1851 1851
 		}
1852 1852
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1860,39 +1860,39 @@  discard block
 block discarded – undo
1860 1860
 	 * Display opttions for including user address into account form
1861 1861
 	 */
1862 1862
 	function ajax_integrate_billing_into_register() {
1863
-		check_ajax_referer( 'wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce' );
1863
+		check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce');
1864 1864
 		global $wpshop_account;
1865 1865
 		$wpshop_billing_address = get_option('wpshop_billing_address');
1866 1866
 		$current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null;
1867 1867
 		$selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null;
1868
-		$attribute = !empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array();
1869
-		$billing_form_fields = wps_address::get_addresss_form_fields_by_type ( $current_billing_address );
1868
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
1869
+		$billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address);
1870 1870
 		$possible_values_for_billing = array('' => __('No corresponding field', 'wpshop'));
1871
-		foreach ( $billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1872
-			foreach ( $attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1871
+		foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1872
+			foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1873 1873
 				$possible_values_for_billing[$attribute_build_code] = $attribute_definition['label'];
1874 1874
 			}
1875 1875
 		}
1876
-		$attributes_set = wpshop_attributes_set::getElement( 'yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1876
+		$attributes_set = wpshop_attributes_set::getElement('yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1877 1877
 		/*	Get the attribute set details in order to build the product interface	*/
1878
-		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'");
1879
-		if(!empty($productAttributeSetDetails)){
1880
-			foreach($productAttributeSetDetails as $productAttributeSetDetail){
1881
-				if(count($productAttributeSetDetail['attribut']) >= 1){
1882
-					foreach($productAttributeSetDetail['attribut'] as $attribute) {
1883
-						if(!empty($attribute->id)) {
1884
-							$submitOrderInfos = !empty( $_POST['submitOrderInfos'] ) ? (int) $_POST['submitOrderInfos'] : 0;
1885
-							if( !empty($submitOrderInfos) ) {
1878
+		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'");
1879
+		if (!empty($productAttributeSetDetails)) {
1880
+			foreach ($productAttributeSetDetails as $productAttributeSetDetail) {
1881
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
1882
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
1883
+						if (!empty($attribute->id)) {
1884
+							$submitOrderInfos = !empty($_POST['submitOrderInfos']) ? (int)$_POST['submitOrderInfos'] : 0;
1885
+							if (!empty($submitOrderInfos)) {
1886 1886
 								$value = $attribute[$attribute->data_type][$attribute->code];
1887 1887
 							}
1888 1888
 							else {
1889 1889
 								$value = '';
1890
-								if ( $attribute->code != 'user_pass') {
1890
+								if ($attribute->code != 'user_pass') {
1891 1891
 									$code = $attribute->code;
1892 1892
 									$value = $user->$code;
1893 1893
 								}
1894 1894
 							}
1895
-							$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute, $value, array() );
1895
+							$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array());
1896 1896
 							$account_form_field[$attribute->code] = $attribute_output_def;
1897 1897
 						}
1898 1898
 					}
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
 
1903 1903
 		$possible_values = array();
1904 1904
 		$matching_field = '';
1905
-		foreach ( $account_form_field as $attribute_code => $attribute_detail) {
1905
+		foreach ($account_form_field as $attribute_code => $attribute_detail) {
1906 1906
 			$possible_values[$attribute_code] = $attribute_detail['label'];
1907 1907
 
1908 1908
 			$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']';
@@ -1934,13 +1934,13 @@  discard block
 block discarded – undo
1934 1934
 	 * Search element in database for shortcode insertion interface
1935 1935
 	 */
1936 1936
 	function ajax_wpshop_element_search() {
1937
-		check_ajax_referer( 'wpshop_element_search', 'wpshop_ajax_nonce' );
1937
+		check_ajax_referer('wpshop_element_search', 'wpshop_ajax_nonce');
1938 1938
 
1939 1939
 		$wpshop_element_searched = isset($_REQUEST['wpshop_element_searched']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_searched']) : null;
1940 1940
 		$wpshop_element_type = isset($_REQUEST['wpshop_element_type']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_type']) : null;
1941 1941
 		$wpshop_format_result = isset($_REQUEST['wpshop_format_result']) ? (bool)wpshop_tools::varSanitizer($_REQUEST['wpshop_format_result']) : true;
1942 1942
 
1943
-		switch ( $wpshop_element_type ) {
1943
+		switch ($wpshop_element_type) {
1944 1944
 			case 'product':
1945 1945
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
1946 1946
 				$data = wpshop_products::product_list($wpshop_format_result, $wpshop_element_searched);
@@ -1950,18 +1950,18 @@  discard block
 block discarded – undo
1950 1950
 				break;
1951 1951
 			case WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS:
1952 1952
 				$wps_provider_ctr = new wps_provider_ctr();
1953
-				$data = $wps_provider_ctr->read( array( 's' => $wpshop_element_searched ) );
1953
+				$data = $wps_provider_ctr->read(array('s' => $wpshop_element_searched));
1954 1954
 				break;
1955 1955
 		}
1956 1956
 
1957
-		if ( $wpshop_format_result ) {
1957
+		if ($wpshop_format_result) {
1958 1958
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1959 1959
 		}
1960 1960
 		else {
1961
-			if ( !empty($data) ) {
1961
+			if (!empty($data)) {
1962 1962
 				$temp_data = $data;
1963
-				unset( $data );
1964
-				foreach ( $temp_data as $post) {
1963
+				unset($data);
1964
+				foreach ($temp_data as $post) {
1965 1965
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1966 1966
 				}
1967 1967
 			}
@@ -1982,35 +1982,35 @@  discard block
 block discarded – undo
1982 1982
 	 * Add product to the end user cart
1983 1983
 	 */
1984 1984
 	function ajax_wpshop_add_to_cart() {
1985
-		check_ajax_referer( 'ajax_pos_product_variation_selection' );
1985
+		check_ajax_referer('ajax_pos_product_variation_selection');
1986 1986
 
1987 1987
 		global $wpdb;
1988 1988
 		$wpshop_cart = new wps_cart();
1989 1989
 
1990 1990
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
1991 1991
 		$product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1;
1992
-		$cart_option = get_option('wpshop_cart_option', array() );
1992
+		$cart_option = get_option('wpshop_cart_option', array());
1993 1993
 		$wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? (array)$_POST['wps_pdt_variations'] : array();
1994
-		$from_administration =  ( !empty($_POST['from_admin']) ) ? (int)$_POST['from_admin'] : false;
1995
-		$order_id =  ( !empty($_POST['wps_orders_order_id']) ) ? wpshop_tools::varSanitizer( $_POST['wps_orders_order_id'] ) : null;
1994
+		$from_administration = (!empty($_POST['from_admin'])) ? (int)$_POST['from_admin'] : false;
1995
+		$order_id = (!empty($_POST['wps_orders_order_id'])) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null;
1996 1996
 
1997 1997
 
1998 1998
 		// Check Cart Animation
1999
-		$cart_animation_choice = ( !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2000
-		if ( !empty($cart_option['total_nb_of_item_allowed']) && ((int) $cart_option['total_nb_of_item_allowed'][0] == 1) ) {
1999
+		$cart_animation_choice = (!empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2000
+		if (!empty($cart_option['total_nb_of_item_allowed']) && ((int)$cart_option['total_nb_of_item_allowed'][0] == 1)) {
2001 2001
 			$wpshop_cart->empty_cart();
2002 2002
 		}
2003 2003
 
2004 2004
 		// Prepare Product to be added to cart
2005
-		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected );
2005
+		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected);
2006 2006
 		$product_to_add_to_cart = $formatted_product[0];
2007 2007
 		$new_pid = $formatted_product[1];
2008 2008
 
2009 2009
 		// Check cart Type
2010 2010
 		$cart_type_for_adding = 'normal';
2011
-		$wpshop_cart_type = !empty( $_POST['wpshop_cart_type'] ) ? sanitize_text_field( $_POST['wpshop_cart_type'] ) : '';
2012
-		if (!empty($wpshop_cart_type) ) {
2013
-			switch(wpshop_tools::varSanitizer($wpshop_cart_type)){
2011
+		$wpshop_cart_type = !empty($_POST['wpshop_cart_type']) ? sanitize_text_field($_POST['wpshop_cart_type']) : '';
2012
+		if (!empty($wpshop_cart_type)) {
2013
+			switch (wpshop_tools::varSanitizer($wpshop_cart_type)) {
2014 2014
 				case 'quotation':
2015 2015
 					$wpshop_cart_type = 'quotation';
2016 2016
 					break;
@@ -2021,43 +2021,43 @@  discard block
 block discarded – undo
2021 2021
 		}
2022 2022
 
2023 2023
 		// Check Product image
2024
-		$product = get_post( $product_id );
2025
-		$product_img = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="no picture" />';
2026
-		if ( !empty($product_id) ) {
2027
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2028
-				$parent_def = wpshop_products::get_parent_variation( $product_id );
2029
-				$parent_post = ( !empty($parent_def['parent_post']) ) ? $parent_def['parent_post'] : array();
2030
-				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
2031
-				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
2032
-				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
2024
+		$product = get_post($product_id);
2025
+		$product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />';
2026
+		if (!empty($product_id)) {
2027
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2028
+				$parent_def = wpshop_products::get_parent_variation($product_id);
2029
+				$parent_post = (!empty($parent_def['parent_post'])) ? $parent_def['parent_post'] : array();
2030
+				$product_title = (!empty($parent_post) && !empty($parent_post->post_title)) ? $parent_post->post_title : '';
2031
+				$product_description = (!empty($parent_post) && !empty($parent_post->post_content)) ? $parent_post->post_content : '';
2032
+				$product_img = (!empty($parent_post->ID)) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : '';
2033 2033
 			}
2034 2034
 			else {
2035 2035
 				$product_title = $product->post_title;
2036 2036
 				$product_description = $product->post_content;
2037
-				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
2037
+				$product_img = get_the_post_thumbnail($product_id, 'thumbnail');
2038 2038
 			}
2039 2039
 		}
2040 2040
 
2041
-		$wps_orders_from_admin = !empty( $_POST['wps_orders_from_admin'] ) ? (int) $_POST['wps_orders_from_admin'] : 0;
2042
-		if ( !empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2041
+		$wps_orders_from_admin = !empty($_POST['wps_orders_from_admin']) ? (int)$_POST['wps_orders_from_admin'] : 0;
2042
+		if (!empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2043 2043
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2044
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type, array(), true, $order_meta, $order_id );
2044
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type, array(), true, $order_meta, $order_id);
2045 2045
 
2046
-			echo json_encode( array(true) );
2046
+			echo json_encode(array(true));
2047 2047
 			die();
2048 2048
 		}
2049 2049
 		else {
2050
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2050
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type);
2051 2051
 		}
2052 2052
 
2053
-		if ( $return == 'success' ) {
2054
-			$cart_page_url = apply_filters( 'wps_cart_page_url', get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_cart_page_id' ) ) ) );
2053
+		if ($return == 'success') {
2054
+			$cart_page_url = apply_filters('wps_cart_page_url', get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))));
2055 2055
 			/** Template parameters	*/
2056 2056
 			$template_part = 'product_added_to_cart_message';
2057 2057
 
2058 2058
 			/** Build template	*/
2059 2059
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2060
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2060
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2061 2061
 				/*	Include the old way template part	*/
2062 2062
 				ob_start();
2063 2063
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2076,14 +2076,14 @@  discard block
 block discarded – undo
2076 2076
 
2077 2077
 			/** Product Price **/
2078 2078
 			$product_price = '';
2079
-			if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart) ) {
2079
+			if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) {
2080 2080
 				$idp = '';
2081 2081
 
2082
-				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2082
+				if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) {
2083 2083
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2084 2084
 				}
2085 2085
 				else {
2086
-					if( strstr( $new_pid, '__') ) {
2086
+					if (strstr($new_pid, '__')) {
2087 2087
 						$idp = $new_pid;
2088 2088
 					}
2089 2089
 					else {
@@ -2091,43 +2091,43 @@  discard block
 block discarded – undo
2091 2091
 					}
2092 2092
 				}
2093 2093
 
2094
-				if( !empty($idp) ) {
2095
-					$default_currency = wpshop_tools::wpshop_get_currency( false );
2096
-					$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
2094
+				if (!empty($idp)) {
2095
+					$default_currency = wpshop_tools::wpshop_get_currency(false);
2096
+					$price_piloting_option = get_option('wpshop_shop_price_piloting');
2097 2097
 
2098 2098
 					$real_price = null;
2099
-					if ( !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid]['item_amount_to_pay_now'] ) ) {
2100
-						$real_price = ( $_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty );
2099
+					if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$new_pid]) && !empty($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'])) {
2100
+						$real_price = ($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty);
2101 2101
 					}
2102 2102
 
2103
-					$pr = empty( $real_price ) ? ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ht']  * $product_qty ) : ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty ) : $real_price;
2104
-					$product_price = wpshop_tools::formate_number( $pr ).$default_currency;
2103
+					$pr = empty($real_price) ? (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty) : ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty) : $real_price;
2104
+					$product_price = wpshop_tools::formate_number($pr) . $default_currency;
2105 2105
 				}
2106 2106
 			}
2107 2107
 			/** Check if there are linked products **/
2108
-			$related_products = get_post_meta( $product_id, '_wpshop_product_related_products', true);
2108
+			$related_products = get_post_meta($product_id, '_wpshop_product_related_products', true);
2109 2109
 			$tpl_component = array();
2110 2110
 			$linked_products = '';
2111
-			if ( !empty($related_products) ) {
2111
+			if (!empty($related_products)) {
2112 2112
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2113
-				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2113
+				$linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>';
2114 2114
 			}
2115 2115
 			else {
2116 2116
 				$linked_products = '';
2117 2117
 			}
2118 2118
 
2119
-			$message_confirmation = sprintf( __('%s has been add to the cart', 'wpshop'), $product->post_title );
2119
+			$message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title);
2120 2120
 
2121
-			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array( 'RELATED_PRODUCTS' => $linked_products , 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description) );
2122
-			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array( 'LINK_CART_PAGE' => wpshop_tools::get_page_id( get_permalink( get_option('wpshop_cart_page_id') ) ) ) );
2121
+			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array('RELATED_PRODUCTS' => $linked_products, 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description));
2122
+			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array('LINK_CART_PAGE' => wpshop_tools::get_page_id(get_permalink(get_option('wpshop_cart_page_id')))));
2123 2123
 
2124
-			$response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content );
2124
+			$response = array(true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content);
2125 2125
 		}
2126 2126
 		else {
2127
-			$response = array( false, $return );
2127
+			$response = array(false, $return);
2128 2128
 		}
2129 2129
 
2130
-		wp_die( json_encode( $response ) );
2130
+		wp_die(json_encode($response));
2131 2131
 	}
2132 2132
  	add_action('wp_ajax_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
2133 2133
 	add_action('wp_ajax_nopriv_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
@@ -2137,45 +2137,45 @@  discard block
 block discarded – undo
2137 2137
 	 * Set product qty into customer cart
2138 2138
 	 */
2139 2139
 	function ajax_wpshop_set_qty_for_product_into_cart() {
2140
-		check_ajax_referer( 'ajax_wpshop_set_qty_for_product_into_cart' );
2140
+		check_ajax_referer('ajax_wpshop_set_qty_for_product_into_cart');
2141 2141
 		$response = array();
2142 2142
 		$wpshop_cart = new wps_cart();
2143 2143
 		$product_id = isset($_POST['product_id']) ? wpshop_tools::varSanitizer($_POST['product_id']) : null;
2144 2144
 		$product_qty = isset($_POST['product_qty']) ? intval(wpshop_tools::varSanitizer($_POST['product_qty'])) : null;
2145 2145
 
2146 2146
 		$pid = $product_id;
2147
-		if (strpos($product_id,'__') !== false) {
2147
+		if (strpos($product_id, '__') !== false) {
2148 2148
 			//$pid = $_SESSION['cart']['order_items'][$product_id]['item_id'];
2149
-			foreach( $_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation ) {
2149
+			foreach ($_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation) {
2150 2150
 				$pid = $variation['product_id'];
2151 2151
 				break;
2152 2152
 			}
2153 2153
 		}
2154 2154
 
2155
-		$global_discount = !empty( $_POST['global_discount'] ) ? (int) $_POST['global_discount'] : 0;
2156
-		if ( !empty($global_discount) ) {
2155
+		$global_discount = !empty($_POST['global_discount']) ? (int)$_POST['global_discount'] : 0;
2156
+		if (!empty($global_discount)) {
2157 2157
 			$_SESSION['cart']['pos_global_discount'] = $global_discount;
2158 2158
 		}
2159 2159
 
2160 2160
 		if (!empty($product_id)) {
2161 2161
 			if (isset($product_qty)) {
2162
-				if ( $product_qty == 0 ) {
2163
-					$variation_of_product = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1) );
2164
-					if ( !empty($variation_of_product) ) {
2165
-						foreach ( $variation_of_product as $p_id) {
2162
+				if ($product_qty == 0) {
2163
+					$variation_of_product = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1));
2164
+					if (!empty($variation_of_product)) {
2165
+						foreach ($variation_of_product as $p_id) {
2166 2166
 							$wpshop_cart->set_product_qty($p_id->ID, $product_qty);
2167 2167
 						}
2168 2168
 					}
2169 2169
 				}
2170
-				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2170
+				$return = $wpshop_cart->set_product_qty($product_id, $product_qty, $pid);
2171 2171
 				$response[] = $return;
2172 2172
 			}
2173 2173
 			else {
2174 2174
 				$response[] = false;
2175
-				$response[] = __('Parameters error.','wpshop');
2175
+				$response[] = __('Parameters error.', 'wpshop');
2176 2176
 			}
2177 2177
 		}
2178
-		wp_die( json_encode( $response ) );
2178
+		wp_die(json_encode($response));
2179 2179
 	}
2180 2180
 	add_action('wp_ajax_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
2181 2181
 	add_action('wp_ajax_nopriv_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
 	 * Display cart after doing an action on it
2185 2185
 	 */
2186 2186
 	function ajax_wpshop_display_cart() {
2187
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2187
+		check_ajax_referer('ajax_wpshop_display_cart');
2188 2188
 		ini_set('display_errors', true);
2189 2189
 		error_reporting(E_ALL);
2190 2190
 		$wps_cart_ctr = new wps_cart();
@@ -2198,8 +2198,8 @@  discard block
 block discarded – undo
2198 2198
 	/**
2199 2199
 	 * Display mini cart widgte after doing an action on it
2200 2200
 	 */
2201
-	function ajax_wpshop_reload_mini_cart(){
2202
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2201
+	function ajax_wpshop_reload_mini_cart() {
2202
+		check_ajax_referer('ajax_wpshop_display_cart');
2203 2203
 		echo wpshop_cart::mini_cart_content();
2204 2204
 		die();
2205 2205
 	}
@@ -2210,16 +2210,16 @@  discard block
 block discarded – undo
2210 2210
 	 * Refresh Price in complete product sheet and Cart summary display
2211 2211
 	 */
2212 2212
 	function wpshop_ajax_wpshop_variation_selection() {
2213
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2213
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2214 2214
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
2215 2215
 		$wpshop_variation_selected = isset($_POST['wpshop_variation']) ? (array)$_POST['wpshop_variation'] : null;
2216 2216
 		$wpshop_free_variation = isset($_POST['wpshop_free_variation']) ? (array)$_POST['wpshop_free_variation'] : null;
2217
-		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field( $_POST['wpshop_current_for_display'] ) : null;
2217
+		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field($_POST['wpshop_current_for_display']) : null;
2218 2218
 		$product_qty = isset($_POST['product_qty']) ? (int)$_POST['product_qty'] : 1;
2219 2219
 
2220
-		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty );
2220
+		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty);
2221 2221
 
2222
-		wp_die( json_encode( $product_variation_summary ) );
2222
+		wp_die(json_encode($product_variation_summary));
2223 2223
 	}
2224 2224
 	add_action('wp_ajax_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
2225 2225
 	add_action('wp_ajax_nopriv_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
@@ -2229,23 +2229,23 @@  discard block
 block discarded – undo
2229 2229
 	function wpshop_ajax_variation_selection_show_detail_for_value() {
2230 2230
 		global $wpdb;
2231 2231
 
2232
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2232
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2233 2233
 
2234 2234
 		$display = '';
2235 2235
 		$attribute_for_detail = isset($_POST['attribute_for_detail']) ? (array)$_POST['attribute_for_detail'] : array();
2236 2236
 
2237
-		if ( !empty( $attribute_for_detail ) ) {
2237
+		if (!empty($attribute_for_detail)) {
2238 2238
 			$selection = array();
2239
-			foreach ( $attribute_for_detail as $selected_variation ) {
2239
+			foreach ($attribute_for_detail as $selected_variation) {
2240 2240
 				$variation_definition = explode('-_variation_val_-', $selected_variation);
2241 2241
 				$attribute_definition = wpshop_attributes::getElement($variation_definition[0], "'valid'", 'code');
2242 2242
 				$post_definition = get_post($variation_definition[1]);
2243 2243
 
2244
-				if ( !empty($post_definition) ) {
2245
-					$post_content = ( !empty($post_definition) && !empty($post_definition->post_content) ) ? $post_definition->post_content : '';
2246
-					if ( empty($post_content) && !empty($post_definition->post_parent) ) {
2244
+				if (!empty($post_definition)) {
2245
+					$post_content = (!empty($post_definition) && !empty($post_definition->post_content)) ? $post_definition->post_content : '';
2246
+					if (empty($post_content) && !empty($post_definition->post_parent)) {
2247 2247
 						$post_parent_definition = get_post($post_definition->post_parent);
2248
-						if ( !empty($post_parent_definition) ) {
2248
+						if (!empty($post_parent_definition)) {
2249 2249
 							$post_content = $post_parent_definition->post_content;
2250 2250
 						}
2251 2251
 					}
@@ -2272,74 +2272,74 @@  discard block
 block discarded – undo
2272 2272
 	 * Save customer account informations
2273 2273
 	 */
2274 2274
 	function wpshop_ajax_save_customer_account() {
2275
-		check_ajax_referer( 'wpshop_customer_register', 'wpshop_ajax_nonce' );
2275
+		check_ajax_referer('wpshop_customer_register', 'wpshop_ajax_nonce');
2276 2276
 		global $wpshop, $wpshop_account, $wpdb;
2277
-		$reponse='';
2277
+		$reponse = '';
2278 2278
 		$status = false;
2279 2279
 		$validate = true;
2280 2280
 
2281
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2281
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2282 2282
 
2283 2283
 		$user_id = get_current_user_id();
2284
-		$current_connected_user = !empty( $user_id ) ? $user_id : null;
2284
+		$current_connected_user = !empty($user_id) ? $user_id : null;
2285 2285
 		$wpshop_billing_address = get_option('wpshop_billing_address');
2286
-		if ( !empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']]) ) {
2287
-			if ( !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) ) {
2288
-				$address_fields = wps_address::get_addresss_form_fields_by_type ( $wpshop_billing_address['choice'] );
2286
+		if (!empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']])) {
2287
+			if (!empty($wpshop_billing_address['integrate_into_register_form_matching_field'])) {
2288
+				$address_fields = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2289 2289
 				$address_field = $address_fields[$wpshop_billing_address['choice']];
2290 2290
 				$temp_aray_for_matching = array_flip($wpshop_billing_address['integrate_into_register_form_matching_field']);
2291
-				foreach ( $address_field as $group_id => $group_detail) {
2292
-					foreach ( $group_detail['content'] as $attribute_build_code => $attribute_def) {
2293
-						if ( in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty( $attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] ) && !empty(  $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]] ) ) {
2291
+				foreach ($address_field as $group_id => $group_detail) {
2292
+					foreach ($group_detail['content'] as $attribute_build_code => $attribute_def) {
2293
+						if (in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']]) && !empty($attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]])) {
2294 2294
 							$attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] = $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]];
2295
-							if ( $attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2']) ) {
2295
+							if ($attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'])) {
2296 2296
 								$attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'] = $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code] . '2'];
2297 2297
 							}
2298 2298
 						}
2299 2299
 					}
2300 2300
 				}
2301
-				$attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty( $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] ) ? $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2301
+				$attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty($attribute[$wpshop_billing_address['choice']]['varchar']['address_title']) ? $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2302 2302
 			}
2303 2303
 			$group = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2304 2304
 			$validate = false;
2305
-			foreach ( $group as $attribute_sets ) {
2306
-				foreach ( $attribute_sets as $attribute_set_field ) {
2305
+			foreach ($group as $attribute_sets) {
2306
+				foreach ($attribute_sets as $attribute_set_field) {
2307 2307
 					$validate = $wpshop->validateForm($attribute_set_field['content'], $attribute[$wpshop_billing_address['choice']], '');
2308 2308
 				}
2309 2309
 			}
2310 2310
 		}
2311
-		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') )) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2311
+		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2312 2312
 
2313
-		$account_form_type = !empty( $_POST['account_form_type'] ) ? sanitize_text_field( $_POST['account_form_type'] ) : '';
2314
-		$validate_personal_form_infos = ( !empty( $account_form_type ) && $account_form_type == 'partial' ) ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2315
-		if( $validate && $validate_personal_form_infos ) {
2316
-			$account_creation_result = $wpshop_account->save_account_form($user_id,  ( ( !empty($account_form_type) && $account_form_type == 'partial' ) ? 'partial' : 'complete') );
2313
+		$account_form_type = !empty($_POST['account_form_type']) ? sanitize_text_field($_POST['account_form_type']) : '';
2314
+		$validate_personal_form_infos = (!empty($account_form_type) && $account_form_type == 'partial') ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2315
+		if ($validate && $validate_personal_form_infos) {
2316
+			$account_creation_result = $wpshop_account->save_account_form($user_id, ((!empty($account_form_type) && $account_form_type == 'partial') ? 'partial' : 'complete'));
2317 2317
 			$status = $account_creation_result[0];
2318 2318
 			$user_id = $account_creation_result[1];
2319
-			$is_partial_account_creation  = $account_creation_result[2];
2320
-			if ( $is_partial_account_creation == 'partial' ) {
2319
+			$is_partial_account_creation = $account_creation_result[2];
2320
+			if ($is_partial_account_creation == 'partial') {
2321 2321
 				$permalink_option = get_option('permalink_structure');
2322
-				if ( !empty($permalink_option) ) {
2323
-					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2322
+				if (!empty($permalink_option)) {
2323
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '?complete_sign_up=ok';
2324 2324
 				}
2325 2325
 				else {
2326
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2326
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '&complete_sign_up=ok';
2327 2327
 				}
2328 2328
 			}
2329 2329
 			else {
2330
-				if ( !empty($_SESSION['cart']) ) {
2331
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2330
+				if (!empty($_SESSION['cart'])) {
2331
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')));
2332 2332
 				}
2333 2333
 				else {
2334
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2334
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2335 2335
 				}
2336 2336
 			}
2337 2337
 			// check if the customer have already register an address
2338
-			$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2338
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2339 2339
 			$exist_address = $wpdb->get_results($query);
2340 2340
 		}
2341 2341
 		// If there is errors
2342
-		if($wpshop->error_count()>0) {
2342
+		if ($wpshop->error_count() > 0) {
2343 2343
 			$reponse = $wpshop->show_messages();
2344 2344
 		}
2345 2345
 
@@ -2356,24 +2356,24 @@  discard block
 block discarded – undo
2356 2356
 	function wpshop_ajax_order_customer_adress_load() {
2357 2357
 		global $wpshop_account;
2358 2358
 		global $wpdb;
2359
-		check_ajax_referer( 'wpshop_order_customer_adress_load', 'wpshop_ajax_nonce' );
2360
-		$current_customer_id = !empty( $_REQUEST['customer_id'] ) ? (int)$_REQUEST['customer_id'] : 0;
2361
-		$order_id = !empty( $_REQUEST['order_id'] ) ? (int)$_REQUEST['order_id'] : 0;
2359
+		check_ajax_referer('wpshop_order_customer_adress_load', 'wpshop_ajax_nonce');
2360
+		$current_customer_id = !empty($_REQUEST['customer_id']) ? (int)$_REQUEST['customer_id'] : 0;
2361
+		$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2362 2362
 
2363
-		$order_postmeta = get_post_meta ($order_id, '_order_postmeta', true);
2364
-		$order_infos_postmeta = get_post_meta ($order_id, '_order_info', true);
2363
+		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
2364
+		$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
2365 2365
 
2366
-		if ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded')) ) {
2366
+		if (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded'))) {
2367 2367
 			/** Billing address display **/
2368 2368
 			$tpl_component['ADDRESS_COMBOBOX'] = '';
2369 2369
 			$tpl_component['ADDRESS_BUTTONS'] = '';
2370 2370
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Billing address', 'wpshop');
2371 2371
 			$tpl_component['ADDRESS_TYPE'] = 'billing_address';
2372 2372
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['billing']['id']);
2373
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['billing']['address'] );
2373
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['billing']['address']);
2374 2374
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2375
-			$retour =  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2376
-			unset( $tpl_component );
2375
+			$retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2376
+			unset($tpl_component);
2377 2377
 
2378 2378
 			/** Shipping address display **/
2379 2379
 			$retour .= '<div id="shipping_infos_bloc" class="wpshop_order_customer_container wpshop_order_customer_container_user_information">';
@@ -2382,67 +2382,67 @@  discard block
 block discarded – undo
2382 2382
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Shipping address', 'wpshop');
2383 2383
 			$tpl_component['ADDRESS_TYPE'] = 'shipping_address';
2384 2384
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['shipping']['id']);
2385
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['shipping']['address']);
2385
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['shipping']['address']);
2386 2386
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2387
-			$retour .=  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2388
-			unset( $tpl_component );
2387
+			$retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2388
+			unset($tpl_component);
2389 2389
 			$retour .= '</div>';
2390 2390
 			$retour .= '<div class="wpshop_cls"></div>';
2391
-			$result = json_encode( array(true, $retour) );
2391
+			$result = json_encode(array(true, $retour));
2392 2392
 
2393 2393
 		}
2394 2394
 
2395
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2396
-			$order_id = !empty( $_REQUEST['order_id'] ) ? (int) $_REQUEST['order_id'] : 0;
2395
+ 		elseif (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2396
+			$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2397 2397
  			$order_info_postmeta = get_post_meta($order_id, '_order_info', true);
2398 2398
 
2399 2399
  			$billing_id_attribute_set = get_option('wpshop_billing_address');
2400 2400
  			$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2401 2401
 
2402
- 			$order_billing_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address']) ) ? $order_info_postmeta['billing']['address'] : array();
2403
- 			$order_shipping_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address']) ) ? $order_info_postmeta['shipping']['address'] : array();
2402
+ 			$order_billing_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address'])) ? $order_info_postmeta['billing']['address'] : array();
2403
+ 			$order_shipping_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address'])) ? $order_info_postmeta['shipping']['address'] : array();
2404 2404
 
2405
- 			$billing_form = $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address );
2406
- 			if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2407
- 				$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address );
2405
+ 			$billing_form = $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address);
2406
+ 			if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2407
+ 				$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address);
2408 2408
  			}
2409 2409
 
2410
- 			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2410
+ 			$result = json_encode(array(true, $billing_form, $shipping_form, $current_customer_id));
2411 2411
  		}
2412 2412
 		else {
2413 2413
 				// Check the attribute set id of Billing Address
2414
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2414
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Billing address', 'wpshop') . '"', '');
2415 2415
 				$attribute_set_id = $wpdb->get_var($query);
2416 2416
 				$billing_id_attribute_set = get_option('wpshop_billing_address');
2417 2417
 				//Check the billing address id of the customer
2418
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2418
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2419 2419
 				$post_addresses = $wpdb->get_results($query);
2420 2420
 				$address_id = '';
2421
-				foreach ( $post_addresses as $post_address ) {
2422
-					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2423
-					if ( $address_type == $attribute_set_id ) {
2421
+				foreach ($post_addresses as $post_address) {
2422
+					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2423
+					if ($address_type == $attribute_set_id) {
2424 2424
 						$address_id = $post_address->ID;
2425 2425
 					}
2426 2426
 				}
2427 2427
 				$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2428 2428
 				$shipping_form = '';
2429
-				if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2429
+				if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2430 2430
 					// Check the attribute set id of Shipping Address
2431
-					$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Shipping address', 'wpshop'). '"', '');
2431
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Shipping address', 'wpshop') . '"', '');
2432 2432
 					$attribute_set_id = $wpdb->get_var($query);
2433 2433
 					//Check the billing address id of the customer
2434
-					$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2434
+					$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2435 2435
 					$post_addresses = $wpdb->get_results($query);
2436 2436
 					$shipping_address_id = '';
2437
-					foreach ( $post_addresses as $post_address ) {
2438
-						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2439
-						if ( $address_type == $attribute_set_id ) {
2437
+					foreach ($post_addresses as $post_address) {
2438
+						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2439
+						if ($address_type == $attribute_set_id) {
2440 2440
 							$shipping_address_id = $post_address->ID;
2441 2441
 						}
2442 2442
 					}
2443
-					$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], $shipping_address_id );
2443
+					$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], $shipping_address_id);
2444 2444
 				}
2445
-				$result = json_encode( array(true, $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], $address_id ), $shipping_form, $current_customer_id) );
2445
+				$result = json_encode(array(true, $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], $address_id), $shipping_form, $current_customer_id));
2446 2446
 		}
2447 2447
 		echo $result;
2448 2448
 		die();
@@ -2454,23 +2454,23 @@  discard block
 block discarded – undo
2454 2454
 	 */
2455 2455
 	function ajax_wpshop_add_entity() {
2456 2456
 		global $wpdb;
2457
-		check_ajax_referer( 'wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce' );
2457
+		check_ajax_referer('wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce');
2458 2458
 
2459
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2459
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2460 2460
 		$attributes = array();
2461 2461
 		/** Get the attribute to create	*/
2462 2462
 		$attribute_to_reload = null;
2463
-		if ( !empty($attribute['new_value_creation']) && is_array( $attribute['new_value_creation'] ) ) {
2464
-			foreach ( $attribute['new_value_creation'] as $attribute_code=>$value) {
2465
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', $attribute_code);
2463
+		if (!empty($attribute['new_value_creation']) && is_array($attribute['new_value_creation'])) {
2464
+			foreach ($attribute['new_value_creation'] as $attribute_code=>$value) {
2465
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $attribute_code);
2466 2466
 				$attribute_def = $wpdb->get_row($query);
2467
-				if ( $value != "" ) {
2468
-					if ( $attribute_def->data_type_to_use == 'internal' ) {
2467
+				if ($value != "") {
2468
+					if ($attribute_def->data_type_to_use == 'internal') {
2469 2469
 						$attribute_default_value = unserialize($attribute_def->default_value);
2470
-						if ( $attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) {
2471
-							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2472
-							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2473
-							$attribute_option_id = $wpdb->get_var( $query );
2470
+						if ($attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
2471
+							$user_id = wp_create_user(sanitize_user($value), wp_generate_password(12, false));
2472
+							$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id);
2473
+							$attribute_option_id = $wpdb->get_var($query);
2474 2474
 						}
2475 2475
 						else {
2476 2476
 							$entity_args = array(
@@ -2483,13 +2483,13 @@  discard block
 block discarded – undo
2483 2483
 						}
2484 2484
 					}
2485 2485
 					else {
2486
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) );
2486
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value));
2487 2487
 						$attribute_option_id = $wpdb->insert_id;
2488 2488
 					}
2489 2489
 
2490
-					foreach ( $attribute as $attribute => $val) {
2490
+					foreach ($attribute as $attribute => $val) {
2491 2491
 						foreach ($val as $k=>$v) {
2492
-							if ( $k == $attribute_code) {
2492
+							if ($k == $attribute_code) {
2493 2493
 								$attribute[$attribute][$k] = $attribute_option_id;
2494 2494
 							}
2495 2495
 						}
@@ -2498,82 +2498,82 @@  discard block
 block discarded – undo
2498 2498
 			}
2499 2499
 		}
2500 2500
 		/** Store send attribute into a new array for save purpose	*/
2501
-		if ( is_array( $attribute ) ) {
2502
-			foreach ( $attribute as $attribute_type => $attribute ) {
2503
-				foreach ( $attribute as $attribute_code => $attribute_value ) {
2504
-					if ( !isset( $attributes[$attribute_code] ) ) {
2501
+		if (is_array($attribute)) {
2502
+			foreach ($attribute as $attribute_type => $attribute) {
2503
+				foreach ($attribute as $attribute_code => $attribute_value) {
2504
+					if (!isset($attributes[$attribute_code])) {
2505 2505
 						$attributes[$attribute_code] = $attribute_value;
2506 2506
 					}
2507 2507
 				}
2508 2508
 			}
2509 2509
 		}
2510 2510
 
2511
-		$post_title = !empty( $_POST['wp_fields']['post_title'] ) ? sanitize_text_field( $_POST['wp_fields']['post_title'] ) : '';
2512
-		$entity_type = !empty( $_POST['entity_type'] ) ? sanitize_text_field( $_POST['entity_type'] ) : '';
2513
-		$attribute_set_id = !empty( $_POST['attribute_set_id'] ) ? (int) $_POST['attribute_set_id'] : 0;
2514
-		$type_of_form = !empty( $_POST['type_of_form'] ) ? sanitize_text_field( $_POST['type_of_form'] ) : '';
2511
+		$post_title = !empty($_POST['wp_fields']['post_title']) ? sanitize_text_field($_POST['wp_fields']['post_title']) : '';
2512
+		$entity_type = !empty($_POST['entity_type']) ? sanitize_text_field($_POST['entity_type']) : '';
2513
+		$attribute_set_id = !empty($_POST['attribute_set_id']) ? (int)$_POST['attribute_set_id'] : 0;
2514
+		$type_of_form = !empty($_POST['type_of_form']) ? sanitize_text_field($_POST['type_of_form']) : '';
2515 2515
 
2516 2516
 		/** Save the new entity into database */
2517
-		$result = wpshop_entities::create_new_entity( $entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id) );
2517
+		$result = wpshop_entities::create_new_entity($entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id));
2518 2518
 		$new_entity_id = $result[1];
2519 2519
 
2520
-		if ( !empty($new_entity_id) ) {
2520
+		if (!empty($new_entity_id)) {
2521 2521
 			/**	Save address for current entity	*/
2522
-			if ( !empty( $type_of_form ) && !empty( $attribute[$type_of_form] ) ) {
2522
+			if (!empty($type_of_form) && !empty($attribute[$type_of_form])) {
2523 2523
 				global $wpshop_account;
2524
-				$result = wps_address::wps_address( $type_of_form );
2525
-				update_post_meta ($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2524
+				$result = wps_address::wps_address($type_of_form);
2525
+				update_post_meta($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2526 2526
 			}
2527 2527
 
2528 2528
 			/** Make price calculation if entity is a product	*/
2529
-			if ( $entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2529
+			if ($entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2530 2530
 				$wpshop_prices_attribute = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2531 2531
 				$calculate_price = false;
2532
-				foreach( $wpshop_prices_attribute as $attribute_price_code ){
2533
-					if ( array_key_exists($attribute_price_code, $attributes) ) {
2532
+				foreach ($wpshop_prices_attribute as $attribute_price_code) {
2533
+					if (array_key_exists($attribute_price_code, $attributes)) {
2534 2534
 						$calculate_price = true;
2535 2535
 					}
2536 2536
 				}
2537
-				if ( $calculate_price ) {
2537
+				if ($calculate_price) {
2538 2538
 					wpshop_products::calculate_price($new_entity_id);
2539 2539
 				}
2540 2540
 			}
2541 2541
 
2542 2542
 			/** Add picture if a file has been send	*/
2543
-			if ( !empty($_FILES) ) {
2543
+			if (!empty($_FILES)) {
2544 2544
 				$wp_upload_dir = wp_upload_dir();
2545 2545
 				$final_dir = $wp_upload_dir['path'] . '/';
2546
-				if ( !is_dir($final_dir) ) {
2546
+				if (!is_dir($final_dir)) {
2547 2547
 					mkdir($final_dir, 0755, true);
2548 2548
 				}
2549 2549
 
2550
-				foreach ( $_FILES as $file ) {
2550
+				foreach ($_FILES as $file) {
2551 2551
 					$tmp_name = $file['tmp_name']['post_thumbnail'];
2552 2552
 					$name = $file['name']['post_thumbnail'];
2553 2553
 
2554 2554
 					$filename = $final_dir . $name;
2555 2555
 					@move_uploaded_file($tmp_name, $filename);
2556 2556
 
2557
-					$wp_filetype = wp_check_filetype(basename($filename), null );
2557
+					$wp_filetype = wp_check_filetype(basename($filename), null);
2558 2558
 					$attachment = array(
2559
-						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ),
2559
+						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path($filename),
2560 2560
 						'post_mime_type' => $wp_filetype['type'],
2561
-						'post_title' => preg_replace( '/\.[^.]+$/', '', basename($filename) ),
2561
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
2562 2562
 						'post_content' => '',
2563 2563
 						'post_status' => 'inherit'
2564 2564
 					);
2565
-					$attach_id = wp_insert_attachment( $attachment, $filename, $new_entity_id );
2565
+					$attach_id = wp_insert_attachment($attachment, $filename, $new_entity_id);
2566 2566
 					require_once(ABSPATH . 'wp-admin/includes/image.php');
2567
-					$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
2568
-					wp_update_attachment_metadata( $attach_id, $attach_data );
2567
+					$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
2568
+					wp_update_attachment_metadata($attach_id, $attach_data);
2569 2569
 					add_post_meta($new_entity_id, '_thumbnail_id', $attach_id, true);
2570 2570
 				}
2571 2571
 			}
2572 2572
 
2573
-			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2573
+			echo json_encode(array(true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id));
2574 2574
 		}
2575 2575
 		else {
2576
-			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2576
+			echo json_encode(array(false, __('An error occured while adding your element', 'wpshop')));
2577 2577
 		}
2578 2578
 
2579 2579
 		die();
@@ -2582,47 +2582,47 @@  discard block
 block discarded – undo
2582 2582
 // 	add_action('wp_ajax_nopriv_wpshop_quick_add_entity', 'ajax_wpshop_add_entity');
2583 2583
 
2584 2584
 	function ajax_wpshop_reload_attribute_for_quick_add() {
2585
-		check_ajax_referer( 'ajax_wpshop_reload_attribute_for_quick_add' );
2585
+		check_ajax_referer('ajax_wpshop_reload_attribute_for_quick_add');
2586 2586
 		$output = '';
2587
-		$attribute_to_reload = !empty( $_POST['attribute_to_reload'] ) ? (array) $_POST['attribute_to_reload'] : array();
2588
-		if ( !empty($attribute_to_reload) ) {
2589
-			foreach ( $attribute_to_reload as $attribute_code ) {
2590
-				$attr_field = wpshop_attributes::display_attribute( $attribute_code, 'frontend' );
2587
+		$attribute_to_reload = !empty($_POST['attribute_to_reload']) ? (array)$_POST['attribute_to_reload'] : array();
2588
+		if (!empty($attribute_to_reload)) {
2589
+			foreach ($attribute_to_reload as $attribute_code) {
2590
+				$attr_field = wpshop_attributes::display_attribute($attribute_code, 'frontend');
2591 2591
 				$output[$attribute_code]['result'] = $attr_field['field_definition']['output'] . $attr_field['field_definition']['options'];
2592 2592
 			}
2593 2593
 		}
2594
-		echo json_encode( array($output) );
2594
+		echo json_encode(array($output));
2595 2595
 		die();
2596 2596
 	}
2597 2597
 	add_action('wp_ajax_reload_attribute_for_quick_add', 'ajax_wpshop_reload_attribute_for_quick_add');
2598 2598
 
2599 2599
 	function ajax_wpshop_change_address() {
2600
-		check_ajax_referer( 'ajax_wpshop_change_address' );
2601
-		$address_id = ( !empty($_POST['address_id']) ? (int) $_POST['address_id'] : null);
2602
-		$address_type = ( !empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2603
-		$is_allowed_destination  = true;
2604
-		if ( !empty($address_id) && !empty($address_type) ) {
2600
+		check_ajax_referer('ajax_wpshop_change_address');
2601
+		$address_id = (!empty($_POST['address_id']) ? (int)$_POST['address_id'] : null);
2602
+		$address_type = (!empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2603
+		$is_allowed_destination = true;
2604
+		if (!empty($address_id) && !empty($address_type)) {
2605 2605
 			//Check if it's an allowed address for shipping
2606 2606
 			$checkout_payment_button = '';
2607
-			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type'])=='quotation') ? 'quotation' : 'cart';
2608
-			$is_allowed_destination = true;//wpshop_shipping_configuration::is_allowed_country ( $address_id );
2609
-			if ( $is_allowed_destination ) {
2607
+			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type']) == 'quotation') ? 'quotation' : 'cart';
2608
+			$is_allowed_destination = true; //wpshop_shipping_configuration::is_allowed_country ( $address_id );
2609
+			if ($is_allowed_destination) {
2610 2610
 				$available_payement_method = wpshop_payment::display_payment_methods_choice_form(0, $cart_type);
2611 2611
 				//if(!empty($available_payement_method[1]['paypal']) || !empty($available_payement_method[1]['banktransfer']) || !empty($available_payement_method[1]['checks']) || WPSHOP_PAYMENT_METHOD_CIC || !empty($available_payement_method[1]['cic']) || ($cart_type == 'quotation')) {
2612
-				if ( !empty($available_payement_method[0]) ) {
2613
-					if ( $cart_type=='quotation' ) {
2614
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2612
+				if (!empty($available_payement_method[0])) {
2613
+					if ($cart_type == 'quotation') {
2614
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array());
2615 2615
 					}
2616 2616
 					else {
2617
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2617
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array());
2618 2618
 					}
2619 2619
 				}
2620 2620
 			}
2621 2621
 			else {
2622 2622
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2623 2623
 			}
2624
-			if( $address_type == 'billing_address') {
2625
-				$billing_option = get_option( 'wpshop_billing_address' );
2624
+			if ($address_type == 'billing_address') {
2625
+				$billing_option = get_option('wpshop_billing_address');
2626 2626
 				$address_option = $billing_option['choice'];
2627 2627
 			}
2628 2628
 			else {
@@ -2630,16 +2630,16 @@  discard block
 block discarded – undo
2630 2630
 				$address_option = $shipping_address_option['choice'];
2631 2631
 			}
2632 2632
 			$add = wps_address::get_addresss_form_fields_by_type($address_option);
2633
-			$address_infos = get_post_meta($address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
2634
-			$retour = wpshop_account::display_an_address ( $add, $address_infos, $address_id);
2633
+			$address_infos = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
2634
+			$retour = wpshop_account::display_an_address($add, $address_infos, $address_id);
2635 2635
 
2636 2636
 			$_SESSION[$address_type] = $address_id;
2637 2637
 
2638
-			$edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&amp;id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>';
2639
-			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2638
+			$edit_link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?') === false ? '?' : '&') . 'action=editAddress&amp;id=' . $address_id . '" title="' . __('Edit', 'wpshop') . '">' . __('Edit', 'wpshop') . '</a>';
2639
+			$result = json_encode(array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button));
2640 2640
 		}
2641 2641
 		else {
2642
-			$result = json_encode( array(false, 'missing_informations') );
2642
+			$result = json_encode(array(false, 'missing_informations'));
2643 2643
 		}
2644 2644
 		echo $result;
2645 2645
 
@@ -2649,26 +2649,26 @@  discard block
 block discarded – undo
2649 2649
 	add_action('wp_ajax_nopriv_change_address', 'ajax_wpshop_change_address');
2650 2650
 
2651 2651
 	function ajax_wpshop_load_create_new_customer_interface() {
2652
-		check_ajax_referer( 'ajax_wpshop_load_create_new_customer_interface' );
2652
+		check_ajax_referer('ajax_wpshop_load_create_new_customer_interface');
2653 2653
 		$billing_address_option = get_option('wpshop_billing_address');
2654 2654
 		$shipping_address_option = get_option('wpshop_shipping_address_choice');
2655 2655
 
2656 2656
 		$tpl_component = array();
2657 2657
 		$tpl_component['LOADING_ICON'] = WPSHOP_LOADING_ICON;
2658
-		if ( !empty($billing_address) ) {
2659
-			echo wpshop_account::get_addresses_by_type( $billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2658
+		if (!empty($billing_address)) {
2659
+			echo wpshop_account::get_addresses_by_type($billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2660 2660
 		}
2661 2661
 		$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] = wpshop_account::display_form_fields($billing_address_option['choice'], '', 'first');
2662 2662
 
2663
-		if ( $shipping_address_option['activate'] ) {
2664
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> '.__('Use as shipping information','wpshop').'</label></p><br/>';
2663
+		if ($shipping_address_option['activate']) {
2664
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> ' . __('Use as shipping information', 'wpshop') . '</label></p><br/>';
2665 2665
 			$display = 'display:none;';
2666
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="'.$display.'">';
2666
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="' . $display . '">';
2667 2667
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= wpshop_account::display_form_fields($shipping_address_option['choice'], '', 'first');
2668 2668
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '</div><br/>';
2669 2669
 		}
2670 2670
 
2671
-		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save','wpshop') . '" /></p>';
2671
+		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save', 'wpshop') . '" /></p>';
2672 2672
 		$output = wpshop_display::display_template_element('wpshop_customer_addresses_form_admin', $tpl_component, array(), 'admin');
2673 2673
 		unset($tpl_component);
2674 2674
 		$result = json_encode(array(true, $output));
@@ -2678,18 +2678,18 @@  discard block
 block discarded – undo
2678 2678
 	add_action('wp_ajax_load_create_new_customer_interface', 'ajax_wpshop_load_create_new_customer_interface');
2679 2679
 
2680 2680
 	function ajax_wpshop_create_new_customer() {
2681
-		check_ajax_referer( 'ajax_wpshop_create_new_customer' );
2681
+		check_ajax_referer('ajax_wpshop_create_new_customer');
2682 2682
 		$result = '';
2683 2683
 		$billing_address = !empty($_REQUEST['billing_address']) ? sanitize_key($_REQUEST['billing_address']) : '';
2684 2684
 		$shipping_address = !empty($_REQUEST['shipping_address']) ? sanitize_key($_REQUEST['shipping_address']) : '';
2685 2685
 		$shiptobilling = !empty($_REQUEST['shiptobilling']) ? sanitize_key($_REQUEST['shiptobilling']) : null;
2686 2686
 		$username = !empty($_POST['attribute'][$billing_address]['varchar']['address_user_email']) ? sanitize_text_field($_POST['attribute'][$billing_address]['varchar']['address_user_email']) : null;
2687
-		if ( $username != null ) {
2687
+		if ($username != null) {
2688 2688
 			/** Crerate the new customer user account */
2689
-			$password = wp_generate_password( $length=12, $include_standard_special_chars=false );
2689
+			$password = wp_generate_password($length = 12, $include_standard_special_chars = false);
2690 2690
 			$email = $username;
2691
-			if ( !empty($username) && !username_exists($username) && !empty($email) && !email_exists($email) ) {
2692
-				$user_id = wp_create_user( $username, $password, $email );
2691
+			if (!empty($username) && !username_exists($username) && !empty($email) && !email_exists($email)) {
2692
+				$user_id = wp_create_user($username, $password, $email);
2693 2693
 				// @TODO : REQUEST
2694 2694
 				// $_REQUEST['user']['customer_id'] = $user_id;
2695 2695
 				/** Save addresses */
@@ -2700,21 +2700,21 @@  discard block
 block discarded – undo
2700 2700
 					wpshop_account::same_billing_and_shipping_address($billing_address, $shipping_address);
2701 2701
 				}
2702 2702
 
2703
-				if ( !empty($billing_address) ) {
2704
-					wps_address::save_address_infos( $billing_address );
2703
+				if (!empty($billing_address)) {
2704
+					wps_address::save_address_infos($billing_address);
2705 2705
 				}
2706
-				if( !empty($shipping_address ) ) {
2707
-					wps_address::save_address_infos( $shipping_address);
2706
+				if (!empty($shipping_address)) {
2707
+					wps_address::save_address_infos($shipping_address);
2708 2708
 				}
2709
-				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2709
+				$result = json_encode(array(true, __('Customer created', 'wpshop'), $user_id));
2710 2710
 			}
2711 2711
 			else {
2712
-				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2712
+				$result = json_encode(array(false, __('A customer account is already created with this email address', 'wpshop')));
2713 2713
 			}
2714 2714
 
2715 2715
 		}
2716 2716
 		else {
2717
-			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2717
+			$result = json_encode(array(false, __('An email address is required', 'wpshop')));
2718 2718
 		}
2719 2719
 		echo $result;
2720 2720
 		die();
@@ -2724,26 +2724,26 @@  discard block
 block discarded – undo
2724 2724
 	/**
2725 2725
 	 * Send a message to customer
2726 2726
 	 */
2727
-	function ajax_wpshop_send_message_by_type () {
2728
-		check_ajax_referer( 'ajax_wpshop_send_message_by_type' );
2727
+	function ajax_wpshop_send_message_by_type() {
2728
+		check_ajax_referer('ajax_wpshop_send_message_by_type');
2729 2729
 		global $wpdb;
2730 2730
 		$result = array();
2731
-		$message_type_id = ( !empty( $_POST['message_type_id'])) ? (int) $_POST['message_type_id'] : null;
2732
-		$customer_id = ( !empty( $_POST['customer_user_id'])) ? (int) $_POST['customer_user_id'] : null;
2733
-		$model_name = ( !empty( $_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2734
-		$order_id = ( !empty( $_POST['order_id'])) ? (int) $_POST['order_id'] : null;
2735
-		if ( !empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2731
+		$message_type_id = (!empty($_POST['message_type_id'])) ? (int)$_POST['message_type_id'] : null;
2732
+		$customer_id = (!empty($_POST['customer_user_id'])) ? (int)$_POST['customer_user_id'] : null;
2733
+		$model_name = (!empty($_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2734
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2735
+		if (!empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2736 2736
 			$order_post_meta = get_post_meta($order_id, '_order_postmeta', true);
2737
-			$receiver_infos = get_userdata( $customer_id );
2737
+			$receiver_infos = get_userdata($customer_id);
2738 2738
 			$email = $receiver_infos->user_email;
2739 2739
 			$first_name = get_user_meta($customer_id, 'first_name', true);
2740 2740
 			$last_name = get_user_meta($customer_id, 'last_name', true);
2741 2741
 			$wps_message = new wps_message_ctr();
2742
-			$wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) );
2743
-			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2742
+			$wps_message->wpshop_prepared_email($email, $model_name, array('order_id' => $order_id, 'order_key' => ((!empty($order_post_meta) && !empty($order_post_meta['order_key'])) ? $order_post_meta['order_key'] : ''), 'order_date' => ((!empty($order_post_meta) && !empty($order_post_meta['order_date'])) ? $order_post_meta['order_date'] : ''), 'customer_first_name' => $first_name, 'customer_last_name' => $last_name));
2743
+			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id));
2744 2744
 		}
2745 2745
 		else {
2746
-			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2746
+			$result = array('status' => false, 'response' => __('An error occured', 'wpshop'));
2747 2747
 		}
2748 2748
 		echo json_encode($result);
2749 2749
 		die();
@@ -2752,23 +2752,23 @@  discard block
 block discarded – undo
2752 2752
 
2753 2753
 
2754 2754
 	function ajax_wpshop_upload_downloadable_file_action() {
2755
-		check_ajax_referer( 'ajax_wpshop_upload_downloadable_file_action' );
2755
+		check_ajax_referer('ajax_wpshop_upload_downloadable_file_action');
2756 2756
 		$result = '';
2757
-		$element_identifier = ( !empty( $_POST ) && !empty( $_POST[ 'element_identifier' ] ) && is_int( (int)$_POST[ 'element_identifier' ] ) ) ? (int)$_POST[ 'element_identifier' ] : 0;
2758
-		$wpshop_uploaded_file = ( !empty( $_FILES ) && !empty( $_FILES[ 'wpshop_file' ] ) && is_array( (array)$_FILES[ 'wpshop_file' ] ) ) ? (array)$_FILES[ 'wpshop_file' ] : array();
2757
+		$element_identifier = (!empty($_POST) && !empty($_POST['element_identifier']) && is_int((int)$_POST['element_identifier'])) ? (int)$_POST['element_identifier'] : 0;
2758
+		$wpshop_uploaded_file = (!empty($_FILES) && !empty($_FILES['wpshop_file']) && is_array((array)$_FILES['wpshop_file'])) ? (array)$_FILES['wpshop_file'] : array();
2759 2759
 
2760
-		if ( !empty( $wpshop_uploaded_file ) && !empty( $element_identifier ) ) {
2761
-			if(!is_dir(WPSHOP_UPLOAD_DIR)){
2760
+		if (!empty($wpshop_uploaded_file) && !empty($element_identifier)) {
2761
+			if (!is_dir(WPSHOP_UPLOAD_DIR)) {
2762 2762
 				mkdir(WPSHOP_UPLOAD_DIR, 0755, true);
2763 2763
 			}
2764 2764
 			$file = $wpshop_uploaded_file;
2765 2765
 			$tmp_name = $file['tmp_name'];
2766
-			$name = sanitize_file_name( current_time( 'mysql', 0 ).'__'.$file["name"] );
2767
-			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR.$name);
2766
+			$name = sanitize_file_name(current_time('mysql', 0) . '__' . $file["name"]);
2767
+			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR . $name);
2768 2768
 
2769
-			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2770
-			update_post_meta( $element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2771
-			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2769
+			$n = WPSHOP_UPLOAD_URL . '/' . $name;
2770
+			update_post_meta($element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2771
+			$result = '<a href="' . $n . '" target="_blank" download>' . $name . '</a>';
2772 2772
 		}
2773 2773
 		else {
2774 2774
 			$result = '';
@@ -2779,92 +2779,92 @@  discard block
 block discarded – undo
2779 2779
 	add_action('wp_ajax_upload_downloadable_file_action', 'ajax_wpshop_upload_downloadable_file_action');
2780 2780
 
2781 2781
 	function ajax_wpshop_fill_the_downloadable_dialog() {
2782
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2783
-		check_ajax_referer( "ajax_wpshop_fill_the_downloadable_dialog".$product_id );
2782
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2783
+		check_ajax_referer("ajax_wpshop_fill_the_downloadable_dialog" . $product_id);
2784 2784
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2785 2785
 	}
2786 2786
 	function ajax_wpshop_fill_the_downloadable_dialog_unnonced() {
2787
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2787
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2788 2788
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2789 2789
 	}
2790
-	function ajax_wpshop_fill_the_downloadable_dialog_exec( $product_id ) {
2791
-		$output  = '<form method="post" action="' .admin_url('admin-ajax.php') .'" id="upload_downloadable_file" enctype="multipart/form-data" >';
2792
-		$output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>';
2790
+	function ajax_wpshop_fill_the_downloadable_dialog_exec($product_id) {
2791
+		$output  = '<form method="post" action="' . admin_url('admin-ajax.php') . '" id="upload_downloadable_file" enctype="multipart/form-data" >';
2792
+		$output .= '<p class="formField"><label for="wpshop_file">' . __('Choose your file to send', 'wpshop') . '</label><input type="file" name="wpshop_file" /></p>';
2793 2793
 		$output .= '<input type="hidden" name="action" value="upload_downloadable_file_action" />';
2794
-		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' .esc_attr( $product_id). '" />';
2795
-		$output .= wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false );
2796
-		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' .__('Send your file', 'wpshop'). '</a></p>';
2794
+		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' . esc_attr($product_id) . '" />';
2795
+		$output .= wp_nonce_field('ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false);
2796
+		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' . __('Send your file', 'wpshop') . '</a></p>';
2797 2797
 		$output .= '</form>';
2798
-		$output .='<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2798
+		$output .= '<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2799 2799
 		beforeSubmit : function() { },success: function(response) {
2800
-		jQuery(".is_downloadable_statut_'.$product_id.'").html( response );
2800
+		jQuery(".is_downloadable_statut_'.$product_id . '").html( response );
2801 2801
 		jQuery(".send_downloadable_file_dialog").dialog("close");
2802 2802
 		}});</script>';
2803
-		$output = apply_filters( 'wpshop_download_file_dialog', $output, $product_id );
2803
+		$output = apply_filters('wpshop_download_file_dialog', $output, $product_id);
2804 2804
 
2805
-		$response = array( 'status' => true, 'response' => $output);
2806
-		echo json_encode( $response );
2805
+		$response = array('status' => true, 'response' => $output);
2806
+		echo json_encode($response);
2807 2807
 		die();
2808 2808
 	}
2809 2809
 	add_action('wp_ajax_fill_the_downloadable_dialog', 'ajax_wpshop_fill_the_downloadable_dialog');
2810 2810
 	add_action('wp_ajax_fill_the_downloadable_dialog_unnonced', 'ajax_wpshop_fill_the_downloadable_dialog_unnonced');
2811 2811
 
2812 2812
 	function ajax_wpshop_show_downloadable_interface_in_admin() {
2813
-		$post_id = !empty( $_POST ) && !empty( $_POST[ 'post_id' ] ) && is_int( (int)$_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : 0;
2814
-		check_ajax_referer( 'ajax_wpshop_show_downloadable_interface_in_admin'.$post_id );
2813
+		$post_id = !empty($_POST) && !empty($_POST['post_id']) && is_int((int)$_POST['post_id']) ? (int)$_POST['post_id'] : 0;
2814
+		check_ajax_referer('ajax_wpshop_show_downloadable_interface_in_admin' . $post_id);
2815 2815
 		global $wpdb;
2816 2816
 		$status = false;
2817
-		$selected_value = ( !empty($_POST['selected_value']) ) ? sanitize_text_field( $_POST['selected_value'] ) : '';
2818
-		$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $selected_value);
2819
-		$value = $wpdb->get_var( $query );
2817
+		$selected_value = (!empty($_POST['selected_value'])) ? sanitize_text_field($_POST['selected_value']) : '';
2818
+		$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $selected_value);
2819
+		$value = $wpdb->get_var($query);
2820 2820
 
2821
-		if ( !empty($value) && __( $value, 'wpshop') == __('Yes', 'wpshop') ) {
2821
+		if (!empty($value) && __($value, 'wpshop') == __('Yes', 'wpshop')) {
2822 2822
 			$status = true;
2823 2823
 		}
2824
-		$response = array( 'status' => $status );
2825
-		echo json_encode( $response );
2824
+		$response = array('status' => $status);
2825
+		echo json_encode($response);
2826 2826
 		die();
2827 2827
 	}
2828
-	add_action( 'wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2828
+	add_action('wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2829 2829
 
2830 2830
 	function ajax_wpshop_restart_the_order() {
2831
-		check_ajax_referer( 'ajax_wpshop_restart_the_order' );
2831
+		check_ajax_referer('ajax_wpshop_restart_the_order');
2832 2832
 
2833 2833
 		global $wpshop_cart, $wpdb;
2834 2834
 		$status = $add_to_cart_checking = $manage_stock_checking_bool = false;
2835 2835
 		$add_to_cart_checking_message = '';
2836 2836
 		$result = __('Error, you cannot restart this order', 'wpshop');
2837
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2838
-		$is_make_order_again = ( !empty($_POST['make_order_again']) ) ? sanitize_text_field( $_POST['make_order_again'] ) : null;
2839
-		if( !empty( $order_id ) ) {
2837
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2838
+		$is_make_order_again = (!empty($_POST['make_order_again'])) ? sanitize_text_field($_POST['make_order_again']) : null;
2839
+		if (!empty($order_id)) {
2840 2840
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2841 2841
 			$_SESSION['cart'] = array();
2842 2842
 			$_SESSION['cart']['order_items'] = array();
2843 2843
 			$wpshop_cart_type = $order_meta['cart_type'];
2844 2844
 
2845
-			if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
2845
+			if (!empty($order_meta) && !empty($order_meta['order_items'])) {
2846 2846
 				$wpshop_cart_type = $order_meta['cart_type'];
2847
-				foreach( $order_meta['order_items'] as $item_key => $item ) {
2848
-					$item_meta = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true );
2849
-					$stock =  $item_meta['product_stock'];
2847
+				foreach ($order_meta['order_items'] as $item_key => $item) {
2848
+					$item_meta = get_post_meta($item['item_id'], '_wpshop_product_metadata', true);
2849
+					$stock = $item_meta['product_stock'];
2850 2850
 					$qty = $item['item_qty'];
2851
-					$item_option = get_post_meta( $item['item_id'], '_wpshop_product_options', true );
2852
-					if( !empty($item_meta['manage_stock']) ) {
2853
-						$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $item_meta['manage_stock']);
2854
-						$manage_stock_checking = $wpdb->get_var( $query );
2855
-						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2851
+					$item_option = get_post_meta($item['item_id'], '_wpshop_product_options', true);
2852
+					if (!empty($item_meta['manage_stock'])) {
2853
+						$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $item_meta['manage_stock']);
2854
+						$manage_stock_checking = $wpdb->get_var($query);
2855
+						if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2856 2856
 							$manage_stock_checking_bool = true;
2857 2857
 						}
2858 2858
 					}
2859 2859
 					else {
2860
-						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2861
-							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2862
-							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
2860
+						if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2861
+							$parent_product = wpshop_products::get_parent_variation($item['item_id']);
2862
+							if (!empty($parent_product) && !empty($parent_product['parent_post_meta'])) {
2863 2863
 								$parent_metadata = $parent_product['parent_post_meta'];
2864
-								if( !empty($parent_product['parent_post_meta']['manage_stock']) ) {
2865
-									$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2866
-									$manage_stock_checking = $wpdb->get_var( $query );
2867
-									if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2864
+								if (!empty($parent_product['parent_post_meta']['manage_stock'])) {
2865
+									$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2866
+									$manage_stock_checking = $wpdb->get_var($query);
2867
+									if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2868 2868
 										$manage_stock_checking_bool = true;
2869 2869
 										$stock = $parent_product['parent_post_meta']['product_stock'];
2870 2870
 									}
@@ -2877,8 +2877,8 @@  discard block
 block discarded – undo
2877 2877
 
2878 2878
 
2879 2879
 					/** Checking stock **/
2880
-					if ( empty($item_meta['manage_stock']) || ( !empty($item_meta['manage_stock']) && !$manage_stock_checking_bool )|| ( !empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty ) ) {
2881
-						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2880
+					if (empty($item_meta['manage_stock']) || (!empty($item_meta['manage_stock']) && !$manage_stock_checking_bool) || (!empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty)) {
2881
+						$_SESSION['cart']['order_items'][$item_key] = $item;
2882 2882
 					}
2883 2883
 					else {
2884 2884
 						$add_to_cart_checking = true;
@@ -2887,40 +2887,40 @@  discard block
 block discarded – undo
2887 2887
 				}
2888 2888
 
2889 2889
 				$wps_cart_ctr = new wps_cart();
2890
-				$order = $wps_cart_ctr->calcul_cart_information( array() );
2890
+				$order = $wps_cart_ctr->calcul_cart_information(array());
2891 2891
 				$order['cart_type'] = $wpshop_cart_type;
2892
-				$wps_cart_ctr->store_cart_in_session( $order );
2892
+				$wps_cart_ctr->store_cart_in_session($order);
2893 2893
 			}
2894 2894
 
2895
-			if ( empty($is_make_order_again) ) {
2895
+			if (empty($is_make_order_again)) {
2896 2896
 				$_SESSION['order_id'] = $order_id;
2897 2897
 			}
2898 2898
 			$status = true;
2899 2899
 
2900
-			$result = get_permalink( get_option('wpshop_cart_page_id') );
2900
+			$result = get_permalink(get_option('wpshop_cart_page_id'));
2901 2901
 		}
2902 2902
 
2903
-		$response = array( 'status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2904
-		echo json_encode( $response );
2903
+		$response = array('status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2904
+		echo json_encode($response);
2905 2905
 		die();
2906 2906
 	}
2907
-	add_action( 'wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2907
+	add_action('wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2908 2908
 
2909 2909
 
2910 2910
 
2911 2911
 	function wps_hide_notice_messages() {
2912
-		check_ajax_referer( 'wps_hide_notice_messages' );
2912
+		check_ajax_referer('wps_hide_notice_messages');
2913 2913
 
2914 2914
 		$status = false;
2915
-		$indicator = !empty($_POST['indicator'] ) ? sanitize_text_field($_POST['indicator']) : null;
2916
-		if ( !empty($indicator) ) {
2915
+		$indicator = !empty($_POST['indicator']) ? sanitize_text_field($_POST['indicator']) : null;
2916
+		if (!empty($indicator)) {
2917 2917
 			$user_id = get_current_user_id();
2918
-			$hide_notice_meta = get_user_meta( $user_id, '_wps_hide_notice_messages_indicator', true);
2918
+			$hide_notice_meta = get_user_meta($user_id, '_wps_hide_notice_messages_indicator', true);
2919 2919
 			$hide_notice_meta = !empty($hide_notice_meta) ? $hide_notice_meta : array();
2920 2920
 			$indicators = explode(',', $indicator);
2921
-			if ( !empty($indicators) && is_array($indicators) ) {
2922
-				foreach( $indicators as $i ) {
2923
-					if ( !empty($i) ) {
2921
+			if (!empty($indicators) && is_array($indicators)) {
2922
+				foreach ($indicators as $i) {
2923
+					if (!empty($i)) {
2924 2924
 						$hide_notice_meta[$i] = true;
2925 2925
 					}
2926 2926
 				}
@@ -2929,7 +2929,7 @@  discard block
 block discarded – undo
2929 2929
 			$status = true;
2930 2930
 		}
2931 2931
 		$response = array('status' => $status);
2932
-		echo json_encode( $response );
2932
+		echo json_encode($response);
2933 2933
 		die();
2934 2934
 	}
2935 2935
 	add_action('wp_ajax_wps_hide_notice_messages', 'wps_hide_notice_messages');
@@ -2937,106 +2937,106 @@  discard block
 block discarded – undo
2937 2937
 
2938 2938
 
2939 2939
 	function wps_update_products_prices() {
2940
-		check_ajax_referer( 'wps_update_products_prices' );
2940
+		check_ajax_referer('wps_update_products_prices');
2941 2941
 		$action = wpshop_prices::mass_update_prices();
2942
-		$response = array( 'status' => $action[0], 'response' => $action[1] );
2943
-		echo json_encode( $response );
2942
+		$response = array('status' => $action[0], 'response' => $action[1]);
2943
+		echo json_encode($response);
2944 2944
 		die();
2945 2945
 	}
2946
-	add_action( 'wp_ajax_update_products_prices', 'wps_update_products_prices' );
2946
+	add_action('wp_ajax_update_products_prices', 'wps_update_products_prices');
2947 2947
 
2948 2948
 	/** Quotation is payable by customer **/
2949 2949
 	function wps_quotation_is_payable_by_customer() {
2950
-		check_ajax_referer( 'wps_quotation_is_payable_by_customer' );
2950
+		check_ajax_referer('wps_quotation_is_payable_by_customer');
2951 2951
 		global $wpdb;
2952 2952
 		$status = false;
2953 2953
 		$response = '';
2954
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
2955
-		if( isset($order_id) ) {
2956
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2957
-			if( isset( $order_metadata['pay_quotation'] ) ) {
2958
-				unset( $order_metadata['pay_quotation'] );
2954
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
2955
+		if (isset($order_id)) {
2956
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2957
+			if (isset($order_metadata['pay_quotation'])) {
2958
+				unset($order_metadata['pay_quotation']);
2959 2959
 			} else {
2960 2960
 				$order_metadata['pay_quotation'] = 'on';
2961 2961
 			}
2962
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
2962
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
2963 2963
 
2964
-			$response = wpshop_orders::display_customer_pay_quotation( isset( $order_metadata['pay_quotation'] ), $order_id );
2964
+			$response = wpshop_orders::display_customer_pay_quotation(isset($order_metadata['pay_quotation']), $order_id);
2965 2965
 			$status = true;
2966 2966
 		} else {
2967
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2967
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
2968 2968
 		}
2969
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
2969
+		echo json_encode(array('status' => $status, 'response' => $response));
2970 2970
 		die();
2971 2971
 	}
2972
-	add_action( 'wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer' );
2972
+	add_action('wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer');
2973 2973
 
2974 2974
 	/** Send a direct payment Link **/
2975 2975
 	function wps_send_direct_payment_link() {
2976
-		check_ajax_referer( 'wps_send_direct_payment_link' );
2976
+		check_ajax_referer('wps_send_direct_payment_link');
2977 2977
 		global $wpdb;
2978 2978
 		$status = false; $response = '';
2979
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2980
-		if( !empty($order_id) ) {
2979
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2980
+		if (!empty($order_id)) {
2981 2981
 			/** Get the customer **/
2982
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2983
-			if( !empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) {
2984
-				$user_infos = get_userdata( $order_metadata['customer_id'] );
2982
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2983
+			if (!empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') {
2984
+				$user_infos = get_userdata($order_metadata['customer_id']);
2985 2985
 
2986
-				$first_name =  get_user_meta($user_infos->ID, 'first_name', true);
2987
-				$last_name =  get_user_meta($user_infos->ID, 'last_name', true);
2986
+				$first_name = get_user_meta($user_infos->ID, 'first_name', true);
2987
+				$last_name = get_user_meta($user_infos->ID, 'last_name', true);
2988 2988
 
2989 2989
 
2990 2990
 				/** Create an activation key **/
2991
-				$token = wps_orders_ctr::wps_token_order_customer( $order_id );
2991
+				$token = wps_orders_ctr::wps_token_order_customer($order_id);
2992 2992
 				/*$token = wp_generate_password(20, false);
2993 2993
 				$wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login) );*/
2994 2994
 
2995
-				$permalink_option = get_option( 'permalink_structure' );
2996
-				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url( $order_id ) . '">' .__( 'Click here to pay your order', 'wpshop' ). '</a>';
2995
+				$permalink_option = get_option('permalink_structure');
2996
+				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url($order_id) . '">' . __('Click here to pay your order', 'wpshop') . '</a>';
2997 2997
 
2998 2998
 				/** Send message **/
2999 2999
 				$wps_message = new wps_message_ctr();
3000 3000
 				$wps_message->wpshop_prepared_email($user_infos->user_email,
3001 3001
 				'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE',
3002
-				array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '' )
3002
+				array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '')
3003 3003
 				);
3004 3004
 
3005
-				$response = __( 'Direct payment link has been send', 'wpshop' );
3005
+				$response = __('Direct payment link has been send', 'wpshop');
3006 3006
 				$status = true;
3007 3007
 			}
3008 3008
 			else {
3009
-				$response = __( 'An error was occured', 'wpshop' );
3009
+				$response = __('An error was occured', 'wpshop');
3010 3010
 			}
3011 3011
 		}
3012 3012
 		else {
3013
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
3013
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
3014 3014
 		}
3015
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3015
+		echo json_encode(array('status' => $status, 'response' => $response));
3016 3016
 		die();
3017 3017
 	}
3018
-	add_action( 'wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link' );
3018
+	add_action('wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link');
3019 3019
 
3020 3020
 	function wps_mass_action_product() {
3021
-		check_ajax_referer( 'wps_mass_action_product' );
3021
+		check_ajax_referer('wps_mass_action_product');
3022 3022
 		$mass_actions_tools_page = '';
3023
-		$default_attributes = array( 'product_stock', 'barcode', 'product_price', 'special_price', );
3023
+		$default_attributes = array('product_stock', 'barcode', 'product_price', 'special_price',);
3024 3024
 
3025 3025
 		/**	Copy an attribute content to another	*/
3026
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_PRODUCT ), "'valid'", 'entity_id', true);
3027
-		if ( !empty( $attribute_list ) ) {
3026
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_PRODUCT), "'valid'", 'entity_id', true);
3027
+		if (!empty($attribute_list)) {
3028 3028
 			$mass_actions_tools_page .= '
3029
-			<form action="' . admin_url( "admin-ajax.php" ) . '" method="POST" id="wps_mass_action_on_entity_form" >
3029
+			<form action="' . admin_url("admin-ajax.php") . '" method="POST" id="wps_mass_action_on_entity_form" >
3030 3030
 				<input type="hidden" value="wps_mass_action_on_entity_launch" name="action" />
3031
-				<!--<div>' . __( 'Choose attribute to display into list', 'wpshop' ) . '
3031
+				<!--<div>' . __('Choose attribute to display into list', 'wpshop') . '
3032 3032
 					<ul>';
3033
-			foreach ( $attribute_list as $attribute ) {
3033
+			foreach ($attribute_list as $attribute) {
3034 3034
 				$mass_actions_tools_page .= '
3035
-						<li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked( in_array( $attribute->code, $default_attributes ), true, false ) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __( $attribute->frontend_label, 'wpshop' ) . '</li>';
3035
+						<li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked(in_array($attribute->code, $default_attributes), true, false) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __($attribute->frontend_label, 'wpshop') . '</li>';
3036 3036
 			}
3037 3037
 			$mass_actions_tools_page .= '
3038 3038
 					</ul>
3039
-					<button>' . __( 'Voir la liste des produits', 'wpshop' ) . '</button> -->
3039
+					<button>' . __('Voir la liste des produits', 'wpshop') . '</button> -->
3040 3040
 				</div>
3041 3041
 			</form>
3042 3042
 			<div id="wps_entity_list" >' . wps_mass_action_on_entity_launch() . '</div>
@@ -3049,32 +3049,32 @@  discard block
 block discarded – undo
3049 3049
 			</script>';
3050 3050
 		}
3051 3051
 
3052
-		wp_die( $mass_actions_tools_page );
3052
+		wp_die($mass_actions_tools_page);
3053 3053
 	}
3054
-	add_action( 'wp_ajax_wps_mass_action_product', 'wps_mass_action_product' );
3054
+	add_action('wp_ajax_wps_mass_action_product', 'wps_mass_action_product');
3055 3055
 
3056 3056
 	function wps_put_history_back() {
3057
-		check_ajax_referer( 'wps_put_history_back' );
3057
+		check_ajax_referer('wps_put_history_back');
3058 3058
 
3059 3059
 		global $wpdb;
3060 3060
 		$upload_dir = wp_upload_dir();
3061
-		$log_dir = $upload_dir[ 'basedir' ] . '/wps_repair/';
3062
-		wp_mkdir_p( $log_dir );
3063
-		$value_to_take = !empty($_POST[ 'value_to_take' ]) ? (array) $_POST[ 'value_to_take' ] : array();
3064
-		foreach ( $value_to_take as $product_id => $product_element ) {
3065
-			foreach( $product_element as $attribute_id => $attribute_value_to_take ){
3066
-				$query = $wpdb->prepare( "SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take );
3067
-				$the_new_value = $wpdb->get_row( $query );
3068
-				if ( 6 == $attribute_id ) {
3069
-					$query = $wpdb->prepare( "SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id );
3070
-					$the_tax = $wpdb->get_row( $query );
3071
-					$pttc = number_format( $the_new_value->value, 5, ".", " " );
3072
-					$ht = number_format( $pttc / ( 1 + ( $the_tax->value / 100 ) ), 5, ".", " " );
3073
-					$tax_amount = number_format( $pttc - $ht, 5, ".", " " );
3074
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 6 ) );
3075
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 28 ) );
3076
-					$wpdb->delete( 'wp_wpshop__attribute_value_integer', array( "entity_id" => $product_id, "attribute_id" => 29 ) );
3077
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 30 ) );
3061
+		$log_dir = $upload_dir['basedir'] . '/wps_repair/';
3062
+		wp_mkdir_p($log_dir);
3063
+		$value_to_take = !empty($_POST['value_to_take']) ? (array)$_POST['value_to_take'] : array();
3064
+		foreach ($value_to_take as $product_id => $product_element) {
3065
+			foreach ($product_element as $attribute_id => $attribute_value_to_take) {
3066
+				$query = $wpdb->prepare("SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take);
3067
+				$the_new_value = $wpdb->get_row($query);
3068
+				if (6 == $attribute_id) {
3069
+					$query = $wpdb->prepare("SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id);
3070
+					$the_tax = $wpdb->get_row($query);
3071
+					$pttc = number_format($the_new_value->value, 5, ".", " ");
3072
+					$ht = number_format($pttc / (1 + ($the_tax->value / 100)), 5, ".", " ");
3073
+					$tax_amount = number_format($pttc - $ht, 5, ".", " ");
3074
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 6));
3075
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 28));
3076
+					$wpdb->delete('wp_wpshop__attribute_value_integer', array("entity_id" => $product_id, "attribute_id" => 29));
3077
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 30));
3078 3078
 
3079 3079
 					$common_datas = array(
3080 3080
 						'value_id' => null,
@@ -3082,20 +3082,20 @@  discard block
 block discarded – undo
3082 3082
 						'entity_id' => $product_id,
3083 3083
 						'unit_id' => null,
3084 3084
 						'user_id' => 1,
3085
-						'creation_date_value' => current_time( "mysql", 0 ),
3085
+						'creation_date_value' => current_time("mysql", 0),
3086 3086
 						'language' => 'fr_FR',
3087 3087
 					);
3088 3088
 
3089
-					$content_to_write =  "
3090
-" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'ttc' => $pttc,  'ht' => $ht,  'tax_rate_id' => $the_tax->rate_id,  'tax_amount' => $tax_amount,  ) ). '';
3091
-					$fp = fopen( $log_dir . 'correction_prix.txt', 'a' );
3092
-					fwrite( $fp, $content_to_write );
3093
-					fclose( $fp );
3089
+					$content_to_write = "
3090
+" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('ttc' => $pttc, 'ht' => $ht, 'tax_rate_id' => $the_tax->rate_id, 'tax_amount' => $tax_amount,)) . '';
3091
+					$fp = fopen($log_dir . 'correction_prix.txt', 'a');
3092
+					fwrite($fp, $content_to_write);
3093
+					fclose($fp);
3094 3094
 
3095
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 6, 'value' => $pttc ) ) );
3096
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3097
-					$wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3098
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3095
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 6, 'value' => $pttc)));
3096
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 28, 'value' => $ht)));
3097
+					$wpdb->insert('wp_wpshop__attribute_value_integer', array_merge($common_datas, array('attribute_id' => 29, 'value' => $the_tax->rate_id)));
3098
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 30, 'value' => $tax_amount)));
3099 3099
 				}
3100 3100
 				else {
3101 3101
 					$common_datas = array(
@@ -3104,33 +3104,33 @@  discard block
 block discarded – undo
3104 3104
 						'entity_id' => $product_id,
3105 3105
 						'unit_id' => null,
3106 3106
 						'user_id' => 1,
3107
-						'creation_date_value' => current_time( "mysql", 0 ),
3107
+						'creation_date_value' => current_time("mysql", 0),
3108 3108
 						'language' => 'fr_FR',
3109 3109
 					);
3110
-					$wpdb->delete( $the_new_value->value_type, array( "entity_id" => $product_id, "attribute_id" => $attribute_id ) );
3111
-					$wpdb->insert( $the_new_value->value_type, array_merge( $common_datas, array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ) ) ) );
3112
-
3113
-					$content_to_write =  "
3114
-" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ),  ) ). '';
3115
-					$fp = fopen( $log_dir . 'correction_attribut.txt', 'a' );
3116
-					fwrite( $fp, $content_to_write );
3117
-					fclose( $fp );
3110
+					$wpdb->delete($the_new_value->value_type, array("entity_id" => $product_id, "attribute_id" => $attribute_id));
3111
+					$wpdb->insert($the_new_value->value_type, array_merge($common_datas, array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value))));
3112
+
3113
+					$content_to_write = "
3114
+" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value),)) . '';
3115
+					$fp = fopen($log_dir . 'correction_attribut.txt', 'a');
3116
+					fwrite($fp, $content_to_write);
3117
+					fclose($fp);
3118 3118
 				}
3119 3119
 			}
3120 3120
 		}
3121 3121
 		wp_die();
3122 3122
 	}
3123
-	add_action( 'wp_ajax_wps_put_history_back', 'wps_put_history_back' );
3123
+	add_action('wp_ajax_wps_put_history_back', 'wps_put_history_back');
3124 3124
 
3125 3125
 	function wps_mass_action_on_entity_launch() {
3126 3126
 		global $wpdb;
3127 3127
 		$response = '';
3128 3128
 		$element_to_output = array();
3129 3129
 
3130
-		$attributes_to_test = array( 'decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118' );
3130
+		$attributes_to_test = array('decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118');
3131 3131
 
3132 3132
 		$decimal_attribute = $attributes_to_test['decimal']; //,30,28
3133
-		$query = $wpdb->prepare( "
3133
+		$query = $wpdb->prepare("
3134 3134
 				SELECT P.ID, P.post_title,
3135 3135
 					D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3136 3136
 				FROM {$wpdb->posts} AS P
@@ -3144,21 +3144,21 @@  discard block
 block discarded – undo
3144 3144
 					AND H.value_type = 'wp_wpshop__attribute_value_decimal'
3145 3145
 
3146 3146
 				ORDER BY H.entity_id ASC, H.value_id DESC",
3147
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3147
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3148 3148
 		);
3149
-		 $list_of_element = $wpdb->get_results( $query );
3150
-		 if ( !empty( $list_of_element ) ) {
3151
-			foreach ( $list_of_element as $element ) {
3152
-				$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3153
-				$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3154
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3155
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3156
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3149
+		 $list_of_element = $wpdb->get_results($query);
3150
+		 if (!empty($list_of_element)) {
3151
+			foreach ($list_of_element as $element) {
3152
+				$element_to_output[$element->ID]['title'] = $element->post_title;
3153
+				$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3154
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3155
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3156
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3157 3157
 			}
3158 3158
 		}
3159 3159
 
3160 3160
 		$attribute_list = $attributes_to_test['varchar'];
3161
-		$query = $wpdb->prepare( "
3161
+		$query = $wpdb->prepare("
3162 3162
 			SELECT P.ID, P.post_title,
3163 3163
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3164 3164
 			FROM {$wpdb->posts} AS P
@@ -3171,22 +3171,22 @@  discard block
 block discarded – undo
3171 3171
 				AND H.value != ''
3172 3172
 				AND H.value_type = 'wp_wpshop__attribute_value_varchar'
3173 3173
 			ORDER BY H.creation_date",
3174
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3174
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3175 3175
 		);
3176
-		$list_of_element = $wpdb->get_results( $query );
3177
-		if ( !empty( $list_of_element ) ) {
3178
-			foreach ( $list_of_element as $element ) {
3179
-			 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3180
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3181
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3182
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3183
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3176
+		$list_of_element = $wpdb->get_results($query);
3177
+		if (!empty($list_of_element)) {
3178
+			foreach ($list_of_element as $element) {
3179
+			 	$element_to_output[$element->ID]['title'] = $element->post_title;
3180
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3181
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3182
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3183
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3184 3184
 			}
3185 3185
 		}
3186 3186
 
3187 3187
 
3188 3188
 		$attribute_list = $attributes_to_test['text'];
3189
-		$query = $wpdb->prepare( "
3189
+		$query = $wpdb->prepare("
3190 3190
 				SELECT P.ID, P.post_title,
3191 3191
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3192 3192
 				FROM {$wpdb->posts} AS P
@@ -3199,21 +3199,21 @@  discard block
 block discarded – undo
3199 3199
 				AND H.value != ''
3200 3200
 				AND H.value_type = 'wp_wpshop__attribute_value_text'
3201 3201
 			ORDER BY H.creation_date",
3202
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3202
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3203 3203
 		);
3204
-		$list_of_element = $wpdb->get_results( $query );
3205
-		if ( !empty( $list_of_element ) ) {
3206
-		foreach ( $list_of_element as $element ) {
3207
-		 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3208
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3209
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3210
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3211
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3204
+		$list_of_element = $wpdb->get_results($query);
3205
+		if (!empty($list_of_element)) {
3206
+		foreach ($list_of_element as $element) {
3207
+		 	$element_to_output[$element->ID]['title'] = $element->post_title;
3208
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3209
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3210
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3211
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3212 3212
 		 	}
3213 3213
 		}
3214 3214
 
3215 3215
 		$attribute_list = $attributes_to_test['integer'];
3216
-		$query = $wpdb->prepare( "
3216
+		$query = $wpdb->prepare("
3217 3217
 				SELECT P.ID, P.post_title,
3218 3218
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3219 3219
 				FROM {$wpdb->posts} AS P
@@ -3226,21 +3226,21 @@  discard block
 block discarded – undo
3226 3226
 				AND H.value != ''
3227 3227
 				AND H.value_type = 'wp_wpshop__attribute_value_integer'
3228 3228
 			ORDER BY H.creation_date",
3229
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3229
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3230 3230
 		);
3231
-							$list_of_element = $wpdb->get_results( $query );
3232
-							if ( !empty( $list_of_element ) ) {
3233
-							foreach ( $list_of_element as $element ) {
3234
-					 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3235
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3236
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3237
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3238
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3231
+							$list_of_element = $wpdb->get_results($query);
3232
+							if (!empty($list_of_element)) {
3233
+							foreach ($list_of_element as $element) {
3234
+					 	$element_to_output[$element->ID]['title'] = $element->post_title;
3235
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3236
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3237
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3238
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3239 3239
 					 	}
3240 3240
 							}
3241 3241
 
3242 3242
 		$array_done = array();
3243
-		if ( !empty( $element_to_output ) ) {
3243
+		if (!empty($element_to_output)) {
3244 3244
 			$lines = '';
3245 3245
 			$done_header = array();
3246 3246
 
@@ -3248,23 +3248,23 @@  discard block
 block discarded – undo
3248 3248
 			/** Formate informations **/
3249 3249
 			$formatted_datas = array();
3250 3250
 			$controller_rows_array = array();
3251
-			foreach( $attributes_to_test as $attribute_to_test ) {
3252
-				$atts = explode( ',', $attribute_to_test );
3253
-				foreach( $atts as $att ) {
3254
-					$controller_rows_array[ $att ] = false;
3251
+			foreach ($attributes_to_test as $attribute_to_test) {
3252
+				$atts = explode(',', $attribute_to_test);
3253
+				foreach ($atts as $att) {
3254
+					$controller_rows_array[$att] = false;
3255 3255
 				}
3256 3256
 			}
3257 3257
 
3258
-			foreach(  $element_to_output as $element_id => $element_definition ) {
3258
+			foreach ($element_to_output as $element_id => $element_definition) {
3259 3259
 				$formatted_datas[$element_id]['title'] = $element_definition['title'];
3260 3260
 				$formatted_datas[$element_id]['content'] = array();
3261 3261
 
3262
-				foreach( $attributes_to_test as $attribute_to_test ) {
3263
-					$atts = explode( ',', $attribute_to_test );
3264
-					foreach( $atts as $att ) {
3265
-						if( !empty($element_definition['content'][$att]) ) {
3262
+				foreach ($attributes_to_test as $attribute_to_test) {
3263
+					$atts = explode(',', $attribute_to_test);
3264
+					foreach ($atts as $att) {
3265
+						if (!empty($element_definition['content'][$att])) {
3266 3266
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3267
-							$controller_rows_array[ $att ] = true;
3267
+							$controller_rows_array[$att] = true;
3268 3268
 						}
3269 3269
 						else {
3270 3270
 							$formatted_datas[$element_id]['content'][$att] = array();
@@ -3273,39 +3273,39 @@  discard block
 block discarded – undo
3273 3273
 				}
3274 3274
 			}
3275 3275
 
3276
-			foreach ( $formatted_datas as $element_id => $element_definition ) {
3277
-				if ( !in_array( $element_id, $array_done ) ) {
3278
-					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition[ 'title' ] . '</td>';
3279
-					ksort( $element_definition[ 'content' ] );
3280
-					foreach ( $element_definition[ 'content' ] as $atribute_id => $value_on_date ) {
3281
-						if( $controller_rows_array[$atribute_id] ) {
3282
-							$current_attribute = wpshop_attributes::getElement( $atribute_id );
3283
-							if ( !in_array( $atribute_id, $done_header ) ) {
3284
-								$more_header .= '<td style="border:1px solid black;" >' . __( $current_attribute->frontend_label, 'wpshop' ) . '</td>';
3276
+			foreach ($formatted_datas as $element_id => $element_definition) {
3277
+				if (!in_array($element_id, $array_done)) {
3278
+					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition['title'] . '</td>';
3279
+					ksort($element_definition['content']);
3280
+					foreach ($element_definition['content'] as $atribute_id => $value_on_date) {
3281
+						if ($controller_rows_array[$atribute_id]) {
3282
+							$current_attribute = wpshop_attributes::getElement($atribute_id);
3283
+							if (!in_array($atribute_id, $done_header)) {
3284
+								$more_header .= '<td style="border:1px solid black;" >' . __($current_attribute->frontend_label, 'wpshop') . '</td>';
3285 3285
 								$done_header[] = $atribute_id;
3286 3286
 							}
3287 3287
 							$last_value = 'XXXXX';
3288 3288
 							$counter_for_line = 0;
3289 3289
 							$content_line = '';
3290
-							foreach ( $value_on_date as $date => $value ) {
3291
-								if ( $value[ 'histo' ][ 'value' ] != $last_value ) {
3292
-									$current_val = $value[ 'current' ];
3293
-									$old_val = $value[ 'histo' ][ 'value' ];
3290
+							foreach ($value_on_date as $date => $value) {
3291
+								if ($value['histo']['value'] != $last_value) {
3292
+									$current_val = $value['current'];
3293
+									$old_val = $value['histo']['value'];
3294 3294
 									// Test if attribute data Type is integer
3295
-									if ( $current_attribute->data_type == 'integer' ) {
3296
-										if( $current_attribute->data_type_to_use == 'internal' ) {
3295
+									if ($current_attribute->data_type == 'integer') {
3296
+										if ($current_attribute->data_type_to_use == 'internal') {
3297 3297
 											$current_val = get_the_title($current_val);
3298 3298
 											$old_val = get_the_title($old_val);
3299 3299
 										}
3300 3300
 										else {
3301
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3302
-											$old_val = $wpdb->get_var( $query );
3303
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
3304
-											$current_val = $wpdb->get_var( $query );
3301
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $old_val);
3302
+											$old_val = $wpdb->get_var($query);
3303
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $current_val);
3304
+											$current_val = $wpdb->get_var($query);
3305 3305
 										}
3306 3306
 									}
3307
-									$content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value[ 'histo' ][ 'value_id' ] . '"' . checked( ( 0 == $counter_for_line ? true : false), true, false ) . '/>' . __( 'Current value', 'wpshop' ) . ' : ' .$current_val. ' / ' . __( 'Last value', 'wpshop' ) . ' : ' .$old_val. '</label><br/>';
3308
-									$last_value = $value[ 'histo' ][ 'value' ];
3307
+									$content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value['histo']['value_id'] . '"' . checked((0 == $counter_for_line ? true : false), true, false) . '/>' . __('Current value', 'wpshop') . ' : ' . $current_val . ' / ' . __('Last value', 'wpshop') . ' : ' . $old_val . '</label><br/>';
3308
+									$last_value = $value['histo']['value'];
3309 3309
 									$counter_for_line++;
3310 3310
 								}
3311 3311
 							}
@@ -3315,16 +3315,16 @@  discard block
 block discarded – undo
3315 3315
 						}
3316 3316
 					}
3317 3317
 					$lines .= '</tr>';
3318
-					$array_done[ $element_id ];
3318
+					$array_done[$element_id];
3319 3319
 				}
3320 3320
 			}
3321 3321
 
3322 3322
 			$response = '
3323
-				<form action="' . admin_url( 'admin-ajax.php' ) . '" method="POST" id="wps_put_histo_back" >
3323
+				<form action="' . admin_url('admin-ajax.php') . '" method="POST" id="wps_put_histo_back" >
3324 3324
 					<input type="text" name="action" value="wps_put_history_back" />
3325
-					' . wp_nonce_field( 'wps_put_history_back' ) . '
3325
+					' . wp_nonce_field('wps_put_history_back') . '
3326 3326
 					<table style="border-collapse: collapse;border:1px solid black;" cellpadding="0" cellspacing="0" >
3327
-						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __( 'Product', 'wpshop' ) . '</td>'.$more_header.'</tr>
3327
+						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __('Product', 'wpshop') . '</td>' . $more_header . '</tr>
3328 3328
 						' . $lines . '
3329 3329
 					</table>
3330 3330
 				</form><script type="text/javascript" >
@@ -3341,36 +3341,36 @@  discard block
 block discarded – undo
3341 3341
 
3342 3342
 
3343 3343
 	function wps_delete_picture_category() {
3344
-		check_ajax_referer( 'wps_delete_picture_category' );
3344
+		check_ajax_referer('wps_delete_picture_category');
3345 3345
 		$status = false; $response = '';
3346
-		$cat_id = ( !empty($_POST['cat_id']) ) ? (int) $_POST['cat_id'] : null;
3347
-		if( !empty($cat_id) ) {
3346
+		$cat_id = (!empty($_POST['cat_id'])) ? (int)$_POST['cat_id'] : null;
3347
+		if (!empty($cat_id)) {
3348 3348
 			// Get Category option
3349
-			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id );
3350
-			if( !empty($category_option) && !empty($category_option['wpshop_category_picture']) ) {
3351
-				unset( $category_option['wpshop_category_picture'] );
3352
-				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3353
-				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3349
+			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id);
3350
+			if (!empty($category_option) && !empty($category_option['wpshop_category_picture'])) {
3351
+				unset($category_option['wpshop_category_picture']);
3352
+				update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option);
3353
+				$response = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview"/>';
3354 3354
 				$status = true;
3355 3355
 			}
3356 3356
 			else {
3357
-				$response = __( 'Category options are not defined', 'wpshop');
3357
+				$response = __('Category options are not defined', 'wpshop');
3358 3358
 			}
3359 3359
 		}
3360 3360
 		else {
3361
-			$response = __( 'Category ID is not defined', 'wpshop');
3361
+			$response = __('Category ID is not defined', 'wpshop');
3362 3362
 		}
3363
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3363
+		echo json_encode(array('status' => $status, 'response' => $response));
3364 3364
 		wp_die();
3365 3365
 	}
3366
-	add_action( 'wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category' );
3366
+	add_action('wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category');
3367 3367
 
3368 3368
 	/* EAV */
3369 3369
 
3370 3370
 	/* ATTRIBUTES SET */
3371 3371
 
3372 3372
 	function saveNewAttributeSetSection() {
3373
-		check_ajax_referer( 'saveNewAttributeSetSection' );
3373
+		check_ajax_referer('saveNewAttributeSetSection');
3374 3374
 		global $wpdb;
3375 3375
 		$attributeSetSectionName = sanitize_text_field($_REQUEST['attributeSetSectionName']);
3376 3376
 		$elementIdentifier = (int)$_REQUEST['elementIdentifier'];
@@ -3378,37 +3378,37 @@  discard block
 block discarded – undo
3378 3378
 		$attributeSetInfos['id'] = '';
3379 3379
 		$attributeSetInfos['status'] = 'valid';
3380 3380
 		$attributeSetInfos['attribute_set_id'] = $elementIdentifier;
3381
-		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM ". WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3381
+		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3382 3382
 		$attributeSetInfos['position'] = $wpdb->get_var($query);
3383 3383
 		$attributeSetInfos['creation_date'] = date('Y-m-d H:i:s');
3384 3384
 		$attributeSetInfos['code'] = wpshop_tools::slugify($attributeSetSectionName, array('noAccent', 'noSpaces', 'lowerCase'));
3385 3385
 		$attributeSetInfos['name'] = $attributeSetSectionName;
3386 3386
 
3387
-		$more_script='';
3387
+		$more_script = '';
3388 3388
 		$attributeSetSectionCreation = wpshop_database::save($attributeSetInfos, WPSHOP_DBT_ATTRIBUTE_GROUP);
3389
-		if ( $attributeSetSectionCreation == 'done' ) {
3389
+		if ($attributeSetSectionCreation == 'done') {
3390 3390
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
3391
-			$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
3391
+			$more_script = 'wpshop_go_to("#attribute_group_' . $wpdb->insert_id . '")';
3392 3392
 		}
3393 3393
 		else {
3394 3394
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
3395 3395
 		}
3396 3396
 
3397
-		$script = '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3398
-		wp_die( wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script );
3397
+		$script = '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
3398
+		wp_die(wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script);
3399 3399
 	}
3400
-	add_action( 'wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection' );
3400
+	add_action('wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection');
3401 3401
 
3402 3402
 	function editAttributeSetSection() {
3403
-		check_ajax_referer( 'editAttributeSetSection' );
3403
+		check_ajax_referer('editAttributeSetSection');
3404 3404
 		$attributeSetSectionName = sanitize_title($_REQUEST['attributeSetSectionName']);
3405 3405
 		$attributeSetSectionId = sanitize_key($_REQUEST['attributeSetSectionId']);
3406 3406
 		$attributeSetSectionDefault = sanitize_text_field($_REQUEST['attributeSetSectionDefault']);
3407 3407
 		$backend_display_type = sanitize_text_field($_REQUEST['attributeSetSectionDisplayType']);
3408 3408
 		$display_on_frontend = sanitize_text_field($_REQUEST['attributeSetSectionDisplayinFrontEnd']);
3409
-		$backend_display_type = in_array($backend_display_type, array('movable-tab','fixed-tab')) ? $backend_display_type : 'fixed-tab';
3409
+		$backend_display_type = in_array($backend_display_type, array('movable-tab', 'fixed-tab')) ? $backend_display_type : 'fixed-tab';
3410 3410
 
3411
-		if($attributeSetSectionDefault == 'yes'){
3411
+		if ($attributeSetSectionDefault == 'yes') {
3412 3412
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, array('last_update_date' => current_time('mysql', 0), 'default_group' => 'no'), array('attribute_set_id' => $elementIdentifier));
3413 3413
 		}
3414 3414
 		$attributeSetInfos = array();
@@ -3418,18 +3418,18 @@  discard block
 block discarded – undo
3418 3418
 		$attributeSetInfos['backend_display_type'] = $backend_display_type;
3419 3419
 		$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
3420 3420
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3421
-		if ( $attributeSetSectionCreation == 'done' )
3421
+		if ($attributeSetSectionCreation == 'done')
3422 3422
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
3423 3423
 		else
3424 3424
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
3425 3425
 		echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>';
3426 3426
 		wp_die();
3427 3427
 	}
3428
-	add_action( 'wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection' );
3428
+	add_action('wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection');
3429 3429
 
3430 3430
 	function deleteAttributeSetSection() {
3431
-		check_ajax_referer( 'deleteAttributeSetSection' );
3432
-		$attributeSetSectionId = (int) $_REQUEST['attributeSetSectionId'];
3431
+		check_ajax_referer('deleteAttributeSetSection');
3432
+		$attributeSetSectionId = (int)$_REQUEST['attributeSetSectionId'];
3433 3433
 		$attributeSetInfos = array();
3434 3434
 		$attributeSetInfos['status'] = 'deleted';
3435 3435
 		$attributeSetInfos['last_update_date'] = current_time('mysql', 0);
@@ -3438,21 +3438,21 @@  discard block
 block discarded – undo
3438 3438
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3439 3439
 
3440 3440
 		$more_script = '';
3441
-		if ( $attributeSetSectionCreation == 'done' ) {
3441
+		if ($attributeSetSectionCreation == 'done') {
3442 3442
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
3443
-			$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
3443
+			$more_script .= 'jQuery("#attribute_group_' . $attributeSetSectionId . '").remove();';
3444 3444
 		}
3445 3445
 		else
3446 3446
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
3447
-		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3447
+		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
3448 3448
 		wp_die();
3449 3449
 	}
3450
-	add_action( 'wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection' );
3450
+	add_action('wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection');
3451 3451
 
3452 3452
 	/* ATTRIBUTES UNIT */
3453 3453
 
3454 3454
 	function load_unit_interface() {
3455
-		check_ajax_referer( 'load_unit_interface' );
3455
+		check_ajax_referer('load_unit_interface');
3456 3456
 		?>
3457 3457
 		<div id="wpshop_unit_main_listing_interface">
3458 3458
 			<div class="wpshop_full_page_tabs">
@@ -3471,28 +3471,28 @@  discard block
 block discarded – undo
3471 3471
 
3472 3472
 		wp_die();
3473 3473
 	}
3474
-	add_action( 'wp_ajax_wps_attribute_unit_interface', 'load_unit_interface' );
3474
+	add_action('wp_ajax_wps_attribute_unit_interface', 'load_unit_interface');
3475 3475
 
3476 3476
 	function load_attribute_units() {
3477
-		check_ajax_referer( 'load_attribute_units' );
3478
-		wp_die( wpshop_attributes_unit::elementList() );
3477
+		check_ajax_referer('load_attribute_units');
3478
+		wp_die(wpshop_attributes_unit::elementList());
3479 3479
 	}
3480
-	add_action( 'wp_ajax_wps_attribute_unit_load', 'load_attribute_units' );
3480
+	add_action('wp_ajax_wps_attribute_unit_load', 'load_attribute_units');
3481 3481
 
3482 3482
 	function add_attribute_unit() {
3483
-		check_ajax_referer( 'add_attribute_unit' );
3484
-		wp_die( wpshop_attributes_unit::elementEdition( '' ) );
3483
+		check_ajax_referer('add_attribute_unit');
3484
+		wp_die(wpshop_attributes_unit::elementEdition(''));
3485 3485
 	}
3486
-	add_action( 'wp_ajax_wps_attribute_unit_add', 'add_attribute_unit' );
3486
+	add_action('wp_ajax_wps_attribute_unit_add', 'add_attribute_unit');
3487 3487
 
3488 3488
 	function edit_attribute_unit() {
3489
-		check_ajax_referer( 'edit_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3490
-		wp_die( wpshop_attributes_unit::elementEdition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3489
+		check_ajax_referer('edit_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3490
+		wp_die(wpshop_attributes_unit::elementEdition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3491 3491
 	}
3492
-	add_action( 'wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit' );
3492
+	add_action('wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit');
3493 3493
 
3494 3494
 	function save_new_attribute_unit() {
3495
-		check_ajax_referer( 'save_new_attribute_unit' );
3495
+		check_ajax_referer('save_new_attribute_unit');
3496 3496
 		$save_output = '';
3497 3497
 
3498 3498
 		$attribute_unit_informations['id'] = '';
@@ -3506,11 +3506,11 @@  discard block
 block discarded – undo
3506 3506
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3507 3507
 
3508 3508
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT);
3509
-		if($save_unit_result == 'done'){
3509
+		if ($save_unit_result == 'done') {
3510 3510
 			$save_output = wpshop_attributes_unit::elementList();
3511 3511
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
3512 3512
 		}
3513
-		else{
3513
+		else {
3514 3514
 			$save_output = wpshop_attributes_unit::elementEdition();
3515 3515
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
3516 3516
 		}
@@ -3518,10 +3518,10 @@  discard block
 block discarded – undo
3518 3518
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3519 3519
 		wp_die();
3520 3520
 	}
3521
-	add_action( 'wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit' );
3521
+	add_action('wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit');
3522 3522
 
3523 3523
 	function update_attribute_unit() {
3524
-		check_ajax_referer( 'update_attribute_unit' );
3524
+		check_ajax_referer('update_attribute_unit');
3525 3525
 		$save_output = '';
3526 3526
 
3527 3527
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['id']);
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
 		$attribute_unit_informations['change_rate'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['change_rate']);
3535 3535
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3536 3536
 
3537
-		if ( $attribute_unit_informations['is_default_of_group'] == 'yes' ) {
3537
+		if ($attribute_unit_informations['is_default_of_group'] == 'yes') {
3538 3538
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array(
3539 3539
 				'is_default_of_group' => 'no'
3540 3540
 			), array(
@@ -3542,8 +3542,8 @@  discard block
 block discarded – undo
3542 3542
 			));
3543 3543
 		}
3544 3544
 
3545
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3546
-		if ( $save_unit_result == 'done' ) {
3545
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3546
+		if ($save_unit_result == 'done') {
3547 3547
 			$save_output = wpshop_attributes_unit::elementList();
3548 3548
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
3549 3549
 		}
@@ -3555,17 +3555,17 @@  discard block
 block discarded – undo
3555 3555
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3556 3556
 		wp_die();
3557 3557
 	}
3558
-	add_action( 'wp_ajax_wps_attribute_unit_update', 'update_attribute_unit' );
3558
+	add_action('wp_ajax_wps_attribute_unit_update', 'update_attribute_unit');
3559 3559
 
3560 3560
 	function delete_attribute_unit() {
3561
-		check_ajax_referer( 'delete_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3561
+		check_ajax_referer('delete_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3562 3562
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3563 3563
 		$save_output = '';
3564 3564
 
3565 3565
 		$attribute_unit_informations['status'] = 'deleted';
3566 3566
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3567 3567
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
3568
-		if ( $save_unit_result == 'done' ) {
3568
+		if ($save_unit_result == 'done') {
3569 3569
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
3570 3570
 		}
3571 3571
 		else {
@@ -3575,30 +3575,30 @@  discard block
 block discarded – undo
3575 3575
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::elementList();
3576 3576
 		wp_die();
3577 3577
 	}
3578
-	add_action( 'wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit' );
3578
+	add_action('wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit');
3579 3579
 
3580 3580
 	/* ATTRIBUTES UNIT GROUP */
3581 3581
 
3582 3582
 	function load_attribute_unit_groups() {
3583
-		check_ajax_referer( 'load_attribute_unit_groups' );
3584
-		wp_die( wpshop_attributes_unit::unit_group_list() );
3583
+		check_ajax_referer('load_attribute_unit_groups');
3584
+		wp_die(wpshop_attributes_unit::unit_group_list());
3585 3585
 	}
3586
-	add_action( 'wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups' );
3586
+	add_action('wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups');
3587 3587
 
3588 3588
 	function add_attribute_unit_group() {
3589
-		check_ajax_referer( 'add_attribute_unit_group' );
3590
-		wp_die( wpshop_attributes_unit::unit_group_edition( '' ) );
3589
+		check_ajax_referer('add_attribute_unit_group');
3590
+		wp_die(wpshop_attributes_unit::unit_group_edition(''));
3591 3591
 	}
3592
-	add_action( 'wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group' );
3592
+	add_action('wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group');
3593 3593
 
3594 3594
 	function edit_attribute_unit_group() {
3595
-		check_ajax_referer( 'edit_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? $_REQUEST['elementIdentifier'] : '' ) );
3596
-		wp_die( wpshop_attributes_unit::unit_group_edition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3595
+		check_ajax_referer('edit_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? $_REQUEST['elementIdentifier'] : ''));
3596
+		wp_die(wpshop_attributes_unit::unit_group_edition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3597 3597
 	}
3598
-	add_action( 'wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group' );
3598
+	add_action('wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group');
3599 3599
 
3600 3600
 	function save_new_attribute_unit_group() {
3601
-		check_ajax_referer( 'save_new_attribute_unit_group' );
3601
+		check_ajax_referer('save_new_attribute_unit_group');
3602 3602
 		$save_output = '';
3603 3603
 
3604 3604
 		$attribute_unit_informations['id'] = '';
@@ -3607,11 +3607,11 @@  discard block
 block discarded – undo
3607 3607
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3608 3608
 
3609 3609
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3610
-		if($save_unit_result == 'done'){
3610
+		if ($save_unit_result == 'done') {
3611 3611
 			$save_output = wpshop_attributes_unit::unit_group_list();
3612 3612
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
3613 3613
 		}
3614
-		else{
3614
+		else {
3615 3615
 			$save_output = wpshop_attributes_unit::unit_group_edition();
3616 3616
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
3617 3617
 		}
@@ -3619,10 +3619,10 @@  discard block
 block discarded – undo
3619 3619
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3620 3620
 		wp_die();
3621 3621
 	}
3622
-	add_action( 'wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group' );
3622
+	add_action('wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group');
3623 3623
 
3624 3624
 	function update_attribute_unit_group() {
3625
-		check_ajax_referer( 'update_attribute_unit_group' );
3625
+		check_ajax_referer('update_attribute_unit_group');
3626 3626
 		$save_output = '';
3627 3627
 
3628 3628
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['id']);
@@ -3630,12 +3630,12 @@  discard block
 block discarded – undo
3630 3630
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3631 3631
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3632 3632
 
3633
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3634
-		if($save_unit_result == 'done'){
3633
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3634
+		if ($save_unit_result == 'done') {
3635 3635
 			$save_output = wpshop_attributes_unit::unit_group_list();
3636 3636
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
3637 3637
 		}
3638
-		else{
3638
+		else {
3639 3639
 			$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
3640 3640
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
3641 3641
 		}
@@ -3643,65 +3643,65 @@  discard block
 block discarded – undo
3643 3643
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3644 3644
 		wp_die();
3645 3645
 	}
3646
-	add_action( 'wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group' );
3646
+	add_action('wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group');
3647 3647
 
3648 3648
 	function delete_attribute_unit_group() {
3649
-		check_ajax_referer( 'delete_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3649
+		check_ajax_referer('delete_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3650 3650
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3651 3651
 		$save_output = '';
3652 3652
 
3653 3653
 		$attribute_unit_informations['status'] = 'deleted';
3654 3654
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3655 3655
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3656
-		if($save_unit_result == 'done'){
3656
+		if ($save_unit_result == 'done') {
3657 3657
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
3658 3658
 		}
3659
-		else{
3659
+		else {
3660 3660
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
3661 3661
 		}
3662 3662
 
3663 3663
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::unit_group_list();
3664 3664
 		wp_die();
3665 3665
 	}
3666
-	add_action( 'wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group' );
3666
+	add_action('wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group');
3667 3667
 
3668 3668
 	function products_by_criteria() {
3669
-		check_ajax_referer( 'products_by_criteria' );
3669
+		check_ajax_referer('products_by_criteria');
3670 3670
 		$attr = !empty($_REQUEST['attr']) ? sanitize_text_field($_REQUEST['attr']) : '';
3671 3671
 		// If a filter by attribute is found, recalcul the products that matching it
3672
-		if(!empty($attr)) {
3673
-			$att = explode(':',$attr);
3674
-			$products_id = wpshop_products::get_products_matching_attribute($att[0],$att[1]);
3672
+		if (!empty($attr)) {
3673
+			$att = explode(':', $attr);
3674
+			$products_id = wpshop_products::get_products_matching_attribute($att[0], $att[1]);
3675 3675
 		}
3676
-		$products_id = !empty($products_id) ? $products_id : sanitize_text_field( $_REQUEST['pid'] );
3677
-		$page_number = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'page_number' ] ) && is_int( (int) $_REQUEST['page_number'] ) ? (int) $_REQUEST['page_number'] : 0;
3676
+		$products_id = !empty($products_id) ? $products_id : sanitize_text_field($_REQUEST['pid']);
3677
+		$page_number = !empty($_REQUEST) && !empty($_REQUEST['page_number']) && is_int((int)$_REQUEST['page_number']) ? (int)$_REQUEST['page_number'] : 0;
3678 3678
 
3679
-		$criteria = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'criteria' ] ) ? sanitize_text_field( $_REQUEST[ 'criteria' ] ) : null;
3680
-		$cid = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'cid' ] ) && is_int( (int)$_REQUEST[ 'cid' ] ) ? (int)$_REQUEST[ 'cid' ] : null;
3681
-		$display_type = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'display_type' ] ) ? sanitize_text_field( $_REQUEST[ 'display_type' ] ) : null;
3682
-		$order = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'order' ] ) ? sanitize_text_field( $_REQUEST[ 'order' ] ) : null;
3683
-		$products_per_page = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'products_per_page' ] ) && is_int( (int)$_REQUEST[ 'products_per_page' ] ) ? (int)$_REQUEST[ 'products_per_page' ] : 0;
3679
+		$criteria = !empty($_REQUEST) && !empty($_REQUEST['criteria']) ? sanitize_text_field($_REQUEST['criteria']) : null;
3680
+		$cid = !empty($_REQUEST) && !empty($_REQUEST['cid']) && is_int((int)$_REQUEST['cid']) ? (int)$_REQUEST['cid'] : null;
3681
+		$display_type = !empty($_REQUEST) && !empty($_REQUEST['display_type']) ? sanitize_text_field($_REQUEST['display_type']) : null;
3682
+		$order = !empty($_REQUEST) && !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null;
3683
+		$products_per_page = !empty($_REQUEST) && !empty($_REQUEST['products_per_page']) && is_int((int)$_REQUEST['products_per_page']) ? (int)$_REQUEST['products_per_page'] : 0;
3684 3684
 
3685
-		$data = wpshop_products::wpshop_get_product_by_criteria( $criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page );
3686
-		if($data[0]) {
3685
+		$data = wpshop_products::wpshop_get_product_by_criteria($criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page);
3686
+		if ($data[0]) {
3687 3687
 			echo json_encode(array(true, do_shortcode($data[1])));
3688
-		} else echo json_encode(array(false,__('No product found','wpshop')));
3688
+		} else echo json_encode(array(false, __('No product found', 'wpshop')));
3689 3689
 		wp_die();
3690 3690
 	}
3691
-	add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' );
3692
-	add_action( 'wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria' );
3691
+	add_action('wp_ajax_wps_products_by_criteria', 'products_by_criteria');
3692
+	add_action('wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria');
3693 3693
 
3694 3694
 	function ajax_sendMessage() {
3695
-		check_ajax_referer( 'sendMessage' );
3696
-		$post_id = !empty($_REQUEST['postid']) ? (int) $_REQUEST['postid'] : null;
3695
+		check_ajax_referer('sendMessage');
3696
+		$post_id = !empty($_REQUEST['postid']) ? (int)$_REQUEST['postid'] : null;
3697 3697
 		$title = !empty($_REQUEST['title']) ? sanitize_title($_REQUEST['title']) : '';
3698 3698
 		$message = !empty($_REQUEST['message']) ? sanitize_text_field($_REQUEST['message']) : '';
3699
-		$recipient = !empty($_REQUEST['recipient']) ? (array) $_REQUEST['recipient'] : array();
3700
-		if ( isset($post_id) && isset($title) && isset($message) && !empty($recipient) ) {
3699
+		$recipient = !empty($_REQUEST['recipient']) ? (array)$_REQUEST['recipient'] : array();
3700
+		if (isset($post_id) && isset($title) && isset($message) && !empty($recipient)) {
3701 3701
 			$user_info = get_userdata($recipient);
3702 3702
 			$first_name = $user_info->user_firstname;
3703 3703
 			$last_name = $user_info->user_lastname;
3704
-			$data = array('customer_first_name'=>$first_name,'customer_last_name'=>$last_name);
3704
+			$data = array('customer_first_name'=>$first_name, 'customer_last_name'=>$last_name);
3705 3705
 
3706 3706
 			$wps_message_ctr = new wps_message_ctr();
3707 3707
 
@@ -3710,73 +3710,73 @@  discard block
 block discarded – undo
3710 3710
 			$message = $wps_message_ctr->customMessage($message, $data);
3711 3711
 
3712 3712
 			if (!empty($user_info->user_email)) {
3713
-				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$post_id, $object=array());
3713
+				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save = true, $model_id = $post_id, $object = array());
3714 3714
 				$array = array('result' => true, 'message' => '');
3715 3715
 			}
3716
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
3716
+			else $array = array('result' => true, 'message' => __('An error occured', 'wpshop'));
3717 3717
 		}
3718 3718
 		else {
3719
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3719
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3720 3720
 		}
3721 3721
 
3722 3722
 		echo json_encode($array);
3723 3723
 		wp_die();
3724 3724
 	}
3725
-	add_action( 'wp_ajax_wps_ajax_send_message', 'ajax_sendMessage' );
3725
+	add_action('wp_ajax_wps_ajax_send_message', 'ajax_sendMessage');
3726 3726
 
3727 3727
 	function ajax_resendMessage() {
3728
-		check_ajax_referer( 'resendMessage' );
3729
-		$message_id = !empty($_REQUEST['messageid']) ? (array) $_REQUEST['messageid'] : array();
3728
+		check_ajax_referer('resendMessage');
3729
+		$message_id = !empty($_REQUEST['messageid']) ? (array)$_REQUEST['messageid'] : array();
3730 3730
 		if (isset($message_id)) {
3731
-			$ids = explode('-',$message_id);
3731
+			$ids = explode('-', $message_id);
3732 3732
 			$postid = $ids[0];
3733
-			$date = $ids[1].'-'.$ids[2];
3733
+			$date = $ids[1] . '-' . $ids[2];
3734 3734
 			$arraykey = $ids[3];
3735 3735
 
3736
-			$historic = get_post_meta($postid, 'wpshop_messages_histo_'.$date, true);
3736
+			$historic = get_post_meta($postid, 'wpshop_messages_histo_' . $date, true);
3737 3737
 
3738 3738
 			if (isset($historic[$arraykey])) {
3739 3739
 				$historic[$arraykey]['mess_dispatch_date'][] = current_time('mysql', 0);
3740
-				update_post_meta($postid, 'wpshop_messages_histo_'.$date, $historic);
3740
+				update_post_meta($postid, 'wpshop_messages_histo_' . $date, $historic);
3741 3741
 
3742 3742
 				$data = $historic[$arraykey];
3743 3743
 				$wps_message_ctr = new wps_message_ctr();
3744
-				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
3744
+				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save = false, $object = array());
3745 3745
 
3746 3746
 				$array = array('result' => true, 'message' => '');
3747 3747
 			}
3748 3748
 			else {
3749
-				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3749
+				$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3750 3750
 			}
3751 3751
 		}
3752 3752
 		else {
3753
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3753
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3754 3754
 		}
3755 3755
 
3756 3756
 		echo json_encode($array);
3757 3757
 		wp_die();
3758 3758
 	}
3759
-	add_action( 'wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage' );
3759
+	add_action('wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage');
3760 3760
 
3761 3761
 	function related_products() {
3762
-		check_ajax_referer( 'related_products' );
3762
+		check_ajax_referer('related_products');
3763 3763
 		$search = sanitize_text_field($_REQUEST['search']);
3764 3764
 		$data = wpshop_products::product_list(false, $search);
3765
-		$array=array();
3765
+		$array = array();
3766 3766
 		foreach ($data as $d) {
3767 3767
 			$array[] = array('id' => $d->ID, 'name' => $d->post_title);
3768 3768
 		}
3769 3769
 		echo json_encode($array);
3770 3770
 		wp_die();
3771 3771
 	}
3772
-	add_action( 'wp_ajax_wps_related_products', 'related_products' );
3772
+	add_action('wp_ajax_wps_related_products', 'related_products');
3773 3773
 
3774 3774
 	function applyCoupon() {
3775
-		check_ajax_referer( 'applyCoupon' );
3775
+		check_ajax_referer('applyCoupon');
3776 3776
 		$wps_coupon_ctr = new wps_coupon_ctr();
3777 3777
 		$coupon_code = sanitize_text_field($_REQUEST['coupon_code']);
3778 3778
 		$result = $wps_coupon_ctr->applyCoupon($coupon_code);
3779
-		if ($result['status']===true) {
3779
+		if ($result['status'] === true) {
3780 3780
 			$wps_cart_ctr = new wps_cart();
3781 3781
 			$order = $wps_cart_ctr->calcul_cart_information(array());
3782 3782
 			$wps_cart_ctr->store_cart_in_session($order);
@@ -3784,6 +3784,6 @@  discard block
 block discarded – undo
3784 3784
 		} else echo json_encode(array(false, $result['message']));
3785 3785
 		wp_die();
3786 3786
 	}
3787
-	add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' );
3787
+	add_action('wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon');
3788 3788
 
3789 3789
 ?>
Please login to merge, or discard this patch.
core/wps_utils/wps_utils.php 2 patches
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for product mass modification module
4 4
  *
@@ -30,56 +30,56 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return string The template file path to use
32 32
 	 */
33
-	public static function get_template_part( $plugin_dir_name, $main_template_dir, $side, $slug, $name=null, $debug = null ) {
33
+	public static function get_template_part($plugin_dir_name, $main_template_dir, $side, $slug, $name = null, $debug = null) {
34 34
 		$path = '';
35 35
 
36 36
 		$templates = array();
37 37
 		$name = (string)$name;
38
-		if ( '' !== $name )
38
+		if ('' !== $name)
39 39
 			$templates[] = "{$side}/{$slug}-{$name}.php";
40 40
 		$templates[] = "{$side}/{$slug}.php";
41 41
 
42 42
 		/**	Check if required template exists into current theme	*/
43 43
 		$check_theme_template = array();
44
-		foreach ( $templates as $template ) {
44
+		foreach ($templates as $template) {
45 45
 			$check_theme_template = $plugin_dir_name . "/" . $template;
46
-			$path = locate_template( $check_theme_template, false );
47
-			if( !empty($path) ) {
46
+			$path = locate_template($check_theme_template, false);
47
+			if (!empty($path)) {
48 48
 				break;
49 49
 			}
50 50
 		}
51 51
 
52 52
 		/**	Allow debugging	*/
53
-		if ( !empty( $debug ) ) {
53
+		if (!empty($debug)) {
54 54
 			echo '--- Debug mode ON - Start ---<br/>';
55 55
 			echo __FILE__ . '<br/>';
56 56
 			echo 'Debug for display method<br/>';
57 57
 			echo 'Asked path ' . $path . '<br/>';
58 58
 		}
59 59
 
60
-		if ( empty( $path ) ) {
61
-			foreach ( (array) $templates as $template_name ) {
62
-				if ( !$template_name )
60
+		if (empty($path)) {
61
+			foreach ((array)$templates as $template_name) {
62
+				if (!$template_name)
63 63
 					continue;
64 64
 
65
-				if ( !empty( $debug ) ) {
65
+				if (!empty($debug)) {
66 66
 					echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>';
67 67
 				}
68 68
 
69
-				$file_exists = file_exists( $main_template_dir . $template_name );
70
-				if ( $file_exists ) {
69
+				$file_exists = file_exists($main_template_dir . $template_name);
70
+				if ($file_exists) {
71 71
 					$path = $main_template_dir . $template_name;
72 72
 					break;
73 73
 				}
74 74
 
75
-				if ( !empty( $debug ) ) {
75
+				if (!empty($debug)) {
76 76
 					echo __LINE__ . ' - ' . (bool)$file_exists . '<hr/>';
77 77
 				}
78 78
 			}
79 79
 		}
80 80
 
81 81
 		/**	Allow debugging	*/
82
-		if ( !empty( $debug ) ) {
82
+		if (!empty($debug)) {
83 83
 			echo '--- Debug mode ON - END ---<br/><br/>';
84 84
 		}
85 85
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 *	@return mixed $sanitizedVar The var after treatment
104 104
 	 */
105 105
 	public static function varSanitizer($varToSanitize, $varDefaultValue = '', $varType = '') {
106
-		$sanitizedVar = is_string( $varToSanitize ) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue ;
106
+		$sanitizedVar = is_string($varToSanitize) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue;
107 107
 
108 108
 		return $sanitizedVar;
109 109
 	}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	public static function forceDownload($Fichier_a_telecharger, $delete_after_download = false) {
117 117
 
118 118
 		$nom_fichier = basename($Fichier_a_telecharger);
119
-		switch(strrchr($nom_fichier, ".")) {
119
+		switch (strrchr($nom_fichier, ".")) {
120 120
 			case ".gz": $type = "application/x-gzip"; break;
121 121
 			case ".tgz": $type = "application/x-gzip"; break;
122 122
 			case ".zip": $type = "application/zip"; break;
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
 		header("Content-disposition: attachment; filename=$nom_fichier");
134 134
 		header("Content-Type: application/force-download");
135 135
 		header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n
136
-		header("Content-Length: ".filesize($Fichier_a_telecharger));
136
+		header("Content-Length: " . filesize($Fichier_a_telecharger));
137 137
 		header("Pragma: no-cache");
138 138
 		header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
139 139
 		header("Expires: 0");
140 140
 		ob_end_clean();
141 141
 		readfile($Fichier_a_telecharger);
142
-		if ( $delete_after_download ) {
143
-			unlink( $Fichier_a_telecharger );
142
+		if ($delete_after_download) {
143
+			unlink($Fichier_a_telecharger);
144 144
 		}
145 145
 		exit;
146 146
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @return boolean
151 151
 	 */
152 152
 	public static function is_sendsms_actived() {
153
-		if(is_plugin_active('wordpress-send-sms/Send-SMS.php')) {
153
+		if (is_plugin_active('wordpress-send-sms/Send-SMS.php')) {
154 154
 			$configOption = get_option('sendsms_config', '');
155 155
 			$ligne = unserialize($configOption);
156 156
 			$nicOVH = $ligne['nicOVH'];
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param unknown_type $input
168 168
 	 * @return Ambigous <multitype:, multitype:multitype:unknown  >
169 169
 	 */
170
-	public static function search_all_possibilities( $input ) {
170
+	public static function search_all_possibilities($input) {
171 171
 		$result = array();
172 172
 
173 173
 		while (list($key, $values) = each($input)) {
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
 			}
177 177
 
178 178
 			if (empty($result)) {
179
-				foreach($values as $value) {
179
+				foreach ($values as $value) {
180 180
 					$result[] = array($key => $value);
181 181
 				}
182 182
 			}
183 183
 			else {
184 184
 				$append = array();
185
-				foreach($result as &$product) {
185
+				foreach ($result as &$product) {
186 186
 					$product[$key] = array_shift($values);
187 187
 					$copy = $product;
188 188
 
189
-					foreach($values as $item) {
189
+					foreach ($values as $item) {
190 190
 						$copy[$key] = $item;
191 191
 						$append[] = $copy;
192 192
 					}
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 	 * @param boolean $code : false return sigle, true return code (€ or EUR)
207 207
 	 * @return string currency code or sigle
208 208
 	 */
209
-	public static function wpshop_get_currency($code=false) {
209
+	public static function wpshop_get_currency($code = false) {
210 210
 		// Currency
211
-		if( is_null( self::$currency_cache ) ) {
211
+		if (is_null(self::$currency_cache)) {
212 212
 			global $wpdb;
213 213
 			$current_currency = get_option('wpshop_shop_default_currency');
214
-			$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
215
-			self::$currency_cache = $wpdb->get_row( $query );
214
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
215
+			self::$currency_cache = $wpdb->get_row($query);
216 216
 		}
217
-		if ( !empty(self::$currency_cache) ) {
218
-			$code = ($code) ?  self::$currency_cache->name : self::$currency_cache->unit;
217
+		if (!empty(self::$currency_cache)) {
218
+			$code = ($code) ? self::$currency_cache->name : self::$currency_cache->unit;
219 219
 			return $code;
220 220
 		}
221 221
 		else {
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	public static function wpshop_get_sigle($code, $column_to_return = "unit") {
232 232
 		$tmp_code = (int)$code;
233 233
 		$key_to_get = 'name';
234
-		if ( is_int($tmp_code) && !empty($tmp_code) ) {
234
+		if (is_int($tmp_code) && !empty($tmp_code)) {
235 235
 			$key_to_get = 'id';
236 236
 		}
237 237
 		$old_way_currencies = unserialize(WPSHOP_SHOP_CURRENCIES);
238
-		if ( array_key_exists( $code, $old_way_currencies)) {
238
+		if (array_key_exists($code, $old_way_currencies)) {
239 239
 			$code = $old_way_currencies[$code];
240 240
 			$key_to_get = 'name';
241 241
 		}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @param string $var : variable to clean
251 251
 	 * @return string
252 252
 	 */
253
-	public static function wpshop_clean( $var ) {
253
+	public static function wpshop_clean($var) {
254 254
 		return trim(strip_tags(stripslashes($var)));
255 255
 	}
256 256
 
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param   string	phone number
260 260
 	 * @return  boolean
261 261
 	 */
262
-	public static function is_phone( $phone ) {
263
-		return preg_match( '/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone );
262
+	public static function is_phone($phone) {
263
+		return preg_match('/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone);
264 264
 	}
265 265
 
266 266
 	/**
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param   string	postcode
269 269
 	 * @return  boolean
270 270
 	 */
271
-	public static function is_postcode( $postcode ) {
272
-		return preg_match( '/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode );
271
+	public static function is_postcode($postcode) {
272
+		return preg_match('/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode);
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,14 +279,14 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 *	@return string $type The form input type to use for the given field
281 281
 	 */
282
-	public static function defineFieldType($dataFieldType, $input_type, $frontend_verification){
282
+	public static function defineFieldType($dataFieldType, $input_type, $frontend_verification) {
283 283
 		$type = 'text';
284 284
 
285
-		if ( $dataFieldType == 'datetime' ) {
285
+		if ($dataFieldType == 'datetime') {
286 286
 			$type = 'text';
287 287
 		}
288 288
 		else {
289
-			switch ( $frontend_verification ) {
289
+			switch ($frontend_verification) {
290 290
 				case 'phone':
291 291
 					$type = 'tel';
292 292
 					break;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @return array The different element send by request method
308 308
 	 */
309
-	public static function getMethode(){
309
+	public static function getMethode() {
310 310
 		$request_method = null;
311 311
 		if ($_SERVER["REQUEST_METHOD"] == "GET") {
312 312
 			$request_method = (array)$_GET;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 			$request_method = (array)$_POST;
316 316
 		}
317 317
 
318
-		if ( null === $request_method ) {
318
+		if (null === $request_method) {
319 319
 			die ('Invalid REQUEST_METHOD (not GET, not POST).');
320 320
 		}
321 321
 		else {
@@ -331,36 +331,36 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 *	@return string $slugified The input string that was slugified with the selected method
333 333
 	 */
334
-	public static function slugify($toSlugify, $slugifyType){
334
+	public static function slugify($toSlugify, $slugifyType) {
335 335
 		$slugified = '';
336 336
 
337
-		if($toSlugify != '')
337
+		if ($toSlugify != '')
338 338
 		{
339 339
 			$slugified = $toSlugify;
340
-			foreach($slugifyType as $type)
340
+			foreach ($slugifyType as $type)
341 341
 			{
342
-				if($type == 'noAccent')
342
+				if ($type == 'noAccent')
343 343
 				{
344
-					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
345
-					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
344
+					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
345
+					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U", "e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
346 346
 				}
347
-				elseif($type == 'noSpaces')
347
+				elseif ($type == 'noSpaces')
348 348
 				{
349 349
 					$pattern = array('/\s/');
350 350
 					$rep_pat = array('_');
351 351
 					$slugified = trim($slugified);
352 352
 				}
353
-				elseif($type == 'lowerCase')
353
+				elseif ($type == 'lowerCase')
354 354
 				{
355 355
 					$slugified = strtolower($slugified);
356 356
 				}
357
-				elseif($type == 'noPunctuation')
357
+				elseif ($type == 'noPunctuation')
358 358
 				{
359 359
 					$pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//");
360 360
 					$rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_");
361 361
 				}
362 362
 
363
-				if(is_array($pattern) && is_array($rep_pat))
363
+				if (is_array($pattern) && is_array($rep_pat))
364 364
 				{
365 365
 					$slugified = preg_replace($pattern, $rep_pat, utf8_decode($slugified));
366 366
 				}
@@ -379,17 +379,17 @@  discard block
 block discarded – undo
379 379
 	 *	@return string $string The output string that was trunk if necessary
380 380
 	 */
381 381
 	public static function trunk($string, $maxlength) {
382
-		if(strlen($string)>$maxlength+3)
383
-			return substr($string,0,$maxlength).'...';
382
+		if (strlen($string) > $maxlength + 3)
383
+			return substr($string, 0, $maxlength) . '...';
384 384
 		else return $string;
385 385
 	}
386 386
 
387 387
 	/**
388 388
 	 * Run a safe redirect in javascript
389 389
 	 */
390
-	public static function wpshop_safe_redirect($url='') {
391
-		$url = empty($url) ? admin_url('admin.php?page='.WPSHOP_URL_SLUG_DASHBOARD) : $url;
392
-		echo '<script type="text/javascript">window.top.location.href = "'.$url.'"</script>';
390
+	public static function wpshop_safe_redirect($url = '') {
391
+		$url = empty($url) ? admin_url('admin.php?page=' . WPSHOP_URL_SLUG_DASHBOARD) : $url;
392
+		echo '<script type="text/javascript">window.top.location.href = "' . $url . '"</script>';
393 393
 		exit;
394 394
 	}
395 395
 
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 	 * @param array $args : Hook arguments
400 400
 	 * @return string
401 401
 	 */
402
-	public static function create_custom_hook ($hook_name, $args = '') {
402
+	public static function create_custom_hook($hook_name, $args = '') {
403 403
 		ob_start();
404
-		if ( !empty($args) ) {
404
+		if (!empty($args)) {
405 405
 			do_action($hook_name, $args);
406 406
 		}
407 407
 		else {
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) {
422 422
 		$code = '';
423
-		if ( !function_exists( 'get_plugin_data') )
424
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
425
-		$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
423
+		if (!function_exists('get_plugin_data'))
424
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
425
+		$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
426 426
 		$code_part = array();
427
-		$code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5);
428
-		$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
429
-		$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
427
+		$code_part[] = substr(hash("sha256", $plugin_name), WPSHOP_ADDONS_KEY_IS, 5);
428
+		$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
429
+		$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
430 430
 		$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
431 431
 		$att = $encrypt_base_attribute;
432
-		$code .= '-' . substr(hash ( "sha256" , $att ),  WPSHOP_ADDONS_KEY_IS, 5);
432
+		$code .= '-' . substr(hash("sha256", $att), WPSHOP_ADDONS_KEY_IS, 5);
433 433
 
434 434
 		return $code;
435 435
 	}
@@ -440,15 +440,15 @@  discard block
 block discarded – undo
440 440
 	 * @param string $encrypt_base_attribute
441 441
 	 * @return boolean
442 442
 	 */
443
-	public static function check_plugin_activation_code( $plugin_name, $encrypt_base_attribute, $from = 'file') {
443
+	public static function check_plugin_activation_code($plugin_name, $encrypt_base_attribute, $from = 'file') {
444 444
 		$is_valid = false;
445 445
 		$valid_activation_code = self::get_plugin_validation_code($plugin_name, $encrypt_base_attribute);
446
-		$activation_code_filename = WP_PLUGIN_DIR .'/'. $plugin_name.'/encoder.txt';
447
-		if ( is_file($activation_code_filename) ) {
448
-			$activation_code_file = fopen($activation_code_filename, 'r' );
449
-			if ( $activation_code_file !== false) {
450
-				$activation_code = fread( $activation_code_file, filesize($activation_code_filename));
451
-				if ( $activation_code == $valid_activation_code ) {
446
+		$activation_code_filename = WP_PLUGIN_DIR . '/' . $plugin_name . '/encoder.txt';
447
+		if (is_file($activation_code_filename)) {
448
+			$activation_code_file = fopen($activation_code_filename, 'r');
449
+			if ($activation_code_file !== false) {
450
+				$activation_code = fread($activation_code_file, filesize($activation_code_filename));
451
+				if ($activation_code == $valid_activation_code) {
452 452
 					$is_valid = true;
453 453
 				}
454 454
 			}
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
 	 * @param unknown_type $number
462 462
 	 * @return string
463 463
 	 */
464
-	public static function formate_number( $number ) {
465
-		$number = number_format( $number, 2, '.', '' );
466
-		$exploded_number = explode( '.', $number );
464
+	public static function formate_number($number) {
465
+		$number = number_format($number, 2, '.', '');
466
+		$exploded_number = explode('.', $number);
467 467
 		$number = $exploded_number[0];
468
-		if( $exploded_number[1] != '00' ) {
469
-			$number .= '<span class="wps_number_cents">,' . $exploded_number[1]. '</span>';
468
+		if ($exploded_number[1] != '00') {
469
+			$number .= '<span class="wps_number_cents">,' . $exploded_number[1] . '</span>';
470 470
 		}
471 471
 		return $number;
472 472
 	}
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 	 * @param int $page_id
477 477
 	 * @return int
478 478
 	 */
479
-	public static function get_page_id( $page_id ) {
480
-		if( !empty($page_id) ) {
481
-			if ( function_exists( 'icl_object_id' ) && defined('ICL_LANGUAGE_CODE') ) {
482
-				$element_post_type = get_post_type( $page_id );
483
-				$translated_element_id = icl_object_id( $page_id, $element_post_type, true, ICL_LANGUAGE_CODE );
484
-				if( !empty($translated_element_id) ) {
479
+	public static function get_page_id($page_id) {
480
+		if (!empty($page_id)) {
481
+			if (function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE')) {
482
+				$element_post_type = get_post_type($page_id);
483
+				$translated_element_id = icl_object_id($page_id, $element_post_type, true, ICL_LANGUAGE_CODE);
484
+				if (!empty($translated_element_id)) {
485 485
 					$page_id = $translated_element_id;
486 486
 				}
487 487
 			}
@@ -489,65 +489,65 @@  discard block
 block discarded – undo
489 489
 		return $page_id;
490 490
 	}
491 491
 
492
-	public static function minutes_to_time( $minutes, $format = '%hh %imin' ) {
493
-		$dtF = new \DateTime( '@0' );
494
-		$dtT = new \DateTime( '@' . ( $minutes * 60 ) );
495
-		return $dtF->diff($dtT)->format( $format );
492
+	public static function minutes_to_time($minutes, $format = '%hh %imin') {
493
+		$dtF = new \DateTime('@0');
494
+		$dtT = new \DateTime('@' . ($minutes * 60));
495
+		return $dtF->diff($dtT)->format($format);
496 496
 	}
497 497
 
498 498
 	public static function number_format_hack($n) {
499 499
 		return number_format($n, 5, '.', '');
500 500
 	}
501
-	public static function is_serialized( $data, $strict = true ) {
502
-		if ( ! is_string( $data ) ) {
501
+	public static function is_serialized($data, $strict = true) {
502
+		if (!is_string($data)) {
503 503
 			return false;
504 504
 		}
505
-		$data = trim( $data );
506
-		if ( 'N;' == $data ) {
505
+		$data = trim($data);
506
+		if ('N;' == $data) {
507 507
 			return true;
508 508
 		}
509
-		if ( strlen( $data ) < 4 ) {
509
+		if (strlen($data) < 4) {
510 510
 			return false;
511 511
 		}
512
-		if ( ':' !== $data[1] ) {
512
+		if (':' !== $data[1]) {
513 513
 			return false;
514 514
 		}
515
-		if ( $strict ) {
516
-			$lastc = substr( $data, -1 );
517
-			if ( ';' !== $lastc && '}' !== $lastc ) {
515
+		if ($strict) {
516
+			$lastc = substr($data, -1);
517
+			if (';' !== $lastc && '}' !== $lastc) {
518 518
 				return false;
519 519
 			}
520 520
 		} else {
521
-			$semicolon = strpos( $data, ';' );
522
-			$brace = strpos( $data, '}' );
523
-			if ( false === $semicolon && false === $brace ) {
521
+			$semicolon = strpos($data, ';');
522
+			$brace = strpos($data, '}');
523
+			if (false === $semicolon && false === $brace) {
524 524
 				return false;
525 525
 			}
526
-			if ( false !== $semicolon && $semicolon < 3 ) {
526
+			if (false !== $semicolon && $semicolon < 3) {
527 527
 				return false;
528 528
 			}
529
-			if ( false !== $brace && $brace < 4 ) {
529
+			if (false !== $brace && $brace < 4) {
530 530
 				return false;
531 531
 			}
532 532
 		}
533 533
 		$token = $data[0];
534
-		switch ( $token ) {
534
+		switch ($token) {
535 535
 			case 's' :
536
-				if ( $strict ) {
537
-					if ( '"' !== substr( $data, -2, 1 ) ) {
536
+				if ($strict) {
537
+					if ('"' !== substr($data, -2, 1)) {
538 538
 						return false;
539 539
 					}
540
-				} elseif ( false === strpos( $data, '"' ) ) {
540
+				} elseif (false === strpos($data, '"')) {
541 541
 					return false;
542 542
 				}
543 543
 			case 'a' :
544 544
 			case 'O' :
545
-				return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
545
+				return (bool)preg_match("/^{$token}:[0-9]+:/s", $data);
546 546
 			case 'b' :
547 547
 			case 'i' :
548 548
 			case 'd' :
549 549
 				$end = $strict ? '$' : '';
550
-				return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
550
+				return (bool)preg_match("/^{$token}:[0-9.E-]+;$end/", $data);
551 551
 		}
552 552
 		return false;
553 553
 	}
Please login to merge, or discard this patch.
Braces   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for product mass modification module
4 6
  *
@@ -35,8 +37,9 @@  discard block
 block discarded – undo
35 37
 
36 38
 		$templates = array();
37 39
 		$name = (string)$name;
38
-		if ( '' !== $name )
39
-			$templates[] = "{$side}/{$slug}-{$name}.php";
40
+		if ( '' !== $name ) {
41
+					$templates[] = "{$side}/{$slug}-{$name}.php";
42
+		}
40 43
 		$templates[] = "{$side}/{$slug}.php";
41 44
 
42 45
 		/**	Check if required template exists into current theme	*/
@@ -59,8 +62,9 @@  discard block
 block discarded – undo
59 62
 
60 63
 		if ( empty( $path ) ) {
61 64
 			foreach ( (array) $templates as $template_name ) {
62
-				if ( !$template_name )
63
-					continue;
65
+				if ( !$template_name ) {
66
+									continue;
67
+				}
64 68
 
65 69
 				if ( !empty( $debug ) ) {
66 70
 					echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>';
@@ -179,8 +183,7 @@  discard block
 block discarded – undo
179 183
 				foreach($values as $value) {
180 184
 					$result[] = array($key => $value);
181 185
 				}
182
-			}
183
-			else {
186
+			} else {
184 187
 				$append = array();
185 188
 				foreach($result as &$product) {
186 189
 					$product[$key] = array_shift($values);
@@ -217,8 +220,7 @@  discard block
 block discarded – undo
217 220
 		if ( !empty(self::$currency_cache) ) {
218 221
 			$code = ($code) ?  self::$currency_cache->name : self::$currency_cache->unit;
219 222
 			return $code;
220
-		}
221
-		else {
223
+		} else {
222 224
 			return '';
223 225
 		}
224 226
 	}
@@ -284,8 +286,7 @@  discard block
 block discarded – undo
284 286
 
285 287
 		if ( $dataFieldType == 'datetime' ) {
286 288
 			$type = 'text';
287
-		}
288
-		else {
289
+		} else {
289 290
 			switch ( $frontend_verification ) {
290 291
 				case 'phone':
291 292
 					$type = 'tel';
@@ -317,8 +318,7 @@  discard block
 block discarded – undo
317 318
 
318 319
 		if ( null === $request_method ) {
319 320
 			die ('Invalid REQUEST_METHOD (not GET, not POST).');
320
-		}
321
-		else {
321
+		} else {
322 322
 			return $request_method;
323 323
 		}
324 324
 	}
@@ -343,18 +343,15 @@  discard block
 block discarded – undo
343 343
 				{
344 344
 					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
345 345
 					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
346
-				}
347
-				elseif($type == 'noSpaces')
346
+				} elseif($type == 'noSpaces')
348 347
 				{
349 348
 					$pattern = array('/\s/');
350 349
 					$rep_pat = array('_');
351 350
 					$slugified = trim($slugified);
352
-				}
353
-				elseif($type == 'lowerCase')
351
+				} elseif($type == 'lowerCase')
354 352
 				{
355 353
 					$slugified = strtolower($slugified);
356
-				}
357
-				elseif($type == 'noPunctuation')
354
+				} elseif($type == 'noPunctuation')
358 355
 				{
359 356
 					$pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//");
360 357
 					$rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_");
@@ -379,9 +376,11 @@  discard block
 block discarded – undo
379 376
 	 *	@return string $string The output string that was trunk if necessary
380 377
 	 */
381 378
 	public static function trunk($string, $maxlength) {
382
-		if(strlen($string)>$maxlength+3)
383
-			return substr($string,0,$maxlength).'...';
384
-		else return $string;
379
+		if(strlen($string)>$maxlength+3) {
380
+					return substr($string,0,$maxlength).'...';
381
+		} else {
382
+			return $string;
383
+		}
385 384
 	}
386 385
 
387 386
 	/**
@@ -403,8 +402,7 @@  discard block
 block discarded – undo
403 402
 		ob_start();
404 403
 		if ( !empty($args) ) {
405 404
 			do_action($hook_name, $args);
406
-		}
407
-		else {
405
+		} else {
408 406
 			do_action($hook_name);
409 407
 		}
410 408
 		$content = ob_get_contents();
@@ -420,8 +418,9 @@  discard block
 block discarded – undo
420 418
 	 */
421 419
 	public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) {
422 420
 		$code = '';
423
-		if ( !function_exists( 'get_plugin_data') )
424
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
421
+		if ( !function_exists( 'get_plugin_data') ) {
422
+					require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
423
+		}
425 424
 		$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
426 425
 		$code_part = array();
427 426
 		$code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5);
Please login to merge, or discard this patch.
templates/backend/product-listing/wps_orders_product_listing_table.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,78 +1,78 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- $order_post_meta = !empty($post) ? get_post_meta( $post->ID, '_wpshop_order_status', true ) : ""; ?>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ $order_post_meta = !empty($post) ? get_post_meta($post->ID, '_wpshop_order_status', true) : ""; ?>
3 3
 <div class="wps-table">
4 4
 	<div class="wps-table-header wps-table-row">
5
-		<div class="wps-table-cell"><?php _e( 'Picture', 'wpshop'); ?></div>
6
-		<div class="wps-table-cell"><?php _e( 'Product reference', 'wpshop'); ?></div>
7
-		<div class="wps-table-cell"><?php _e( 'Product name', 'wpshop'); ?></div>
8
-		<div class="wps-table-cell"><?php _e( 'Price', 'wpshop'); ?></div>
5
+		<div class="wps-table-cell"><?php _e('Picture', 'wpshop'); ?></div>
6
+		<div class="wps-table-cell"><?php _e('Product reference', 'wpshop'); ?></div>
7
+		<div class="wps-table-cell"><?php _e('Product name', 'wpshop'); ?></div>
8
+		<div class="wps-table-cell"><?php _e('Price', 'wpshop'); ?></div>
9 9
 
10
-		<?php if ( 'completed' != $order_post_meta ) : ?>
11
-			<div class="wps-table-cell"><?php _e( 'Quantity', 'wpshop'); ?></div>
12
-			<div class="wps-table-cell"><?php _e( 'Add to order', 'wpshop'); ?></div>
10
+		<?php if ('completed' != $order_post_meta) : ?>
11
+			<div class="wps-table-cell"><?php _e('Quantity', 'wpshop'); ?></div>
12
+			<div class="wps-table-cell"><?php _e('Add to order', 'wpshop'); ?></div>
13 13
 		<?php endif; ?>
14 14
 	</div>
15
-	<?php if( !empty($products) ) :
16
-		$total_products = count( $products );
15
+	<?php if (!empty($products)) :
16
+		$total_products = count($products);
17 17
 		$i = 0;
18 18
 		$elements_per_page = 20;
19
-		$paged = absint( isset( $_REQUEST['paged_order'] ) ? $_REQUEST['paged_order'] : 1 );
20
-		$paginate_links = paginate_links( array(
19
+		$paged = absint(isset($_REQUEST['paged_order']) ? $_REQUEST['paged_order'] : 1);
20
+		$paginate_links = paginate_links(array(
21 21
 			'base' => '%_%',
22 22
 			'format' => '?paged_order=%#%',
23 23
 			'current' => $paged,
24
-			'total' => ceil( $total_products / $elements_per_page )
25
-		) );
26
-		foreach ( $products as $product ) :
27
-			if( ( $elements_per_page * ( $paged - 1 ) ) > $i ) {
24
+			'total' => ceil($total_products / $elements_per_page)
25
+		));
26
+		foreach ($products as $product) :
27
+			if (($elements_per_page * ($paged - 1)) > $i) {
28 28
 				$i++;
29 29
 				continue;
30
-			} elseif ( ( $elements_per_page * $paged ) <= $i ) {
30
+			} elseif (($elements_per_page * $paged) <= $i) {
31 31
 				break;
32 32
 			}
33 33
 			$i++;
34 34
 			$pid = $product->ID;
35 35
 	?>
36
-	<?php $product_metadata = get_post_meta( $product->ID, '_wpshop_product_metadata', true ); ?>
36
+	<?php $product_metadata = get_post_meta($product->ID, '_wpshop_product_metadata', true); ?>
37 37
 	<div class="wps-table-content wps-table-row">
38
-		<div class="wps-table-cell  wps-cart-item-img"><?php echo get_the_post_thumbnail( $product->ID, 'thumbnail' ); ?></div>
39
-		<div class="wps-table-cell"><?php echo ( !empty( $product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div>
38
+		<div class="wps-table-cell  wps-cart-item-img"><?php echo get_the_post_thumbnail($product->ID, 'thumbnail'); ?></div>
39
+		<div class="wps-table-cell"><?php echo (!empty($product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div>
40 40
 		<div class="wps-table-cell"><?php echo $product->post_title; ?></div>
41 41
 		<div class="wps-table-cell">
42 42
 		<?php
43 43
 			$product = wpshop_products::get_product_data($product->ID);
44
-			echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid') );
44
+			echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid'));
45 45
 		?>
46 46
 		</div>
47
-		<?php if ( 'completed' != $order_post_meta ) : ?>
47
+		<?php if ('completed' != $order_post_meta) : ?>
48 48
 			<div class="wps-table-cell">
49
-				<a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a>
49
+				<a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a>
50 50
 				<input id="wps-cart-product-qty-<?php echo $pid; ?>" class="wps-cart-product-qty" type="text" value="1" name="french-hens" size="3" style="text-align : center">
51
-				<a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a>
51
+				<a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a>
52 52
 			</div>
53 53
 			<div class="wps-table-cell">
54
-				<a href="#" data-nonce="<?php echo wp_create_nonce( 'wps_add_product_to_order_admin' ); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e( 'Add to order', 'wpshop'); ?></a>
54
+				<a href="#" data-nonce="<?php echo wp_create_nonce('wps_add_product_to_order_admin'); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e('Add to order', 'wpshop'); ?></a>
55 55
 			</div>
56 56
 		<?php endif; ?>
57 57
 	</div>
58 58
 	<?php endforeach;
59 59
 	else :
60
-		if( !empty( $research ) ) : ?>
61
-		<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research ); ?></div>
60
+		if (!empty($research)) : ?>
61
+		<div class="wps-alert-info"><?php printf(__('No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research); ?></div>
62 62
 	<?php else :
63
-			$letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __('ALL', 'wpshop' ); ?>
64
-			<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper( $letter_display ) ); ?></div>
63
+			$letter_display = (strtoupper($current_letter) != 'ALL') ? $current_letter : __('ALL', 'wpshop'); ?>
64
+			<div class="wps-alert-info"><?php printf(__('No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper($letter_display)); ?></div>
65 65
 	<?php endif;
66 66
 		endif; ?>
67 67
 </div>
68 68
 <?php
69
-if( !empty($products) && $total_products > $elements_per_page ) :
69
+if (!empty($products) && $total_products > $elements_per_page) :
70 70
 	echo $paginate_links;
71 71
 	?>
72 72
 	<input type="hidden" name="last_query[oid]" value="<?php echo $post->ID; ?>">
73
-	<input type="hidden" name="last_query[letter]" value="<?php echo strtoupper( $current_letter ); ?>">
73
+	<input type="hidden" name="last_query[letter]" value="<?php echo strtoupper($current_letter); ?>">
74 74
 	<input type="hidden" name="last_query[research]" value="<?php echo $research; ?>">
75
-	<input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce( 'refresh_product_list_'.strtolower($current_letter) ); ?>">
75
+	<input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce('refresh_product_list_' . strtolower($current_letter)); ?>">
76 76
 	<?php
77 77
 endif;
78 78
 ?>
Please login to merge, or discard this patch.
includes/modules/wps_payment_mode/templates/frontend/payment-modes.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) { exit;
1
+<?php if (!defined('ABSPATH')) { exit;
2 2
 }
3 3
 ?>
4
-<div><span class="wps-h2"><?php _e( 'Payment mode choice', 'wpshop' ); ?> :</span></div>
5
-<?php if ( ! empty( $payment_modes ) ) : ?>
6
-<?php $count_payment_mode = count( $payment_modes ); ?>
7
-<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce( 'wps_load_shipping_methods' ); ?>">
8
-	<?php foreach ( $payment_modes as $payment_mode_id => $payment_mode ) : ?>
9
-		<?php if ( $default_choice == $payment_mode_id ) :
4
+<div><span class="wps-h2"><?php _e('Payment mode choice', 'wpshop'); ?> :</span></div>
5
+<?php if (!empty($payment_modes)) : ?>
6
+<?php $count_payment_mode = count($payment_modes); ?>
7
+<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce('wps_load_shipping_methods'); ?>">
8
+	<?php foreach ($payment_modes as $payment_mode_id => $payment_mode) : ?>
9
+		<?php if ($default_choice == $payment_mode_id) :
10 10
 			$class = 'wps-activ';
11 11
 			$checked = 'checked="checked"';
12 12
 else :
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 endif; ?>
15 15
 		<li class="<?php echo $class; ?> wps-bloc-loader">
16 16
 			<label>
17
-				<span><input type="radio" name="wps-payment-method" value="<?php echo $payment_mode_id; ?>" id="<?php echo $payment_mode_id ; ?>" <?php echo $checked; ?> /></span>
17
+				<span><input type="radio" name="wps-payment-method" value="<?php echo $payment_mode_id; ?>" id="<?php echo $payment_mode_id; ?>" <?php echo $checked; ?> /></span>
18 18
 				<span class="wps-shipping-method-logo">
19
-					<?php echo ( ! empty( $payment_mode['logo'] ) ? ( (strstr( $payment_mode['logo'], 'http://' ) === false ) ? wp_get_attachment_image( $payment_mode['logo'], 'full' ) : '<img src="' . $payment_mode['logo'] . '" alt="" />' ) : '' ); ?>
19
+					<?php echo (!empty($payment_mode['logo']) ? ((strstr($payment_mode['logo'], 'http://') === false) ? wp_get_attachment_image($payment_mode['logo'], 'full') : '<img src="' . $payment_mode['logo'] . '" alt="" />') : ''); ?>
20 20
 				</span>
21
-				<span class="wps-shipping-method-name"><strong><?php _e( $payment_mode['name'], 'wpshop' ); ?></strong></span>
21
+				<span class="wps-shipping-method-name"><strong><?php _e($payment_mode['name'], 'wpshop'); ?></strong></span>
22 22
 			</label>
23 23
 			<div class="wps-itemList-content">
24
-				<?php _e( $payment_mode['description'], 'wpshop' ); ?>
24
+				<?php _e($payment_mode['description'], 'wpshop'); ?>
25 25
 			</div>
26 26
 		</li>
27 27
 	<?php endforeach; ?>
28 28
 </ul>
29 29
 <?php else : ?>
30
-	<div class="wps-alert-info"><?php _e( 'No payment mode available', 'wpshop' ); ?>	</div>
30
+	<div class="wps-alert-info"><?php _e('No payment mode available', 'wpshop'); ?>	</div>
31 31
 <?php endif; ?>
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,8 +9,10 @@  discard block
 block discarded – undo
9 9
 		<?php if ( $default_choice == $payment_mode_id ) :
10 10
 			$class = 'wps-activ';
11 11
 			$checked = 'checked="checked"';
12
-else :
12
+else {
13
+	:
13 14
 			$checked = $class = '';
15
+}
14 16
 endif; ?>
15 17
 		<li class="<?php echo $class; ?> wps-bloc-loader">
16 18
 			<label>
@@ -26,6 +28,9 @@  discard block
 block discarded – undo
26 28
 		</li>
27 29
 	<?php endforeach; ?>
28 30
 </ul>
29
-<?php else : ?>
30
-	<div class="wps-alert-info"><?php _e( 'No payment mode available', 'wpshop' ); ?>	</div>
31
+<?php else {
32
+	: ?>
33
+	<div class="wps-alert-info"><?php _e( 'No payment mode available', 'wpshop' );
34
+}
35
+?>	</div>
31 36
 <?php endif; ?>
Please login to merge, or discard this patch.
includes/modules/wps_cart/controller/wps_cart_ctr.php 1 patch
Spacing   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -1,48 +1,48 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_cart {
3 3
 
4 4
 	function __construct() {
5 5
 		/** WPShop Cart Shortcode **/
6
-		add_shortcode( 'wps_cart', array( &$this, 'display_cart' ) );
7
-		add_shortcode( 'wpshop_cart', array( &$this, 'display_cart' ) );
6
+		add_shortcode('wps_cart', array(&$this, 'display_cart'));
7
+		add_shortcode('wpshop_cart', array(&$this, 'display_cart'));
8 8
 		/** WPShop Mini Cart Shortcode **/
9
-		add_shortcode( 'wps_mini_cart', array( &$this, 'display_mini_cart' ) );
10
-		add_shortcode( 'wpshop_mini_cart', array( &$this, 'display_mini_cart' ) );
9
+		add_shortcode('wps_mini_cart', array(&$this, 'display_mini_cart'));
10
+		add_shortcode('wpshop_mini_cart', array(&$this, 'display_mini_cart'));
11 11
 		/** WPShop Resume Cart Shorcode **/
12
-		add_shortcode( 'wps_resume_cart', array( &$this, 'display_resume_cart' ) );
13
-		add_shortcode( 'wpshop_resume_cart', array( &$this, 'display_resume_cart' ) );
12
+		add_shortcode('wps_resume_cart', array(&$this, 'display_resume_cart'));
13
+		add_shortcode('wpshop_resume_cart', array(&$this, 'display_resume_cart'));
14 14
 		/** Apply Coupon Interface **/
15
-		add_shortcode( 'wps_apply_coupon', array( &$this, 'display_apply_coupon_interface' ) );
16
-		add_shortcode( 'wpshop_apply_coupon', array( &$this, 'display_apply_coupon_interface' ) );
15
+		add_shortcode('wps_apply_coupon', array(&$this, 'display_apply_coupon_interface'));
16
+		add_shortcode('wpshop_apply_coupon', array(&$this, 'display_apply_coupon_interface'));
17 17
 		/** NUmeration Cart **/
18
-		add_shortcode( 'wps-numeration-cart', array( &$this, 'display_wps_numeration_cart' ) );
19
-		add_shortcode( 'wpshop-numeration-cart', array( &$this, 'display_wps_numeration_cart' ) );
18
+		add_shortcode('wps-numeration-cart', array(&$this, 'display_wps_numeration_cart'));
19
+		add_shortcode('wpshop-numeration-cart', array(&$this, 'display_wps_numeration_cart'));
20 20
 		/** Button add to cart */
21
-		add_shortcode( 'wpshop_button_add_to_cart', array( &$this, 'display_button_add_to_cart' ) );
21
+		add_shortcode('wpshop_button_add_to_cart', array(&$this, 'display_button_add_to_cart'));
22 22
 
23
-		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
24
-		add_action( 'init', array( $this, 'load_cart_from_db' ) );
23
+		add_action('wp_enqueue_scripts', array($this, 'add_scripts'));
24
+		add_action('init', array($this, 'load_cart_from_db'));
25 25
 
26 26
 		/** Ajax Actions **/
27
-		add_action( 'wp_ajax_wps_reload_cart', array( $this, 'wps_reload_cart' ) );
28
-		add_action( 'wp_ajax_nopriv_wps_reload_cart', array( $this, 'wps_reload_cart' ) );
27
+		add_action('wp_ajax_wps_reload_cart', array($this, 'wps_reload_cart'));
28
+		add_action('wp_ajax_nopriv_wps_reload_cart', array($this, 'wps_reload_cart'));
29 29
 
30
-		add_action( 'wp_ajax_wps_reload_mini_cart', array( &$this, 'wps_reload_mini_cart' ) );
31
-		add_action( 'wp_ajax_nopriv_wps_reload_mini_cart', array( &$this, 'wps_reload_mini_cart' ) );
30
+		add_action('wp_ajax_wps_reload_mini_cart', array(&$this, 'wps_reload_mini_cart'));
31
+		add_action('wp_ajax_nopriv_wps_reload_mini_cart', array(&$this, 'wps_reload_mini_cart'));
32 32
 
33
-		add_action( 'wp_ajax_wps_reload_summary_cart', array( &$this, 'wps_reload_summary_cart' ) );
34
-		add_action( 'wp_ajax_nopriv_wps_reload_summary_cart', array( &$this, 'wps_reload_summary_cart' ) );
33
+		add_action('wp_ajax_wps_reload_summary_cart', array(&$this, 'wps_reload_summary_cart'));
34
+		add_action('wp_ajax_nopriv_wps_reload_summary_cart', array(&$this, 'wps_reload_summary_cart'));
35 35
 
36
-		add_action( 'wp_ajax_wps_apply_coupon', array( &$this, 'wps_apply_coupon' ) );
37
-		add_action( 'wp_ajax_nopriv_wps_apply_coupon', array( &$this, 'wps_apply_coupon' ) );
36
+		add_action('wp_ajax_wps_apply_coupon', array(&$this, 'wps_apply_coupon'));
37
+		add_action('wp_ajax_nopriv_wps_apply_coupon', array(&$this, 'wps_apply_coupon'));
38 38
 
39
-		add_action( 'wp_ajax_wps_cart_pass_to_step_two', array( &$this, 'wps_cart_pass_to_step_two' ) );
40
-		add_action( 'wp_ajax_nopriv_wps_cart_pass_to_step_two', array( &$this, 'wps_cart_pass_to_step_two' ) );
39
+		add_action('wp_ajax_wps_cart_pass_to_step_two', array(&$this, 'wps_cart_pass_to_step_two'));
40
+		add_action('wp_ajax_nopriv_wps_cart_pass_to_step_two', array(&$this, 'wps_cart_pass_to_step_two'));
41 41
 
42
-		add_action( 'wp_ajax_wps_empty_cart', array( &$this, 'wps_empty_cart' ) );
43
-		add_action( 'wp_ajax_nopriv_wps_empty_cart', array( &$this, 'wps_empty_cart' ) );
42
+		add_action('wp_ajax_wps_empty_cart', array(&$this, 'wps_empty_cart'));
43
+		add_action('wp_ajax_nopriv_wps_empty_cart', array(&$this, 'wps_empty_cart'));
44 44
 
45
-		add_action( 'wsphop_options', array(&$this, 'declare_options' ), 8);
45
+		add_action('wsphop_options', array(&$this, 'declare_options'), 8);
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function add_scripts() {
52 52
 		wp_enqueue_script('jquery');
53
-		wp_enqueue_script( 'wps_cart_js',  WPS_CART_URL . WPS_CART_DIR.'/assets/frontend/js/wps_cart.js' );
53
+		wp_enqueue_script('wps_cart_js', WPS_CART_URL . WPS_CART_DIR . '/assets/frontend/js/wps_cart.js');
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * Declare Cart Options
58 58
 	 */
59
-	public static function declare_options () {
60
-		if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
61
-			$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
62
-			$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : '';
59
+	public static function declare_options() {
60
+		if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
61
+			$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
62
+			$old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : '';
63 63
 
64
-			if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' )
65
-				&& ( $old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation' ) ) {
64
+			if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation')
65
+				&& ($old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation')) {
66 66
 					/**	Add module option to wpshop general options	*/
67 67
 					register_setting('wpshop_options', 'wpshop_cart_option', array('wps_cart', 'wpshop_options_validate_cart_type'));
68 68
 					add_settings_field('wpshop_cart_type', __('Which type of cart do you want to display', 'wpshop'), array('wps_cart', 'wpshop_cart_type_field'), 'wpshop_cart_info', 'wpshop_cart_info');
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param unknown_type $input
76 76
 	 * @return unknown
77 77
 	 */
78
-	public static function wpshop_options_validate_cart_type( $input ) {
78
+	public static function wpshop_options_validate_cart_type($input) {
79 79
 		return $input;
80 80
 	}
81 81
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * Cart Options Fields
84 84
 	 */
85 85
 	public static function wpshop_cart_type_field() {
86
-		$cart_option = get_option( 'wpshop_cart_option' );
86
+		$cart_option = get_option('wpshop_cart_option');
87 87
 
88 88
 		$output  = '<select name="wpshop_cart_option[cart_type]">';
89
-		$output .= '<option value="simplified_ati" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_ati' ) ? 'selected="selected"' : ''). ' >' .__( 'Simplified cart ATI', 'wpshop'). '</option>';
90
-		$output .= '<option value="simplified_et" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_et' ) ? 'selected="selected"' : ''). ' >' .__( 'Simplified cart ET', 'wpshop'). '</option>';
91
-		$output .= '<option value="full_cart" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'full_cart' ) ? 'selected="selected"' : ''). ' >' .__( 'Full cart', 'wpshop'). '</option>';
89
+		$output .= '<option value="simplified_ati" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_ati') ? 'selected="selected"' : '') . ' >' . __('Simplified cart ATI', 'wpshop') . '</option>';
90
+		$output .= '<option value="simplified_et" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_et') ? 'selected="selected"' : '') . ' >' . __('Simplified cart ET', 'wpshop') . '</option>';
91
+		$output .= '<option value="full_cart" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'full_cart') ? 'selected="selected"' : '') . ' >' . __('Full cart', 'wpshop') . '</option>';
92 92
 		$output .= '</select>';
93 93
 
94 94
 		echo $output;
95 95
 	}
96 96
 
97 97
 	/** Display Cart **/
98
-	function display_cart( $args ) {
99
-		$cart_type = ( !empty($args) && !empty($args['cart_type']) ) ?  $args['cart_type']: '';
100
-		$oid =  ( !empty($args) && !empty($args['oid']) ) ?  $args['oid'] : '';
101
-		$output  = '<div id="wps_cart_container" data-nonce="' . wp_create_nonce( 'wps_reload_cart' ) . '" class="wps-bloc-loader wps-cart-wrapper">';
98
+	function display_cart($args) {
99
+		$cart_type = (!empty($args) && !empty($args['cart_type'])) ? $args['cart_type'] : '';
100
+		$oid = (!empty($args) && !empty($args['oid'])) ? $args['oid'] : '';
101
+		$output  = '<div id="wps_cart_container" data-nonce="' . wp_create_nonce('wps_reload_cart') . '" class="wps-bloc-loader wps-cart-wrapper">';
102 102
 		$output .= self::cart_content($cart_type, $oid);
103 103
 		$output .= '</div>';
104 104
 
@@ -106,84 +106,84 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 	/** Cart Content **/
109
-	public static function cart_content( $cart_type = '', $oid = '' ) {
109
+	public static function cart_content($cart_type = '', $oid = '') {
110 110
 		global $wpdb;
111 111
 		$output = '';
112 112
 		$account_origin = false;
113
-		$cart_option = get_option( 'wpshop_cart_option' );
114
-		$cart_option = ( !empty($cart_option) && !empty($cart_option['cart_type']) ) ? $cart_option['cart_type'] : 'simplified_ati';
113
+		$cart_option = get_option('wpshop_cart_option');
114
+		$cart_option = (!empty($cart_option) && !empty($cart_option['cart_type'])) ? $cart_option['cart_type'] : 'simplified_ati';
115 115
 
116
-		$price_piloting  = get_option( 'wpshop_shop_price_piloting' );
116
+		$price_piloting = get_option('wpshop_shop_price_piloting');
117 117
 
118 118
 		$coupon_title = $coupon_value = '';
119
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
120
-		if( !empty($oid) ) {
119
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
120
+		if (!empty($oid)) {
121 121
 			$account_origin = true;
122
-			$cart_content = get_post_meta( $oid, '_order_postmeta', true);
122
+			$cart_content = get_post_meta($oid, '_order_postmeta', true);
123 123
 		}
124
-		$currency = wpshop_tools::wpshop_get_currency( false );
124
+		$currency = wpshop_tools::wpshop_get_currency(false);
125 125
 
126
-		if ( !empty($cart_content) ) {
127
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
126
+		if (!empty($cart_content)) {
127
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
128 128
 
129
-			if ( !empty($cart_content['coupon_id']) ) {
130
-				$coupon_title = get_the_title( $cart_content['coupon_id']);
131
-				$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
129
+			if (!empty($cart_content['coupon_id'])) {
130
+				$coupon_title = get_the_title($cart_content['coupon_id']);
131
+				$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
132 132
 			}
133 133
 
134
-			if ( !empty($cart_items) ) {
134
+			if (!empty($cart_items)) {
135 135
 				/** Total values **/
136
-				$shipping_cost_et = ( !empty($cart_content['order_shipping_cost']) ) ? ( (!empty($price_piloting) && $price_piloting != 'HT') ? ( $cart_content['order_shipping_cost'] / ( 1 + ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) ) ) : $cart_content['order_shipping_cost'] ) : 0;
137
-				$shipping_cost_vat = ( !empty( $shipping_cost_et) ) ? ( $shipping_cost_et * ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) ) : 0;
138
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? ( (!empty($price_piloting) && $price_piloting != 'HT') ? $cart_content['order_shipping_cost'] : $cart_content['order_shipping_cost'] + $shipping_cost_vat ) : 0;
139
-				$total_et = ( !empty( $cart_content['order_total_ht']) ) ? $cart_content['order_total_ht'] : 0;
140
-				$order_totla_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
141
-				$order_amount_to_pay_now = wpshop_tools::formate_number( $cart_content['order_amount_to_pay_now'] );
142
-				$total_ati = ( !empty( $order_amount_to_pay_now ) && !empty($oid) && $order_amount_to_pay_now > 0 ) ? $cart_content['order_amount_to_pay_now'] : ( (!empty($cart_content['order_grand_total']) ) ? $cart_content['order_grand_total'] : 0 );
136
+				$shipping_cost_et = (!empty($cart_content['order_shipping_cost'])) ? ((!empty($price_piloting) && $price_piloting != 'HT') ? ($cart_content['order_shipping_cost'] / (1 + (WPSHOP_VAT_ON_SHIPPING_COST / 100))) : $cart_content['order_shipping_cost']) : 0;
137
+				$shipping_cost_vat = (!empty($shipping_cost_et)) ? ($shipping_cost_et * (WPSHOP_VAT_ON_SHIPPING_COST / 100)) : 0;
138
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? ((!empty($price_piloting) && $price_piloting != 'HT') ? $cart_content['order_shipping_cost'] : $cart_content['order_shipping_cost'] + $shipping_cost_vat) : 0;
139
+				$total_et = (!empty($cart_content['order_total_ht'])) ? $cart_content['order_total_ht'] : 0;
140
+				$order_totla_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
141
+				$order_amount_to_pay_now = wpshop_tools::formate_number($cart_content['order_amount_to_pay_now']);
142
+				$total_ati = (!empty($order_amount_to_pay_now) && !empty($oid) && $order_amount_to_pay_now > 0) ? $cart_content['order_amount_to_pay_now'] : ((!empty($cart_content['order_grand_total'])) ? $cart_content['order_grand_total'] : 0);
143 143
 				unset($tracking);
144
-				if( !empty($cart_content['order_trackingNumber']) ) {
144
+				if (!empty($cart_content['order_trackingNumber'])) {
145 145
 					$tracking['number'] = $cart_content['order_trackingNumber'];
146 146
 				}
147
-				if( !empty($cart_content['order_trackingLink']) ) {
147
+				if (!empty($cart_content['order_trackingLink'])) {
148 148
 					$tracking['link'] = $cart_content['order_trackingLink'];
149 149
 				}
150 150
 				ob_start();
151
-				require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart") );
151
+				require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart"));
152 152
 				$output = ob_get_contents();
153 153
 				ob_end_clean();
154 154
 			}
155 155
 			else {
156
-				return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
156
+				return '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; ;
157 157
 			}
158 158
 		}
159 159
 		else {
160
-			return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
160
+			return '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; ;
161 161
 		}
162 162
 		return $output;
163 163
 	}
164 164
 
165 165
 	/** Display mini cart **/
166
-	function display_mini_cart( $args ) {
166
+	function display_mini_cart($args) {
167 167
 		$total_cart_item = 0;
168
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
169
-		$type = ( !empty($args) && !empty($args['type']) ) ? $args['type'] : '';
168
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
169
+		$type = (!empty($args) && !empty($args['type'])) ? $args['type'] : '';
170 170
 
171 171
 
172
-		if ( !empty($cart_content) ) {
173
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
172
+		if (!empty($cart_content)) {
173
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
174 174
 			/** Count items **/
175
-			$total_cart_item = self::total_cart_items( $cart_items );
176
-			$mini_cart_body = self::mini_cart_content( $type );
175
+			$total_cart_item = self::total_cart_items($cart_items);
176
+			$mini_cart_body = self::mini_cart_content($type);
177 177
 		}
178 178
 		else {
179 179
 			$mini_cart_body = self::mini_cart_content();
180 180
 		}
181 181
 		ob_start();
182
-		if( !empty($type) && $type == 'fixed' ) {
183
-			require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart") );
182
+		if (!empty($type) && $type == 'fixed') {
183
+			require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart"));
184 184
 		}
185 185
 		else {
186
-			require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart") );
186
+			require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart"));
187 187
 		}
188 188
 
189 189
 		$output = ob_get_contents();
@@ -192,37 +192,37 @@  discard block
 block discarded – undo
192 192
 	}
193 193
 
194 194
 	/** Mini cart Content **/
195
-	public static function mini_cart_content( $type = '') {
196
-		$currency = wpshop_tools::wpshop_get_currency( false );
197
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
195
+	public static function mini_cart_content($type = '') {
196
+		$currency = wpshop_tools::wpshop_get_currency(false);
197
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
198 198
 		$output = '';
199
-		if ( !empty($cart_content) ) {
200
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
201
-			if ( !empty($cart_items) ) {
202
-				if ( !empty($cart_content['coupon_id']) ) {
203
-					$coupon_title = get_the_title( $cart_content['coupon_id']);
204
-					$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
199
+		if (!empty($cart_content)) {
200
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
201
+			if (!empty($cart_items)) {
202
+				if (!empty($cart_content['coupon_id'])) {
203
+					$coupon_title = get_the_title($cart_content['coupon_id']);
204
+					$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
205 205
 				}
206
-				$order_total_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
207
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? $cart_content['order_shipping_cost'] : 0;
208
-				$total_ati  = $total_cart = ( !empty($cart_content['order_amount_to_pay_now']) ) ? $cart_content['order_amount_to_pay_now'] : 0;
206
+				$order_total_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
207
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? $cart_content['order_shipping_cost'] : 0;
208
+				$total_ati = $total_cart = (!empty($cart_content['order_amount_to_pay_now'])) ? $cart_content['order_amount_to_pay_now'] : 0;
209 209
 
210 210
 				ob_start();
211
-				if( !empty($type) && $type == 'fixed' ) {
212
-					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content") );
211
+				if (!empty($type) && $type == 'fixed') {
212
+					require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content"));
213 213
 				}
214 214
 				else {
215
-					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content") );
215
+					require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content"));
216 216
 				}
217 217
 				$output = ob_get_contents();
218 218
 				ob_end_clean();
219 219
 			}
220 220
 			else {
221
-				$output = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
221
+				$output = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
222 222
 			}
223 223
 		}
224 224
 		else {
225
-			$output = '<div class="wps-alert-info">' . __( 'Your cart is empty', 'wpshop' ).'</div>';
225
+			$output = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
226 226
 		}
227 227
 		return $output;
228 228
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	function display_resume_cart() {
232 232
 		$cart_summary_content = self::resume_cart_content();
233 233
 		ob_start();
234
-		require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart") );
234
+		require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart"));
235 235
 		$output = ob_get_contents();
236 236
 		ob_end_clean();
237 237
 		return $output;
@@ -240,29 +240,29 @@  discard block
 block discarded – undo
240 240
 	/** Resume cart Content **/
241 241
 	public static function resume_cart_content() {
242 242
 		$output = '';
243
-		$currency = wpshop_tools::wpshop_get_currency( false );
244
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
245
-		if ( !empty($cart_content) ) {
246
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
247
-			if ( !empty($cart_items) ) {
248
-				if ( !empty($cart_content['coupon_id']) ) {
249
-					$coupon_title = get_the_title( $cart_content['coupon_id']);
250
-					$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
243
+		$currency = wpshop_tools::wpshop_get_currency(false);
244
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
245
+		if (!empty($cart_content)) {
246
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
247
+			if (!empty($cart_items)) {
248
+				if (!empty($cart_content['coupon_id'])) {
249
+					$coupon_title = get_the_title($cart_content['coupon_id']);
250
+					$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
251 251
 				}
252
-				$order_total_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
253
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? $cart_content['order_shipping_cost'] : 0;
254
-				$total_ati  = $total_cart = ( !empty($cart_content['order_amount_to_pay_now']) ) ? $cart_content['order_amount_to_pay_now'] : 0;
252
+				$order_total_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
253
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? $cart_content['order_shipping_cost'] : 0;
254
+				$total_ati = $total_cart = (!empty($cart_content['order_amount_to_pay_now'])) ? $cart_content['order_amount_to_pay_now'] : 0;
255 255
 				ob_start();
256
-				require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content") );
256
+				require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content"));
257 257
 				$output = ob_get_contents();
258 258
 				ob_end_clean();
259 259
 			}
260 260
 			else {
261
-				$resume_cart_body = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
261
+				$resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
262 262
 			}
263 263
 		}
264 264
 		else {
265
-			$resume_cart_body ='<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
265
+			$resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
266 266
 		}
267 267
 		return $output;
268 268
 	}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	 * @param array cart
273 273
 	 * @return int total items
274 274
 	 */
275
-	public static function total_cart_items( $cart_items ) {
275
+	public static function total_cart_items($cart_items) {
276 276
 		$count = 0;
277
-		if( !empty($cart_items) && is_array( $cart_items )) {
278
-			foreach( $cart_items as $cart_item ) {
277
+		if (!empty($cart_items) && is_array($cart_items)) {
278
+			foreach ($cart_items as $cart_item) {
279 279
 				$count += $cart_item['item_qty'];
280 280
 			}
281 281
 		}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * Reload Persistent cart for logged user and if a persistent cart exists
287 287
 	 */
288 288
 	function load_cart_from_db() {
289
-		if(empty($_SESSION['cart']) && get_current_user_id() ) {
289
+		if (empty($_SESSION['cart']) && get_current_user_id()) {
290 290
 			$cart = $this->get_persistent_cart();
291 291
 			$_SESSION['cart'] = $cart;
292 292
 			$_SESSION['coupon'] = 0;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return array()
299 299
 	 */
300 300
 	function get_persistent_cart() {
301
-		if(get_current_user_id())
301
+		if (get_current_user_id())
302 302
 			$cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true);
303 303
 		return empty($cart) ? array() : $cart;
304 304
 	}
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * Save the persistent cart when updated
315 315
 	 */
316 316
 	function persistent_cart_update() {
317
-		if(get_current_user_id())
318
-			update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array(
317
+		if (get_current_user_id())
318
+			update_user_meta(get_current_user_id(), '_wpshop_persistent_cart', array(
319 319
 					'cart' => $_SESSION['cart'],
320 320
 			));
321 321
 	}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * Delete the persistent cart
325 325
 	 */
326 326
 	function persistent_cart_destroy() {
327
-		delete_user_meta( get_current_user_id(), '_wpshop_persistent_cart' );
327
+		delete_user_meta(get_current_user_id(), '_wpshop_persistent_cart');
328 328
 	}
329 329
 
330 330
 	/**
@@ -344,60 +344,60 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @return mixed If an error occured return a alert message. In the other case if the quantity is correctly set return true
346 346
 	 */
347
-	function set_product_qty($product_id, $quantity, $combined_variation_id = '', $cart = array(), $from_admin = '', $order_id = '' ) {
347
+	function set_product_qty($product_id, $quantity, $combined_variation_id = '', $cart = array(), $from_admin = '', $order_id = '') {
348 348
 		// Init Cart var
349
-		$cart = ( !empty($cart) ) ? $cart : $_SESSION['cart'];
350
-		$wpshop_cart_type = ( !empty($cart) && !empty($cart['cart_type']) ) ? $cart['cart_type'] : 'normal';
349
+		$cart = (!empty($cart)) ? $cart : $_SESSION['cart'];
350
+		$wpshop_cart_type = (!empty($cart) && !empty($cart['cart_type'])) ? $cart['cart_type'] : 'normal';
351 351
 		$parent_product_id = $product_id;
352 352
 		$selected_variations = array();
353 353
 
354 354
 		// Test if Product exists
355
-		if( !empty($product_id) && !empty($cart['order_items']) && !empty( $cart['order_items'][ $product_id ] ) ) {
355
+		if (!empty($product_id) && !empty($cart['order_items']) && !empty($cart['order_items'][$product_id])) {
356 356
 			// Test if is composed product ID
357 357
 			$pid = $product_id;
358
-			if (strpos($pid,'__') !== false) {
359
-				$product_data_id = explode( '__', $pid );
360
-				$pid = ( !empty( $product_data_id ) && !empty( $product_data_id[1] ) ) ? $product_data_id[1] : $cart['order_items'][ $product_id ]['item_id'];
358
+			if (strpos($pid, '__') !== false) {
359
+				$product_data_id = explode('__', $pid);
360
+				$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $cart['order_items'][$product_id]['item_id'];
361 361
 			}
362 362
 
363 363
 			// Checking stock
364 364
 			$wps_product_ctr = new wps_product_ctr();
365
-			$return = $wps_product_ctr->check_stock($pid, $quantity, $combined_variation_id );
366
-			if( $return !== true) {
365
+			$return = $wps_product_ctr->check_stock($pid, $quantity, $combined_variation_id);
366
+			if ($return !== true) {
367 367
 				return $return;
368 368
 			}
369 369
 
370 370
 			// Check Variations to construct product to add to cart
371
-			if( !empty($product_data_id) || get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
371
+			if (!empty($product_data_id) || get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
372 372
 				// Check Parent ID
373
-				if( get_post_type($cart['order_items'][ $product_id ]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
374
-					$parent_product_id = $cart['order_items'][ $product_id ]['item_id'];
373
+				if (get_post_type($cart['order_items'][$product_id]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
374
+					$parent_product_id = $cart['order_items'][$product_id]['item_id'];
375 375
 				}
376 376
 				else {
377
-					$parent_data = wpshop_products::get_parent_variation( $cart['order_items'][ $product_id ]['item_id'] );
377
+					$parent_data = wpshop_products::get_parent_variation($cart['order_items'][$product_id]['item_id']);
378 378
 					$parent_post = $parent_data['parent_post'];
379 379
 					$parent_product_id = $parent_post->ID;
380 380
 				}
381
-				if( !empty($product_data_id) ) {
382
-					unset( $product_data_id[0] );
383
-					if( !empty($product_data_id) ) {
384
-						foreach( $product_data_id as $i ) {
385
-							$mtdt = get_post_meta( $i, '_wpshop_variations_attribute_def', true );
386
-							if( !empty($mtdt) && is_array($mtdt) ) {
387
-								$selected_variations = array_merge( $selected_variations, $mtdt );
381
+				if (!empty($product_data_id)) {
382
+					unset($product_data_id[0]);
383
+					if (!empty($product_data_id)) {
384
+						foreach ($product_data_id as $i) {
385
+							$mtdt = get_post_meta($i, '_wpshop_variations_attribute_def', true);
386
+							if (!empty($mtdt) && is_array($mtdt)) {
387
+								$selected_variations = array_merge($selected_variations, $mtdt);
388 388
 							}
389 389
 						}
390 390
 					}
391 391
 				}
392 392
 				else {
393
-					$selected_variations = get_post_meta( $product_id, '_wpshop_variations_attribute_def', true );
393
+					$selected_variations = get_post_meta($product_id, '_wpshop_variations_attribute_def', true);
394 394
 				}
395 395
 			}
396 396
 
397
-			$formatted_product = $this->prepare_product_to_add_to_cart( $parent_product_id, $quantity, $selected_variations );
397
+			$formatted_product = $this->prepare_product_to_add_to_cart($parent_product_id, $quantity, $selected_variations);
398 398
 			$product_to_add_to_cart = $formatted_product[0];
399 399
 			$new_pid = $product_id;
400
-			$return = $this->add_to_cart( $product_to_add_to_cart, array( $new_pid => $quantity ), $wpshop_cart_type, array(), $from_admin, $cart, $order_id );
400
+			$return = $this->add_to_cart($product_to_add_to_cart, array($new_pid => $quantity), $wpshop_cart_type, array(), $from_admin, $cart, $order_id);
401 401
 			return $return;
402 402
 		}
403 403
 		else {
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
 	 * @param   string	product_id	contains the id of the product to add to the cart
411 411
 	 * @param   string	quantity	contains the quantity of the item to add
412 412
 	 */
413
-	function add_to_cart( $product_list, $quantity, $type='normal', $extra_params=array(), $from_admin = '', $order_meta = '', $order_id = '' ) {
413
+	function add_to_cart($product_list, $quantity, $type = 'normal', $extra_params = array(), $from_admin = '', $order_meta = '', $order_id = '') {
414 414
 		global $wpdb;
415 415
 		/** Check if a cart already exist. If there is already a cart that is not the same type (could be a cart or a quotation)	*/
416
-		if ( empty( $from_admin ) ){
417
-			if(isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type'] ) {
416
+		if (empty($from_admin)) {
417
+			if (isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type']) {
418 418
 				return __('You have another element type into your cart. Please finalize it by going to cart page.', 'wpshop');
419 419
 			}
420 420
 			else {
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
 		$order_items = array();
428 428
 
429 429
 		foreach ($product_list as $pid => $product_more_content) {
430
-			if ( count($product_list) == 1 ) {
431
-				if ( !isset( $quantity[$pid] ) ) $quantity[$pid] = 1;
430
+			if (count($product_list) == 1) {
431
+				if (!isset($quantity[$pid])) $quantity[$pid] = 1;
432 432
 				$product = wpshop_products::get_product_data($product_more_content['id'], false, '"publish", "free_product"');
433 433
 				/** Check if the selected product exist	*/
434
-				if ( $product === false ) return __('This product does not exist', 'wpshop');
434
+				if ($product === false) return __('This product does not exist', 'wpshop');
435 435
 
436 436
 				/** Get information about the product price	*/
437 437
 				$product_price_check = wpshop_prices::get_product_price($product, 'check_only');
438
-				if ( $product_price_check !== true ) return $product_price_check;
438
+				if ($product_price_check !== true) return $product_price_check;
439 439
 
440 440
 				$the_quantity = 1;
441 441
 
442
-				if ( !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) ) {
442
+				if (!empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0])) {
443 443
 					/** Get the asked quantity for each product and check if there is enough stock	*/
444 444
 					$the_quantity = $quantity[$pid];
445 445
 				}
@@ -451,127 +451,127 @@  discard block
 block discarded – undo
451 451
 				//$quantity[$pid] = $the_quantity;
452 452
 
453 453
 				$variation_id = 0;
454
-				if ( !empty($product_more_content) && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) && !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' ){
454
+				if (!empty($product_more_content) && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) && !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined') {
455 455
 					$variation_id = $product_more_content['variations'][0];
456 456
 				}
457 457
 				//$quantity_to_check = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$pid]) && !empty($_SESSION['cart']['order_items'][$pid]['item_qty'])  ) ? $_SESSION['cart']['order_items'][$pid]['item_qty'] : $the_quantity;
458 458
 
459 459
 				$wps_product_ctr = new wps_product_ctr();
460
-				$product_stock = $wps_product_ctr->check_stock($product_more_content['id'], $the_quantity, $variation_id );
461
-				if ( $product_stock !== true ) {
460
+				$product_stock = $wps_product_ctr->check_stock($product_more_content['id'], $the_quantity, $variation_id);
461
+				if ($product_stock !== true) {
462 462
 					return $product_stock;
463 463
 				}
464
-				$count_items += (int) $product_more_content['product_qty'];
464
+				$count_items += (int)$product_more_content['product_qty'];
465 465
 			}
466 466
 
467 467
 			$order_items[$pid]['product_id'] = $product_more_content['id'];
468 468
 			$order_items[$pid]['product_qty'] = $the_quantity;
469 469
 
470 470
 			/** For product with variation	*/
471
-			$order_items[$pid]['product_variation_type'] = !empty( $product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
471
+			$order_items[$pid]['product_variation_type'] = !empty($product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
472 472
 			$order_items[$pid]['free_variation'] = !empty($product_more_content['free_variation']) ? $product_more_content['free_variation'] : '';
473 473
 			$order_items[$pid]['product_variation'] = '';
474
-			if ( !empty($product_more_content['variations']) ) {
475
-				foreach ( $product_more_content['variations'] as $variation_id) {
474
+			if (!empty($product_more_content['variations'])) {
475
+				foreach ($product_more_content['variations'] as $variation_id) {
476 476
 					$order_items[$pid]['product_variation'][] = $variation_id;
477 477
 				}
478 478
 			}
479 479
 		}
480 480
 
481
-		$current_cart = ( !empty( $order_meta )) ? $order_meta : array();
481
+		$current_cart = (!empty($order_meta)) ? $order_meta : array();
482 482
 
483
-		foreach( $current_cart['order_items'] as $item_id => $item ) {
484
-			if( !array_key_exists( $item_id, $order_items ) ) {
483
+		foreach ($current_cart['order_items'] as $item_id => $item) {
484
+			if (!array_key_exists($item_id, $order_items)) {
485 485
 				$count_items += $item['item_qty'];
486 486
 			}
487 487
 		}
488
-		$wpshop_cart_option = get_option( 'wpshop_cart_option' );
489
-		if( !empty( $wpshop_cart_option ) && !empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) && (int) $count_items > (int) $wpshop_cart_option[ 'total_nb_of_item_allowed' ][0] ) {
488
+		$wpshop_cart_option = get_option('wpshop_cart_option');
489
+		if (!empty($wpshop_cart_option) && !empty($wpshop_cart_option['total_nb_of_item_allowed']) && (int)$count_items > (int)$wpshop_cart_option['total_nb_of_item_allowed'][0]) {
490 490
 			return __('No more products can be added to your cart.', 'wpshop');
491 491
 		}
492 492
 
493
-		$order = $this->calcul_cart_information($order_items, $extra_params, $current_cart );
493
+		$order = $this->calcul_cart_information($order_items, $extra_params, $current_cart);
494 494
 
495
-		if( empty($from_admin) ) {
495
+		if (empty($from_admin)) {
496 496
 			self::store_cart_in_session($order);
497 497
 			/** Store the cart into database for connected user */
498
-			if ( get_current_user_id() ) {
498
+			if (get_current_user_id()) {
499 499
 				$this->persistent_cart_update();
500 500
 			}
501 501
 		}
502 502
 		else {
503
-			update_post_meta($order_id, '_order_postmeta', $order );
503
+			update_post_meta($order_id, '_order_postmeta', $order);
504 504
 
505 505
 		}
506 506
 		return 'success';
507 507
 	}
508 508
 
509
-	function prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected = array() ) {
509
+	function prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected = array()) {
510 510
 		$product_price = '';
511 511
 		$product_data = wpshop_products::get_product_data($product_id);
512 512
 
513 513
 		// Free vars
514
-		if ( !empty($wpshop_variation_selected['free']) ){
514
+		if (!empty($wpshop_variation_selected['free'])) {
515 515
 			$free_variations = $wpshop_variation_selected['free'];
516 516
 			unset($wpshop_variation_selected['free']);
517 517
 		}
518 518
 
519 519
 		// If product have many variations
520
-		if ( count($wpshop_variation_selected ) > 1 ) {
521
-			if ( !empty($wpshop_variation_selected) ) {
522
-				$product_with_variation = wpshop_products::get_variation_by_priority( $wpshop_variation_selected, $product_id, true );
520
+		if (count($wpshop_variation_selected) > 1) {
521
+			if (!empty($wpshop_variation_selected)) {
522
+				$product_with_variation = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true);
523 523
 			}
524 524
 
525
-			if ( !empty($product_with_variation[$product_id]['variations']) ) {
525
+			if (!empty($product_with_variation[$product_id]['variations'])) {
526 526
 				$product = $product_data;
527 527
 				$has_variation = true;
528 528
 				$head_product_id = $product_id;
529 529
 
530
-				if ( !empty($product_with_variation[$product_id]['variations']) && ( count($product_with_variation[$product_id]['variations']) == 1 ) && ($product_with_variation[$product_id]['variation_priority'] != 'single') ) {
530
+				if (!empty($product_with_variation[$product_id]['variations']) && (count($product_with_variation[$product_id]['variations']) == 1) && ($product_with_variation[$product_id]['variation_priority'] != 'single')) {
531 531
 					$product_id = $product_with_variation[$product_id]['variations'][0];
532 532
 				}
533 533
 				$product = wpshop_products::get_product_data($product_id, true);
534 534
 
535
-				$the_product = array_merge( array(
535
+				$the_product = array_merge(array(
536 536
 						'product_id'	=> $product_id,
537 537
 						'product_qty' 	=> $product_qty
538 538
 				), $product);
539 539
 
540 540
 				/*	Add variation to product into cart for storage	*/
541
-				if ( !empty($product_with_variation[$head_product_id]['variations']) ) {
542
-					$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_with_variation[$head_product_id]['variations'], $head_product_id, array('type' => $product_with_variation[$head_product_id]['variation_priority']) );
541
+				if (!empty($product_with_variation[$head_product_id]['variations'])) {
542
+					$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_with_variation[$head_product_id]['variations'], $head_product_id, array('type' => $product_with_variation[$head_product_id]['variation_priority']));
543 543
 				}
544 544
 
545 545
 				$product_data = $the_product;
546 546
 			}
547 547
 		}
548 548
 
549
-		$product_to_add_to_cart = array( $product_id => array( 'id' => $product_id, 'product_qty' => $product_qty ) );
549
+		$product_to_add_to_cart = array($product_id => array('id' => $product_id, 'product_qty' => $product_qty));
550 550
 
551
-		if ( !empty( $wpshop_variation_selected ) ) {
552
-			$variation_calculator = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true );
553
-			if ( !empty($variation_calculator[$product_id]) ) {
551
+		if (!empty($wpshop_variation_selected)) {
552
+			$variation_calculator = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true);
553
+			if (!empty($variation_calculator[$product_id])) {
554 554
 				$product_to_add_to_cart[$product_id] = array_merge($product_to_add_to_cart[$product_id], $variation_calculator[$product_id]);
555 555
 			}
556 556
 		}
557 557
 
558 558
 		$new_pid = $product_id;
559 559
 		//Create custom ID on single variations Product
560
-		if( !empty($product_to_add_to_cart[$product_id]['variations']) && count( $product_to_add_to_cart[$product_id]['variations'] ) && !empty( $product_to_add_to_cart[$product_id]['variation_priority'] ) && $product_to_add_to_cart[$product_id]['variation_priority'] == 'single' ) {
560
+		if (!empty($product_to_add_to_cart[$product_id]['variations']) && count($product_to_add_to_cart[$product_id]['variations']) && !empty($product_to_add_to_cart[$product_id]['variation_priority']) && $product_to_add_to_cart[$product_id]['variation_priority'] == 'single') {
561 561
 			$tmp_obj = $product_to_add_to_cart[$product_id];
562
-			unset( $product_to_add_to_cart[$product_id] );
562
+			unset($product_to_add_to_cart[$product_id]);
563 563
 			$key = $product_id;
564
-			foreach( $tmp_obj['variations'] as $variation_key) {
565
-				$key.= '__'. $variation_key;
564
+			foreach ($tmp_obj['variations'] as $variation_key) {
565
+				$key .= '__' . $variation_key;
566 566
 			}
567 567
 			$product_to_add_to_cart[$key] = $tmp_obj;
568 568
 			$new_pid = $key;
569 569
 		}
570 570
 		// Add free variations
571
-		if( !empty($free_variations) ) {
571
+		if (!empty($free_variations)) {
572 572
 			$product_to_add_to_cart[$new_pid]['free_variation'] = $free_variations;
573 573
 		}
574
-		return array( $product_to_add_to_cart, $new_pid );
574
+		return array($product_to_add_to_cart, $new_pid);
575 575
 	}
576 576
 
577 577
 	/**
@@ -582,67 +582,67 @@  discard block
 block discarded – undo
582 582
 	 * @param boolean $from_admin
583 583
 	 * @return array
584 584
 	 */
585
-	function calcul_cart_information( $product_list, $custom_order_information = '', $current_cart = array(), $from_admin = false ) {
585
+	function calcul_cart_information($product_list, $custom_order_information = '', $current_cart = array(), $from_admin = false) {
586 586
 		// Price piloting option
587
-		$price_piloting = get_option( 'wpshop_shop_price_piloting' );
587
+		$price_piloting = get_option('wpshop_shop_price_piloting');
588 588
 
589 589
 		// Init vars
590
-		$cart_infos = ( !empty($current_cart) ) ? $current_cart : ( ( !empty($_SESSION) && !empty($_SESSION['cart']) && !$from_admin ) ? $_SESSION['cart'] : array() );
591
-		$cart_items = ( !empty($current_cart) && !empty($current_cart['order_items']) ) ? $current_cart['order_items'] : array();
592
-		$cart_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !$from_admin ) ? $_SESSION['cart']['order_items'] : $cart_items;
590
+		$cart_infos = (!empty($current_cart)) ? $current_cart : ((!empty($_SESSION) && !empty($_SESSION['cart']) && !$from_admin) ? $_SESSION['cart'] : array());
591
+		$cart_items = (!empty($current_cart) && !empty($current_cart['order_items'])) ? $current_cart['order_items'] : array();
592
+		$cart_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !$from_admin) ? $_SESSION['cart']['order_items'] : $cart_items;
593 593
 		$order_total_ht = $order_total_ttc = $total_vat = 0; $order_tva = array();
594 594
 		$total_weight = $nb_of_items = $order_shipping_cost_by_article = 0;
595 595
 		$order_discount_rate = $order_discount_amount = $order_items_discount_amount = $order_total_discount_amount = 0;
596 596
 		$cart_infos['order_amount_to_pay_now'] = 0;
597 597
 
598 598
 		// If Product list is not empty, add products to order
599
-		if( !empty($product_list) ) {
600
-			foreach ( $product_list as $product_id => $d ) {
599
+		if (!empty($product_list)) {
600
+			foreach ($product_list as $product_id => $d) {
601 601
 				$product_key = $product_id;
602
-				if( isset( $d['product_qty']) ) {
602
+				if (isset($d['product_qty'])) {
603 603
 					// Formate datas
604 604
 					$product_id = $head_product_id = $d['product_id'];
605 605
 					$product_qty = $d['product_qty'];
606 606
 					$product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
607 607
 
608 608
 					// If product is a single variation product
609
-					if ( !empty($product_variation) && ( count($product_variation) == 1 ) ) {
609
+					if (!empty($product_variation) && (count($product_variation) == 1)) {
610 610
 						$product_id = $product_variation[0];
611 611
 					}
612 612
 
613 613
 					// Construct final product
614 614
 					$product = wpshop_products::get_product_data($d['product_id'], true, '"publish", "free_product"');
615
-					$the_product = array_merge( array('product_id'	=> $d['product_id'], 'product_qty' 	=> $product_qty ), $product);
615
+					$the_product = array_merge(array('product_id'	=> $d['product_id'], 'product_qty' 	=> $product_qty), $product);
616 616
 
617 617
 					//	Add variation to product into cart for storage
618
-					if ( !empty($product_variation) ) {
619
-						$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']) );
618
+					if (!empty($product_variation)) {
619
+						$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
620 620
 					}
621 621
 
622 622
 					// Free Variations Checking
623
-					if ( !empty( $d['free_variation'] ) ) {
623
+					if (!empty($d['free_variation'])) {
624 624
 						$the_product['item_meta']['free_variation'] = $d['free_variation'];
625 625
 						$head_product_id = $the_product['product_id'];
626 626
 					}
627 627
 
628 628
 					// If product is a variation, we check parent product general
629
-					if( get_post_type( $the_product['product_id'] )  == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
630
-						$parent_def = wpshop_products::get_parent_variation( $the_product['product_id'] );
631
-						if( !empty($parent_def) && !empty($parent_def['parent_post']) ) {
632
-							$variation_def = get_post_meta( $parent_def['parent_post']->ID, '_wpshop_variation_defining', true );
629
+					if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
630
+						$parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
631
+						if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
632
+							$variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
633 633
 							$parent_meta = $parent_def['parent_post_meta'];
634
-							if( !empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority'] ) && !empty($variation_def['options']['price_behaviour']) && in_array( 'addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1 ) {
635
-								$the_product['product_price'] += number_format( str_replace( ',', '.', $parent_meta['product_price'] ), 2, '.', '' );
636
-								$the_product['price_ht'] += number_format( str_replace( ',', '.',$parent_meta['price_ht']) , 2, '.', '' );
637
-								$the_product['tva'] += number_format( str_replace( ',', '.', $parent_meta['tva']) , 2, '.', '' );
634
+							if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
635
+								$the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
636
+								$the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
637
+								$the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
638 638
 							}
639 639
 						}
640 640
 					}
641 641
 
642 642
 					// Delete product if its qty is equals to zero, else add this product to order
643
-					if( empty( $d['product_qty'] ) ) {
644
-						unset( $cart_items[$product_key] );
645
-						unset( $cart_infos['order_items'][$product_key] );
643
+					if (empty($d['product_qty'])) {
644
+						unset($cart_items[$product_key]);
645
+						unset($cart_infos['order_items'][$product_key]);
646 646
 					}
647 647
 					else {
648 648
 						$wps_orders = new wps_orders_ctr();
@@ -653,16 +653,16 @@  discard block
 block discarded – undo
653 653
 		}
654 654
 
655 655
 		// Add automaticaly Add-to-cart Products
656
-		$cart_items = $this->add_automaticaly_product_to_cart( $cart_items );
656
+		$cart_items = $this->add_automaticaly_product_to_cart($cart_items);
657 657
 
658 658
 		// Calcul Cart Informations
659 659
 		$cart_has_special_product = false;
660
-		if( !empty($cart_items) && is_array($cart_items) ) {
661
-			foreach( $cart_items as $item_id => $item ) {
660
+		if (!empty($cart_items) && is_array($cart_items)) {
661
+			foreach ($cart_items as $item_id => $item) {
662 662
 
663
-				if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) {
663
+				if (!empty($item['item_amount_to_pay_now'])) {
664 664
 					$cart_has_special_product = true;
665
-					$cart_infos['order_amount_to_pay_now'] += ( $item[ 'item_amount_to_pay_now' ] * $item[ 'item_qty' ] );
665
+					$cart_infos['order_amount_to_pay_now'] += ($item['item_amount_to_pay_now'] * $item['item_qty']);
666 666
 				}
667 667
 				else {
668 668
 					$cart_infos['order_amount_to_pay_now'] += $item['item_total_ttc'];
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
 				$order_total_ht += $item['item_total_ht'];
672 672
 				$order_total_ttc += $item['item_total_ttc'];
673 673
 				// VAT
674
-				if( !empty($order_tva[ $item['item_tva_rate'] ]) ) {
675
-					$order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount'];
674
+				if (!empty($order_tva[$item['item_tva_rate']])) {
675
+					$order_tva[$item['item_tva_rate']] += $item['item_tva_total_amount'];
676 676
 				}
677 677
 				else {
678
-					$order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount'];
678
+					$order_tva[$item['item_tva_rate']] = $item['item_tva_total_amount'];
679 679
 				}
680 680
 			}
681 681
 		}
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
 		$cart_infos['order_total_ttc'] = $order_total_ttc;
690 690
 
691 691
 		// Calcul Shipping cost
692
-		if( !$from_admin && empty( $cart_infos['order_shipping_cost_fixe'] ) && empty($_SESSION[ 'wps-pos-addon' ]) ) {
692
+		if (!$from_admin && empty($cart_infos['order_shipping_cost_fixe']) && empty($_SESSION['wps-pos-addon'])) {
693 693
 			$wps_shipping = new wps_shipping();
694
-			$total_cart_ht_or_ttc_regarding_config = ( !empty($price_piloting) && $price_piloting == 'HT' ) ? $cart_infos['order_total_ht'] : $cart_infos['order_total_ttc'];
695
-			$cart_weight = $wps_shipping->calcul_cart_weight( $cart_infos['order_items'] );
696
-			$total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost( $cart_infos['order_items'] );
697
-			foreach( $cart_infos['order_items'] as $item ) {
698
-				if( !empty($item['item_is_downloadable_']) && ( __( $item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) {
694
+			$total_cart_ht_or_ttc_regarding_config = (!empty($price_piloting) && $price_piloting == 'HT') ? $cart_infos['order_total_ht'] : $cart_infos['order_total_ttc'];
695
+			$cart_weight = $wps_shipping->calcul_cart_weight($cart_infos['order_items']);
696
+			$total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost($cart_infos['order_items']);
697
+			foreach ($cart_infos['order_items'] as $item) {
698
+				if (!empty($item['item_is_downloadable_']) && (__($item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) {
699 699
 					$is_downloadable_products = 'is_downloadable_';
700 700
 				} else {
701 701
 					$is_downloadable_products = '';
@@ -707,39 +707,39 @@  discard block
 block discarded – undo
707 707
 		}
708 708
 
709 709
 		// If Price piloting is ET, calcul VAT on Shipping cost
710
-		if ( !empty($price_piloting) && $price_piloting == 'HT') {
711
-			$shipping_cost_vat = ( !empty($cart_infos['order_shipping_cost']) ) ? ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) * number_format(  $cart_infos['order_shipping_cost'], 2, '.', '') : 0;
710
+		if (!empty($price_piloting) && $price_piloting == 'HT') {
711
+			$shipping_cost_vat = (!empty($cart_infos['order_shipping_cost'])) ? (WPSHOP_VAT_ON_SHIPPING_COST / 100) * number_format($cart_infos['order_shipping_cost'], 2, '.', '') : 0;
712 712
 			$order_tva['VAT_shipping_cost'] = $shipping_cost_vat;
713 713
 		}
714 714
 
715 715
 		// Calcul VAT Total
716
-		if( !empty($order_tva) ) {
717
-			foreach( $order_tva as $vat_rate => $vat_value ) {
716
+		if (!empty($order_tva)) {
717
+			foreach ($order_tva as $vat_rate => $vat_value) {
718 718
 				$total_vat += $vat_value;
719 719
 			}
720 720
 		}
721 721
 
722 722
 		// Recap totals
723
-		$cart_infos['order_total_ttc'] = ( $cart_infos['order_total_ht'] + ( !empty( $cart_infos ) && !empty( $cart_infos[ 'order_shipping_cost' ] )  ? $cart_infos['order_shipping_cost'] : 0 )  + $total_vat );
723
+		$cart_infos['order_total_ttc'] = ($cart_infos['order_total_ht'] + (!empty($cart_infos) && !empty($cart_infos['order_shipping_cost']) ? $cart_infos['order_shipping_cost'] : 0) + $total_vat);
724 724
 		$cart_infos['order_grand_total_before_discount'] = $cart_infos['order_grand_total'] = $cart_infos['order_total_ttc'];
725 725
 
726 726
 		// Total to pay now
727 727
 		$total_received = 0;
728
-		if( !empty( $cart_infos['order_payment']['received'] ) ) {
729
-			foreach( $cart_infos['order_payment']['received'] as $received ) {
730
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
728
+		if (!empty($cart_infos['order_payment']['received'])) {
729
+			foreach ($cart_infos['order_payment']['received'] as $received) {
730
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
731 731
 			}
732 732
 		}
733 733
 		$cart_infos['order_amount_to_pay_now'] = $cart_infos['order_grand_total'] - $total_received;
734 734
 
735 735
 		// Apply cart rules
736
-		$cart_rule = wpshop_cart_rules::get_cart_rule( $cart_infos['order_grand_total'] );
737
-		if( $cart_rule['cart_rule_exist'] ) {
738
-			if ( !empty( $cart_rule['cart_rule_info']['discount_type'] ) ) {
739
-				if ( $cart_rule['cart_rule_info']['discount_type'] == 'absolute_discount' ) {
736
+		$cart_rule = wpshop_cart_rules::get_cart_rule($cart_infos['order_grand_total']);
737
+		if ($cart_rule['cart_rule_exist']) {
738
+			if (!empty($cart_rule['cart_rule_info']['discount_type'])) {
739
+				if ($cart_rule['cart_rule_info']['discount_type'] == 'absolute_discount') {
740 740
 					$cart_infos['order_discount_type'] = 'amount';
741 741
 				}
742
-				if ( $cart_rule['cart_rule_info']['discount_type'] == 'percent_discount' ) {
742
+				if ($cart_rule['cart_rule_info']['discount_type'] == 'percent_discount') {
743 743
 					$cart_infos['order_discount_type'] = 'percent';
744 744
 				}
745 745
 			}
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
 		}
748 748
 
749 749
 		// Apply coupons
750
-		if( !empty( $_SESSION['cart']) && !$from_admin ) {
751
-			if( !empty($_SESSION['cart']['coupon_id']) ) {
750
+		if (!empty($_SESSION['cart']) && !$from_admin) {
751
+			if (!empty($_SESSION['cart']['coupon_id'])) {
752 752
 				$wps_coupon_mdl = new wps_coupon_model();
753
-				$coupon = $wps_coupon_mdl->get_coupon_data( $_SESSION['cart']['coupon_id'] );
754
-				if( !empty($coupon) && !empty($coupon['wpshop_coupon_code']) ) {
753
+				$coupon = $wps_coupon_mdl->get_coupon_data($_SESSION['cart']['coupon_id']);
754
+				if (!empty($coupon) && !empty($coupon['wpshop_coupon_code'])) {
755 755
 					$wps_coupon = new wps_coupon_ctr();
756
-					$coupon_checking = $wps_coupon->applyCoupon( $coupon['wpshop_coupon_code'] );
756
+					$coupon_checking = $wps_coupon->applyCoupon($coupon['wpshop_coupon_code']);
757 757
 					// If Coupon conditions are Ok
758
-					if( !empty($coupon_checking) && !empty( $coupon_checking['status'] ) && ( true == $coupon_checking['status'] ) ) {
758
+					if (!empty($coupon_checking) && !empty($coupon_checking['status']) && (true == $coupon_checking['status'])) {
759 759
 						$cart_infos['order_discount_type'] = $coupon['wpshop_coupon_discount_type'];
760 760
 						$cart_infos['order_discount_value'] = $coupon['wpshop_coupon_discount_value'];
761 761
 					}
@@ -764,51 +764,51 @@  discard block
 block discarded – undo
764 764
 		}
765 765
 
766 766
 		// Checking Discounts
767
-		if( !empty($cart_infos['order_discount_type']) && isset( $cart_infos['order_discount_value'] ) ) {
767
+		if (!empty($cart_infos['order_discount_type']) && isset($cart_infos['order_discount_value'])) {
768 768
 			// Calcul discount on Order
769 769
 			switch ($cart_infos['order_discount_type']) {
770 770
 				case 'amount':
771
-					$cart_infos['order_discount_amount_total_cart'] = number_format( str_replace( ',', '.', $cart_infos['order_discount_value'] ), 2, '.', '');
771
+					$cart_infos['order_discount_amount_total_cart'] = number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '');
772 772
 				break;
773 773
 				case 'percent':
774
-					$cart_infos['order_discount_amount_total_cart'] = number_format( $cart_infos['order_grand_total'], 2, '.', '') * ( number_format( str_replace( ',', '.', $cart_infos['order_discount_value']), 2, '.', '') / 100);
774
+					$cart_infos['order_discount_amount_total_cart'] = number_format($cart_infos['order_grand_total'], 2, '.', '') * (number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '') / 100);
775 775
 				break;
776 776
 			}
777
-			if ( number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '') > number_format( $cart_infos['order_grand_total'], 2, '.', '') ) {
777
+			if (number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '') > number_format($cart_infos['order_grand_total'], 2, '.', '')) {
778 778
 				$cart_infos['order_grand_total'] = 0;
779 779
 			}
780 780
 			else {
781
-				$cart_infos['order_grand_total'] -= number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '');
781
+				$cart_infos['order_grand_total'] -= number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '');
782 782
 			}
783
-			$cart_infos['order_amount_to_pay_now'] = number_format( $cart_infos['order_grand_total'] - $total_received, 2, '.', '');
783
+			$cart_infos['order_amount_to_pay_now'] = number_format($cart_infos['order_grand_total'] - $total_received, 2, '.', '');
784 784
 		}
785 785
 
786 786
 		// Apply Partial Payments
787 787
 		$wpshop_payment = new wpshop_payment();
788
-		if( !empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation' ) {
789
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'], 'for_quotation' );
788
+		if (!empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation') {
789
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total'], 'for_quotation');
790 790
 		}
791 791
 		else {
792
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'] );
792
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total']);
793 793
 		}
794
-		if ( !empty($partial_payment['amount_to_pay']) && ( empty( $cart_infos['order_status'] ) || $cart_infos['order_status'] == 'awaiting_payment' ) && ( empty( $product_partial_payment_amount ) ) ) {
794
+		if (!empty($partial_payment['amount_to_pay']) && (empty($cart_infos['order_status']) || $cart_infos['order_status'] == 'awaiting_payment') && (empty($product_partial_payment_amount))) {
795 795
 			unset($partial_payment['display']);
796
-			$cart_infos['order_partial_payment'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
797
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
796
+			$cart_infos['order_partial_payment'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
797
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
798 798
 		}
799 799
 		// Apply Partial Payments : Subscription part.
800
-		elseif ( ! empty( $cart_has_special_product ) ) {
801
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $cart_infos['order_amount_to_pay_now'] ), 2, '.', '');
800
+		elseif (!empty($cart_has_special_product)) {
801
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $cart_infos['order_amount_to_pay_now']), 2, '.', '');
802 802
 			$cart_infos['order_product_partial_payment'] = 'subscription';
803 803
 		}
804 804
 
805 805
 		// Cart Type
806
-		if ( isset( $_SESSION['cart']['cart_type'] ) ) {
806
+		if (isset($_SESSION['cart']['cart_type'])) {
807 807
 			$cart_infos['cart_type'] = $_SESSION['cart']['cart_type'];
808 808
 		}
809 809
 
810 810
 		// Apply Extra actions on cart infos
811
-		$cart_infos = apply_filters( 'wps_extra_calcul_in_cart', $cart_infos, $_SESSION );
811
+		$cart_infos = apply_filters('wps_extra_calcul_in_cart', $cart_infos, $_SESSION);
812 812
 
813 813
 		return $cart_infos;
814 814
 	}
@@ -818,18 +818,18 @@  discard block
 block discarded – undo
818 818
 	 * @param array $cart_items
819 819
 	 * @return array
820 820
 	 */
821
-	function add_automaticaly_product_to_cart( $cart_items ) {
821
+	function add_automaticaly_product_to_cart($cart_items) {
822 822
 		global $wpdb;
823 823
 		// Recovery all products with options
824 824
 		$query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
825 825
 		$post_list_with_options = $wpdb->get_results($query);
826 826
 		$wps_orders = new wps_orders_ctr();
827
-		if ( !empty($post_list_with_options) && !empty($cart_items) ) {
828
-			foreach ( $post_list_with_options as $product_info) {
827
+		if (!empty($post_list_with_options) && !empty($cart_items)) {
828
+			foreach ($post_list_with_options as $product_info) {
829 829
 				$product_meta = unserialize($product_info->meta_value);
830
-				if ( !empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id]) ) {
830
+				if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id])) {
831 831
 					$product = wpshop_products::get_product_data($product_info->post_id, true, '"draft", "publish"');
832
-					$the_product = array_merge( array(
832
+					$the_product = array_merge(array(
833 833
 							'product_id'	=> $product_info->post_id,
834 834
 							'product_qty' 	=> 1
835 835
 					), $product);
@@ -843,28 +843,28 @@  discard block
 block discarded – undo
843 843
 
844 844
 	/** Ajax action to reload cart **/
845 845
 	public static function wps_reload_cart() {
846
-		check_ajax_referer( 'wps_reload_cart' );
846
+		check_ajax_referer('wps_reload_cart');
847 847
 
848 848
 		$wps_cart = new wps_cart();
849 849
 		$result = $wps_cart->cart_content();
850 850
 
851
-		wp_die( json_encode( array( 'response' => $result) ) );
851
+		wp_die(json_encode(array('response' => $result)));
852 852
 	}
853 853
 
854 854
 
855 855
 	/** Ajax action to reload mini cart */
856 856
 	public function wps_reload_mini_cart() {
857
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
857
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
858 858
 
859
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) )
859
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_mini_cart'))
860 860
 			wp_die();
861 861
 
862 862
 		$wps_cart = new wps_cart();
863
-		$result = $wps_cart->mini_cart_content( sanitize_title( $_POST['type']) );
864
-		$count_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])  ) ? $wps_cart->total_cart_items( $_SESSION['cart']['order_items'] ) : 0;
863
+		$result = $wps_cart->mini_cart_content(sanitize_title($_POST['type']));
864
+		$count_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $wps_cart->total_cart_items($_SESSION['cart']['order_items']) : 0;
865 865
 		$free_shipping_alert = wpshop_tools::create_custom_hook('wpshop_free_shipping_cost_alert');
866 866
 
867
-		echo json_encode( array( 'response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert) );
867
+		echo json_encode(array('response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert));
868 868
 		die();
869 869
 	}
870 870
 
@@ -874,35 +874,35 @@  discard block
 block discarded – undo
874 874
 	 * @return string
875 875
 	 */
876 876
 	function display_wps_numeration_cart() {
877
-		$cart_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) ? $_SESSION['cart']['order_items'] : array();
878
-		$total_cart_item = self::total_cart_items( $cart_items );
877
+		$cart_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $_SESSION['cart']['order_items'] : array();
878
+		$total_cart_item = self::total_cart_items($cart_items);
879 879
 
880 880
 		ob_start();
881
-		require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart") );
881
+		require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart"));
882 882
 		$output = ob_get_contents();
883 883
 		ob_end_clean();
884 884
 		return $output;
885 885
 	}
886 886
 
887
-	public function display_button_add_to_cart( $args ) {
888
-		$button_text = __( 'Add to cart', 'wpshop' );
887
+	public function display_button_add_to_cart($args) {
888
+		$button_text = __('Add to cart', 'wpshop');
889 889
 		$use_button = true;
890
-		$output = __( 'No product has been found.', 'wpshop' );
890
+		$output = __('No product has been found.', 'wpshop');
891 891
 
892
-		if ( !empty( $args ) && !empty( $args['pid'] ) ) {
892
+		if (!empty($args) && !empty($args['pid'])) {
893 893
 
894 894
 			/** The user send the text in argument */
895
-			if ( !empty( $args['text' ] ) ) {
895
+			if (!empty($args['text'])) {
896 896
 				$button_text = $args['text'];
897 897
 			}
898 898
 
899 899
 			/** The user send use input */
900
-			if ( !empty( $args['use_button'] ) && 'false' == $args['use_button'] ) {
900
+			if (!empty($args['use_button']) && 'false' == $args['use_button']) {
901 901
 				$use_button = false;
902 902
 			}
903 903
 
904 904
 			ob_start();
905
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart' ) );
905
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart'));
906 906
 			$output = ob_get_clean();
907 907
 		}
908 908
 
@@ -911,21 +911,21 @@  discard block
 block discarded – undo
911 911
 
912 912
 	/** Ajax action to reload summary cart */
913 913
 	public static function wps_reload_summary_cart() {
914
-		check_ajax_referer( 'wps_reload_summary_cart' );
914
+		check_ajax_referer('wps_reload_summary_cart');
915 915
 
916 916
 		$wps_cart = new wps_cart();
917 917
 		$result = $wps_cart->resume_cart_content();
918 918
 
919
-		wp_die( json_encode( array( 'response' => $result, ) ) );
919
+		wp_die(json_encode(array('response' => $result,)));
920 920
 	}
921 921
 
922 922
 
923 923
 	/** Display Apply Coupon Interface **/
924 924
 	function display_apply_coupon_interface() {
925 925
 		$output = '';
926
-		if ( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) {
926
+		if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) {
927 927
 			ob_start();
928
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon") );
928
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon"));
929 929
 			$output = ob_get_contents();
930 930
 			ob_end_clean();
931 931
 		}
@@ -935,30 +935,30 @@  discard block
 block discarded – undo
935 935
 
936 936
 	/** AJAX - action to apply coupon **/
937 937
 	function wps_apply_coupon() {
938
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
938
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
939 939
 
940
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) )
940
+		if (!wp_verify_nonce($_wpnonce, 'wps_apply_coupon'))
941 941
 			wp_die();
942 942
 
943 943
 		$status = false; $response = '';
944
-		$coupon = ( !empty($_POST['coupon_code']) ) ? wpshop_tools::varSanitizer( $_POST['coupon_code']) : null;
945
-		if( !empty($coupon) ) {
944
+		$coupon = (!empty($_POST['coupon_code'])) ? wpshop_tools::varSanitizer($_POST['coupon_code']) : null;
945
+		if (!empty($coupon)) {
946 946
 			$wps_coupon_ctr = new wps_coupon_ctr();
947 947
 			$result = $wps_coupon_ctr->applyCoupon($coupon);
948
-			if ($result['status']===true) {
948
+			if ($result['status'] === true) {
949 949
 				$order = $this->calcul_cart_information(array());
950 950
 				$this->store_cart_in_session($order);
951 951
 				$status = true;
952
-				$response = '<div class="wps-alert-success">' .__( 'The coupon has been applied', 'wpshop' ). '</div>';
952
+				$response = '<div class="wps-alert-success">' . __('The coupon has been applied', 'wpshop') . '</div>';
953 953
 			}
954 954
 			else {
955
-				$response = '<div class="wps-alert-error">' .$result['message']. '</div>';
955
+				$response = '<div class="wps-alert-error">' . $result['message'] . '</div>';
956 956
 			}
957 957
 		}
958 958
 		else {
959
-			$response = '<div class="wps-alert-error">'.__( 'A coupon code is required', 'wpshop'). '</div>';
959
+			$response = '<div class="wps-alert-error">' . __('A coupon code is required', 'wpshop') . '</div>';
960 960
 		}
961
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
961
+		echo json_encode(array('status' => $status, 'response' => $response));
962 962
 		die();
963 963
 	}
964 964
 
@@ -967,24 +967,24 @@  discard block
 block discarded – undo
967 967
 	 * AJAX - Pass to step two in the Checkout tunnel
968 968
 	 */
969 969
 	public static function wps_cart_pass_to_step_two() {
970
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
970
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
971 971
 
972
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) )
972
+		if (!wp_verify_nonce($_wpnonce, 'wps_cart_pass_to_step_two'))
973 973
 			wp_die();
974 974
 
975 975
 		$status = false; $response = '';
976
-		$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
977
-		if( !empty($checkout_page_id) ) {
978
-			$permalink_option = get_option( 'permalink_structure' );
979
-			$step = ( get_current_user_id() != 0 ) ?  3 : 2;
980
-			$response = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step;
976
+		$checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'));
977
+		if (!empty($checkout_page_id)) {
978
+			$permalink_option = get_option('permalink_structure');
979
+			$step = (get_current_user_id() != 0) ? 3 : 2;
980
+			$response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=' . $step;
981 981
 			$response = apply_filters('wps_extra_signup_actions', $response);
982 982
 			$status = true;
983 983
 		}
984 984
 		else {
985
-			$response = '<div class="wps-alert-error">' .__( 'An error was occured, please retry later or contact the website administrator', 'wpshop' ). '</div>';
985
+			$response = '<div class="wps-alert-error">' . __('An error was occured, please retry later or contact the website administrator', 'wpshop') . '</div>';
986 986
 		}
987
-		echo json_encode( array( 'status' => $status, 'response' => $response));
987
+		echo json_encode(array('status' => $status, 'response' => $response));
988 988
 		die();
989 989
 	}
990 990
 
@@ -993,14 +993,14 @@  discard block
 block discarded – undo
993 993
 	 * AJAX - Empty the cart
994 994
 	 */
995 995
 	function wps_empty_cart() {
996
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
996
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
997 997
 
998
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) )
998
+		if (!wp_verify_nonce($_wpnonce, 'wps_empty_cart'))
999 999
 			wp_die();
1000 1000
 
1001 1001
 
1002 1002
 		$this->empty_cart();
1003
-		echo json_encode( array( 'status' => true) );
1003
+		echo json_encode(array('status' => true));
1004 1004
 		die();
1005 1005
 	}
1006 1006
 }
Please login to merge, or discard this patch.
modules/wps_cart/templates/frontend/mini-cart/fixed-mini-cart-content.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 ?>
3
-<!-- <span class="wps-mini-cart-body-title"><strong><?php echo $total_cart_item; ?></strong><?php _e( 'item(s)', 'wpshop'); ?><span><strong><?php echo number_format( $total_cart, 2, '.', ''); ?></strong> <?php echo $currency; ?></span></span>-->
3
+<!-- <span class="wps-mini-cart-body-title"><strong><?php echo $total_cart_item; ?></strong><?php _e('item(s)', 'wpshop'); ?><span><strong><?php echo number_format($total_cart, 2, '.', ''); ?></strong> <?php echo $currency; ?></span></span>-->
4 4
 <div>
5 5
 	<ul>
6
-		<?php foreach( $cart_items as $item_id => $item ) : ?>
6
+		<?php foreach ($cart_items as $item_id => $item) : ?>
7 7
 		<?php
8
-			$item_post_type = get_post_type( $item_id );
9
-			if ( $item_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
10
-				$parent_def = wpshop_products::get_parent_variation( $item_id );
8
+			$item_post_type = get_post_type($item_id);
9
+			if ($item_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
10
+				$parent_def = wpshop_products::get_parent_variation($item_id);
11 11
 				$parent_post = $parent_def['parent_post'];
12 12
 				$item_id = $parent_post->ID;
13
-				$item_title =  $parent_post->post_title;
13
+				$item_title = $parent_post->post_title;
14 14
 			}
15 15
 			else {
16 16
 				$item_title = $item['item_name'];
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 		?>
19 19
 		<li id="wps_product_<?php echo $item_id; ?>">
20 20
 			<div class="wps-cart-item-img">
21
-				<a href="<?php echo get_permalink( $item_id ); ?>" title="">
22
-					<?php echo get_the_post_thumbnail( $item_id, 'thumbnail' ); ?>
21
+				<a href="<?php echo get_permalink($item_id); ?>" title="">
22
+					<?php echo get_the_post_thumbnail($item_id, 'thumbnail'); ?>
23 23
 				</a>
24 24
 			</div>
25 25
 			<div class="wps-cart-item-content">
@@ -28,49 +28,49 @@  discard block
 block discarded – undo
28 28
 				</a>
29 29
 				<?php
30 30
 				$variations_indicator = '';
31
-				$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
31
+				$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
32 32
 				$output_order = array();
33
-				if ( count($product_attribute_order_detail) > 0  && is_array($product_attribute_order_detail) ) {
34
-					foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
35
-						foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
36
-							if ( !empty($attribute_def->code) )
33
+				if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) {
34
+					foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
35
+						foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
36
+							if (!empty($attribute_def->code))
37 37
 								$output_order[$attribute_def->code] = $position;
38 38
 						}
39 39
 					}
40 40
 				}
41
-				$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $item['item_meta'], $output_order, 'cart' );
41
+				$variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'cart');
42 42
 				ksort($variation_attribute_ordered['attribute_list']);
43
-				if( !empty($variation_attribute_ordered['attribute_list']) ) {
43
+				if (!empty($variation_attribute_ordered['attribute_list'])) {
44 44
 					$variations_indicator .= '<ul class="wps-cart-item-variations" >';
45
-					foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) {
46
-						if ( !empty($attribute_variation_to_output) ) {
45
+					foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) {
46
+						if (!empty($attribute_variation_to_output)) {
47 47
 							$variations_indicator .= $attribute_variation_to_output;
48 48
 						}
49 49
 					}
50
-					$variations_indicator = apply_filters( 'wps_cart_item_variation_list', $variations_indicator, $variation_attribute_ordered, $item, 0 );
50
+					$variations_indicator = apply_filters('wps_cart_item_variation_list', $variations_indicator, $variation_attribute_ordered, $item, 0);
51 51
 					$variations_indicator .= '</ul>';
52 52
 				}
53 53
 				echo $variations_indicator;
54 54
 				?>
55 55
 			</div>
56 56
 			<div class="wps-cart-item-price">
57
-			   	<span class="wps-price"><?php echo wpshop_tools::formate_number( $item['item_total_ttc'] ); ?><span> <?php echo $currency; ?></span></span>
58
-			   	<span class="wps-tva"><?php _e( 'ATI', 'wpshop'); ?></span><br>
57
+			   	<span class="wps-price"><?php echo wpshop_tools::formate_number($item['item_total_ttc']); ?><span> <?php echo $currency; ?></span></span>
58
+			   	<span class="wps-tva"><?php _e('ATI', 'wpshop'); ?></span><br>
59 59
 			</div>
60 60
 			<div class="wps-cart-item-close">
61
-				<button type="button" class="wps-bton-icon wps_cart_delete_product" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>"><i class="wps-icon-trash"></i></button>
61
+				<button type="button" class="wps-bton-icon wps_cart_delete_product" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>"><i class="wps-icon-trash"></i></button>
62 62
 			</div>
63 63
 		</li>
64 64
 		<?php endforeach; ?>
65 65
 	</ul>
66 66
 </div>
67
-<p><?php _e( 'Shipping cost', 'wpshop' ); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?></strong>€</span></p>
67
+<p><?php _e('Shipping cost', 'wpshop'); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number($shipping_cost_ati); ?></strong>€</span></p>
68 68
 
69
-<?php if ( !empty( $cart_content['coupon_id']) ) : ?>
70
-	<p><?php _e( 'Total ATI before discount', 'wpshop' ); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number( $order_total_before_discount ); ?></strong> <?php echo $currency; ?></span></p>
71
-	<p><?php _e( 'Discount', 'wpshop' ); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number( $coupon_value ); ?></strong> <?php echo $currency; ?></span></p>
69
+<?php if (!empty($cart_content['coupon_id'])) : ?>
70
+	<p><?php _e('Total ATI before discount', 'wpshop'); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number($order_total_before_discount); ?></strong> <?php echo $currency; ?></span></p>
71
+	<p><?php _e('Discount', 'wpshop'); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number($coupon_value); ?></strong> <?php echo $currency; ?></span></p>
72 72
 <?php endif; ?>
73 73
 
74
-<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop'); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number( $total_ati ); ?></strong> <?php echo $currency; ?></span></p>
75
-<button class="wps-bton-second-halfwidth wpsjq-closeFixedCart"><i class="wps-icon-arrowleft"></i><?php _e( 'Return', 'wpshop'); ?></button>
76
-<a href="<?php echo get_permalink( wpshop_tools::get_page_id( get_option('wpshop_cart_page_id') ) ); ?>" class="wps-bton-first-halfwidth" role="button"><i class="wps-icon-paiement"></i><?php _e( 'Order', 'wpshop'); ?></a>
74
+<p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?><span class="wps-inline-alignRight"><strong><?php echo wpshop_tools::formate_number($total_ati); ?></strong> <?php echo $currency; ?></span></p>
75
+<button class="wps-bton-second-halfwidth wpsjq-closeFixedCart"><i class="wps-icon-arrowleft"></i><?php _e('Return', 'wpshop'); ?></button>
76
+<a href="<?php echo get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))); ?>" class="wps-bton-first-halfwidth" role="button"><i class="wps-icon-paiement"></i><?php _e('Order', 'wpshop'); ?></a>
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 ?>
3 5
 <!-- <span class="wps-mini-cart-body-title"><strong><?php echo $total_cart_item; ?></strong><?php _e( 'item(s)', 'wpshop'); ?><span><strong><?php echo number_format( $total_cart, 2, '.', ''); ?></strong> <?php echo $currency; ?></span></span>-->
4 6
 <div>
@@ -11,8 +13,7 @@  discard block
 block discarded – undo
11 13
 				$parent_post = $parent_def['parent_post'];
12 14
 				$item_id = $parent_post->ID;
13 15
 				$item_title =  $parent_post->post_title;
14
-			}
15
-			else {
16
+			} else {
16 17
 				$item_title = $item['item_name'];
17 18
 			}
18 19
 		?>
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 				if ( count($product_attribute_order_detail) > 0  && is_array($product_attribute_order_detail) ) {
34 35
 					foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
35 36
 						foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
36
-							if ( !empty($attribute_def->code) )
37
-								$output_order[$attribute_def->code] = $position;
37
+							if ( !empty($attribute_def->code) ) {
38
+															$output_order[$attribute_def->code] = $position;
39
+							}
38 40
 						}
39 41
 					}
40 42
 				}
Please login to merge, or discard this patch.
controller/wps_product_variation_interface.ctr.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -52,19 +52,19 @@
 block discarded – undo
52 52
 	 * @return boolean          Actual state of module.
53 53
 	 */
54 54
 	public function is_activate( $new_val = null ) {
55
-	    if ( ! isset( $this->is_active ) ) {
56
-	        $option = get_option( 'wps_variation_interface_display', null );
57
-	        if ( is_null( $option ) ) {
58
-	            $new_val = true;
59
-	            $option = false;
60
-	        }
61
-	        $this->is_active = (bool) $option;
62
-	    }
63
-	    if ( isset( $new_val ) && $this->is_active !== $new_val ) {
64
-	        update_option( 'wps_variation_interface_display', $new_val );
65
-	        $this->is_active = $new_val;
66
-	    }
67
-	    return $this->is_active;
55
+		if ( ! isset( $this->is_active ) ) {
56
+			$option = get_option( 'wps_variation_interface_display', null );
57
+			if ( is_null( $option ) ) {
58
+				$new_val = true;
59
+				$option = false;
60
+			}
61
+			$this->is_active = (bool) $option;
62
+		}
63
+		if ( isset( $new_val ) && $this->is_active !== $new_val ) {
64
+			update_option( 'wps_variation_interface_display', $new_val );
65
+			$this->is_active = $new_val;
66
+		}
67
+		return $this->is_active;
68 68
 	}
69 69
 	/**
70 70
 	 * Get variations of an element.
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	 * Call hooks.
14 14
 	 */
15 15
 	public function __construct() {
16
-		add_action( 'init', array( $this, 'init' ) );
17
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 11, 2 );
18
-		add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
19
-		add_filter( 'wpshop_attribute_output_def', array( $this, 'wpshop_attribute_output_def' ), 10, 2 );
16
+		add_action('init', array($this, 'init'));
17
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 11, 2);
18
+		add_action('save_post', array($this, 'save_post'), 10, 2);
19
+		add_filter('wpshop_attribute_output_def', array($this, 'wpshop_attribute_output_def'), 10, 2);
20 20
 	}
21 21
 	/**
22 22
 	 * Call private functions if class is activate.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 * @param  array  $arguments  Array of arguments to pass.
26 26
 	 * @return mixed             Return of real function called.
27 27
 	 */
28
-	public function __call( $name, $arguments ) {
29
-		if ( method_exists( $this, $name ) ) {
30
-			if ( $this->is_activate() ) {
31
-				return call_user_func_array( array( $this, $name ), $arguments );
28
+	public function __call($name, $arguments) {
29
+		if (method_exists($this, $name)) {
30
+			if ($this->is_activate()) {
31
+				return call_user_func_array(array($this, $name), $arguments);
32 32
 			}
33 33
 		}
34 34
 	}
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	 * @return void
40 40
 	 */
41 41
 	public function init() {
42
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // Input var okay.
43
-		$wps_variation_interface = ! empty( $_GET['wps_variation_interface'] ) ? filter_var( wp_unslash( $_GET['wps_variation_interface'] ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) : null; // Input var okay.
44
-		if ( wp_verify_nonce( $_wpnonce, 'wps_remove_variation_interface' ) && null !== $wps_variation_interface ) {
45
-			$this->is_activate( $wps_variation_interface );
42
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])) : ''; // Input var okay.
43
+		$wps_variation_interface = !empty($_GET['wps_variation_interface']) ? filter_var(wp_unslash($_GET['wps_variation_interface']), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) : null; // Input var okay.
44
+		if (wp_verify_nonce($_wpnonce, 'wps_remove_variation_interface') && null !== $wps_variation_interface) {
45
+			$this->is_activate($wps_variation_interface);
46 46
 		}
47 47
 	}
48 48
 	/**
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	 * @param  boolean $new_val If set & db is different, save it.
52 52
 	 * @return boolean          Actual state of module.
53 53
 	 */
54
-	public function is_activate( $new_val = null ) {
55
-	    if ( ! isset( $this->is_active ) ) {
56
-	        $option = get_option( 'wps_variation_interface_display', null );
57
-	        if ( is_null( $option ) ) {
54
+	public function is_activate($new_val = null) {
55
+	    if (!isset($this->is_active)) {
56
+	        $option = get_option('wps_variation_interface_display', null);
57
+	        if (is_null($option)) {
58 58
 	            $new_val = true;
59 59
 	            $option = false;
60 60
 	        }
61
-	        $this->is_active = (bool) $option;
61
+	        $this->is_active = (bool)$option;
62 62
 	    }
63
-	    if ( isset( $new_val ) && $this->is_active !== $new_val ) {
64
-	        update_option( 'wps_variation_interface_display', $new_val );
63
+	    if (isset($new_val) && $this->is_active !== $new_val) {
64
+	        update_option('wps_variation_interface_display', $new_val);
65 65
 	        $this->is_active = $new_val;
66 66
 	    }
67 67
 	    return $this->is_active;
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 * @param  array $element Direct array attribute of db.
73 73
 	 * @return void          It set directly in variable class.
74 74
 	 */
75
-	private function get_variations( $element ) {
76
-		if ( ! isset( $this->variations ) ) {
77
-			$variations = wpshop_attributes::get_variation_available_attribute( $element );
78
-			$this->variations = (array) array_merge( ( isset( $variations['available'] ) ? $variations['available'] : array()), ( isset( $variations['unavailable'] ) ? $variations['unavailable'] : array() ) );
79
-			unset( $variations );
75
+	private function get_variations($element) {
76
+		if (!isset($this->variations)) {
77
+			$variations = wpshop_attributes::get_variation_available_attribute($element);
78
+			$this->variations = (array)array_merge((isset($variations['available']) ? $variations['available'] : array()), (isset($variations['unavailable']) ? $variations['unavailable'] : array()));
79
+			unset($variations);
80 80
 		}
81 81
 	}
82 82
 	/**
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 * @param  string  $post_status Generated by WP.
87 87
 	 * @param  WP_Post $post Generated by WP.
88 88
 	 */
89
-	public function add_meta_boxes( $post_status, $post ) {
89
+	public function add_meta_boxes($post_status, $post) {
90 90
 		global $pagenow;
91
-		if ( $this->is_activate() ) {
92
-			$this->get_variations( $post->ID );
93
-			remove_meta_box( 'wpshop_wpshop_variations', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal' );
94
-			if ( 'post-new.php' !== $pagenow && ! empty( $this->variations ) ) {
95
-				add_meta_box( 'wpshop_wpshop_variations', __( 'Product variation', 'wpshop' ), array( $this, 'meta_box_variation' ), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default' );
91
+		if ($this->is_activate()) {
92
+			$this->get_variations($post->ID);
93
+			remove_meta_box('wpshop_wpshop_variations', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal');
94
+			if ('post-new.php' !== $pagenow && !empty($this->variations)) {
95
+				add_meta_box('wpshop_wpshop_variations', __('Product variation', 'wpshop'), array($this, 'meta_box_variation'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default');
96 96
 			}
97 97
 		}
98 98
 	}
@@ -102,49 +102,49 @@  discard block
 block discarded – undo
102 102
 	 * @param  object $post Given by WordPress.
103 103
 	 * @return void       Display directly.
104 104
 	 */
105
-	private function meta_box_variation( $post ) {
106
-		$this->get_variations( $post->ID );
105
+	private function meta_box_variation($post) {
106
+		$this->get_variations($post->ID);
107 107
 		global $wpdb;
108 108
 		$ids = array();
109
-		foreach ( $this->variations as $key => $variation ) {
110
-			$available = wpshop_attributes::get_select_output( $variation['attribute_complete_def'] );
111
-			$this->variations[ $key ]['available'] = array_keys( $available['possible_value'] );
112
-			$ids = array_merge( $ids, array_keys( $available['possible_value'] ) );
109
+		foreach ($this->variations as $key => $variation) {
110
+			$available = wpshop_attributes::get_select_output($variation['attribute_complete_def']);
111
+			$this->variations[$key]['available'] = array_keys($available['possible_value']);
112
+			$ids = array_merge($ids, array_keys($available['possible_value']));
113 113
 		}
114
-		$sql = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id IN (\'' . implode( '\', \'', $ids ) . '\') AND status = %s';
115
-		$query = call_user_func( array( $wpdb, 'prepare' ), $sql, 'valid' );
116
-		$product = wpshop_products::get_product_data( $post->ID, false, '"publish","draft","future"' );
117
-		$is_used_in_variation = wpshop_attributes::getElement( 'yes', "'valid', 'notused'", 'is_used_in_variation', true );
114
+		$sql = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id IN (\'' . implode('\', \'', $ids) . '\') AND status = %s';
115
+		$query = call_user_func(array($wpdb, 'prepare'), $sql, 'valid');
116
+		$product = wpshop_products::get_product_data($post->ID, false, '"publish","draft","future"');
117
+		$is_used_in_variation = wpshop_attributes::getElement('yes', "'valid', 'notused'", 'is_used_in_variation', true);
118 118
 		$attribute_list = array();
119
-		foreach ( $is_used_in_variation as $attribute ) {
120
-			if ( in_array( $attribute->backend_input, array( 'multiple-select', 'select', 'radio', 'checkbox' ), true ) ) {
121
-				$values = wpshop_attributes::get_select_output( $attribute );
122
-				if ( ! empty( $values['possible_value'] ) ) {
119
+		foreach ($is_used_in_variation as $attribute) {
120
+			if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'), true)) {
121
+				$values = wpshop_attributes::get_select_output($attribute);
122
+				if (!empty($values['possible_value'])) {
123 123
 					$attribute->possible_value = $values['possible_value'];
124 124
 				}
125 125
 			}
126
-			$attribute_list[ $attribute->code ] = $attribute;
126
+			$attribute_list[$attribute->code] = $attribute;
127 127
 		}
128
-		$variation_defining = get_post_meta( $post->ID, '_wpshop_variation_defining', true );
129
-		$variations_saved = wpshop_products::get_variation( $post->ID );
130
-		if ( ! empty( $variations_saved ) ) {
131
-			foreach ( $variations_saved as $variation_id => $variation ) {
132
-				$downloadable = get_post_meta( $variation_id, 'attribute_option_is_downloadable_', true );
133
-				if ( ! empty( $downloadable['file_url'] ) ) {
134
-					$variations_saved[ $variation_id ]['file']['path'] = $downloadable['file_url'];
135
-					$variations_saved[ $variation_id ]['file']['name'] = basename( $downloadable['file_url'] );
128
+		$variation_defining = get_post_meta($post->ID, '_wpshop_variation_defining', true);
129
+		$variations_saved = wpshop_products::get_variation($post->ID);
130
+		if (!empty($variations_saved)) {
131
+			foreach ($variations_saved as $variation_id => $variation) {
132
+				$downloadable = get_post_meta($variation_id, 'attribute_option_is_downloadable_', true);
133
+				if (!empty($downloadable['file_url'])) {
134
+					$variations_saved[$variation_id]['file']['path'] = $downloadable['file_url'];
135
+					$variations_saved[$variation_id]['file']['name'] = basename($downloadable['file_url']);
136 136
 				}
137 137
 			}
138 138
 		}
139
-		$price_piloting = get_option( 'wpshop_shop_price_piloting' );
139
+		$price_piloting = get_option('wpshop_shop_price_piloting');
140 140
 		$product_currency = wpshop_tools::wpshop_get_currency();
141
-		wp_enqueue_style( 'wps-product-variation-interface-style', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/css/style-backend.css' );
142
-		wp_enqueue_script( 'wps-product-variation-interface-script', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend.js' );
143
-		wp_enqueue_script( 'wps-product-variation-interface-script-utils', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend-utils.js' );
144
-		wp_localize_script( 'wps-product-variation-interface-script', 'wps_product_variation_interface', apply_filters( 'wps_filters_product_variation_extra_columns_product_definition', array(
141
+		wp_enqueue_style('wps-product-variation-interface-style', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/css/style-backend.css');
142
+		wp_enqueue_script('wps-product-variation-interface-script', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend.js');
143
+		wp_enqueue_script('wps-product-variation-interface-script-utils', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend-utils.js');
144
+		wp_localize_script('wps-product-variation-interface-script', 'wps_product_variation_interface', apply_filters('wps_filters_product_variation_extra_columns_product_definition', array(
145 145
 			'variation' => $this->variations,
146
-			'nonce_delete' => wp_create_nonce( 'wpshop_variation_management' ),
147
-			'variation_value' => call_user_func( array( $wpdb, 'get_results' ), $query ),
146
+			'nonce_delete' => wp_create_nonce('wpshop_variation_management'),
147
+			'variation_value' => call_user_func(array($wpdb, 'get_results'), $query),
148 148
 			'product_price' => $product['product_price'],
149 149
 			'tx_tva' => $product['tx_tva'],
150 150
 			'attribute_in_variation' => $attribute_list,
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 			'price_piloting' => $price_piloting,
153 153
 			'currency' => $product_currency,
154 154
 			'variation_defining' => $variation_defining,
155
-			'label_file' => __( 'Click to add file', 'wpshop' ),
156
-		) ) );
157
-		require_once wpshop_tools::get_template_part( WPSPDTVARIATION_INTERFACE_DIR, WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR, 'backend', 'meta_box_variation' );
155
+			'label_file' => __('Click to add file', 'wpshop'),
156
+		)));
157
+		require_once wpshop_tools::get_template_part(WPSPDTVARIATION_INTERFACE_DIR, WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR, 'backend', 'meta_box_variation');
158 158
 	}
159 159
 	/**
160 160
 	 * Save other values out of old variation interface.
@@ -163,24 +163,24 @@  discard block
 block discarded – undo
163 163
 	 * @param  object $post    WP_Post of WordPress.
164 164
 	 * @return void
165 165
 	 */
166
-	private function save_post( $post_id, $post ) {
167
-		if ( wp_is_post_revision( $post_id ) || WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT !== $post->post_type || ! isset( $_REQUEST['wpshop_variation_defining']['options'] ) || ! isset( $_REQUEST['wps_pdt_variations'] ) ) { // Input var okay.
166
+	private function save_post($post_id, $post) {
167
+		if (wp_is_post_revision($post_id) || WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT !== $post->post_type || !isset($_REQUEST['wpshop_variation_defining']['options']) || !isset($_REQUEST['wps_pdt_variations'])) { // Input var okay.
168 168
 			return;
169 169
 		}
170
-		wpshop_products::variation_parameters_save( $post_id, $_REQUEST['wpshop_variation_defining']['options'] ); // Input var okay.
171
-		remove_action( 'save_post', array( $this, 'save_post' ) );
172
-		foreach ( $_REQUEST['wps_pdt_variations'] as $variation_id => $data ) { // Input var okay.
170
+		wpshop_products::variation_parameters_save($post_id, $_REQUEST['wpshop_variation_defining']['options']); // Input var okay.
171
+		remove_action('save_post', array($this, 'save_post'));
172
+		foreach ($_REQUEST['wps_pdt_variations'] as $variation_id => $data) { // Input var okay.
173 173
 			$variation = array(
174 174
 				'ID' => $variation_id,
175 175
 			);
176
-			if ( isset( $data['status'] ) && 'on' === $data['status'] ) {
176
+			if (isset($data['status']) && 'on' === $data['status']) {
177 177
 				$variation['post_status'] = 'publish';
178 178
 			} else {
179 179
 				$variation['post_status'] = 'draft';
180 180
 			}
181
-			wp_update_post( $variation );
181
+			wp_update_post($variation);
182 182
 		}
183
-		add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
183
+		add_action('save_post', array($this, 'save_post'), 10, 2);
184 184
 	}
185 185
 	/**
186 186
 	 * Delete display in attributes products always in metabox.
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 	 * @param  array $element Direct array attribute of db.
190 190
 	 * @return array          SAme array $output modified.
191 191
 	 */
192
-	public function wpshop_attribute_output_def( $output, $element ) {
193
-		if ( $this->is_activate() ) {
194
-			$this->get_variations( $element );
195
-			if ( ! empty( $this->variations ) && in_array( $output['field_definition']['name'], array_keys( $this->variations ), true ) ) {
192
+	public function wpshop_attribute_output_def($output, $element) {
193
+		if ($this->is_activate()) {
194
+			$this->get_variations($element);
195
+			if (!empty($this->variations) && in_array($output['field_definition']['name'], array_keys($this->variations), true)) {
196 196
 				$output['field'] = '';
197 197
 			}
198 198
 		}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return void
206 206
 	 */
207 207
 	public function wpshop_download_file_dialog_active() {
208
-		add_filter( 'wps_filters_product_variation_file', array( $this, 'wps_filters_product_variation_file' ), 0, 1 );
208
+		add_filter('wps_filters_product_variation_file', array($this, 'wps_filters_product_variation_file'), 0, 1);
209 209
 	}
210 210
 	/**
211 211
 	 * Add old upload box for custom php dsiplay.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $string Input filter.
215 215
 	 * @return string The div for box.
216 216
 	 */
217
-	public function wps_filters_product_variation_file( $string ) {
218
-		return '<div style="display: none" onclick="open_dialog_box(this, %ID%, \'' . esc_html_e( 'Send the downloadable file', 'wpshop' ) . '\')"><div class="is_downloadable_statut_%ID%"></div></div>';
217
+	public function wps_filters_product_variation_file($string) {
218
+		return '<div style="display: none" onclick="open_dialog_box(this, %ID%, \'' . esc_html_e('Send the downloadable file', 'wpshop') . '\')"><div class="is_downloadable_statut_%ID%"></div></div>';
219 219
 	}
220 220
 }
Please login to merge, or discard this patch.
wps_product_variation_interface/templates/backend/meta_box_variation.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@  discard block
 block discarded – undo
2 2
 	<div data-view-model="wps_variations_options_summary" id="wps_variations_summary_display">
3 3
 		<b>%summary%</b>
4 4
 	</div>
5
-	<a id="wps_variations_parameters" title="<?php esc_html_e( 'Edit possibilities', 'wpshop' ); ?>" href="#">
5
+	<a id="wps_variations_parameters" title="<?php esc_html_e('Edit possibilities', 'wpshop'); ?>" href="#">
6 6
 		<?php // href=">?php print wp_nonce_url( get_edit_post_link( $post->ID ) . '&wps_variation_interface=false', 'wps_remove_variation_interface' );?<">. ?>
7 7
 		<span class="dashicons dashicons-admin-generic"></span>
8 8
 	</a>
9 9
 </div>
10 10
 <div id="wps_variations_options">
11 11
 	<ul id="wps_variations_options_title">
12
-		<li><?php esc_html_e( 'Generate option', 'wpshop' ); ?></li>
13
-		<li><?php esc_html_e( 'Option', 'wpshop' ); ?></li>
14
-		<li><?php esc_html_e( 'Requiered', 'wpshop' ); ?></li>
15
-		<li><?php esc_html_e( 'Possibilities', 'wpshop' ); ?></li>
16
-		<li><?php esc_html_e( 'Default', 'wpshop' ); ?></li>
12
+		<li><?php esc_html_e('Generate option', 'wpshop'); ?></li>
13
+		<li><?php esc_html_e('Option', 'wpshop'); ?></li>
14
+		<li><?php esc_html_e('Requiered', 'wpshop'); ?></li>
15
+		<li><?php esc_html_e('Possibilities', 'wpshop'); ?></li>
16
+		<li><?php esc_html_e('Default', 'wpshop'); ?></li>
17 17
 	</ul>
18 18
 	<ul data-view-model="wps_variations_options_raw" class="wps_variations_options_raw">
19 19
 		<li class="wps_variations_generate_col">
@@ -44,42 +44,42 @@  discard block
 block discarded – undo
44 44
 </div>
45 45
 <div id="wps_variations_questions">
46 46
 	<ul>
47
-		<li class="wps_variations_questions_question_col"><?php esc_html_e( 'Do you want to manage each options singly or combine them ?', 'wpshop' ); ?></li>
47
+		<li class="wps_variations_questions_question_col"><?php esc_html_e('Do you want to manage each options singly or combine them ?', 'wpshop'); ?></li>
48 48
 		<li class="wps_variations_questions_answers_col">
49 49
 			<?php
50 50
 				$id = uniqid();
51 51
 			?>
52
-			<input id="question_combine_options_<?php echo intval( $id ); ?>" name="question_combine_options" type="radio" value="combine">
53
-			<label for="question_combine_options_<?php echo intval( $id ); ?>"><?php esc_html_e( 'Combined options', 'wpshop' ); ?></label>
52
+			<input id="question_combine_options_<?php echo intval($id); ?>" name="question_combine_options" type="radio" value="combine">
53
+			<label for="question_combine_options_<?php echo intval($id); ?>"><?php esc_html_e('Combined options', 'wpshop'); ?></label>
54 54
 			<?php
55 55
 				$id = uniqid();
56 56
 			?>
57
-			<input id="question_combine_options_<?php echo intval( $id ); ?>" name="question_combine_options" type="radio" value="single">
58
-			<label for="question_combine_options_<?php echo intval( $id ); ?>"><?php esc_html_e( 'Distinct options', 'wpshop' ); ?></label>
57
+			<input id="question_combine_options_<?php echo intval($id); ?>" name="question_combine_options" type="radio" value="single">
58
+			<label for="question_combine_options_<?php echo intval($id); ?>"><?php esc_html_e('Distinct options', 'wpshop'); ?></label>
59 59
 		</li>
60 60
 	</ul>
61 61
 </div>
62 62
 <div id="wps_variations_tabs">
63 63
 	<ul>
64
-		<li data-tab="wps_variations_price_option_tab" class="disabled"><?php esc_html_e( 'Options prices', 'wpshop' ); ?></li>
65
-		<li id="wps_variations_apply_btn" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpshop_variation_management' ) ); ?>">
66
-			<?php esc_html_e( 'Apply modifications', 'wpshop' ); ?>
64
+		<li data-tab="wps_variations_price_option_tab" class="disabled"><?php esc_html_e('Options prices', 'wpshop'); ?></li>
65
+		<li id="wps_variations_apply_btn" data-nonce="<?php echo esc_attr(wp_create_nonce('wpshop_variation_management')); ?>">
66
+			<?php esc_html_e('Apply modifications', 'wpshop'); ?>
67 67
 		</li>
68 68
 	</ul>
69 69
 </div>
70 70
 <div id="wps_variations_price_option_tab" class="wps_variations_tabs">
71 71
 	<ul id="wps_variations_price_option_tab_title">
72
-		<li class="wps_variations_price_id_col"><?php esc_html_e( 'ID', 'wpshop' ); ?></li>
73
-		<li class="wps_variations_price_name_col"><?php esc_html_e( 'Options', 'wpshop' ); ?></li>
74
-		<li class="wps_variations_price_config_col"><?php esc_html_e( 'Prices', 'wpshop' ); ?></li>
75
-		<li class="wps_variations_price_final_col"><?php esc_html_e( 'Final prices', 'wpshop' ); ?></li>
76
-		<li class="wps_variations_price_vat_col"><?php esc_html_e( 'VAT', 'wpshop' ); ?></li>
77
-		<li class="wps_variations_price_stock_col"><?php esc_html_e( 'Stock', 'wpshop' ); ?></li>
78
-		<li class="wps_variations_price_weight_col"><?php esc_html_e( 'Weight', 'wpshop' ); ?></li>
79
-		<li class="wps_variations_price_reference_col"><?php esc_html_e( 'Ref. product', 'wpshop' ); ?></li>
80
-		<li class="wps_variations_price_file_col"><?php esc_html_e( 'Link download', 'wpshop' ); ?></li>
81
-		<?php echo esc_html( apply_filters( 'wps_filters_product_variation_extra_columns_title', '' ) ); ?>
82
-		<li class="wps_variations_price_active_col"><?php esc_html_e( 'Activate', 'wpshop' ); ?></li>
72
+		<li class="wps_variations_price_id_col"><?php esc_html_e('ID', 'wpshop'); ?></li>
73
+		<li class="wps_variations_price_name_col"><?php esc_html_e('Options', 'wpshop'); ?></li>
74
+		<li class="wps_variations_price_config_col"><?php esc_html_e('Prices', 'wpshop'); ?></li>
75
+		<li class="wps_variations_price_final_col"><?php esc_html_e('Final prices', 'wpshop'); ?></li>
76
+		<li class="wps_variations_price_vat_col"><?php esc_html_e('VAT', 'wpshop'); ?></li>
77
+		<li class="wps_variations_price_stock_col"><?php esc_html_e('Stock', 'wpshop'); ?></li>
78
+		<li class="wps_variations_price_weight_col"><?php esc_html_e('Weight', 'wpshop'); ?></li>
79
+		<li class="wps_variations_price_reference_col"><?php esc_html_e('Ref. product', 'wpshop'); ?></li>
80
+		<li class="wps_variations_price_file_col"><?php esc_html_e('Link download', 'wpshop'); ?></li>
81
+		<?php echo esc_html(apply_filters('wps_filters_product_variation_extra_columns_title', '')); ?>
82
+		<li class="wps_variations_price_active_col"><?php esc_html_e('Activate', 'wpshop'); ?></li>
83 83
 	</ul>
84 84
 	<ul data-view-model="wps_variations_price_option_raw">
85 85
 		<li class="wps_variations_price_id_col">
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 		</li>
119 119
 		<li class="wps_variations_price_file_col" data-view-model="wps_variations_price_option_file_%ID%">
120 120
 			<span class="wps_variations_price_option_price_file" onclick="wps_variations_price_option_raw.control.file(this)">%link%</span>
121
-			<?php echo esc_html( apply_filters( 'wps_filters_product_variation_file', '<input style="display: none;" type="file" name="wpshop_file" id="wpshop_file" onchange="wps_variations_price_option_raw.control.link(event, this)">' ) ); ?>
122
-			<?php wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action', 'wpshop_file_nonce' );?>
121
+			<?php echo esc_html(apply_filters('wps_filters_product_variation_file', '<input style="display: none;" type="file" name="wpshop_file" id="wpshop_file" onchange="wps_variations_price_option_raw.control.link(event, this)">')); ?>
122
+			<?php wp_nonce_field('ajax_wpshop_upload_downloadable_file_action', 'wpshop_file_nonce'); ?>
123 123
 			<a class="wps_variations_price_option_price_download_file" href="%path%" target="_blank" download="" style="display: %download%">
124 124
 				<span class="dashicons dashicons-download"></span>
125 125
 			</a>
126 126
 		</li>
127
-		<?php echo esc_html( apply_filters( 'wps_filters_product_variation_extra_columns_content', '' ) ); ?>
127
+		<?php echo esc_html(apply_filters('wps_filters_product_variation_extra_columns_content', '')); ?>
128 128
 		<li class="wps_variations_price_active_col">
129 129
 			<input name="wps_pdt_variations[%ID%][status]" onclick="wps_variations_price_option_raw.control.activate(this)" type="checkbox" %price_option_activate%>
130 130
 		</li>
Please login to merge, or discard this patch.