Completed
Push — master ( 5c12d6...edf3a9 )
by
unknown
13:25
created
includes/wpshop_ajax.php 2 patches
Spacing   +981 added lines, -981 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" data-nonce="' . esc_attr( wp_create_nonce( 'wpshop_change_order_state' ) ) . '" 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" data-nonce="' . esc_attr(wp_create_nonce('wpshop_change_order_state')) . '" 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, $wps_shipping_mode_ctr;
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;
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 
525 525
 				$order_postmeta = $order;
526 526
 				ob_start();
527
-				require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $wps_shipping_mode_ctr->template_dir, 'backend', 'order-shipping-informations' ) );
527
+				require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $wps_shipping_mode_ctr->template_dir, 'backend', 'order-shipping-informations'));
528 528
 				$output_shipping_box = ob_get_clean();
529 529
 
530
-				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
530
+				$result = array(true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content);
531 531
 			}
532 532
 			else {
533 533
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
@@ -544,39 +544,39 @@  discard block
 block discarded – undo
544 544
 		echo json_encode($result);
545 545
 		die();
546 546
 	}
547
-	add_action( 'wp_ajax_change_order_state', 'wpshop_ajax_change_order_state' );
547
+	add_action('wp_ajax_change_order_state', 'wpshop_ajax_change_order_state');
548 548
 
549 549
 
550 550
 	/* Send a confirmation e-mail to the customer */
551
-	function wpshop_send_confirmation_shipping_email($order_id){
551
+	function wpshop_send_confirmation_shipping_email($order_id) {
552 552
 		$wps_message = new wps_message_ctr();
553
-		if ( !empty($order_id) ) {
553
+		if (!empty($order_id)) {
554 554
 			$order_info = get_post_meta($order_id, '_order_info', true);
555 555
 			$order = get_post_meta($order_id, '_order_postmeta', true);
556
-			$email = ( !empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
556
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
557 557
 			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
558
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
558
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
559 559
 
560
-			if( empty($email) && !empty($order['customer_id']) ) {
561
-				$user_data = get_userdata( $order['customer_id'] );
560
+			if (empty($email) && !empty($order['customer_id'])) {
561
+				$user_data = get_userdata($order['customer_id']);
562 562
 				$email = $user_data->user_email;
563 563
 			}
564 564
 
565
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
566
-			$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'] : '' );
565
+			$shipping_mode_option = get_option('wps_shipping_mode');
566
+			$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'] : '');
567 567
 
568 568
 
569
-			$wps_message->wpshop_prepared_email (
569
+			$wps_message->wpshop_prepared_email(
570 570
 				$email,
571 571
 				'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE',
572 572
 				array(
573 573
 					'order_id' => $order_id,
574
-					'order_key' => ( !empty($order['order_key']) ? $order['order_key'] : '' ),
574
+					'order_key' => (!empty($order['order_key']) ? $order['order_key'] : ''),
575 575
 					'customer_first_name' => $first_name,
576 576
 					'customer_last_name' => $last_name,
577
-					'order_date' => ( !empty($order['order_date']) ? $order['order_date'] : '' ),
578
-					'order_trackingNumber' => ( !empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : '' ),
579
-					'order_trackingLink' => ( !empty($order['order_trackingLink']) ? $order['order_trackingLink'] : '' ),
577
+					'order_date' => (!empty($order['order_date']) ? $order['order_date'] : ''),
578
+					'order_trackingNumber' => (!empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : ''),
579
+					'order_trackingLink' => (!empty($order['order_trackingLink']) ? $order['order_trackingLink'] : ''),
580 580
 					'order_addresses' => '',
581 581
 					'order_billing_address' => '',
582 582
 					'order_shipping_address' => '',
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @return string The html output for the new value
596 596
 	 */
597 597
 	function ajax_new_option_for_select_callback() {
598
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
598
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
599 599
 		global $wpdb;
600 600
 
601
-		$option_id=$option_default_value=$option_value_id=$options_value='';
602
-		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int) $_GET['attribute_identifier'] : '0';
603
-		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field( $_REQUEST['attribute_new_label'] ) : '');
601
+		$option_id = $option_default_value = $option_value_id = $options_value = '';
602
+		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int)$_GET['attribute_identifier'] : '0';
603
+		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field($_REQUEST['attribute_new_label']) : '');
604 604
 		$options_value = sanitize_title($option_name);
605 605
 
606 606
 		/*	Check if given value does not exist before continuing	*/
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		$existing_values = $wpdb->get_results($query);
609 609
 
610 610
 		/*	If given value does not exist: display result. If value exist alert a error message	*/
611
-		if( empty($existing_values) ) {
611
+		if (empty($existing_values)) {
612 612
 			$tpl_component = array();
613 613
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_ID'] = $option_id;
614 614
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_NAME'] = stripslashes($option_name);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", stripslashes($options_value));
617 617
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = '';
618 618
 			$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
619
-			if ( current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0) ) :
619
+			if (current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0)) :
620 620
 				$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');
621 621
 			endif;
622 622
 			$output = wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * Add a new value to an attribute from select type directly from an entity element edition interface
636 636
 	 */
637 637
 	function ajax_new_option_for_select_from_product_edition_callback() {
638
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
638
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
639 639
 
640 640
 		global $wpdb;
641 641
 		$result = '';
@@ -652,13 +652,13 @@  discard block
 block discarded – undo
652 652
 		$attribute_options_label = isset($_POST['attribute_new_label']) ? wpshop_tools::varSanitizer($_POST['attribute_new_label']) : null;
653 653
 		$attribute_options_value = sanitize_title($attribute_options_label);
654 654
 
655
-		if ( $type == 'internal' ) {
655
+		if ($type == 'internal') {
656 656
 			/**	Check if the given value does not exist	*/
657 657
 			$query = $wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_status = 'publish'", $attribute_options_label);
658 658
 			$existing_values = $wpdb->get_results($query);
659 659
 
660 660
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
661
-			if ( count($existing_values) <= 0 ) {
661
+			if (count($existing_values) <= 0) {
662 662
 				$result_status = true;
663 663
 				/**	Create the new value as an entity into post database	*/
664 664
 				$new_post = array(
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 			$existing_values = $wpdb->get_results($query);
682 682
 
683 683
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
684
-			if( count($existing_values) <= 0 ) {
684
+			if (count($existing_values) <= 0) {
685 685
 				$result_status = true;
686 686
 				$position = 1;
687 687
 				/**	Get the last value position for adding the new at the end	*/
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
 
701 701
 		if ($result_status) {
702 702
 			$tmp_selection_for_output = array();
703
-			foreach ( $attribute_selected_values as $value ) {
703
+			foreach ($attribute_selected_values as $value) {
704 704
 				$tmp_selection_for_output[]['value'] = $value;
705 705
 			}
706 706
 			$tmp_selection_for_output[]['value'] = $new_option_id;
707
-			foreach ( $tmp_selection_for_output as $tmp_value ) {
707
+			foreach ($tmp_selection_for_output as $tmp_value) {
708 708
 				$selection_for_output[] = (object)$tmp_value;
709 709
 			}
710 710
 			$attribute_selected_values[] = $new_option_id;
711
-			$input = wpshop_attributes::get_attribute_field_definition( $attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display) );
711
+			$input = wpshop_attributes::get_attribute_field_definition($attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display));
712 712
 			$result = $input['output'] . $input['options'];
713 713
 		}
714 714
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 * Delete a value for a select list attribute
722 722
 	 */
723 723
 	function ajax_delete_option_for_select_callback() {
724
-		check_ajax_referer( 'wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce' );
724
+		check_ajax_referer('wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce');
725 725
 
726 726
 		$attribute_value_id = isset($_POST['attribute_value_id']) ? wpshop_tools::varSanitizer($_POST['attribute_value_id']) : '0';
727 727
 
@@ -745,18 +745,18 @@  discard block
 block discarded – undo
745 745
 	 * Display the field for the selected attribute type
746 746
 	 */
747 747
 	function ajax_attribute_output_type_callback() {
748
-		check_ajax_referer( 'wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce' );
748
+		check_ajax_referer('wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce');
749 749
 
750 750
 		$data_type_to_use = isset($_POST['data_type_to_use']) ? str_replace('_data', '', wpshop_tools::varSanitizer($_POST['data_type_to_use'], '')) : 'custom';
751 751
 		$current_type = isset($_POST['current_type']) ? wpshop_tools::varSanitizer($_POST['current_type']) : 'short_text';
752
-		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval( wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
752
+		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval(wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
753 753
 		$the_input = __('An error occured while getting field type', 'wpshop');
754 754
 		$input_def = array();
755 755
 		$input_def['name'] = 'default_value';
756 756
 		$input_def['id'] = 'wpshop_attributes_edition_table_field_id_default_value';
757 757
 		$input_label = __('Default value', 'wpshop');
758 758
 
759
-		switch($current_type){
759
+		switch ($current_type) {
760 760
 			case 'short_text':
761 761
 			case 'float_field':
762 762
 				$input_def['type'] = 'text';
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 			case 'multiple-select':
768 768
 			case 'radio':
769 769
 			case 'checkbox':
770
-				$input_label=__('Options list for attribute', 'wpshop');
770
+				$input_label = __('Options list for attribute', 'wpshop');
771 771
 				$the_input = wpshop_attributes::get_select_options_list($elementIdentifier, $data_type_to_use);
772 772
 				break;
773 773
 			case 'date_field':
774
-				$input_label=__('Date field configuration', 'wpshop');
774
+				$input_label = __('Date field configuration', 'wpshop');
775 775
 
776
-				$the_input = wpshop_attributes::attribute_type_date_config( array() );
776
+				$the_input = wpshop_attributes::attribute_type_date_config(array());
777 777
 				break;
778 778
 			case 'textarea':
779 779
 				$input_def['type'] = 'textarea';
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	 * Get the attribute set list when creating a new attribute for direct affectation
792 792
 	 */
793 793
 	function ajax_attribute_entity_set_selection_callback() {
794
-		check_ajax_referer( 'wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce' );
794
+		check_ajax_referer('wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce');
795 795
 
796 796
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
797 797
 
798
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
798
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
799 799
 
800 800
 		echo json_encode($the_input);
801 801
 		die();
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	 * Get the attribute set list when creating a new attribute for direct affectation
806 806
 	 */
807 807
 	function ajax_attribute_set_entity_selection_callback() {
808
-		check_ajax_referer( 'wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce' );
808
+		check_ajax_referer('wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce');
809 809
 
810 810
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
811 811
 
812
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
812
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
813 813
 
814 814
 		echo json_encode($the_input);
815 815
 		die();
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	 * Dialog box allowing to change attribute data type from custom to internal
821 821
 	 */
822 822
 	function ajax_attribute_select_data_type_callback() {
823
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce' );
823
+		check_ajax_referer('wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce');
824 824
 		$result = '';
825 825
 
826 826
 		$current_attribute = isset($_POST['current_attribute']) ? intval(wpshop_tools::varSanitizer($_POST['current_attribute'])) : null;
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
 
829 829
 		$types_toggled = unserialize(WPSHOP_ATTR_SELECT_TYPE_TOGGLED);
830 830
 		$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>';
831
-		$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
+		$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>';
832 832
 
833
-		if ( $attribute->data_type_to_use == 'custom' ) {
834
-			$sub_output='';
833
+		if ($attribute->data_type_to_use == 'custom') {
834
+			$sub_output = '';
835 835
 			$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
836
-			unset($input_def);$input_def=array();
836
+			unset($input_def); $input_def = array();
837 837
 			$input_def['label'] = __('Type of data for list', 'wpshop');
838 838
 			$input_def['type'] = 'select';
839 839
 			$input_def['name'] = 'internal_data';
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 			$input_def['possible_value'] = $wp_types;
842 842
 			$input_def['value'] = !empty($attribute_select_options[0]->default_value) ? $attribute_select_options[0]->default_value : null;
843 843
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
844
-			$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
+			$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>';
845 845
 			$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" />';
846 846
 		}
847 847
 		else {
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 	 */
875 875
 	function ajax_attribute_select_data_type_change_callback() {
876 876
 		global $wpdb;
877
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce' );
877
+		check_ajax_referer('wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce');
878 878
 		$result = '';
879 879
 
880 880
 		$current_attribute = isset($_POST['attribute_id']) ? intval(wpshop_tools::varSanitizer($_POST['attribute_id'])) : null;
@@ -884,10 +884,10 @@  discard block
 block discarded – undo
884 884
 		$delete_entity = isset($_POST['delete_entity']) ? wpshop_tools::varSanitizer($_POST['delete_entity']) : false;
885 885
 
886 886
 
887
-		if ( $data_type == 'internal' ) {
887
+		if ($data_type == 'internal') {
888 888
 			$options_list = wpshop_attributes::get_select_option_list_($current_attribute);
889
-			if(!empty($options_list)){
890
-				foreach($options_list as $option){
889
+			if (!empty($options_list)) {
890
+				foreach ($options_list as $option) {
891 891
 					/*	Creat the new entity	*/
892 892
 					$new_post = array(
893 893
 							'post_title' 	=> $option->name,
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 							'post_type' 	=> $internal_data_type
897 897
 					);
898 898
 					$new_option_id = wp_insert_post($new_post);
899
-					if(!empty($new_option_id)){
899
+					if (!empty($new_option_id)) {
900 900
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'deleted'), array('attribute_id'=>$current_attribute));
901 901
 					}
902 902
 				}
@@ -905,19 +905,19 @@  discard block
 block discarded – undo
905 905
 		else {
906 906
 			$post_list = query_posts(array('post_type' => $internal_data_type));
907 907
 			if (!empty($post_list)) {
908
-				$p=1;
908
+				$p = 1;
909 909
 				$error = false;
910 910
 				foreach ($post_list as $post) {
911
-					$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));
912
-					if(is_int($last_insert) && $delete_items_of_entity){
911
+					$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));
912
+					if (is_int($last_insert) && $delete_items_of_entity) {
913 913
 						wp_delete_post($post->ID, true);
914 914
 					}
915
-					else{
915
+					else {
916 916
 						$error = true;
917 917
 					}
918 918
 					$p++;
919 919
 				}
920
-				if(!$error && $delete_entity){
920
+				if (!$error && $delete_entity) {
921 921
 					$post = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_name=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, $internal_data_type);
922 922
 					wp_delete_post($wpdb->get_var($post), true);
923 923
 				}
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 	/**
938 938
 	 * Duplicate an existing attribute from an entity to another
939 939
 	 */
940
-	function ajax_wpshop_duplicate_attribute_callback (){
941
-		check_ajax_referer( 'wpshop_duplicate_attribute', 'wpshop_ajax_nonce' );
940
+	function ajax_wpshop_duplicate_attribute_callback() {
941
+		check_ajax_referer('wpshop_duplicate_attribute', 'wpshop_ajax_nonce');
942 942
 		global $wpdb;
943 943
 
944 944
 		$result = '';
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
 		/*	Check if the attribute to duplicate does not exist for the selected entity	*/
959 959
 		$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']);
960 960
 		$check_existing_attribute = $wpdb->get_var($query);
961
-		if ( empty($check_existing_attribute) ) {
961
+		if (empty($check_existing_attribute)) {
962 962
 			/*	Save new attribut for the selected entity	*/
963 963
 			$new_attribute = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE, $attribute_def);
964 964
 			$new_attribute_id = $wpdb->insert_id;
965 965
 
966 966
 			if ($new_attribute) {
967
-				if ( in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom') ) {
967
+				if (in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom')) {
968 968
 					$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d", $current_attribute);
969 969
 					$attribute_options_list = $wpdb->get_results($query, ARRAY_A);
970
-					foreach ( $attribute_options_list as $option ) {
970
+					foreach ($attribute_options_list as $option) {
971 971
 						$option['id'] = '';
972 972
 						$option['creation_date'] = current_time('mysql', 0);
973 973
 						$option['attribute_id'] = $new_attribute_id;
@@ -998,27 +998,27 @@  discard block
 block discarded – undo
998 998
 	/**
999 999
 	 * Load comboBox of unit or group of unit
1000 1000
 	 */
1001
-	function wpshop_ajax_load_attribute_unit_list(){
1002
-		check_ajax_referer( 'wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce' );
1001
+	function wpshop_ajax_load_attribute_unit_list() {
1002
+		check_ajax_referer('wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce');
1003 1003
 		$response = '';
1004 1004
 
1005
-		$current_group = ( isset( $_POST[ 'current_group' ] ) && !empty( $_POST[ 'current_group' ] ) ) ? sanitize_text_field( $_POST[ 'current_group' ] ) : null;
1006
-		$selected_list = ( isset( $_POST[ 'selected_list' ] ) && !empty( $_POST[ 'selected_list' ] ) ) ? sanitize_text_field( $_POST[ 'selected_list' ] ) : null;
1005
+		$current_group = (isset($_POST['current_group']) && !empty($_POST['current_group'])) ? sanitize_text_field($_POST['current_group']) : null;
1006
+		$selected_list = (isset($_POST['selected_list']) && !empty($_POST['selected_list'])) ? sanitize_text_field($_POST['selected_list']) : null;
1007 1007
 
1008 1008
 		$group = wpshop_tools::varSanitizer($current_group);
1009 1009
 		$selected_list = wpshop_tools::varSanitizer($selected_list);
1010 1010
 
1011
-		if ( !empty($group) && !empty($selected_list)) {
1011
+		if (!empty($group) && !empty($selected_list)) {
1012 1012
 			/* Test if we want display the group unit list OR the unit list */
1013
-			if ( $selected_list == 'group unit' ) {
1013
+			if ($selected_list == 'group unit') {
1014 1014
 				$list = wpshop_attributes_unit::get_unit_group();
1015 1015
 			}
1016 1016
 			else {
1017 1017
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1018 1018
 			}
1019 1019
 
1020
-			foreach( $list as $unit ) {
1021
-				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1020
+			foreach ($list as $unit) {
1021
+				$response .= '<option value="' . $unit->id . '" ' . (($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '') . '>' . $unit->name . '</option>';
1022 1022
 			}
1023 1023
 			$result = array(true, $response);
1024 1024
 		}
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 /**	Tools page	*/
1036 1036
 	function wpshop_ajax_db_check_tool() {
1037
-		check_ajax_referer( 'wpshop_ajax_db_check_tool', '_wpnonce' );
1037
+		check_ajax_referer('wpshop_ajax_db_check_tool', '_wpnonce');
1038 1038
 
1039 1039
 		global $wpdb, $wpshop_db_table_operation_list, $wpshop_db_table, $wpshop_update_way;
1040 1040
 		$current_db_version = get_option('wpshop_db_options', 0);
@@ -1050,22 +1050,22 @@  discard block
 block discarded – undo
1050 1050
 </div>
1051 1051
 <div class="tools_db_modif_list_version_details" >
1052 1052
 	<ul>';
1053
-			foreach($plugin_db_modification as $modif_name => $modif_list){
1054
-				switch($modif_name){
1053
+			foreach ($plugin_db_modification as $modif_name => $modif_list) {
1054
+				switch ($modif_name) {
1055 1055
 					case 'FIELD_ADD':{
1056
-						foreach($modif_list as $table_name => $field_list){
1056
+						foreach ($modif_list as $table_name => $field_list) {
1057 1057
 							$sub_modif = '  ';
1058
-							foreach($field_list as $column_name){
1059
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1058
+							foreach ($field_list as $column_name) {
1059
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1060 1060
 								$columns = $wpdb->get_row($query);
1061 1061
 								$sub_modif .= $column_name;
1062
-								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1062
+								if (!empty($columns->Field) && ($columns->Field == $column_name)) {
1063 1063
 									$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" />';
1064 1064
 								}
1065
-								else{
1065
+								else {
1066 1066
 									$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" />';
1067 1067
 									$error_nb++;
1068
-									if ( !empty($error_list[$plugin_db_version]) ) {
1068
+									if (!empty($error_list[$plugin_db_version])) {
1069 1069
 										$error_list[$plugin_db_version] += 1;
1070 1070
 									}
1071 1071
 									else {
@@ -1074,56 +1074,56 @@  discard block
 block discarded – undo
1074 1074
 								}
1075 1075
 								$sub_modif .= ' / ';
1076 1076
 							}
1077
-							$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
+							$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>';
1078 1078
 						}
1079 1079
 					}break;
1080 1080
 					case 'FIELD_DROP':{
1081
-						foreach($modif_list as $table_name => $field_list){
1081
+						foreach ($modif_list as $table_name => $field_list) {
1082 1082
 							$sub_modif = '  ';
1083
-							foreach($field_list as $column_name){
1084
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1083
+							foreach ($field_list as $column_name) {
1084
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1085 1085
 								$columns = $wpdb->get_row($query);
1086 1086
 								$sub_modif .= $column_name;
1087
-								if(empty($columns) || ($columns->Field != $column_name)){
1087
+								if (empty($columns) || ($columns->Field != $column_name)) {
1088 1088
 									$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" />';
1089 1089
 								}
1090
-								else{
1090
+								else {
1091 1091
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1092 1092
 									$error_nb++;
1093 1093
 									$error_list[$plugin_db_version] += 1;
1094 1094
 								}
1095 1095
 								$sub_modif .= ' / ';
1096 1096
 							}
1097
-							$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
+							$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>';
1098 1098
 						}
1099 1099
 					}break;
1100 1100
 					case 'FIELD_CHANGE':{
1101
-						foreach($modif_list as $table_name => $field_list){
1101
+						foreach ($modif_list as $table_name => $field_list) {
1102 1102
 							$sub_modif = '  ';
1103
-							foreach($field_list as $field_infos){
1104
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_infos['field']);
1103
+							foreach ($field_list as $field_infos) {
1104
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_infos['field']);
1105 1105
 								$columns = $wpdb->get_row($query);
1106 1106
 								$what_is_changed = '';
1107
-								if(isset($field_infos['type'])){
1107
+								if (isset($field_infos['type'])) {
1108 1108
 									$what_is_changed = __('field type', 'wpshop');
1109 1109
 									$changed_key = 'type';
1110
-									if($columns->Type == $field_infos['type']){
1110
+									if ($columns->Type == $field_infos['type']) {
1111 1111
 										$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" />';
1112 1112
 									}
1113
-									else{
1113
+									else {
1114 1114
 										$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" />';
1115 1115
 										$error_nb++;
1116 1116
 										$error_list[$plugin_db_version] += 1;
1117 1117
 									}
1118 1118
 									$sub_modif .= sprintf(__('Change %s for field %s to %s', 'wpshop'), $what_is_changed, $field_infos['field'], $field_infos[$changed_key]);
1119 1119
 								}
1120
-								if(isset($field_infos['original_name'])){
1120
+								if (isset($field_infos['original_name'])) {
1121 1121
 									$what_is_changed = __('field name', 'wpshop');
1122 1122
 									$changed_key = 'original_name';
1123
-									if($columns->Field == $field_infos['field']){
1123
+									if ($columns->Field == $field_infos['field']) {
1124 1124
 										$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" />';
1125 1125
 									}
1126
-									else{
1126
+									else {
1127 1127
 										$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" />';
1128 1128
 										$error_nb++;
1129 1129
 										$error_list[$plugin_db_version] += 1;
@@ -1138,59 +1138,59 @@  discard block
 block discarded – undo
1138 1138
 					}break;
1139 1139
 
1140 1140
 					case 'DROP_INDEX':{
1141
-						foreach($modif_list as $table_name => $field_list){
1141
+						foreach ($modif_list as $table_name => $field_list) {
1142 1142
 							$sub_modif = '   ';
1143
-							foreach($field_list as $column_name){
1144
-								$query = $wpdb->prepare("SHOW INDEX FROM " .$table_name . " WHERE Column_name = %s", $column_name);
1143
+							foreach ($field_list as $column_name) {
1144
+								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s", $column_name);
1145 1145
 								$columns = $wpdb->get_row($query);
1146 1146
 								$sub_modif .= $column_name;
1147
-								if((empty($columns)) || ($columns->Column_name != $column_name)){
1147
+								if ((empty($columns)) || ($columns->Column_name != $column_name)) {
1148 1148
 									$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" />';
1149 1149
 								}
1150
-								else{
1150
+								else {
1151 1151
 									$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" />';
1152 1152
 									$error_nb++;
1153 1153
 									$error_list[$plugin_db_version] += 1;
1154 1154
 								}
1155 1155
 								$sub_modif .= ' / ';
1156 1156
 							}
1157
-							$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
+							$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>';
1158 1158
 						}
1159 1159
 					}break;
1160 1160
 					case 'ADD_INDEX':{
1161
-						foreach($modif_list as $table_name => $field_list){
1161
+						foreach ($modif_list as $table_name => $field_list) {
1162 1162
 							$sub_modif = '   ';
1163
-							foreach($field_list as $column_name){
1163
+							foreach ($field_list as $column_name) {
1164 1164
 								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s OR Key_name = %s", $column_name, $column_name);
1165 1165
 								$columns = $wpdb->get_row($query);
1166 1166
 								$sub_modif .= $column_name;
1167
-								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1167
+								if (($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)) {
1168 1168
 									$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" />';
1169 1169
 								}
1170
-								else{
1170
+								else {
1171 1171
 									$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" />';
1172 1172
 									$error_nb++;
1173 1173
 									$error_list[$plugin_db_version] += 1;
1174 1174
 								}
1175 1175
 								$sub_modif .= ' / ';
1176 1176
 							}
1177
-							$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
+							$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>';
1178 1178
 						}
1179 1179
 					}break;
1180 1180
 
1181 1181
 					case 'ADD_TABLE':{
1182 1182
 						$sub_modif = '  ';
1183
-						foreach($modif_list as $table_name){
1183
+						foreach ($modif_list as $table_name) {
1184 1184
 							$sub_modif .= $table_name;
1185 1185
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table_name);
1186 1186
 							$table_exists = $wpdb->query($query);
1187
-							if($table_exists == 1){
1187
+							if ($table_exists == 1) {
1188 1188
 								$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" />';
1189 1189
 							}
1190
-							else{
1190
+							else {
1191 1191
 								$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" />';
1192 1192
 								$error_nb++;
1193
-								if ( !empty($error_list[$plugin_db_version]) ) {
1193
+								if (!empty($error_list[$plugin_db_version])) {
1194 1194
 									$error_list[$plugin_db_version] += 1;
1195 1195
 								}
1196 1196
 								else {
@@ -1203,29 +1203,29 @@  discard block
 block discarded – undo
1203 1203
 					}break;
1204 1204
 					case 'TABLE_RENAME':{
1205 1205
 						$sub_modif = '  ';
1206
-						foreach($modif_list as $table){
1206
+						foreach ($modif_list as $table) {
1207 1207
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1208 1208
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1209 1209
 							$table_exists = $wpdb->query($query);
1210 1210
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1211 1211
 							$old_table_exists = $wpdb->query($query);
1212
-							if(($table_exists == 1) && ($old_table_exists == 1)){
1212
+							if (($table_exists == 1) && ($old_table_exists == 1)) {
1213 1213
 								$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" />';
1214 1214
 								$error_nb++;
1215
-								if ( !empty($error_list[$plugin_db_version]) ) {
1215
+								if (!empty($error_list[$plugin_db_version])) {
1216 1216
 									$error_list[$plugin_db_version] += 1;
1217 1217
 								}
1218 1218
 								else {
1219 1219
 									$error_list[$plugin_db_version] = 1;
1220 1220
 								}
1221 1221
 							}
1222
-							elseif($table_exists == 1){
1222
+							elseif ($table_exists == 1) {
1223 1223
 								$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" />';
1224 1224
 							}
1225
-							else{
1225
+							else {
1226 1226
 								$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" />';
1227 1227
 								$error_nb++;
1228
-								if ( !empty($error_list[$plugin_db_version]) ) {
1228
+								if (!empty($error_list[$plugin_db_version])) {
1229 1229
 									$error_list[$plugin_db_version] += 1;
1230 1230
 								}
1231 1231
 								else {
@@ -1238,27 +1238,27 @@  discard block
 block discarded – undo
1238 1238
 					}break;
1239 1239
 					case 'TABLE_RENAME_FOR_DELETION':{
1240 1240
 						$sub_modif = '  ';
1241
-						foreach($modif_list as $table){
1241
+						foreach ($modif_list as $table) {
1242 1242
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1243 1243
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1244 1244
 							$table_delete_exists = $wpdb->query($query);
1245 1245
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1246 1246
 							$old_table_exists = $wpdb->query($query);
1247
-							if(($table_delete_exists == 1) || ($old_table_exists == 1)){
1248
-								if($old_table_exists == 1){
1247
+							if (($table_delete_exists == 1) || ($old_table_exists == 1)) {
1248
+								if ($old_table_exists == 1) {
1249 1249
 									$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" />';
1250 1250
 									$error_nb++;
1251
-									if ( !empty($error_list[$plugin_db_version]) ) {
1251
+									if (!empty($error_list[$plugin_db_version])) {
1252 1252
 										$error_list[$plugin_db_version] += 1;
1253 1253
 									}
1254 1254
 									else {
1255 1255
 										$error_list[$plugin_db_version] = 1;
1256 1256
 									}
1257 1257
 								}
1258
-								else{
1258
+								else {
1259 1259
 									$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" />';
1260 1260
 									$warning_nb++;
1261
-									if ( !empty($warning_list[$plugin_db_version]) ) {
1261
+									if (!empty($warning_list[$plugin_db_version])) {
1262 1262
 										$warning_list[$plugin_db_version] += 1;
1263 1263
 									}
1264 1264
 									else {
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 								}
1268 1268
 								$sub_modif .= $deleted_table_result;
1269 1269
 							}
1270
-							else{
1270
+							else {
1271 1271
 								$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" />';
1272 1272
 							}
1273 1273
 							$sub_modif .= ' / ';
@@ -1282,57 +1282,57 @@  discard block
 block discarded – undo
1282 1282
 		}
1283 1283
 
1284 1284
 		$db_table_field_error = '';
1285
-		foreach($wpshop_db_table as $table_name => $table_definition){
1286
-			if(!empty($table_definition)){
1285
+		foreach ($wpshop_db_table as $table_name => $table_definition) {
1286
+			if (!empty($table_definition)) {
1287 1287
 				$table_line = explode("
1288 1288
 ", $table_definition);
1289 1289
 
1290 1290
 				$sub_db_table_field_error = '  ';
1291
-				foreach($table_line as $table_definition_line){
1291
+				foreach ($table_line as $table_definition_line) {
1292 1292
 					$def_line = trim($table_definition_line);
1293
-					if(substr($def_line, 0, 1) == "`"){
1293
+					if (substr($def_line, 0, 1) == "`") {
1294 1294
 						$line_element = explode(" ", $def_line);
1295 1295
 						$field_name = str_replace("`", "", $line_element[0]);
1296
-						$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_name);
1296
+						$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_name);
1297 1297
 						$columns = $wpdb->get_row($query);
1298
-						if ( !empty($columns->Field) && ($columns->Field != $field_name)) {
1298
+						if (!empty($columns->Field) && ($columns->Field != $field_name)) {
1299 1299
 							$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" />' */;
1300 1300
 							$error_nb++;
1301 1301
 						}
1302 1302
 					}
1303 1303
 				}
1304 1304
 				$sub_db_table_field_error = trim(substr($sub_db_table_field_error, 0, -2));
1305
-				if(!empty($sub_db_table_field_error)){
1305
+				if (!empty($sub_db_table_field_error)) {
1306 1306
 					$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/>';
1307 1307
 				}
1308 1308
 			}
1309 1309
 		}
1310
-		if(!empty($db_table_field_error)){
1310
+		if (!empty($db_table_field_error)) {
1311 1311
 			$db_table_field_error = '<hr class="clear" />' . $db_table_field_error . '<hr/>';
1312 1312
 		}
1313 1313
 
1314 1314
 		/*	Start display	*/
1315 1315
 		$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/>';
1316
-		if($error_nb > 0){
1316
+		if ($error_nb > 0) {
1317 1317
 			$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/>
1318 1318
 							<ul>';
1319
-			foreach($error_list as $version => $element_nb){
1320
-				$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>';
1319
+			foreach ($error_list as $version => $element_nb) {
1320
+				$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>';
1321 1321
 			}
1322 1322
 			$plugin_install_error .= '
1323 1323
 							</ul>';
1324 1324
 		}
1325
-		if($warning_nb > 0){
1325
+		if ($warning_nb > 0) {
1326 1326
 			$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/>';
1327
-			foreach($warning_list as $version => $element_nb){
1327
+			foreach ($warning_list as $version => $element_nb) {
1328 1328
 				$plugin_install_error .= '&nbsp;&nbsp;' . sprintf(__('There are %d warning into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - ';
1329 1329
 			}
1330 1330
 			$plugin_install_error = substr($plugin_install_error, 0, -3) . '<hr/>';
1331 1331
 		}
1332 1332
 
1333 1333
 		$max_number = 0;
1334
-		foreach($wpshop_update_way as $number => $operation){
1335
-			if($number > $max_number){
1334
+		foreach ($wpshop_update_way as $number => $operation) {
1335
+			if ($number > $max_number) {
1336 1336
 				$max_number = $number;
1337 1337
 			}
1338 1338
 		}
@@ -1342,30 +1342,30 @@  discard block
 block discarded – undo
1342 1342
 	add_action('wp_ajax_wpshop_tool_db_check', 'wpshop_ajax_db_check_tool');
1343 1343
 
1344 1344
 	function wpshop_tool_default_datas_check() {
1345
-		check_ajax_referer( 'wpshop_tool_default_datas_check' );
1345
+		check_ajax_referer('wpshop_tool_default_datas_check');
1346 1346
 
1347 1347
 		$output_ok = $output_error = '';
1348 1348
 
1349 1349
 		/**	Get defined default datas type	*/
1350
-		$default_custom_post_type = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES );
1350
+		$default_custom_post_type = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES);
1351 1351
 
1352 1352
 		/**	Read the default data saved to check	*/
1353
-		if ( !empty($default_custom_post_type) ) {
1354
-			foreach ( $default_custom_post_type as $type ) {
1353
+		if (!empty($default_custom_post_type)) {
1354
+			foreach ($default_custom_post_type as $type) {
1355 1355
 				$has_error = false;
1356 1356
 				$file_uri = WPSHOP_TEMPLATES_DIR . 'default_datas/' . $type . '.csv';
1357
-				if ( is_file( $file_uri ) ) {
1357
+				if (is_file($file_uri)) {
1358 1358
 					unset($tpl_component);
1359 1359
 					$tpl_component = array();
1360 1360
 					$tpl_component['CUSTOM_POST_TYPE_NAME'] = 'wpshop_cpt_' . $type;
1361 1361
 
1362 1362
 					/**	Launch check on custom post type	*/
1363
-					$check_cpt = wpshop_entities::check_default_custom_post_type( $type, $tpl_component );
1363
+					$check_cpt = wpshop_entities::check_default_custom_post_type($type, $tpl_component);
1364 1364
 					$has_error = $check_cpt[0];
1365 1365
 					$tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER'] = $check_cpt[1];
1366
-					$tpl_component = array_merge( $tpl_component, $check_cpt[2] );
1366
+					$tpl_component = array_merge($tpl_component, $check_cpt[2]);
1367 1367
 
1368
-					if ( $has_error ) {
1368
+					if ($has_error) {
1369 1369
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1370 1370
 					}
1371 1371
 					else {
@@ -1381,77 +1381,77 @@  discard block
 block discarded – undo
1381 1381
 	add_action('wp_ajax_wpshop_tool_default_datas_check', 'wpshop_tool_default_datas_check');
1382 1382
 
1383 1383
 	function wpshop_ajax_repair_default_datas() {
1384
-		check_ajax_referer( 'wpshop_ajax_repair_default_datas' );
1384
+		check_ajax_referer('wpshop_ajax_repair_default_datas');
1385 1385
 
1386 1386
 		global $wpdb;
1387 1387
 		$output = '';
1388 1388
 		$container = '';
1389 1389
 		$result = '';
1390 1390
 
1391
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1392
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1391
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1392
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1393 1393
 
1394
-		switch ( $selected_type ) {
1394
+		switch ($selected_type) {
1395 1395
 			case WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES:
1396
-				$result = wpshop_entities::create_cpt_from_csv_file( $identifier );
1396
+				$result = wpshop_entities::create_cpt_from_csv_file($identifier);
1397 1397
 			break;
1398 1398
 			case WPSHOP_DBT_ATTRIBUTE:
1399
-				$result = wpshop_entities::create_cpt_attributes_from_csv_file( $identifier );
1399
+				$result = wpshop_entities::create_cpt_attributes_from_csv_file($identifier);
1400 1400
 			break;
1401 1401
 		}
1402 1402
 
1403
-		echo json_encode( $result );
1403
+		echo json_encode($result);
1404 1404
 		die();
1405 1405
 	}
1406 1406
 	add_action('wp_ajax_wpshop_ajax_repair_default_datas', 'wpshop_ajax_repair_default_datas');
1407 1407
 
1408 1408
 	function wpshop_ajax_translate_default_datas() {
1409
-		check_ajax_referer( 'wpshop_ajax_translate_default_datas' );
1409
+		check_ajax_referer('wpshop_ajax_translate_default_datas');
1410 1410
 		global $wpdb;
1411 1411
 		$result = array('status' => true);
1412 1412
 
1413
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1414
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1413
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1414
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1415 1415
 
1416
-		$entity_id = wpshop_entities::get_entity_identifier_from_code( $identifier );
1416
+		$entity_id = wpshop_entities::get_entity_identifier_from_code($identifier);
1417 1417
 		$query = $wpdb->prepare("SELECT id, frontend_label FROM " . $selected_type . " WHERE entity_id = %d", $entity_id);
1418
-		$attribute_list = $wpdb->get_results( $query );
1419
-		if ( !empty($attribute_list) ) {
1420
-			foreach ( $attribute_list as $attribute) {
1421
-				$update_result = $wpdb->update( $selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id) );
1422
-				if ( $update_result === false ) {
1418
+		$attribute_list = $wpdb->get_results($query);
1419
+		if (!empty($attribute_list)) {
1420
+			foreach ($attribute_list as $attribute) {
1421
+				$update_result = $wpdb->update($selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id));
1422
+				if ($update_result === false) {
1423 1423
 					$result['status'] = false;
1424 1424
 				}
1425 1425
 			}
1426 1426
 		}
1427 1427
 
1428
-		echo json_encode( $result );
1428
+		echo json_encode($result);
1429 1429
 		die();
1430 1430
 	}
1431 1431
 	add_action('wp_ajax_wpshop_ajax_translate_default_datas', 'wpshop_ajax_translate_default_datas');
1432 1432
 
1433 1433
 	function wpshop_ajax_db_repair_tool() {
1434
-		check_ajax_referer( 'wpshop_ajax_db_repair_tool' );
1434
+		check_ajax_referer('wpshop_ajax_db_repair_tool');
1435 1435
 
1436 1436
 		$version_id = isset($_POST['version_id']) ? wpshop_tools::varSanitizer($_POST['version_id']) : null;
1437 1437
 
1438
-		echo wpshop_install::alter_db_structure_on_update( $version_id );
1438
+		echo wpshop_install::alter_db_structure_on_update($version_id);
1439 1439
 
1440 1440
 		die();
1441 1441
 	}
1442 1442
 	add_action('wp_ajax_wpshop_ajax_db_repair_tool', 'wpshop_ajax_db_repair_tool');
1443 1443
 
1444 1444
 	function wps_mass_action_main_interface() {
1445
-		check_ajax_referer( 'wps_mass_action_main_interface' );
1445
+		check_ajax_referer('wps_mass_action_main_interface');
1446 1446
 		$tpl_component = array();
1447 1447
 
1448 1448
 		/**	Copy an attribute content to another	*/
1449
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ), "'valid'", 'entity_id', true);
1449
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), "'valid'", 'entity_id', true);
1450 1450
 		$possible_values = array('' => __('Choose an attribute', 'wpshop'));
1451 1451
 		$possible_values_for_variation = array('' => __('Choose an attribute', 'wpshop'));
1452
-		foreach ( $attribute_list as $attribute ) {
1452
+		foreach ($attribute_list as $attribute) {
1453 1453
 			$possible_values[$attribute->id] = $attribute->frontend_label;
1454
-			if ( $attribute->is_used_for_variation == 'yes' ) {
1454
+			if ($attribute->is_used_for_variation == 'yes') {
1455 1455
 				$possible_values_for_variation[$attribute->id] = $attribute->frontend_label;
1456 1456
 			}
1457 1457
 		}
@@ -1482,22 +1482,22 @@  discard block
 block discarded – undo
1482 1482
 	add_action('wp_ajax_wps_mass_action', 'wps_mass_action_main_interface');
1483 1483
 
1484 1484
 	function wps_mass_action_update_attribute_value() {
1485
-		check_ajax_referer( 'wps_mass_action_update_attribute_value' );
1485
+		check_ajax_referer('wps_mass_action_update_attribute_value');
1486 1486
 		global $wpdb;
1487 1487
 		$response = array();
1488 1488
 
1489
-		$from = !empty( $_POST['wps_update_att_values']['from'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['from'] ) : '';
1490
-		$to = !empty( $_POST['wps_update_att_values']['to'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['to'] ) : '';
1491
-		$entity_to_transfert = !empty( $_POST['wps_entity_to_transfert'] ) ? sanitize_text_field( $_POST['wps_entity_to_transfert'] ) : '';
1489
+		$from = !empty($_POST['wps_update_att_values']['from']) ? sanitize_text_field($_POST['wps_update_att_values']['from']) : '';
1490
+		$to = !empty($_POST['wps_update_att_values']['to']) ? sanitize_text_field($_POST['wps_update_att_values']['to']) : '';
1491
+		$entity_to_transfert = !empty($_POST['wps_entity_to_transfert']) ? sanitize_text_field($_POST['wps_entity_to_transfert']) : '';
1492 1492
 
1493
-		if ( $from != $to ) {
1493
+		if ($from != $to) {
1494 1494
 			$from_attribute = wpshop_attributes::getElement($from, "'valid'");
1495 1495
 			$to_attribute = wpshop_attributes::getElement($to, "'valid'");
1496
-			if ( $from_attribute->data_type == $to_attribute->data_type ) {
1496
+			if ($from_attribute->data_type == $to_attribute->data_type) {
1497 1497
 
1498 1498
 				/**	Manage specific case	*/
1499 1499
 				$query_more_args = array();
1500
-				switch( $to_attribute->code ){
1500
+				switch ($to_attribute->code) {
1501 1501
 					case "barcode":
1502 1502
 							$more_query = "
1503 1503
 						AND VAL.value NOT LIKE %s";
@@ -1513,22 +1513,22 @@  discard block
 block discarded – undo
1513 1513
 					WHERE VAL.attribute_id = %d
1514 1514
 						AND P.post_type = %s
1515 1515
 						AND VAL.value != ''" . $more_query,
1516
-					array_merge( array( $from, $entity_to_transfert ), $query_more_args )
1516
+					array_merge(array($from, $entity_to_transfert), $query_more_args)
1517 1517
 				);
1518
-				$element_list_to_update = $wpdb->get_results( $query );
1518
+				$element_list_to_update = $wpdb->get_results($query);
1519 1519
 
1520
-				if ( !empty($element_list_to_update) ) {
1520
+				if (!empty($element_list_to_update)) {
1521 1521
 					$has_error = false;
1522 1522
 					$error_count = 0;
1523
-					foreach ( $element_list_to_update as $element ) {
1523
+					foreach ($element_list_to_update as $element) {
1524 1524
 
1525 1525
 						/**	Historicize the old value of recevier attribute	*/
1526
-						if (  $to_attribute->is_historisable == 'yes' ) {
1526
+						if ($to_attribute->is_historisable == 'yes') {
1527 1527
 							$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);
1528
-							$attribute_histos = $wpdb->get_results( $query );
1529
-							if ( !empty( $attribute_histos ) ) {
1530
-								foreach ( $attribute_histos as $attribute_histo ) {
1531
-									if ( !empty( $attribute_histo->value ) ) {
1528
+							$attribute_histos = $wpdb->get_results($query);
1529
+							if (!empty($attribute_histos)) {
1530
+								foreach ($attribute_histos as $attribute_histo) {
1531
+									if (!empty($attribute_histo->value)) {
1532 1532
 										$attribute_histo_content['status'] = 'valid';
1533 1533
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1534 1534
 										$attribute_histo_content['creation_date_value'] = $attribute_histo->creation_date_value;
@@ -1541,12 +1541,12 @@  discard block
 block discarded – undo
1541 1541
 										$attribute_histo_content['value'] = $attribute_histo->value;
1542 1542
 										$attribute_histo_content['value_type'] = WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType;
1543 1543
 										$last_histo = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO, $attribute_histo_content);
1544
-										if ( $last_histo === false ) {
1544
+										if ($last_histo === false) {
1545 1545
 											$has_error = true;
1546 1546
 											$error_count++;
1547 1547
 										}
1548 1548
 										else {
1549
-											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1549
+											$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array('value_id' => $attribute_histo->value_id));
1550 1550
 										}
1551 1551
 									}
1552 1552
 								}
@@ -1555,36 +1555,36 @@  discard block
 block discarded – undo
1555 1555
 
1556 1556
 						/**		*/
1557 1557
 						$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);
1558
-						$attribute_to_save = $wpdb->get_row( $query, ARRAY_A );
1558
+						$attribute_to_save = $wpdb->get_row($query, ARRAY_A);
1559 1559
 						unset($attribute_to_save['value_id']);
1560 1560
 						$attribute_to_save['attribute_id'] = $to_attribute->id;
1561 1561
 						$attribute_to_save['creation_date_value'] = current_time('mysql', 0);
1562 1562
 						$attribute_to_save['user_id'] = get_current_user_id();
1563
-						$new_value = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save );
1564
-						if ( $new_value === false ) {
1563
+						$new_value = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save);
1564
+						if ($new_value === false) {
1565 1565
 							$has_error = true;
1566 1566
 							$error_count++;
1567 1567
 						}
1568 1568
 						else {
1569 1569
 							/**	Save new atribute values in product metadata	*/
1570
-							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1570
+							$current_product_metadata = get_post_meta($element->ID, '_wpshop_product_metadata', true);
1571 1571
 							$current_product_metadata[$to_attribute->code] = $element->value;
1572
-							update_post_meta( $element->ID, '_wpshop_product_metadata', $current_product_metadata );
1572
+							update_post_meta($element->ID, '_wpshop_product_metadata', $current_product_metadata);
1573 1573
 
1574 1574
 							/**	Save a single meta for attribute in case it will be used in specific case where meta needs to be alone	*/
1575
-							if ( ( ($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes'))  || ( $to_attribute->is_filterable == 'yes') && !empty($element->value) ) :
1576
-								update_post_meta( $element->ID, '_' . $to_attribute->code, $element->value );
1575
+							if ((($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ($to_attribute->is_filterable == 'yes') && !empty($element->value)) :
1576
+								update_post_meta($element->ID, '_' . $to_attribute->code, $element->value);
1577 1577
 							endif;
1578 1578
 						}
1579 1579
 					}
1580 1580
 
1581
-					if ( !$has_error ) {
1581
+					if (!$has_error) {
1582 1582
 						$response['status'] = true;
1583 1583
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1584 1584
 					}
1585 1585
 					else {
1586 1586
 						$response['status'] = false;
1587
-						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1587
+						$response['error'] = sprinttf(__('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1588 1588
 					}
1589 1589
 				}
1590 1590
 				else {
@@ -1602,20 +1602,20 @@  discard block
 block discarded – undo
1602 1602
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1603 1603
 		}
1604 1604
 
1605
-		echo json_encode( $response );
1605
+		echo json_encode($response);
1606 1606
 		die();
1607 1607
 	}
1608 1608
 	add_action('wp_ajax_wps_mass_action_update_attribute', 'wps_mass_action_update_attribute_value');
1609 1609
 
1610 1610
 	function wps_tools_mass_action_load_possible_options_for_variations_attributes() {
1611 1611
 		// @TODO attribute_id est introuvable
1612
-		check_ajax_referer( 'wps_tools_mass_action_load_possible_options_for_variations_attributes' );
1612
+		check_ajax_referer('wps_tools_mass_action_load_possible_options_for_variations_attributes');
1613 1613
 		$output = '';
1614
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1615
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1614
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1615
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1616 1616
 
1617 1617
 		/**	Define new default value	*/
1618
-		$attribute_possible_values_output = wpshop_attributes::get_select_output( $attribute, array() );
1618
+		$attribute_possible_values_output = wpshop_attributes::get_select_output($attribute, array());
1619 1619
 		$attribute_possible_values_output['possible_value']['no_changes'] = __('No changes', 'wpshop');
1620 1620
 		$attribute_possible_values_output['possible_value']['none'] = __('No default value', 'wpshop');
1621 1621
 		ksort($attribute_possible_values_output['possible_value']);
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 		$input_def['valueToPut'] = 'index';
1625 1625
 		$input_def['name'] = 'wps_update_att_for_variation_options_values';
1626 1626
 		$input_def['id'] = 'wps_update_att_for_variation_options_values';
1627
-		$output .= __( 'Default value to affect for this attribute to all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1627
+		$output .= __('Default value to affect for this attribute to all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1628 1628
 
1629 1629
 		/**	Define if attribute is required for adding product to cart	*/
1630 1630
 		$input_def = array();
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 		$input_def['valueToPut'] = 'index';
1634 1634
 		$input_def['name'] = 'wps_update_att_for_variation_required_state';
1635 1635
 		$input_def['id'] = 'wps_update_att_for_variation_required_state';
1636
-		$output .= '<br/>' . __( 'Put this attribute as required for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1636
+		$output .= '<br/>' . __('Put this attribute as required for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1637 1637
 
1638 1638
 
1639 1639
 		$input_def = array();
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
 		$input_def['valueToPut'] = 'index';
1643 1643
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][text_from]';
1644 1644
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_text_from';
1645
-		$output .= '<br/>' . __( 'Display "Price from" text before price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1645
+		$output .= '<br/>' . __('Display "Price from" text before price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1646 1646
 
1647 1647
 		$input_def = array();
1648 1648
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'no' => __('No', 'wpshop'), 'yes' => __('Yes', 'wpshop'));
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 		$input_def['valueToPut'] = 'index';
1651 1651
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][lower_price]';
1652 1652
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_lower_price';
1653
-		$output .= '<br/>' . __( 'Display lower price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1653
+		$output .= '<br/>' . __('Display lower price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1654 1654
 
1655 1655
 		$input_def = array();
1656 1656
 		$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'));
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 		$input_def['valueToPut'] = 'index';
1659 1659
 		$input_def['name'] = 'wps_update_att_for_variation[price_behaviour]';
1660 1660
 		$input_def['id'] = 'wps_update_att_for_variation_price_behaviour';
1661
-		$output .= '<br/>' . __( 'Price calculation behaviour', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1661
+		$output .= '<br/>' . __('Price calculation behaviour', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1662 1662
 
1663 1663
 		$input_def = array();
1664 1664
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'single' => __('Priority to single options', 'wpshop'), 'combined' => __('Priority to combined options', 'wpshop'));
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 		$input_def['valueToPut'] = 'index';
1667 1667
 		$input_def['name'] = 'wps_update_att_for_variation[priority]';
1668 1668
 		$input_def['id'] = 'wps_update_att_for_variation_priority';
1669
-		$output .= '<br/>' . __( 'Choose priority combination for calculating options', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1669
+		$output .= '<br/>' . __('Choose priority combination for calculating options', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1670 1670
 
1671 1671
 		echo $output;
1672 1672
 		die();
@@ -1674,69 +1674,69 @@  discard block
 block discarded – undo
1674 1674
 	add_action('wp_ajax_wps_tools_mass_action_load_possible_options_for_variations_attributes', 'wps_tools_mass_action_load_possible_options_for_variations_attributes');
1675 1675
 
1676 1676
 	function wps_mass_action_change_variation_option() {
1677
-		check_ajax_referer( 'wps_mass_action_change_variation_option' );
1677
+		check_ajax_referer('wps_mass_action_change_variation_option');
1678 1678
 		global $wpdb;
1679 1679
 
1680
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1681
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1682
-		$query = $wpdb->prepare( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code );
1683
-		$meta_to_update = $wpdb->get_results( $query );
1680
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1681
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1682
+		$query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code);
1683
+		$meta_to_update = $wpdb->get_results($query);
1684 1684
 		$has_error = false;
1685
-		if ( !empty($meta_to_update) ) {
1686
-			foreach ( $meta_to_update as $meta_def ) {
1687
-				$meta_value = unserialize( $meta_def->meta_value );
1688
-				if ( !empty($meta_value) && !empty( $meta_value['attributes'] ) && in_array( $attribute->code, $meta_value['attributes']) ) {
1685
+		if (!empty($meta_to_update)) {
1686
+			foreach ($meta_to_update as $meta_def) {
1687
+				$meta_value = unserialize($meta_def->meta_value);
1688
+				if (!empty($meta_value) && !empty($meta_value['attributes']) && in_array($attribute->code, $meta_value['attributes'])) {
1689 1689
 
1690
-					$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'] ) : '';
1691
-					if ( $update_att_for_variation_options_values != 'no_changes' ) {
1690
+					$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']) : '';
1691
+					if ($update_att_for_variation_options_values != 'no_changes') {
1692 1692
 						$meta_value['options']['attributes_default_value'][$attribute->code] = $update_att_for_variation_options_values;
1693 1693
 					}
1694 1694
 
1695
-					$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'] ) : '';
1696
-					if ( !empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes') ) {
1697
-						if ( $wps_update_att_for_variation_required_state == 'yes') {
1695
+					$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']) : '';
1696
+					if (!empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes')) {
1697
+						if ($wps_update_att_for_variation_required_state == 'yes') {
1698 1698
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1699 1699
 						}
1700
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1700
+						else if (!empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code])) {
1701 1701
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1702 1702
 						}
1703 1703
 					}
1704 1704
 
1705
-					$update_att_for_variation = !empty( $_POST['wps_update_att_for_variation'] ) ? (array) $_POST['wps_update_att_for_variation'] : array();
1706
-					$text_from = !empty( $update_att_for_variation['text_from'] ) ? sanitize_text_field( $update_att_for_variation['text_from'] ) : '';
1707
-					if ( !empty( $update_att_for_variation ) ) {
1708
-						if ( !empty($text_from) && ($text_from != 'no_changes') ) {
1709
-							if ( $text_from == 'yes' ) {
1705
+					$update_att_for_variation = !empty($_POST['wps_update_att_for_variation']) ? (array)$_POST['wps_update_att_for_variation'] : array();
1706
+					$text_from = !empty($update_att_for_variation['text_from']) ? sanitize_text_field($update_att_for_variation['text_from']) : '';
1707
+					if (!empty($update_att_for_variation)) {
1708
+						if (!empty($text_from) && ($text_from != 'no_changes')) {
1709
+							if ($text_from == 'yes') {
1710 1710
 								$meta_value['options']['price_display']['text_from'] = 'on';
1711 1711
 							}
1712
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1712
+							else if (!empty($meta_value['options']['price_display']['text_from'])) {
1713 1713
 								unset($meta_value['options']['price_display']['text_from']);
1714 1714
 							}
1715 1715
 						}
1716 1716
 
1717
-						$lower_price = !empty( $update_att_for_variation['lower_price'] ) ? sanitize_text_field( $update_att_for_variation['lower_price'] ) : '';
1718
-						if ( !empty($lower_price) && ($lower_price != 'no_changes') ) {
1719
-							if ( $lower_price == 'yes' ) {
1717
+						$lower_price = !empty($update_att_for_variation['lower_price']) ? sanitize_text_field($update_att_for_variation['lower_price']) : '';
1718
+						if (!empty($lower_price) && ($lower_price != 'no_changes')) {
1719
+							if ($lower_price == 'yes') {
1720 1720
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1721 1721
 							}
1722
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1722
+							else if (!empty($meta_value['options']['price_display']['lower_price'])) {
1723 1723
 								unset($meta_value['options']['price_display']['lower_price']);
1724 1724
 							}
1725 1725
 						}
1726 1726
 
1727
-						$price_behaviour = !empty( $update_att_for_variation['price_behaviour'] ) ? sanitize_text_field( $update_att_for_variation['price_behaviour'] ) : '';
1728
-						if ( !empty($price_behaviour) && ($price_behaviour != 'no_changes') ) {
1727
+						$price_behaviour = !empty($update_att_for_variation['price_behaviour']) ? sanitize_text_field($update_att_for_variation['price_behaviour']) : '';
1728
+						if (!empty($price_behaviour) && ($price_behaviour != 'no_changes')) {
1729 1729
 							$meta_value['options']['price_behaviour'][0] = $price_behaviour;
1730 1730
 						}
1731 1731
 
1732
-						$priority = !empty( $update_att_for_variation['priority'] ) ? sanitize_text_field( $update_att_for_variation['priority'] ) : '';
1733
-						if ( !empty($priority) && ($priority != 'no_changes') ) {
1732
+						$priority = !empty($update_att_for_variation['priority']) ? sanitize_text_field($update_att_for_variation['priority']) : '';
1733
+						if (!empty($priority) && ($priority != 'no_changes')) {
1734 1734
 							$meta_value['options']['priority'][0] = $priority;
1735 1735
 						}
1736 1736
 					}
1737 1737
 
1738
-					$meta_save = update_meta( $meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1739
-					if ( $meta_save === false ) {
1738
+					$meta_save = update_meta($meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1739
+					if ($meta_save === false) {
1740 1740
 						$has_error = true;
1741 1741
 					}
1742 1742
 
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			}
1745 1745
 		}
1746 1746
 
1747
-		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
+		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'))));
1748 1748
 		die();
1749 1749
 	}
1750 1750
 	add_action('wp_ajax_wps_mass_action_change_variation_option', 'wps_mass_action_change_variation_option');
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
 	 */
1757 1757
 	function ajax_activate_addons() {
1758 1758
 		global $wpdb;
1759
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1759
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1760 1760
 
1761 1761
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1762 1762
 		$addon_code = isset($_POST['code']) ? wpshop_tools::varSanitizer($_POST['code']) : null;
@@ -1765,56 +1765,56 @@  discard block
 block discarded – undo
1765 1765
 		if (!empty($addon_name) && !empty($addon_code)) {
1766 1766
 			$addons_list = (unserialize(WPSHOP_ADDONS_LIST));
1767 1767
 			if (in_array($addon_name, array_keys($addons_list))) {
1768
-				$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
1768
+				$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
1769 1769
 				$code_part = array();
1770
-				$code_part[] = substr(hash ( "sha256" , $addons_list[$addon_name][0] ),  $addons_list[$addon_name][1], 5);
1771
-				$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
1772
-				$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
1770
+				$code_part[] = substr(hash("sha256", $addons_list[$addon_name][0]), $addons_list[$addon_name][1], 5);
1771
+				$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
1772
+				$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
1773 1773
 				$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
1774 1774
 
1775 1775
 				$current_web_site = site_url('/');
1776 1776
 
1777
-				if ( $addons_list[$addon_name][2] == 'per_site') {
1778
-					$code .= '-' . substr(hash ( "sha256" , $current_web_site ),  $addons_list[$addon_name][1], 5);
1777
+				if ($addons_list[$addon_name][2] == 'per_site') {
1778
+					$code .= '-' . substr(hash("sha256", $current_web_site), $addons_list[$addon_name][1], 5);
1779 1779
 				}
1780 1780
 
1781
-				if ( !empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1782
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1783
-					if ( empty($admin_new_quotation_message) ) {
1784
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1781
+				if (!empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1782
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1783
+					if (empty($admin_new_quotation_message)) {
1784
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1785 1785
 					}
1786
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1787
-					if ( empty($admin_new_quotation_confirm_message) ) {
1788
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1786
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1787
+					if (empty($admin_new_quotation_confirm_message)) {
1788
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1789 1789
 					}
1790 1790
 				}
1791 1791
 
1792 1792
 				if ($code == $addon_code) {
1793
-					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array() );
1793
+					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1794 1794
 					$extra_options[$addon_name]['activate'] = true;
1795 1795
 					$extra_options[$addon_name]['activation_date'] = current_time('mysql', 0);
1796 1796
 					$extra_options[$addon_name]['activation_code'] = $addon_code;
1797
-					if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1798
-						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated','wpshop'));
1799
-						if( !empty($addons_list[$addon_name][3]) ) {
1797
+					if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1798
+						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated', 'wpshop'));
1799
+						if (!empty($addons_list[$addon_name][3])) {
1800 1800
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1801 1801
 						}
1802 1802
 						$state = true;
1803 1803
 					}
1804 1804
 					else {
1805
-						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1805
+						$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1806 1806
 					}
1807 1807
 				}
1808 1808
 				else {
1809
-					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1809
+					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1810 1810
 				}
1811 1811
 			}
1812 1812
 			else {
1813
-				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1813
+				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1814 1814
 			}
1815 1815
 		}
1816 1816
 		else {
1817
-			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1817
+			$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1818 1818
 		}
1819 1819
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
1820 1820
 
@@ -1827,27 +1827,27 @@  discard block
 block discarded – undo
1827 1827
 	 * Addons desactivate
1828 1828
 	 */
1829 1829
 	function ajax_desactivate_wpshop_addons() {
1830
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1830
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1831 1831
 
1832 1832
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1833 1833
 		$state = true;
1834 1834
 
1835
-		if ( !empty($addon_name) ) {
1835
+		if (!empty($addon_name)) {
1836 1836
 			$addons_list = array_keys(unserialize(WPSHOP_ADDONS_LIST));
1837 1837
 			if (in_array($addon_name, $addons_list)) {
1838 1838
 				$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1839 1839
 				$extra_options[$addon_name]['activate'] = false;
1840 1840
 				$extra_options[$addon_name]['deactivation_date'] = current_time('mysql', 0);
1841
-				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1842
-					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1841
+				if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1842
+					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated', 'wpshop'));
1843 1843
 					$state = false;
1844 1844
 				}
1845 1845
 				else {
1846
-					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1846
+					$result = array(false, __('An error occured', 'wpshop'), __('Activated', 'wpshop'));
1847 1847
 				}
1848 1848
 			}
1849 1849
 			else {
1850
-				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1850
+				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated', 'wpshop'));
1851 1851
 			}
1852 1852
 		}
1853 1853
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1861,39 +1861,39 @@  discard block
 block discarded – undo
1861 1861
 	 * Display opttions for including user address into account form
1862 1862
 	 */
1863 1863
 	function ajax_integrate_billing_into_register() {
1864
-		check_ajax_referer( 'wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce' );
1864
+		check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce');
1865 1865
 		global $wpshop_account;
1866 1866
 		$wpshop_billing_address = get_option('wpshop_billing_address');
1867 1867
 		$current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null;
1868 1868
 		$selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null;
1869
-		$attribute = !empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array();
1870
-		$billing_form_fields = wps_address::get_addresss_form_fields_by_type ( $current_billing_address );
1869
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
1870
+		$billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address);
1871 1871
 		$possible_values_for_billing = array('' => __('No corresponding field', 'wpshop'));
1872
-		foreach ( $billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1873
-			foreach ( $attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1872
+		foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1873
+			foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1874 1874
 				$possible_values_for_billing[$attribute_build_code] = $attribute_definition['label'];
1875 1875
 			}
1876 1876
 		}
1877
-		$attributes_set = wpshop_attributes_set::getElement( 'yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1877
+		$attributes_set = wpshop_attributes_set::getElement('yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1878 1878
 		/*	Get the attribute set details in order to build the product interface	*/
1879
-		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'");
1880
-		if(!empty($productAttributeSetDetails)){
1881
-			foreach($productAttributeSetDetails as $productAttributeSetDetail){
1882
-				if(count($productAttributeSetDetail['attribut']) >= 1){
1883
-					foreach($productAttributeSetDetail['attribut'] as $attribute) {
1884
-						if(!empty($attribute->id)) {
1885
-							$submitOrderInfos = !empty( $_POST['submitOrderInfos'] ) ? (int) $_POST['submitOrderInfos'] : 0;
1886
-							if( !empty($submitOrderInfos) ) {
1879
+		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'");
1880
+		if (!empty($productAttributeSetDetails)) {
1881
+			foreach ($productAttributeSetDetails as $productAttributeSetDetail) {
1882
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
1883
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
1884
+						if (!empty($attribute->id)) {
1885
+							$submitOrderInfos = !empty($_POST['submitOrderInfos']) ? (int)$_POST['submitOrderInfos'] : 0;
1886
+							if (!empty($submitOrderInfos)) {
1887 1887
 								$value = $attribute[$attribute->data_type][$attribute->code];
1888 1888
 							}
1889 1889
 							else {
1890 1890
 								$value = '';
1891
-								if ( $attribute->code != 'user_pass') {
1891
+								if ($attribute->code != 'user_pass') {
1892 1892
 									$code = $attribute->code;
1893 1893
 									$value = $user->$code;
1894 1894
 								}
1895 1895
 							}
1896
-							$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute, $value, array() );
1896
+							$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array());
1897 1897
 							$account_form_field[$attribute->code] = $attribute_output_def;
1898 1898
 						}
1899 1899
 					}
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
 
1904 1904
 		$possible_values = array();
1905 1905
 		$matching_field = '';
1906
-		foreach ( $account_form_field as $attribute_code => $attribute_detail) {
1906
+		foreach ($account_form_field as $attribute_code => $attribute_detail) {
1907 1907
 			$possible_values[$attribute_code] = $attribute_detail['label'];
1908 1908
 
1909 1909
 			$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']';
@@ -1935,13 +1935,13 @@  discard block
 block discarded – undo
1935 1935
 	 * Search element in database for shortcode insertion interface
1936 1936
 	 */
1937 1937
 	function ajax_wpshop_element_search() {
1938
-		check_ajax_referer( 'wpshop_element_search', 'wpshop_ajax_nonce' );
1938
+		check_ajax_referer('wpshop_element_search', 'wpshop_ajax_nonce');
1939 1939
 
1940 1940
 		$wpshop_element_searched = isset($_REQUEST['wpshop_element_searched']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_searched']) : null;
1941 1941
 		$wpshop_element_type = isset($_REQUEST['wpshop_element_type']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_type']) : null;
1942 1942
 		$wpshop_format_result = isset($_REQUEST['wpshop_format_result']) ? (bool)wpshop_tools::varSanitizer($_REQUEST['wpshop_format_result']) : true;
1943 1943
 
1944
-		switch ( $wpshop_element_type ) {
1944
+		switch ($wpshop_element_type) {
1945 1945
 			case 'product':
1946 1946
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
1947 1947
 				$data = wpshop_products::product_list($wpshop_format_result, $wpshop_element_searched);
@@ -1951,18 +1951,18 @@  discard block
 block discarded – undo
1951 1951
 				break;
1952 1952
 			case WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS:
1953 1953
 				$wps_provider_ctr = new wps_provider_ctr();
1954
-				$data = $wps_provider_ctr->read( array( 's' => $wpshop_element_searched ) );
1954
+				$data = $wps_provider_ctr->read(array('s' => $wpshop_element_searched));
1955 1955
 				break;
1956 1956
 		}
1957 1957
 
1958
-		if ( $wpshop_format_result ) {
1958
+		if ($wpshop_format_result) {
1959 1959
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1960 1960
 		}
1961 1961
 		else {
1962
-			if ( !empty($data) ) {
1962
+			if (!empty($data)) {
1963 1963
 				$temp_data = $data;
1964
-				unset( $data );
1965
-				foreach ( $temp_data as $post) {
1964
+				unset($data);
1965
+				foreach ($temp_data as $post) {
1966 1966
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1967 1967
 				}
1968 1968
 			}
@@ -1983,35 +1983,35 @@  discard block
 block discarded – undo
1983 1983
 	 * Add product to the end user cart
1984 1984
 	 */
1985 1985
 	function ajax_wpshop_add_to_cart() {
1986
-		check_ajax_referer( 'ajax_pos_product_variation_selection' );
1986
+		check_ajax_referer('ajax_pos_product_variation_selection');
1987 1987
 
1988 1988
 		global $wpdb;
1989 1989
 		$wpshop_cart = new wps_cart();
1990 1990
 
1991 1991
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
1992 1992
 		$product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1;
1993
-		$cart_option = get_option('wpshop_cart_option', array() );
1993
+		$cart_option = get_option('wpshop_cart_option', array());
1994 1994
 		$wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? (array)$_POST['wps_pdt_variations'] : array();
1995
-		$from_administration =  ( !empty($_POST['from_admin']) ) ? (int)$_POST['from_admin'] : false;
1996
-		$order_id =  ( !empty($_POST['wps_orders_order_id']) ) ? wpshop_tools::varSanitizer( $_POST['wps_orders_order_id'] ) : null;
1995
+		$from_administration = (!empty($_POST['from_admin'])) ? (int)$_POST['from_admin'] : false;
1996
+		$order_id = (!empty($_POST['wps_orders_order_id'])) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null;
1997 1997
 
1998 1998
 
1999 1999
 		// Check Cart Animation
2000
-		$cart_animation_choice = ( !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2001
-		if ( !empty($cart_option['total_nb_of_item_allowed']) && ((int) $cart_option['total_nb_of_item_allowed'][0] == 1) ) {
2000
+		$cart_animation_choice = (!empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2001
+		if (!empty($cart_option['total_nb_of_item_allowed']) && ((int)$cart_option['total_nb_of_item_allowed'][0] == 1)) {
2002 2002
 			$wpshop_cart->empty_cart();
2003 2003
 		}
2004 2004
 
2005 2005
 		// Prepare Product to be added to cart
2006
-		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected );
2006
+		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected);
2007 2007
 		$product_to_add_to_cart = $formatted_product[0];
2008 2008
 		$new_pid = $formatted_product[1];
2009 2009
 
2010 2010
 		// Check cart Type
2011 2011
 		$cart_type_for_adding = 'normal';
2012
-		$wpshop_cart_type = !empty( $_POST['wpshop_cart_type'] ) ? sanitize_text_field( $_POST['wpshop_cart_type'] ) : '';
2013
-		if (!empty($wpshop_cart_type) ) {
2014
-			switch(wpshop_tools::varSanitizer($wpshop_cart_type)){
2012
+		$wpshop_cart_type = !empty($_POST['wpshop_cart_type']) ? sanitize_text_field($_POST['wpshop_cart_type']) : '';
2013
+		if (!empty($wpshop_cart_type)) {
2014
+			switch (wpshop_tools::varSanitizer($wpshop_cart_type)) {
2015 2015
 				case 'quotation':
2016 2016
 					$wpshop_cart_type = 'quotation';
2017 2017
 					break;
@@ -2022,43 +2022,43 @@  discard block
 block discarded – undo
2022 2022
 		}
2023 2023
 
2024 2024
 		// Check Product image
2025
-		$product = get_post( $product_id );
2026
-		$product_img = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="no picture" />';
2027
-		if ( !empty($product_id) ) {
2028
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2029
-				$parent_def = wpshop_products::get_parent_variation( $product_id );
2030
-				$parent_post = ( !empty($parent_def['parent_post']) ) ? $parent_def['parent_post'] : array();
2031
-				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
2032
-				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
2033
-				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
2025
+		$product = get_post($product_id);
2026
+		$product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />';
2027
+		if (!empty($product_id)) {
2028
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2029
+				$parent_def = wpshop_products::get_parent_variation($product_id);
2030
+				$parent_post = (!empty($parent_def['parent_post'])) ? $parent_def['parent_post'] : array();
2031
+				$product_title = (!empty($parent_post) && !empty($parent_post->post_title)) ? $parent_post->post_title : '';
2032
+				$product_description = (!empty($parent_post) && !empty($parent_post->post_content)) ? $parent_post->post_content : '';
2033
+				$product_img = (!empty($parent_post->ID)) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : '';
2034 2034
 			}
2035 2035
 			else {
2036 2036
 				$product_title = $product->post_title;
2037 2037
 				$product_description = $product->post_content;
2038
-				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
2038
+				$product_img = get_the_post_thumbnail($product_id, 'thumbnail');
2039 2039
 			}
2040 2040
 		}
2041 2041
 
2042
-		$wps_orders_from_admin = !empty( $_POST['wps_orders_from_admin'] ) ? (int) $_POST['wps_orders_from_admin'] : 0;
2043
-		if ( !empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2042
+		$wps_orders_from_admin = !empty($_POST['wps_orders_from_admin']) ? (int)$_POST['wps_orders_from_admin'] : 0;
2043
+		if (!empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2044 2044
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2045
-			$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
+			$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);
2046 2046
 
2047
-			echo json_encode( array(true) );
2047
+			echo json_encode(array(true));
2048 2048
 			die();
2049 2049
 		}
2050 2050
 		else {
2051
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2051
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type);
2052 2052
 		}
2053 2053
 
2054
-		if ( $return == 'success' ) {
2055
-			$cart_page_url = apply_filters( 'wps_cart_page_url', get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_cart_page_id' ) ) ) );
2054
+		if ($return == 'success') {
2055
+			$cart_page_url = apply_filters('wps_cart_page_url', get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))));
2056 2056
 			/** Template parameters	*/
2057 2057
 			$template_part = 'product_added_to_cart_message';
2058 2058
 
2059 2059
 			/** Build template	*/
2060 2060
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2061
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2061
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2062 2062
 				/*	Include the old way template part	*/
2063 2063
 				ob_start();
2064 2064
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2077,14 +2077,14 @@  discard block
 block discarded – undo
2077 2077
 
2078 2078
 			/** Product Price **/
2079 2079
 			$product_price = '';
2080
-			if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart) ) {
2080
+			if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) {
2081 2081
 				$idp = '';
2082 2082
 
2083
-				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2083
+				if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) {
2084 2084
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2085 2085
 				}
2086 2086
 				else {
2087
-					if( strstr( $new_pid, '__') ) {
2087
+					if (strstr($new_pid, '__')) {
2088 2088
 						$idp = $new_pid;
2089 2089
 					}
2090 2090
 					else {
@@ -2092,43 +2092,43 @@  discard block
 block discarded – undo
2092 2092
 					}
2093 2093
 				}
2094 2094
 
2095
-				if( !empty($idp) ) {
2096
-					$default_currency = wpshop_tools::wpshop_get_currency( false );
2097
-					$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
2095
+				if (!empty($idp)) {
2096
+					$default_currency = wpshop_tools::wpshop_get_currency(false);
2097
+					$price_piloting_option = get_option('wpshop_shop_price_piloting');
2098 2098
 
2099 2099
 					$real_price = null;
2100
-					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'] ) ) {
2101
-						$real_price = ( $_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty );
2100
+					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'])) {
2101
+						$real_price = ($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty);
2102 2102
 					}
2103 2103
 
2104
-					$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;
2105
-					$product_price = wpshop_tools::formate_number( $pr ).$default_currency;
2104
+					$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;
2105
+					$product_price = wpshop_tools::formate_number($pr) . $default_currency;
2106 2106
 				}
2107 2107
 			}
2108 2108
 			/** Check if there are linked products **/
2109
-			$related_products = get_post_meta( $product_id, '_wpshop_product_related_products', true);
2109
+			$related_products = get_post_meta($product_id, '_wpshop_product_related_products', true);
2110 2110
 			$tpl_component = array();
2111 2111
 			$linked_products = '';
2112
-			if ( !empty($related_products) ) {
2112
+			if (!empty($related_products)) {
2113 2113
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2114
-				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2114
+				$linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>';
2115 2115
 			}
2116 2116
 			else {
2117 2117
 				$linked_products = '';
2118 2118
 			}
2119 2119
 
2120
-			$message_confirmation = sprintf( __('%s has been add to the cart', 'wpshop'), $product->post_title );
2120
+			$message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title);
2121 2121
 
2122
-			$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) );
2123
-			$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') ) ) ) );
2122
+			$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));
2123
+			$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')))));
2124 2124
 
2125
-			$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
+			$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);
2126 2126
 		}
2127 2127
 		else {
2128
-			$response = array( false, $return );
2128
+			$response = array(false, $return);
2129 2129
 		}
2130 2130
 
2131
-		wp_die( json_encode( $response ) );
2131
+		wp_die(json_encode($response));
2132 2132
 	}
2133 2133
  	add_action('wp_ajax_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
2134 2134
 	add_action('wp_ajax_nopriv_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
@@ -2138,45 +2138,45 @@  discard block
 block discarded – undo
2138 2138
 	 * Set product qty into customer cart
2139 2139
 	 */
2140 2140
 	function ajax_wpshop_set_qty_for_product_into_cart() {
2141
-		check_ajax_referer( 'ajax_wpshop_set_qty_for_product_into_cart' );
2141
+		check_ajax_referer('ajax_wpshop_set_qty_for_product_into_cart');
2142 2142
 		$response = array();
2143 2143
 		$wpshop_cart = new wps_cart();
2144 2144
 		$product_id = isset($_POST['product_id']) ? wpshop_tools::varSanitizer($_POST['product_id']) : null;
2145 2145
 		$product_qty = isset($_POST['product_qty']) ? intval(wpshop_tools::varSanitizer($_POST['product_qty'])) : null;
2146 2146
 
2147 2147
 		$pid = $product_id;
2148
-		if (strpos($product_id,'__') !== false) {
2148
+		if (strpos($product_id, '__') !== false) {
2149 2149
 			//$pid = $_SESSION['cart']['order_items'][$product_id]['item_id'];
2150
-			foreach( $_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation ) {
2150
+			foreach ($_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation) {
2151 2151
 				$pid = $variation['product_id'];
2152 2152
 				break;
2153 2153
 			}
2154 2154
 		}
2155 2155
 
2156
-		$global_discount = !empty( $_POST['global_discount'] ) ? (int) $_POST['global_discount'] : 0;
2157
-		if ( !empty($global_discount) ) {
2156
+		$global_discount = !empty($_POST['global_discount']) ? (int)$_POST['global_discount'] : 0;
2157
+		if (!empty($global_discount)) {
2158 2158
 			$_SESSION['cart']['pos_global_discount'] = $global_discount;
2159 2159
 		}
2160 2160
 
2161 2161
 		if (!empty($product_id)) {
2162 2162
 			if (isset($product_qty)) {
2163
-				if ( $product_qty == 0 ) {
2164
-					$variation_of_product = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1) );
2165
-					if ( !empty($variation_of_product) ) {
2166
-						foreach ( $variation_of_product as $p_id) {
2163
+				if ($product_qty == 0) {
2164
+					$variation_of_product = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1));
2165
+					if (!empty($variation_of_product)) {
2166
+						foreach ($variation_of_product as $p_id) {
2167 2167
 							$wpshop_cart->set_product_qty($p_id->ID, $product_qty);
2168 2168
 						}
2169 2169
 					}
2170 2170
 				}
2171
-				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2171
+				$return = $wpshop_cart->set_product_qty($product_id, $product_qty, $pid);
2172 2172
 				$response[] = $return;
2173 2173
 			}
2174 2174
 			else {
2175 2175
 				$response[] = false;
2176
-				$response[] = __('Parameters error.','wpshop');
2176
+				$response[] = __('Parameters error.', 'wpshop');
2177 2177
 			}
2178 2178
 		}
2179
-		wp_die( json_encode( $response ) );
2179
+		wp_die(json_encode($response));
2180 2180
 	}
2181 2181
 	add_action('wp_ajax_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
2182 2182
 	add_action('wp_ajax_nopriv_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 	 * Display cart after doing an action on it
2186 2186
 	 */
2187 2187
 	function ajax_wpshop_display_cart() {
2188
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2188
+		check_ajax_referer('ajax_wpshop_display_cart');
2189 2189
 		ini_set('display_errors', true);
2190 2190
 		error_reporting(E_ALL);
2191 2191
 		$wps_cart_ctr = new wps_cart();
@@ -2199,8 +2199,8 @@  discard block
 block discarded – undo
2199 2199
 	/**
2200 2200
 	 * Display mini cart widgte after doing an action on it
2201 2201
 	 */
2202
-	function ajax_wpshop_reload_mini_cart(){
2203
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2202
+	function ajax_wpshop_reload_mini_cart() {
2203
+		check_ajax_referer('ajax_wpshop_display_cart');
2204 2204
 		echo wpshop_cart::mini_cart_content();
2205 2205
 		die();
2206 2206
 	}
@@ -2211,16 +2211,16 @@  discard block
 block discarded – undo
2211 2211
 	 * Refresh Price in complete product sheet and Cart summary display
2212 2212
 	 */
2213 2213
 	function wpshop_ajax_wpshop_variation_selection() {
2214
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2214
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2215 2215
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
2216 2216
 		$wpshop_variation_selected = isset($_POST['wpshop_variation']) ? (array)$_POST['wpshop_variation'] : null;
2217 2217
 		$wpshop_free_variation = isset($_POST['wpshop_free_variation']) ? (array)$_POST['wpshop_free_variation'] : null;
2218
-		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field( $_POST['wpshop_current_for_display'] ) : null;
2218
+		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field($_POST['wpshop_current_for_display']) : null;
2219 2219
 		$product_qty = isset($_POST['product_qty']) ? (int)$_POST['product_qty'] : 1;
2220 2220
 
2221
-		$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
+		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty);
2222 2222
 
2223
-		wp_die( json_encode( $product_variation_summary ) );
2223
+		wp_die(json_encode($product_variation_summary));
2224 2224
 	}
2225 2225
 	add_action('wp_ajax_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
2226 2226
 	add_action('wp_ajax_nopriv_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
@@ -2230,23 +2230,23 @@  discard block
 block discarded – undo
2230 2230
 	function wpshop_ajax_variation_selection_show_detail_for_value() {
2231 2231
 		global $wpdb;
2232 2232
 
2233
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2233
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2234 2234
 
2235 2235
 		$display = '';
2236 2236
 		$attribute_for_detail = isset($_POST['attribute_for_detail']) ? (array)$_POST['attribute_for_detail'] : array();
2237 2237
 
2238
-		if ( !empty( $attribute_for_detail ) ) {
2238
+		if (!empty($attribute_for_detail)) {
2239 2239
 			$selection = array();
2240
-			foreach ( $attribute_for_detail as $selected_variation ) {
2240
+			foreach ($attribute_for_detail as $selected_variation) {
2241 2241
 				$variation_definition = explode('-_variation_val_-', $selected_variation);
2242 2242
 				$attribute_definition = wpshop_attributes::getElement($variation_definition[0], "'valid'", 'code');
2243 2243
 				$post_definition = get_post($variation_definition[1]);
2244 2244
 
2245
-				if ( !empty($post_definition) ) {
2246
-					$post_content = ( !empty($post_definition) && !empty($post_definition->post_content) ) ? $post_definition->post_content : '';
2247
-					if ( empty($post_content) && !empty($post_definition->post_parent) ) {
2245
+				if (!empty($post_definition)) {
2246
+					$post_content = (!empty($post_definition) && !empty($post_definition->post_content)) ? $post_definition->post_content : '';
2247
+					if (empty($post_content) && !empty($post_definition->post_parent)) {
2248 2248
 						$post_parent_definition = get_post($post_definition->post_parent);
2249
-						if ( !empty($post_parent_definition) ) {
2249
+						if (!empty($post_parent_definition)) {
2250 2250
 							$post_content = $post_parent_definition->post_content;
2251 2251
 						}
2252 2252
 					}
@@ -2273,74 +2273,74 @@  discard block
 block discarded – undo
2273 2273
 	 * Save customer account informations
2274 2274
 	 */
2275 2275
 	function wpshop_ajax_save_customer_account() {
2276
-		check_ajax_referer( 'wpshop_customer_register', 'wpshop_ajax_nonce' );
2276
+		check_ajax_referer('wpshop_customer_register', 'wpshop_ajax_nonce');
2277 2277
 		global $wpshop, $wpshop_account, $wpdb;
2278
-		$reponse='';
2278
+		$reponse = '';
2279 2279
 		$status = false;
2280 2280
 		$validate = true;
2281 2281
 
2282
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2282
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2283 2283
 
2284 2284
 		$user_id = get_current_user_id();
2285
-		$current_connected_user = !empty( $user_id ) ? $user_id : null;
2285
+		$current_connected_user = !empty($user_id) ? $user_id : null;
2286 2286
 		$wpshop_billing_address = get_option('wpshop_billing_address');
2287
-		if ( !empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']]) ) {
2288
-			if ( !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) ) {
2289
-				$address_fields = wps_address::get_addresss_form_fields_by_type ( $wpshop_billing_address['choice'] );
2287
+		if (!empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']])) {
2288
+			if (!empty($wpshop_billing_address['integrate_into_register_form_matching_field'])) {
2289
+				$address_fields = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2290 2290
 				$address_field = $address_fields[$wpshop_billing_address['choice']];
2291 2291
 				$temp_aray_for_matching = array_flip($wpshop_billing_address['integrate_into_register_form_matching_field']);
2292
-				foreach ( $address_field as $group_id => $group_detail) {
2293
-					foreach ( $group_detail['content'] as $attribute_build_code => $attribute_def) {
2294
-						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]] ) ) {
2292
+				foreach ($address_field as $group_id => $group_detail) {
2293
+					foreach ($group_detail['content'] as $attribute_build_code => $attribute_def) {
2294
+						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]])) {
2295 2295
 							$attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] = $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]];
2296
-							if ( $attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2']) ) {
2296
+							if ($attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'])) {
2297 2297
 								$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'];
2298 2298
 							}
2299 2299
 						}
2300 2300
 					}
2301 2301
 				}
2302
-				$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
+				$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');
2303 2303
 			}
2304 2304
 			$group = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2305 2305
 			$validate = false;
2306
-			foreach ( $group as $attribute_sets ) {
2307
-				foreach ( $attribute_sets as $attribute_set_field ) {
2306
+			foreach ($group as $attribute_sets) {
2307
+				foreach ($attribute_sets as $attribute_set_field) {
2308 2308
 					$validate = $wpshop->validateForm($attribute_set_field['content'], $attribute[$wpshop_billing_address['choice']], '');
2309 2309
 				}
2310 2310
 			}
2311 2311
 		}
2312
-		$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
+		$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')));
2313 2313
 
2314
-		$account_form_type = !empty( $_POST['account_form_type'] ) ? sanitize_text_field( $_POST['account_form_type'] ) : '';
2315
-		$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);
2316
-		if( $validate && $validate_personal_form_infos ) {
2317
-			$account_creation_result = $wpshop_account->save_account_form($user_id,  ( ( !empty($account_form_type) && $account_form_type == 'partial' ) ? 'partial' : 'complete') );
2314
+		$account_form_type = !empty($_POST['account_form_type']) ? sanitize_text_field($_POST['account_form_type']) : '';
2315
+		$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);
2316
+		if ($validate && $validate_personal_form_infos) {
2317
+			$account_creation_result = $wpshop_account->save_account_form($user_id, ((!empty($account_form_type) && $account_form_type == 'partial') ? 'partial' : 'complete'));
2318 2318
 			$status = $account_creation_result[0];
2319 2319
 			$user_id = $account_creation_result[1];
2320
-			$is_partial_account_creation  = $account_creation_result[2];
2321
-			if ( $is_partial_account_creation == 'partial' ) {
2320
+			$is_partial_account_creation = $account_creation_result[2];
2321
+			if ($is_partial_account_creation == 'partial') {
2322 2322
 				$permalink_option = get_option('permalink_structure');
2323
-				if ( !empty($permalink_option) ) {
2324
-					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2323
+				if (!empty($permalink_option)) {
2324
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '?complete_sign_up=ok';
2325 2325
 				}
2326 2326
 				else {
2327
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2327
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '&complete_sign_up=ok';
2328 2328
 				}
2329 2329
 			}
2330 2330
 			else {
2331
-				if ( !empty($_SESSION['cart']) ) {
2332
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2331
+				if (!empty($_SESSION['cart'])) {
2332
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')));
2333 2333
 				}
2334 2334
 				else {
2335
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2335
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2336 2336
 				}
2337 2337
 			}
2338 2338
 			// check if the customer have already register an address
2339
-			$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2339
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2340 2340
 			$exist_address = $wpdb->get_results($query);
2341 2341
 		}
2342 2342
 		// If there is errors
2343
-		if($wpshop->error_count()>0) {
2343
+		if ($wpshop->error_count() > 0) {
2344 2344
 			$reponse = $wpshop->show_messages();
2345 2345
 		}
2346 2346
 
@@ -2357,24 +2357,24 @@  discard block
 block discarded – undo
2357 2357
 	function wpshop_ajax_order_customer_adress_load() {
2358 2358
 		global $wpshop_account;
2359 2359
 		global $wpdb;
2360
-		check_ajax_referer( 'wpshop_order_customer_adress_load', 'wpshop_ajax_nonce' );
2361
-		$current_customer_id = !empty( $_REQUEST['customer_id'] ) ? (int)$_REQUEST['customer_id'] : 0;
2362
-		$order_id = !empty( $_REQUEST['order_id'] ) ? (int)$_REQUEST['order_id'] : 0;
2360
+		check_ajax_referer('wpshop_order_customer_adress_load', 'wpshop_ajax_nonce');
2361
+		$current_customer_id = !empty($_REQUEST['customer_id']) ? (int)$_REQUEST['customer_id'] : 0;
2362
+		$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2363 2363
 
2364
-		$order_postmeta = get_post_meta ($order_id, '_order_postmeta', true);
2365
-		$order_infos_postmeta = get_post_meta ($order_id, '_order_info', true);
2364
+		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
2365
+		$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
2366 2366
 
2367
-		if ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded')) ) {
2367
+		if (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded'))) {
2368 2368
 			/** Billing address display **/
2369 2369
 			$tpl_component['ADDRESS_COMBOBOX'] = '';
2370 2370
 			$tpl_component['ADDRESS_BUTTONS'] = '';
2371 2371
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Billing address', 'wpshop');
2372 2372
 			$tpl_component['ADDRESS_TYPE'] = 'billing_address';
2373 2373
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['billing']['id']);
2374
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['billing']['address'] );
2374
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['billing']['address']);
2375 2375
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2376
-			$retour =  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2377
-			unset( $tpl_component );
2376
+			$retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2377
+			unset($tpl_component);
2378 2378
 
2379 2379
 			/** Shipping address display **/
2380 2380
 			$retour .= '<div id="shipping_infos_bloc" class="wpshop_order_customer_container wpshop_order_customer_container_user_information">';
@@ -2383,67 +2383,67 @@  discard block
 block discarded – undo
2383 2383
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Shipping address', 'wpshop');
2384 2384
 			$tpl_component['ADDRESS_TYPE'] = 'shipping_address';
2385 2385
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['shipping']['id']);
2386
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['shipping']['address']);
2386
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['shipping']['address']);
2387 2387
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2388
-			$retour .=  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2389
-			unset( $tpl_component );
2388
+			$retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2389
+			unset($tpl_component);
2390 2390
 			$retour .= '</div>';
2391 2391
 			$retour .= '<div class="wpshop_cls"></div>';
2392
-			$result = json_encode( array(true, $retour) );
2392
+			$result = json_encode(array(true, $retour));
2393 2393
 
2394 2394
 		}
2395 2395
 
2396
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2397
-			$order_id = !empty( $_REQUEST['order_id'] ) ? (int) $_REQUEST['order_id'] : 0;
2396
+ 		elseif (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2397
+			$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2398 2398
  			$order_info_postmeta = get_post_meta($order_id, '_order_info', true);
2399 2399
 
2400 2400
  			$billing_id_attribute_set = get_option('wpshop_billing_address');
2401 2401
  			$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2402 2402
 
2403
- 			$order_billing_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address']) ) ? $order_info_postmeta['billing']['address'] : array();
2404
- 			$order_shipping_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address']) ) ? $order_info_postmeta['shipping']['address'] : array();
2403
+ 			$order_billing_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address'])) ? $order_info_postmeta['billing']['address'] : array();
2404
+ 			$order_shipping_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address'])) ? $order_info_postmeta['shipping']['address'] : array();
2405 2405
 
2406
- 			$billing_form = $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address );
2407
- 			if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2408
- 				$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address );
2406
+ 			$billing_form = $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address);
2407
+ 			if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2408
+ 				$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address);
2409 2409
  			}
2410 2410
 
2411
- 			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2411
+ 			$result = json_encode(array(true, $billing_form, $shipping_form, $current_customer_id));
2412 2412
  		}
2413 2413
 		else {
2414 2414
 				// Check the attribute set id of Billing Address
2415
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2415
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Billing address', 'wpshop') . '"', '');
2416 2416
 				$attribute_set_id = $wpdb->get_var($query);
2417 2417
 				$billing_id_attribute_set = get_option('wpshop_billing_address');
2418 2418
 				//Check the billing address id of the customer
2419
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2419
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2420 2420
 				$post_addresses = $wpdb->get_results($query);
2421 2421
 				$address_id = '';
2422
-				foreach ( $post_addresses as $post_address ) {
2423
-					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2424
-					if ( $address_type == $attribute_set_id ) {
2422
+				foreach ($post_addresses as $post_address) {
2423
+					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2424
+					if ($address_type == $attribute_set_id) {
2425 2425
 						$address_id = $post_address->ID;
2426 2426
 					}
2427 2427
 				}
2428 2428
 				$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2429 2429
 				$shipping_form = '';
2430
-				if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2430
+				if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2431 2431
 					// Check the attribute set id of Shipping Address
2432
-					$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Shipping address', 'wpshop'). '"', '');
2432
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Shipping address', 'wpshop') . '"', '');
2433 2433
 					$attribute_set_id = $wpdb->get_var($query);
2434 2434
 					//Check the billing address id of the customer
2435
-					$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2435
+					$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2436 2436
 					$post_addresses = $wpdb->get_results($query);
2437 2437
 					$shipping_address_id = '';
2438
-					foreach ( $post_addresses as $post_address ) {
2439
-						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2440
-						if ( $address_type == $attribute_set_id ) {
2438
+					foreach ($post_addresses as $post_address) {
2439
+						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2440
+						if ($address_type == $attribute_set_id) {
2441 2441
 							$shipping_address_id = $post_address->ID;
2442 2442
 						}
2443 2443
 					}
2444
-					$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], $shipping_address_id );
2444
+					$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], $shipping_address_id);
2445 2445
 				}
2446
-				$result = json_encode( array(true, $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], $address_id ), $shipping_form, $current_customer_id) );
2446
+				$result = json_encode(array(true, $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], $address_id), $shipping_form, $current_customer_id));
2447 2447
 		}
2448 2448
 		echo $result;
2449 2449
 		die();
@@ -2455,23 +2455,23 @@  discard block
 block discarded – undo
2455 2455
 	 */
2456 2456
 	function ajax_wpshop_add_entity() {
2457 2457
 		global $wpdb;
2458
-		check_ajax_referer( 'wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce' );
2458
+		check_ajax_referer('wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce');
2459 2459
 
2460
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2460
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2461 2461
 		$attributes = array();
2462 2462
 		/** Get the attribute to create	*/
2463 2463
 		$attribute_to_reload = null;
2464
-		if ( !empty($attribute['new_value_creation']) && is_array( $attribute['new_value_creation'] ) ) {
2465
-			foreach ( $attribute['new_value_creation'] as $attribute_code=>$value) {
2466
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', $attribute_code);
2464
+		if (!empty($attribute['new_value_creation']) && is_array($attribute['new_value_creation'])) {
2465
+			foreach ($attribute['new_value_creation'] as $attribute_code=>$value) {
2466
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $attribute_code);
2467 2467
 				$attribute_def = $wpdb->get_row($query);
2468
-				if ( $value != "" ) {
2469
-					if ( $attribute_def->data_type_to_use == 'internal' ) {
2468
+				if ($value != "") {
2469
+					if ($attribute_def->data_type_to_use == 'internal') {
2470 2470
 						$attribute_default_value = unserialize($attribute_def->default_value);
2471
-						if ( $attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) {
2472
-							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2473
-							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2474
-							$attribute_option_id = $wpdb->get_var( $query );
2471
+						if ($attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
2472
+							$user_id = wp_create_user(sanitize_user($value), wp_generate_password(12, false));
2473
+							$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id);
2474
+							$attribute_option_id = $wpdb->get_var($query);
2475 2475
 						}
2476 2476
 						else {
2477 2477
 							$entity_args = array(
@@ -2484,13 +2484,13 @@  discard block
 block discarded – undo
2484 2484
 						}
2485 2485
 					}
2486 2486
 					else {
2487
-						$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
+						$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));
2488 2488
 						$attribute_option_id = $wpdb->insert_id;
2489 2489
 					}
2490 2490
 
2491
-					foreach ( $attribute as $attribute => $val) {
2491
+					foreach ($attribute as $attribute => $val) {
2492 2492
 						foreach ($val as $k=>$v) {
2493
-							if ( $k == $attribute_code) {
2493
+							if ($k == $attribute_code) {
2494 2494
 								$attribute[$attribute][$k] = $attribute_option_id;
2495 2495
 							}
2496 2496
 						}
@@ -2499,82 +2499,82 @@  discard block
 block discarded – undo
2499 2499
 			}
2500 2500
 		}
2501 2501
 		/** Store send attribute into a new array for save purpose	*/
2502
-		if ( is_array( $attribute ) ) {
2503
-			foreach ( $attribute as $attribute_type => $attribute ) {
2504
-				foreach ( $attribute as $attribute_code => $attribute_value ) {
2505
-					if ( !isset( $attributes[$attribute_code] ) ) {
2502
+		if (is_array($attribute)) {
2503
+			foreach ($attribute as $attribute_type => $attribute) {
2504
+				foreach ($attribute as $attribute_code => $attribute_value) {
2505
+					if (!isset($attributes[$attribute_code])) {
2506 2506
 						$attributes[$attribute_code] = $attribute_value;
2507 2507
 					}
2508 2508
 				}
2509 2509
 			}
2510 2510
 		}
2511 2511
 
2512
-		$post_title = !empty( $_POST['wp_fields']['post_title'] ) ? sanitize_text_field( $_POST['wp_fields']['post_title'] ) : '';
2513
-		$entity_type = !empty( $_POST['entity_type'] ) ? sanitize_text_field( $_POST['entity_type'] ) : '';
2514
-		$attribute_set_id = !empty( $_POST['attribute_set_id'] ) ? (int) $_POST['attribute_set_id'] : 0;
2515
-		$type_of_form = !empty( $_POST['type_of_form'] ) ? sanitize_text_field( $_POST['type_of_form'] ) : '';
2512
+		$post_title = !empty($_POST['wp_fields']['post_title']) ? sanitize_text_field($_POST['wp_fields']['post_title']) : '';
2513
+		$entity_type = !empty($_POST['entity_type']) ? sanitize_text_field($_POST['entity_type']) : '';
2514
+		$attribute_set_id = !empty($_POST['attribute_set_id']) ? (int)$_POST['attribute_set_id'] : 0;
2515
+		$type_of_form = !empty($_POST['type_of_form']) ? sanitize_text_field($_POST['type_of_form']) : '';
2516 2516
 
2517 2517
 		/** Save the new entity into database */
2518
-		$result = wpshop_entities::create_new_entity( $entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id) );
2518
+		$result = wpshop_entities::create_new_entity($entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id));
2519 2519
 		$new_entity_id = $result[1];
2520 2520
 
2521
-		if ( !empty($new_entity_id) ) {
2521
+		if (!empty($new_entity_id)) {
2522 2522
 			/**	Save address for current entity	*/
2523
-			if ( !empty( $type_of_form ) && !empty( $attribute[$type_of_form] ) ) {
2523
+			if (!empty($type_of_form) && !empty($attribute[$type_of_form])) {
2524 2524
 				global $wpshop_account;
2525
-				$result = wps_address::wps_address( $type_of_form );
2526
-				update_post_meta ($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2525
+				$result = wps_address::wps_address($type_of_form);
2526
+				update_post_meta($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2527 2527
 			}
2528 2528
 
2529 2529
 			/** Make price calculation if entity is a product	*/
2530
-			if ( $entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2530
+			if ($entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2531 2531
 				$wpshop_prices_attribute = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2532 2532
 				$calculate_price = false;
2533
-				foreach( $wpshop_prices_attribute as $attribute_price_code ){
2534
-					if ( array_key_exists($attribute_price_code, $attributes) ) {
2533
+				foreach ($wpshop_prices_attribute as $attribute_price_code) {
2534
+					if (array_key_exists($attribute_price_code, $attributes)) {
2535 2535
 						$calculate_price = true;
2536 2536
 					}
2537 2537
 				}
2538
-				if ( $calculate_price ) {
2538
+				if ($calculate_price) {
2539 2539
 					wpshop_products::calculate_price($new_entity_id);
2540 2540
 				}
2541 2541
 			}
2542 2542
 
2543 2543
 			/** Add picture if a file has been send	*/
2544
-			if ( !empty($_FILES) ) {
2544
+			if (!empty($_FILES)) {
2545 2545
 				$wp_upload_dir = wp_upload_dir();
2546 2546
 				$final_dir = $wp_upload_dir['path'] . '/';
2547
-				if ( !is_dir($final_dir) ) {
2547
+				if (!is_dir($final_dir)) {
2548 2548
 					mkdir($final_dir, 0755, true);
2549 2549
 				}
2550 2550
 
2551
-				foreach ( $_FILES as $file ) {
2551
+				foreach ($_FILES as $file) {
2552 2552
 					$tmp_name = $file['tmp_name']['post_thumbnail'];
2553 2553
 					$name = $file['name']['post_thumbnail'];
2554 2554
 
2555 2555
 					$filename = $final_dir . $name;
2556 2556
 					@move_uploaded_file($tmp_name, $filename);
2557 2557
 
2558
-					$wp_filetype = wp_check_filetype(basename($filename), null );
2558
+					$wp_filetype = wp_check_filetype(basename($filename), null);
2559 2559
 					$attachment = array(
2560
-						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ),
2560
+						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path($filename),
2561 2561
 						'post_mime_type' => $wp_filetype['type'],
2562
-						'post_title' => preg_replace( '/\.[^.]+$/', '', basename($filename) ),
2562
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
2563 2563
 						'post_content' => '',
2564 2564
 						'post_status' => 'inherit'
2565 2565
 					);
2566
-					$attach_id = wp_insert_attachment( $attachment, $filename, $new_entity_id );
2566
+					$attach_id = wp_insert_attachment($attachment, $filename, $new_entity_id);
2567 2567
 					require_once(ABSPATH . 'wp-admin/includes/image.php');
2568
-					$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
2569
-					wp_update_attachment_metadata( $attach_id, $attach_data );
2568
+					$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
2569
+					wp_update_attachment_metadata($attach_id, $attach_data);
2570 2570
 					add_post_meta($new_entity_id, '_thumbnail_id', $attach_id, true);
2571 2571
 				}
2572 2572
 			}
2573 2573
 
2574
-			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2574
+			echo json_encode(array(true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id));
2575 2575
 		}
2576 2576
 		else {
2577
-			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2577
+			echo json_encode(array(false, __('An error occured while adding your element', 'wpshop')));
2578 2578
 		}
2579 2579
 
2580 2580
 		die();
@@ -2583,47 +2583,47 @@  discard block
 block discarded – undo
2583 2583
 // 	add_action('wp_ajax_nopriv_wpshop_quick_add_entity', 'ajax_wpshop_add_entity');
2584 2584
 
2585 2585
 	function ajax_wpshop_reload_attribute_for_quick_add() {
2586
-		check_ajax_referer( 'ajax_wpshop_reload_attribute_for_quick_add' );
2586
+		check_ajax_referer('ajax_wpshop_reload_attribute_for_quick_add');
2587 2587
 		$output = '';
2588
-		$attribute_to_reload = !empty( $_POST['attribute_to_reload'] ) ? (array) $_POST['attribute_to_reload'] : array();
2589
-		if ( !empty($attribute_to_reload) ) {
2590
-			foreach ( $attribute_to_reload as $attribute_code ) {
2591
-				$attr_field = wpshop_attributes::display_attribute( $attribute_code, 'frontend' );
2588
+		$attribute_to_reload = !empty($_POST['attribute_to_reload']) ? (array)$_POST['attribute_to_reload'] : array();
2589
+		if (!empty($attribute_to_reload)) {
2590
+			foreach ($attribute_to_reload as $attribute_code) {
2591
+				$attr_field = wpshop_attributes::display_attribute($attribute_code, 'frontend');
2592 2592
 				$output[$attribute_code]['result'] = $attr_field['field_definition']['output'] . $attr_field['field_definition']['options'];
2593 2593
 			}
2594 2594
 		}
2595
-		echo json_encode( array($output) );
2595
+		echo json_encode(array($output));
2596 2596
 		die();
2597 2597
 	}
2598 2598
 	add_action('wp_ajax_reload_attribute_for_quick_add', 'ajax_wpshop_reload_attribute_for_quick_add');
2599 2599
 
2600 2600
 	function ajax_wpshop_change_address() {
2601
-		check_ajax_referer( 'ajax_wpshop_change_address' );
2602
-		$address_id = ( !empty($_POST['address_id']) ? (int) $_POST['address_id'] : null);
2603
-		$address_type = ( !empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2604
-		$is_allowed_destination  = true;
2605
-		if ( !empty($address_id) && !empty($address_type) ) {
2601
+		check_ajax_referer('ajax_wpshop_change_address');
2602
+		$address_id = (!empty($_POST['address_id']) ? (int)$_POST['address_id'] : null);
2603
+		$address_type = (!empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2604
+		$is_allowed_destination = true;
2605
+		if (!empty($address_id) && !empty($address_type)) {
2606 2606
 			//Check if it's an allowed address for shipping
2607 2607
 			$checkout_payment_button = '';
2608
-			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type'])=='quotation') ? 'quotation' : 'cart';
2609
-			$is_allowed_destination = true;//wpshop_shipping_configuration::is_allowed_country ( $address_id );
2610
-			if ( $is_allowed_destination ) {
2608
+			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type']) == 'quotation') ? 'quotation' : 'cart';
2609
+			$is_allowed_destination = true; //wpshop_shipping_configuration::is_allowed_country ( $address_id );
2610
+			if ($is_allowed_destination) {
2611 2611
 				$available_payement_method = wpshop_payment::display_payment_methods_choice_form(0, $cart_type);
2612 2612
 				//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')) {
2613
-				if ( !empty($available_payement_method[0]) ) {
2614
-					if ( $cart_type=='quotation' ) {
2615
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2613
+				if (!empty($available_payement_method[0])) {
2614
+					if ($cart_type == 'quotation') {
2615
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array());
2616 2616
 					}
2617 2617
 					else {
2618
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2618
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array());
2619 2619
 					}
2620 2620
 				}
2621 2621
 			}
2622 2622
 			else {
2623 2623
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2624 2624
 			}
2625
-			if( $address_type == 'billing_address') {
2626
-				$billing_option = get_option( 'wpshop_billing_address' );
2625
+			if ($address_type == 'billing_address') {
2626
+				$billing_option = get_option('wpshop_billing_address');
2627 2627
 				$address_option = $billing_option['choice'];
2628 2628
 			}
2629 2629
 			else {
@@ -2631,16 +2631,16 @@  discard block
 block discarded – undo
2631 2631
 				$address_option = $shipping_address_option['choice'];
2632 2632
 			}
2633 2633
 			$add = wps_address::get_addresss_form_fields_by_type($address_option);
2634
-			$address_infos = get_post_meta($address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
2635
-			$retour = wpshop_account::display_an_address ( $add, $address_infos, $address_id);
2634
+			$address_infos = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
2635
+			$retour = wpshop_account::display_an_address($add, $address_infos, $address_id);
2636 2636
 
2637 2637
 			$_SESSION[$address_type] = $address_id;
2638 2638
 
2639
-			$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>';
2640
-			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2639
+			$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>';
2640
+			$result = json_encode(array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button));
2641 2641
 		}
2642 2642
 		else {
2643
-			$result = json_encode( array(false, 'missing_informations') );
2643
+			$result = json_encode(array(false, 'missing_informations'));
2644 2644
 		}
2645 2645
 		echo $result;
2646 2646
 
@@ -2650,26 +2650,26 @@  discard block
 block discarded – undo
2650 2650
 	add_action('wp_ajax_nopriv_change_address', 'ajax_wpshop_change_address');
2651 2651
 
2652 2652
 	function ajax_wpshop_load_create_new_customer_interface() {
2653
-		check_ajax_referer( 'ajax_wpshop_load_create_new_customer_interface' );
2653
+		check_ajax_referer('ajax_wpshop_load_create_new_customer_interface');
2654 2654
 		$billing_address_option = get_option('wpshop_billing_address');
2655 2655
 		$shipping_address_option = get_option('wpshop_shipping_address_choice');
2656 2656
 
2657 2657
 		$tpl_component = array();
2658 2658
 		$tpl_component['LOADING_ICON'] = WPSHOP_LOADING_ICON;
2659
-		if ( !empty($billing_address) ) {
2660
-			echo wpshop_account::get_addresses_by_type( $billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2659
+		if (!empty($billing_address)) {
2660
+			echo wpshop_account::get_addresses_by_type($billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2661 2661
 		}
2662 2662
 		$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] = wpshop_account::display_form_fields($billing_address_option['choice'], '', 'first');
2663 2663
 
2664
-		if ( $shipping_address_option['activate'] ) {
2665
-			$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/>';
2664
+		if ($shipping_address_option['activate']) {
2665
+			$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/>';
2666 2666
 			$display = 'display:none;';
2667
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="'.$display.'">';
2667
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="' . $display . '">';
2668 2668
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= wpshop_account::display_form_fields($shipping_address_option['choice'], '', 'first');
2669 2669
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '</div><br/>';
2670 2670
 		}
2671 2671
 
2672
-		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save','wpshop') . '" /></p>';
2672
+		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save', 'wpshop') . '" /></p>';
2673 2673
 		$output = wpshop_display::display_template_element('wpshop_customer_addresses_form_admin', $tpl_component, array(), 'admin');
2674 2674
 		unset($tpl_component);
2675 2675
 		$result = json_encode(array(true, $output));
@@ -2679,18 +2679,18 @@  discard block
 block discarded – undo
2679 2679
 	add_action('wp_ajax_load_create_new_customer_interface', 'ajax_wpshop_load_create_new_customer_interface');
2680 2680
 
2681 2681
 	function ajax_wpshop_create_new_customer() {
2682
-		check_ajax_referer( 'ajax_wpshop_create_new_customer' );
2682
+		check_ajax_referer('ajax_wpshop_create_new_customer');
2683 2683
 		$result = '';
2684 2684
 		$billing_address = !empty($_REQUEST['billing_address']) ? sanitize_key($_REQUEST['billing_address']) : '';
2685 2685
 		$shipping_address = !empty($_REQUEST['shipping_address']) ? sanitize_key($_REQUEST['shipping_address']) : '';
2686 2686
 		$shiptobilling = !empty($_REQUEST['shiptobilling']) ? sanitize_key($_REQUEST['shiptobilling']) : null;
2687 2687
 		$username = !empty($_POST['attribute'][$billing_address]['varchar']['address_user_email']) ? sanitize_text_field($_POST['attribute'][$billing_address]['varchar']['address_user_email']) : null;
2688
-		if ( $username != null ) {
2688
+		if ($username != null) {
2689 2689
 			/** Crerate the new customer user account */
2690
-			$password = wp_generate_password( $length=12, $include_standard_special_chars=false );
2690
+			$password = wp_generate_password($length = 12, $include_standard_special_chars = false);
2691 2691
 			$email = $username;
2692
-			if ( !empty($username) && !username_exists($username) && !empty($email) && !email_exists($email) ) {
2693
-				$user_id = wp_create_user( $username, $password, $email );
2692
+			if (!empty($username) && !username_exists($username) && !empty($email) && !email_exists($email)) {
2693
+				$user_id = wp_create_user($username, $password, $email);
2694 2694
 				// @TODO : REQUEST
2695 2695
 				// $_REQUEST['user']['customer_id'] = $user_id;
2696 2696
 				/** Save addresses */
@@ -2701,21 +2701,21 @@  discard block
 block discarded – undo
2701 2701
 					wpshop_account::same_billing_and_shipping_address($billing_address, $shipping_address);
2702 2702
 				}
2703 2703
 
2704
-				if ( !empty($billing_address) ) {
2705
-					wps_address::save_address_infos( $billing_address );
2704
+				if (!empty($billing_address)) {
2705
+					wps_address::save_address_infos($billing_address);
2706 2706
 				}
2707
-				if( !empty($shipping_address ) ) {
2708
-					wps_address::save_address_infos( $shipping_address);
2707
+				if (!empty($shipping_address)) {
2708
+					wps_address::save_address_infos($shipping_address);
2709 2709
 				}
2710
-				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2710
+				$result = json_encode(array(true, __('Customer created', 'wpshop'), $user_id));
2711 2711
 			}
2712 2712
 			else {
2713
-				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2713
+				$result = json_encode(array(false, __('A customer account is already created with this email address', 'wpshop')));
2714 2714
 			}
2715 2715
 
2716 2716
 		}
2717 2717
 		else {
2718
-			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2718
+			$result = json_encode(array(false, __('An email address is required', 'wpshop')));
2719 2719
 		}
2720 2720
 		echo $result;
2721 2721
 		die();
@@ -2725,26 +2725,26 @@  discard block
 block discarded – undo
2725 2725
 	/**
2726 2726
 	 * Send a message to customer
2727 2727
 	 */
2728
-	function ajax_wpshop_send_message_by_type () {
2729
-		check_ajax_referer( 'ajax_wpshop_send_message_by_type' );
2728
+	function ajax_wpshop_send_message_by_type() {
2729
+		check_ajax_referer('ajax_wpshop_send_message_by_type');
2730 2730
 		global $wpdb;
2731 2731
 		$result = array();
2732
-		$message_type_id = ( !empty( $_POST['message_type_id'])) ? (int) $_POST['message_type_id'] : null;
2733
-		$customer_id = ( !empty( $_POST['customer_user_id'])) ? (int) $_POST['customer_user_id'] : null;
2734
-		$model_name = ( !empty( $_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2735
-		$order_id = ( !empty( $_POST['order_id'])) ? (int) $_POST['order_id'] : null;
2736
-		if ( !empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2732
+		$message_type_id = (!empty($_POST['message_type_id'])) ? (int)$_POST['message_type_id'] : null;
2733
+		$customer_id = (!empty($_POST['customer_user_id'])) ? (int)$_POST['customer_user_id'] : null;
2734
+		$model_name = (!empty($_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2735
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2736
+		if (!empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2737 2737
 			$order_post_meta = get_post_meta($order_id, '_order_postmeta', true);
2738
-			$receiver_infos = get_userdata( $customer_id );
2738
+			$receiver_infos = get_userdata($customer_id);
2739 2739
 			$email = $receiver_infos->user_email;
2740 2740
 			$first_name = get_user_meta($customer_id, 'first_name', true);
2741 2741
 			$last_name = get_user_meta($customer_id, 'last_name', true);
2742 2742
 			$wps_message = new wps_message_ctr();
2743
-			$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) );
2744
-			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2743
+			$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));
2744
+			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id));
2745 2745
 		}
2746 2746
 		else {
2747
-			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2747
+			$result = array('status' => false, 'response' => __('An error occured', 'wpshop'));
2748 2748
 		}
2749 2749
 		echo json_encode($result);
2750 2750
 		die();
@@ -2753,23 +2753,23 @@  discard block
 block discarded – undo
2753 2753
 
2754 2754
 
2755 2755
 	function ajax_wpshop_upload_downloadable_file_action() {
2756
-		check_ajax_referer( 'ajax_wpshop_upload_downloadable_file_action' );
2756
+		check_ajax_referer('ajax_wpshop_upload_downloadable_file_action');
2757 2757
 		$result = '';
2758
-		$element_identifier = ( !empty( $_POST ) && !empty( $_POST[ 'element_identifier' ] ) && is_int( (int)$_POST[ 'element_identifier' ] ) ) ? (int)$_POST[ 'element_identifier' ] : 0;
2759
-		$wpshop_uploaded_file = ( !empty( $_FILES ) && !empty( $_FILES[ 'wpshop_file' ] ) && is_array( (array)$_FILES[ 'wpshop_file' ] ) ) ? (array)$_FILES[ 'wpshop_file' ] : array();
2758
+		$element_identifier = (!empty($_POST) && !empty($_POST['element_identifier']) && is_int((int)$_POST['element_identifier'])) ? (int)$_POST['element_identifier'] : 0;
2759
+		$wpshop_uploaded_file = (!empty($_FILES) && !empty($_FILES['wpshop_file']) && is_array((array)$_FILES['wpshop_file'])) ? (array)$_FILES['wpshop_file'] : array();
2760 2760
 
2761
-		if ( !empty( $wpshop_uploaded_file ) && !empty( $element_identifier ) ) {
2762
-			if(!is_dir(WPSHOP_UPLOAD_DIR)){
2761
+		if (!empty($wpshop_uploaded_file) && !empty($element_identifier)) {
2762
+			if (!is_dir(WPSHOP_UPLOAD_DIR)) {
2763 2763
 				mkdir(WPSHOP_UPLOAD_DIR, 0755, true);
2764 2764
 			}
2765 2765
 			$file = $wpshop_uploaded_file;
2766 2766
 			$tmp_name = $file['tmp_name'];
2767
-			$name = sanitize_file_name( current_time( 'mysql', 0 ).'__'.$file["name"] );
2768
-			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR.$name);
2767
+			$name = sanitize_file_name(current_time('mysql', 0) . '__' . $file["name"]);
2768
+			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR . $name);
2769 2769
 
2770
-			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2771
-			update_post_meta( $element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2772
-			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2770
+			$n = WPSHOP_UPLOAD_URL . '/' . $name;
2771
+			update_post_meta($element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2772
+			$result = '<a href="' . $n . '" target="_blank" download>' . $name . '</a>';
2773 2773
 		}
2774 2774
 		else {
2775 2775
 			$result = '';
@@ -2780,92 +2780,92 @@  discard block
 block discarded – undo
2780 2780
 	add_action('wp_ajax_upload_downloadable_file_action', 'ajax_wpshop_upload_downloadable_file_action');
2781 2781
 
2782 2782
 	function ajax_wpshop_fill_the_downloadable_dialog() {
2783
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2784
-		check_ajax_referer( "ajax_wpshop_fill_the_downloadable_dialog".$product_id );
2783
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2784
+		check_ajax_referer("ajax_wpshop_fill_the_downloadable_dialog" . $product_id);
2785 2785
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2786 2786
 	}
2787 2787
 	function ajax_wpshop_fill_the_downloadable_dialog_unnonced() {
2788
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2788
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2789 2789
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2790 2790
 	}
2791
-	function ajax_wpshop_fill_the_downloadable_dialog_exec( $product_id ) {
2792
-		$output  = '<form method="post" action="' .admin_url('admin-ajax.php') .'" id="upload_downloadable_file" enctype="multipart/form-data" >';
2793
-		$output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>';
2791
+	function ajax_wpshop_fill_the_downloadable_dialog_exec($product_id) {
2792
+		$output  = '<form method="post" action="' . admin_url('admin-ajax.php') . '" id="upload_downloadable_file" enctype="multipart/form-data" >';
2793
+		$output .= '<p class="formField"><label for="wpshop_file">' . __('Choose your file to send', 'wpshop') . '</label><input type="file" name="wpshop_file" /></p>';
2794 2794
 		$output .= '<input type="hidden" name="action" value="upload_downloadable_file_action" />';
2795
-		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' .esc_attr( $product_id). '" />';
2796
-		$output .= wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false );
2797
-		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' .__('Send your file', 'wpshop'). '</a></p>';
2795
+		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' . esc_attr($product_id) . '" />';
2796
+		$output .= wp_nonce_field('ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false);
2797
+		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' . __('Send your file', 'wpshop') . '</a></p>';
2798 2798
 		$output .= '</form>';
2799
-		$output .='<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2799
+		$output .= '<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2800 2800
 		beforeSubmit : function() { },success: function(response) {
2801
-		jQuery(".is_downloadable_statut_'.$product_id.'").html( response );
2801
+		jQuery(".is_downloadable_statut_'.$product_id . '").html( response );
2802 2802
 		jQuery(".send_downloadable_file_dialog").dialog("close");
2803 2803
 		}});</script>';
2804
-		$output = apply_filters( 'wpshop_download_file_dialog', $output, $product_id );
2804
+		$output = apply_filters('wpshop_download_file_dialog', $output, $product_id);
2805 2805
 
2806
-		$response = array( 'status' => true, 'response' => $output);
2807
-		echo json_encode( $response );
2806
+		$response = array('status' => true, 'response' => $output);
2807
+		echo json_encode($response);
2808 2808
 		die();
2809 2809
 	}
2810 2810
 	add_action('wp_ajax_fill_the_downloadable_dialog', 'ajax_wpshop_fill_the_downloadable_dialog');
2811 2811
 	add_action('wp_ajax_fill_the_downloadable_dialog_unnonced', 'ajax_wpshop_fill_the_downloadable_dialog_unnonced');
2812 2812
 
2813 2813
 	function ajax_wpshop_show_downloadable_interface_in_admin() {
2814
-		$post_id = !empty( $_POST ) && !empty( $_POST[ 'post_id' ] ) && is_int( (int)$_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : 0;
2815
-		check_ajax_referer( 'ajax_wpshop_show_downloadable_interface_in_admin'.$post_id );
2814
+		$post_id = !empty($_POST) && !empty($_POST['post_id']) && is_int((int)$_POST['post_id']) ? (int)$_POST['post_id'] : 0;
2815
+		check_ajax_referer('ajax_wpshop_show_downloadable_interface_in_admin' . $post_id);
2816 2816
 		global $wpdb;
2817 2817
 		$status = false;
2818
-		$selected_value = ( !empty($_POST['selected_value']) ) ? sanitize_text_field( $_POST['selected_value'] ) : '';
2819
-		$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $selected_value);
2820
-		$value = $wpdb->get_var( $query );
2818
+		$selected_value = (!empty($_POST['selected_value'])) ? sanitize_text_field($_POST['selected_value']) : '';
2819
+		$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $selected_value);
2820
+		$value = $wpdb->get_var($query);
2821 2821
 
2822
-		if ( !empty($value) && __( $value, 'wpshop') == __('Yes', 'wpshop') ) {
2822
+		if (!empty($value) && __($value, 'wpshop') == __('Yes', 'wpshop')) {
2823 2823
 			$status = true;
2824 2824
 		}
2825
-		$response = array( 'status' => $status );
2826
-		echo json_encode( $response );
2825
+		$response = array('status' => $status);
2826
+		echo json_encode($response);
2827 2827
 		die();
2828 2828
 	}
2829
-	add_action( 'wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2829
+	add_action('wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2830 2830
 
2831 2831
 	function ajax_wpshop_restart_the_order() {
2832
-		check_ajax_referer( 'ajax_wpshop_restart_the_order' );
2832
+		check_ajax_referer('ajax_wpshop_restart_the_order');
2833 2833
 
2834 2834
 		global $wpshop_cart, $wpdb;
2835 2835
 		$status = $add_to_cart_checking = $manage_stock_checking_bool = false;
2836 2836
 		$add_to_cart_checking_message = '';
2837 2837
 		$result = __('Error, you cannot restart this order', 'wpshop');
2838
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2839
-		$is_make_order_again = ( !empty($_POST['make_order_again']) ) ? sanitize_text_field( $_POST['make_order_again'] ) : null;
2840
-		if( !empty( $order_id ) ) {
2838
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2839
+		$is_make_order_again = (!empty($_POST['make_order_again'])) ? sanitize_text_field($_POST['make_order_again']) : null;
2840
+		if (!empty($order_id)) {
2841 2841
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2842 2842
 			$_SESSION['cart'] = array();
2843 2843
 			$_SESSION['cart']['order_items'] = array();
2844 2844
 			$wpshop_cart_type = $order_meta['cart_type'];
2845 2845
 
2846
-			if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
2846
+			if (!empty($order_meta) && !empty($order_meta['order_items'])) {
2847 2847
 				$wpshop_cart_type = $order_meta['cart_type'];
2848
-				foreach( $order_meta['order_items'] as $item_key => $item ) {
2849
-					$item_meta = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true );
2850
-					$stock =  $item_meta['product_stock'];
2848
+				foreach ($order_meta['order_items'] as $item_key => $item) {
2849
+					$item_meta = get_post_meta($item['item_id'], '_wpshop_product_metadata', true);
2850
+					$stock = $item_meta['product_stock'];
2851 2851
 					$qty = $item['item_qty'];
2852
-					$item_option = get_post_meta( $item['item_id'], '_wpshop_product_options', true );
2853
-					if( !empty($item_meta['manage_stock']) ) {
2854
-						$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $item_meta['manage_stock']);
2855
-						$manage_stock_checking = $wpdb->get_var( $query );
2856
-						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2852
+					$item_option = get_post_meta($item['item_id'], '_wpshop_product_options', true);
2853
+					if (!empty($item_meta['manage_stock'])) {
2854
+						$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $item_meta['manage_stock']);
2855
+						$manage_stock_checking = $wpdb->get_var($query);
2856
+						if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2857 2857
 							$manage_stock_checking_bool = true;
2858 2858
 						}
2859 2859
 					}
2860 2860
 					else {
2861
-						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2862
-							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2863
-							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
2861
+						if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2862
+							$parent_product = wpshop_products::get_parent_variation($item['item_id']);
2863
+							if (!empty($parent_product) && !empty($parent_product['parent_post_meta'])) {
2864 2864
 								$parent_metadata = $parent_product['parent_post_meta'];
2865
-								if( !empty($parent_product['parent_post_meta']['manage_stock']) ) {
2866
-									$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2867
-									$manage_stock_checking = $wpdb->get_var( $query );
2868
-									if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2865
+								if (!empty($parent_product['parent_post_meta']['manage_stock'])) {
2866
+									$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2867
+									$manage_stock_checking = $wpdb->get_var($query);
2868
+									if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2869 2869
 										$manage_stock_checking_bool = true;
2870 2870
 										$stock = $parent_product['parent_post_meta']['product_stock'];
2871 2871
 									}
@@ -2878,8 +2878,8 @@  discard block
 block discarded – undo
2878 2878
 
2879 2879
 
2880 2880
 					/** Checking stock **/
2881
-					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 ) ) {
2882
-						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2881
+					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)) {
2882
+						$_SESSION['cart']['order_items'][$item_key] = $item;
2883 2883
 					}
2884 2884
 					else {
2885 2885
 						$add_to_cart_checking = true;
@@ -2888,40 +2888,40 @@  discard block
 block discarded – undo
2888 2888
 				}
2889 2889
 
2890 2890
 				$wps_cart_ctr = new wps_cart();
2891
-				$order = $wps_cart_ctr->calcul_cart_information( array() );
2891
+				$order = $wps_cart_ctr->calcul_cart_information(array());
2892 2892
 				$order['cart_type'] = $wpshop_cart_type;
2893
-				$wps_cart_ctr->store_cart_in_session( $order );
2893
+				$wps_cart_ctr->store_cart_in_session($order);
2894 2894
 			}
2895 2895
 
2896
-			if ( empty($is_make_order_again) ) {
2896
+			if (empty($is_make_order_again)) {
2897 2897
 				$_SESSION['order_id'] = $order_id;
2898 2898
 			}
2899 2899
 			$status = true;
2900 2900
 
2901
-			$result = get_permalink( get_option('wpshop_cart_page_id') );
2901
+			$result = get_permalink(get_option('wpshop_cart_page_id'));
2902 2902
 		}
2903 2903
 
2904
-		$response = array( 'status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2905
-		echo json_encode( $response );
2904
+		$response = array('status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2905
+		echo json_encode($response);
2906 2906
 		die();
2907 2907
 	}
2908
-	add_action( 'wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2908
+	add_action('wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2909 2909
 
2910 2910
 
2911 2911
 
2912 2912
 	function wps_hide_notice_messages() {
2913
-		check_ajax_referer( 'wps_hide_notice_messages' );
2913
+		check_ajax_referer('wps_hide_notice_messages');
2914 2914
 
2915 2915
 		$status = false;
2916
-		$indicator = !empty($_POST['indicator'] ) ? sanitize_text_field($_POST['indicator']) : null;
2917
-		if ( !empty($indicator) ) {
2916
+		$indicator = !empty($_POST['indicator']) ? sanitize_text_field($_POST['indicator']) : null;
2917
+		if (!empty($indicator)) {
2918 2918
 			$user_id = get_current_user_id();
2919
-			$hide_notice_meta = get_user_meta( $user_id, '_wps_hide_notice_messages_indicator', true);
2919
+			$hide_notice_meta = get_user_meta($user_id, '_wps_hide_notice_messages_indicator', true);
2920 2920
 			$hide_notice_meta = !empty($hide_notice_meta) ? $hide_notice_meta : array();
2921 2921
 			$indicators = explode(',', $indicator);
2922
-			if ( !empty($indicators) && is_array($indicators) ) {
2923
-				foreach( $indicators as $i ) {
2924
-					if ( !empty($i) ) {
2922
+			if (!empty($indicators) && is_array($indicators)) {
2923
+				foreach ($indicators as $i) {
2924
+					if (!empty($i)) {
2925 2925
 						$hide_notice_meta[$i] = true;
2926 2926
 					}
2927 2927
 				}
@@ -2930,7 +2930,7 @@  discard block
 block discarded – undo
2930 2930
 			$status = true;
2931 2931
 		}
2932 2932
 		$response = array('status' => $status);
2933
-		echo json_encode( $response );
2933
+		echo json_encode($response);
2934 2934
 		die();
2935 2935
 	}
2936 2936
 	add_action('wp_ajax_wps_hide_notice_messages', 'wps_hide_notice_messages');
@@ -2938,106 +2938,106 @@  discard block
 block discarded – undo
2938 2938
 
2939 2939
 
2940 2940
 	function wps_update_products_prices() {
2941
-		check_ajax_referer( 'wps_update_products_prices' );
2941
+		check_ajax_referer('wps_update_products_prices');
2942 2942
 		$action = wpshop_prices::mass_update_prices();
2943
-		$response = array( 'status' => $action[0], 'response' => $action[1] );
2944
-		echo json_encode( $response );
2943
+		$response = array('status' => $action[0], 'response' => $action[1]);
2944
+		echo json_encode($response);
2945 2945
 		die();
2946 2946
 	}
2947
-	add_action( 'wp_ajax_update_products_prices', 'wps_update_products_prices' );
2947
+	add_action('wp_ajax_update_products_prices', 'wps_update_products_prices');
2948 2948
 
2949 2949
 	/** Quotation is payable by customer **/
2950 2950
 	function wps_quotation_is_payable_by_customer() {
2951
-		check_ajax_referer( 'wps_quotation_is_payable_by_customer' );
2951
+		check_ajax_referer('wps_quotation_is_payable_by_customer');
2952 2952
 		global $wpdb;
2953 2953
 		$status = false;
2954 2954
 		$response = '';
2955
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
2956
-		if( isset($order_id) ) {
2957
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2958
-			if( isset( $order_metadata['pay_quotation'] ) ) {
2959
-				unset( $order_metadata['pay_quotation'] );
2955
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
2956
+		if (isset($order_id)) {
2957
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2958
+			if (isset($order_metadata['pay_quotation'])) {
2959
+				unset($order_metadata['pay_quotation']);
2960 2960
 			} else {
2961 2961
 				$order_metadata['pay_quotation'] = 'on';
2962 2962
 			}
2963
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
2963
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
2964 2964
 
2965
-			$response = wpshop_orders::display_customer_pay_quotation( isset( $order_metadata['pay_quotation'] ), $order_id );
2965
+			$response = wpshop_orders::display_customer_pay_quotation(isset($order_metadata['pay_quotation']), $order_id);
2966 2966
 			$status = true;
2967 2967
 		} else {
2968
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2968
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
2969 2969
 		}
2970
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
2970
+		echo json_encode(array('status' => $status, 'response' => $response));
2971 2971
 		die();
2972 2972
 	}
2973
-	add_action( 'wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer' );
2973
+	add_action('wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer');
2974 2974
 
2975 2975
 	/** Send a direct payment Link **/
2976 2976
 	function wps_send_direct_payment_link() {
2977
-		check_ajax_referer( 'wps_send_direct_payment_link' );
2977
+		check_ajax_referer('wps_send_direct_payment_link');
2978 2978
 		global $wpdb;
2979 2979
 		$status = false; $response = '';
2980
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2981
-		if( !empty($order_id) ) {
2980
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2981
+		if (!empty($order_id)) {
2982 2982
 			/** Get the customer **/
2983
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2984
-			if( !empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) {
2985
-				$user_infos = get_userdata( $order_metadata['customer_id'] );
2983
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2984
+			if (!empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') {
2985
+				$user_infos = get_userdata($order_metadata['customer_id']);
2986 2986
 
2987
-				$first_name =  get_user_meta($user_infos->ID, 'first_name', true);
2988
-				$last_name =  get_user_meta($user_infos->ID, 'last_name', true);
2987
+				$first_name = get_user_meta($user_infos->ID, 'first_name', true);
2988
+				$last_name = get_user_meta($user_infos->ID, 'last_name', true);
2989 2989
 
2990 2990
 
2991 2991
 				/** Create an activation key **/
2992
-				$token = wps_orders_ctr::wps_token_order_customer( $order_id );
2992
+				$token = wps_orders_ctr::wps_token_order_customer($order_id);
2993 2993
 				/*$token = wp_generate_password(20, false);
2994 2994
 				$wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login) );*/
2995 2995
 
2996
-				$permalink_option = get_option( 'permalink_structure' );
2997
-				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url( $order_id ) . '">' .__( 'Click here to pay your order', 'wpshop' ). '</a>';
2996
+				$permalink_option = get_option('permalink_structure');
2997
+				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url($order_id) . '">' . __('Click here to pay your order', 'wpshop') . '</a>';
2998 2998
 
2999 2999
 				/** Send message **/
3000 3000
 				$wps_message = new wps_message_ctr();
3001 3001
 				$wps_message->wpshop_prepared_email($user_infos->user_email,
3002 3002
 				'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE',
3003
-				array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '' )
3003
+				array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '')
3004 3004
 				);
3005 3005
 
3006
-				$response = __( 'Direct payment link has been send', 'wpshop' );
3006
+				$response = __('Direct payment link has been send', 'wpshop');
3007 3007
 				$status = true;
3008 3008
 			}
3009 3009
 			else {
3010
-				$response = __( 'An error was occured', 'wpshop' );
3010
+				$response = __('An error was occured', 'wpshop');
3011 3011
 			}
3012 3012
 		}
3013 3013
 		else {
3014
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
3014
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
3015 3015
 		}
3016
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3016
+		echo json_encode(array('status' => $status, 'response' => $response));
3017 3017
 		die();
3018 3018
 	}
3019
-	add_action( 'wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link' );
3019
+	add_action('wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link');
3020 3020
 
3021 3021
 	function wps_mass_action_product() {
3022
-		check_ajax_referer( 'wps_mass_action_product' );
3022
+		check_ajax_referer('wps_mass_action_product');
3023 3023
 		$mass_actions_tools_page = '';
3024
-		$default_attributes = array( 'product_stock', 'barcode', 'product_price', 'special_price', );
3024
+		$default_attributes = array('product_stock', 'barcode', 'product_price', 'special_price',);
3025 3025
 
3026 3026
 		/**	Copy an attribute content to another	*/
3027
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_PRODUCT ), "'valid'", 'entity_id', true);
3028
-		if ( !empty( $attribute_list ) ) {
3027
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_PRODUCT), "'valid'", 'entity_id', true);
3028
+		if (!empty($attribute_list)) {
3029 3029
 			$mass_actions_tools_page .= '
3030
-			<form action="' . admin_url( "admin-ajax.php" ) . '" method="POST" id="wps_mass_action_on_entity_form" >
3030
+			<form action="' . admin_url("admin-ajax.php") . '" method="POST" id="wps_mass_action_on_entity_form" >
3031 3031
 				<input type="hidden" value="wps_mass_action_on_entity_launch" name="action" />
3032
-				<!--<div>' . __( 'Choose attribute to display into list', 'wpshop' ) . '
3032
+				<!--<div>' . __('Choose attribute to display into list', 'wpshop') . '
3033 3033
 					<ul>';
3034
-			foreach ( $attribute_list as $attribute ) {
3034
+			foreach ($attribute_list as $attribute) {
3035 3035
 				$mass_actions_tools_page .= '
3036
-						<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
+						<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>';
3037 3037
 			}
3038 3038
 			$mass_actions_tools_page .= '
3039 3039
 					</ul>
3040
-					<button>' . __( 'Voir la liste des produits', 'wpshop' ) . '</button> -->
3040
+					<button>' . __('Voir la liste des produits', 'wpshop') . '</button> -->
3041 3041
 				</div>
3042 3042
 			</form>
3043 3043
 			<div id="wps_entity_list" >' . wps_mass_action_on_entity_launch() . '</div>
@@ -3050,32 +3050,32 @@  discard block
 block discarded – undo
3050 3050
 			</script>';
3051 3051
 		}
3052 3052
 
3053
-		wp_die( $mass_actions_tools_page );
3053
+		wp_die($mass_actions_tools_page);
3054 3054
 	}
3055
-	add_action( 'wp_ajax_wps_mass_action_product', 'wps_mass_action_product' );
3055
+	add_action('wp_ajax_wps_mass_action_product', 'wps_mass_action_product');
3056 3056
 
3057 3057
 	function wps_put_history_back() {
3058
-		check_ajax_referer( 'wps_put_history_back' );
3058
+		check_ajax_referer('wps_put_history_back');
3059 3059
 
3060 3060
 		global $wpdb;
3061 3061
 		$upload_dir = wp_upload_dir();
3062
-		$log_dir = $upload_dir[ 'basedir' ] . '/wps_repair/';
3063
-		wp_mkdir_p( $log_dir );
3064
-		$value_to_take = !empty($_POST[ 'value_to_take' ]) ? (array) $_POST[ 'value_to_take' ] : array();
3065
-		foreach ( $value_to_take as $product_id => $product_element ) {
3066
-			foreach( $product_element as $attribute_id => $attribute_value_to_take ){
3067
-				$query = $wpdb->prepare( "SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take );
3068
-				$the_new_value = $wpdb->get_row( $query );
3069
-				if ( 6 == $attribute_id ) {
3070
-					$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 );
3071
-					$the_tax = $wpdb->get_row( $query );
3072
-					$pttc = number_format( $the_new_value->value, 5, ".", " " );
3073
-					$ht = number_format( $pttc / ( 1 + ( $the_tax->value / 100 ) ), 5, ".", " " );
3074
-					$tax_amount = number_format( $pttc - $ht, 5, ".", " " );
3075
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 6 ) );
3076
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 28 ) );
3077
-					$wpdb->delete( 'wp_wpshop__attribute_value_integer', array( "entity_id" => $product_id, "attribute_id" => 29 ) );
3078
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 30 ) );
3062
+		$log_dir = $upload_dir['basedir'] . '/wps_repair/';
3063
+		wp_mkdir_p($log_dir);
3064
+		$value_to_take = !empty($_POST['value_to_take']) ? (array)$_POST['value_to_take'] : array();
3065
+		foreach ($value_to_take as $product_id => $product_element) {
3066
+			foreach ($product_element as $attribute_id => $attribute_value_to_take) {
3067
+				$query = $wpdb->prepare("SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take);
3068
+				$the_new_value = $wpdb->get_row($query);
3069
+				if (6 == $attribute_id) {
3070
+					$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);
3071
+					$the_tax = $wpdb->get_row($query);
3072
+					$pttc = number_format($the_new_value->value, 5, ".", " ");
3073
+					$ht = number_format($pttc / (1 + ($the_tax->value / 100)), 5, ".", " ");
3074
+					$tax_amount = number_format($pttc - $ht, 5, ".", " ");
3075
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 6));
3076
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 28));
3077
+					$wpdb->delete('wp_wpshop__attribute_value_integer', array("entity_id" => $product_id, "attribute_id" => 29));
3078
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 30));
3079 3079
 
3080 3080
 					$common_datas = array(
3081 3081
 						'value_id' => null,
@@ -3083,20 +3083,20 @@  discard block
 block discarded – undo
3083 3083
 						'entity_id' => $product_id,
3084 3084
 						'unit_id' => null,
3085 3085
 						'user_id' => 1,
3086
-						'creation_date_value' => current_time( "mysql", 0 ),
3086
+						'creation_date_value' => current_time("mysql", 0),
3087 3087
 						'language' => 'fr_FR',
3088 3088
 					);
3089 3089
 
3090
-					$content_to_write =  "
3091
-" . 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,  ) ). '';
3092
-					$fp = fopen( $log_dir . 'correction_prix.txt', 'a' );
3093
-					fwrite( $fp, $content_to_write );
3094
-					fclose( $fp );
3090
+					$content_to_write = "
3091
+" . 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,)) . '';
3092
+					$fp = fopen($log_dir . 'correction_prix.txt', 'a');
3093
+					fwrite($fp, $content_to_write);
3094
+					fclose($fp);
3095 3095
 
3096
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 6, 'value' => $pttc ) ) );
3097
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3098
-					$wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3099
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3096
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 6, 'value' => $pttc)));
3097
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 28, 'value' => $ht)));
3098
+					$wpdb->insert('wp_wpshop__attribute_value_integer', array_merge($common_datas, array('attribute_id' => 29, 'value' => $the_tax->rate_id)));
3099
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 30, 'value' => $tax_amount)));
3100 3100
 				}
3101 3101
 				else {
3102 3102
 					$common_datas = array(
@@ -3105,33 +3105,33 @@  discard block
 block discarded – undo
3105 3105
 						'entity_id' => $product_id,
3106 3106
 						'unit_id' => null,
3107 3107
 						'user_id' => 1,
3108
-						'creation_date_value' => current_time( "mysql", 0 ),
3108
+						'creation_date_value' => current_time("mysql", 0),
3109 3109
 						'language' => 'fr_FR',
3110 3110
 					);
3111
-					$wpdb->delete( $the_new_value->value_type, array( "entity_id" => $product_id, "attribute_id" => $attribute_id ) );
3112
-					$wpdb->insert( $the_new_value->value_type, array_merge( $common_datas, array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ) ) ) );
3113
-
3114
-					$content_to_write =  "
3115
-" . 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 ),  ) ). '';
3116
-					$fp = fopen( $log_dir . 'correction_attribut.txt', 'a' );
3117
-					fwrite( $fp, $content_to_write );
3118
-					fclose( $fp );
3111
+					$wpdb->delete($the_new_value->value_type, array("entity_id" => $product_id, "attribute_id" => $attribute_id));
3112
+					$wpdb->insert($the_new_value->value_type, array_merge($common_datas, array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value))));
3113
+
3114
+					$content_to_write = "
3115
+" . 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),)) . '';
3116
+					$fp = fopen($log_dir . 'correction_attribut.txt', 'a');
3117
+					fwrite($fp, $content_to_write);
3118
+					fclose($fp);
3119 3119
 				}
3120 3120
 			}
3121 3121
 		}
3122 3122
 		wp_die();
3123 3123
 	}
3124
-	add_action( 'wp_ajax_wps_put_history_back', 'wps_put_history_back' );
3124
+	add_action('wp_ajax_wps_put_history_back', 'wps_put_history_back');
3125 3125
 
3126 3126
 	function wps_mass_action_on_entity_launch() {
3127 3127
 		global $wpdb;
3128 3128
 		$response = '';
3129 3129
 		$element_to_output = array();
3130 3130
 
3131
-		$attributes_to_test = array( 'decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118' );
3131
+		$attributes_to_test = array('decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118');
3132 3132
 
3133 3133
 		$decimal_attribute = $attributes_to_test['decimal']; //,30,28
3134
-		$query = $wpdb->prepare( "
3134
+		$query = $wpdb->prepare("
3135 3135
 				SELECT P.ID, P.post_title,
3136 3136
 					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
3137 3137
 				FROM {$wpdb->posts} AS P
@@ -3145,21 +3145,21 @@  discard block
 block discarded – undo
3145 3145
 					AND H.value_type = 'wp_wpshop__attribute_value_decimal'
3146 3146
 
3147 3147
 				ORDER BY H.entity_id ASC, H.value_id DESC",
3148
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3148
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3149 3149
 		);
3150
-		 $list_of_element = $wpdb->get_results( $query );
3151
-		 if ( !empty( $list_of_element ) ) {
3152
-			foreach ( $list_of_element as $element ) {
3153
-				$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3154
-				$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3155
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3156
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3157
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3150
+		 $list_of_element = $wpdb->get_results($query);
3151
+		 if (!empty($list_of_element)) {
3152
+			foreach ($list_of_element as $element) {
3153
+				$element_to_output[$element->ID]['title'] = $element->post_title;
3154
+				$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3155
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3156
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3157
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3158 3158
 			}
3159 3159
 		}
3160 3160
 
3161 3161
 		$attribute_list = $attributes_to_test['varchar'];
3162
-		$query = $wpdb->prepare( "
3162
+		$query = $wpdb->prepare("
3163 3163
 			SELECT P.ID, P.post_title,
3164 3164
 				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
3165 3165
 			FROM {$wpdb->posts} AS P
@@ -3172,22 +3172,22 @@  discard block
 block discarded – undo
3172 3172
 				AND H.value != ''
3173 3173
 				AND H.value_type = 'wp_wpshop__attribute_value_varchar'
3174 3174
 			ORDER BY H.creation_date",
3175
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3175
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3176 3176
 		);
3177
-		$list_of_element = $wpdb->get_results( $query );
3178
-		if ( !empty( $list_of_element ) ) {
3179
-			foreach ( $list_of_element as $element ) {
3180
-			 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3181
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3182
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3183
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3184
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3177
+		$list_of_element = $wpdb->get_results($query);
3178
+		if (!empty($list_of_element)) {
3179
+			foreach ($list_of_element as $element) {
3180
+			 	$element_to_output[$element->ID]['title'] = $element->post_title;
3181
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3182
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3183
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3184
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3185 3185
 			}
3186 3186
 		}
3187 3187
 
3188 3188
 
3189 3189
 		$attribute_list = $attributes_to_test['text'];
3190
-		$query = $wpdb->prepare( "
3190
+		$query = $wpdb->prepare("
3191 3191
 				SELECT P.ID, P.post_title,
3192 3192
 				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
3193 3193
 				FROM {$wpdb->posts} AS P
@@ -3200,21 +3200,21 @@  discard block
 block discarded – undo
3200 3200
 				AND H.value != ''
3201 3201
 				AND H.value_type = 'wp_wpshop__attribute_value_text'
3202 3202
 			ORDER BY H.creation_date",
3203
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3203
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3204 3204
 		);
3205
-		$list_of_element = $wpdb->get_results( $query );
3206
-		if ( !empty( $list_of_element ) ) {
3207
-		foreach ( $list_of_element as $element ) {
3208
-		 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3209
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3210
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3211
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3212
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3205
+		$list_of_element = $wpdb->get_results($query);
3206
+		if (!empty($list_of_element)) {
3207
+		foreach ($list_of_element as $element) {
3208
+		 	$element_to_output[$element->ID]['title'] = $element->post_title;
3209
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3210
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3211
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3212
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3213 3213
 		 	}
3214 3214
 		}
3215 3215
 
3216 3216
 		$attribute_list = $attributes_to_test['integer'];
3217
-		$query = $wpdb->prepare( "
3217
+		$query = $wpdb->prepare("
3218 3218
 				SELECT P.ID, P.post_title,
3219 3219
 				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
3220 3220
 				FROM {$wpdb->posts} AS P
@@ -3227,21 +3227,21 @@  discard block
 block discarded – undo
3227 3227
 				AND H.value != ''
3228 3228
 				AND H.value_type = 'wp_wpshop__attribute_value_integer'
3229 3229
 			ORDER BY H.creation_date",
3230
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3230
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3231 3231
 		);
3232
-							$list_of_element = $wpdb->get_results( $query );
3233
-							if ( !empty( $list_of_element ) ) {
3234
-							foreach ( $list_of_element as $element ) {
3235
-					 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3236
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3237
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3238
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3239
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3232
+							$list_of_element = $wpdb->get_results($query);
3233
+							if (!empty($list_of_element)) {
3234
+							foreach ($list_of_element as $element) {
3235
+					 	$element_to_output[$element->ID]['title'] = $element->post_title;
3236
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3237
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3238
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3239
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3240 3240
 					 	}
3241 3241
 							}
3242 3242
 
3243 3243
 		$array_done = array();
3244
-		if ( !empty( $element_to_output ) ) {
3244
+		if (!empty($element_to_output)) {
3245 3245
 			$lines = '';
3246 3246
 			$done_header = array();
3247 3247
 
@@ -3249,23 +3249,23 @@  discard block
 block discarded – undo
3249 3249
 			/** Formate informations **/
3250 3250
 			$formatted_datas = array();
3251 3251
 			$controller_rows_array = array();
3252
-			foreach( $attributes_to_test as $attribute_to_test ) {
3253
-				$atts = explode( ',', $attribute_to_test );
3254
-				foreach( $atts as $att ) {
3255
-					$controller_rows_array[ $att ] = false;
3252
+			foreach ($attributes_to_test as $attribute_to_test) {
3253
+				$atts = explode(',', $attribute_to_test);
3254
+				foreach ($atts as $att) {
3255
+					$controller_rows_array[$att] = false;
3256 3256
 				}
3257 3257
 			}
3258 3258
 
3259
-			foreach(  $element_to_output as $element_id => $element_definition ) {
3259
+			foreach ($element_to_output as $element_id => $element_definition) {
3260 3260
 				$formatted_datas[$element_id]['title'] = $element_definition['title'];
3261 3261
 				$formatted_datas[$element_id]['content'] = array();
3262 3262
 
3263
-				foreach( $attributes_to_test as $attribute_to_test ) {
3264
-					$atts = explode( ',', $attribute_to_test );
3265
-					foreach( $atts as $att ) {
3266
-						if( !empty($element_definition['content'][$att]) ) {
3263
+				foreach ($attributes_to_test as $attribute_to_test) {
3264
+					$atts = explode(',', $attribute_to_test);
3265
+					foreach ($atts as $att) {
3266
+						if (!empty($element_definition['content'][$att])) {
3267 3267
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3268
-							$controller_rows_array[ $att ] = true;
3268
+							$controller_rows_array[$att] = true;
3269 3269
 						}
3270 3270
 						else {
3271 3271
 							$formatted_datas[$element_id]['content'][$att] = array();
@@ -3274,39 +3274,39 @@  discard block
 block discarded – undo
3274 3274
 				}
3275 3275
 			}
3276 3276
 
3277
-			foreach ( $formatted_datas as $element_id => $element_definition ) {
3278
-				if ( !in_array( $element_id, $array_done ) ) {
3279
-					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition[ 'title' ] . '</td>';
3280
-					ksort( $element_definition[ 'content' ] );
3281
-					foreach ( $element_definition[ 'content' ] as $atribute_id => $value_on_date ) {
3282
-						if( $controller_rows_array[$atribute_id] ) {
3283
-							$current_attribute = wpshop_attributes::getElement( $atribute_id );
3284
-							if ( !in_array( $atribute_id, $done_header ) ) {
3285
-								$more_header .= '<td style="border:1px solid black;" >' . __( $current_attribute->frontend_label, 'wpshop' ) . '</td>';
3277
+			foreach ($formatted_datas as $element_id => $element_definition) {
3278
+				if (!in_array($element_id, $array_done)) {
3279
+					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition['title'] . '</td>';
3280
+					ksort($element_definition['content']);
3281
+					foreach ($element_definition['content'] as $atribute_id => $value_on_date) {
3282
+						if ($controller_rows_array[$atribute_id]) {
3283
+							$current_attribute = wpshop_attributes::getElement($atribute_id);
3284
+							if (!in_array($atribute_id, $done_header)) {
3285
+								$more_header .= '<td style="border:1px solid black;" >' . __($current_attribute->frontend_label, 'wpshop') . '</td>';
3286 3286
 								$done_header[] = $atribute_id;
3287 3287
 							}
3288 3288
 							$last_value = 'XXXXX';
3289 3289
 							$counter_for_line = 0;
3290 3290
 							$content_line = '';
3291
-							foreach ( $value_on_date as $date => $value ) {
3292
-								if ( $value[ 'histo' ][ 'value' ] != $last_value ) {
3293
-									$current_val = $value[ 'current' ];
3294
-									$old_val = $value[ 'histo' ][ 'value' ];
3291
+							foreach ($value_on_date as $date => $value) {
3292
+								if ($value['histo']['value'] != $last_value) {
3293
+									$current_val = $value['current'];
3294
+									$old_val = $value['histo']['value'];
3295 3295
 									// Test if attribute data Type is integer
3296
-									if ( $current_attribute->data_type == 'integer' ) {
3297
-										if( $current_attribute->data_type_to_use == 'internal' ) {
3296
+									if ($current_attribute->data_type == 'integer') {
3297
+										if ($current_attribute->data_type_to_use == 'internal') {
3298 3298
 											$current_val = get_the_title($current_val);
3299 3299
 											$old_val = get_the_title($old_val);
3300 3300
 										}
3301 3301
 										else {
3302
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3303
-											$old_val = $wpdb->get_var( $query );
3304
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
3305
-											$current_val = $wpdb->get_var( $query );
3302
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $old_val);
3303
+											$old_val = $wpdb->get_var($query);
3304
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $current_val);
3305
+											$current_val = $wpdb->get_var($query);
3306 3306
 										}
3307 3307
 									}
3308
-									$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/>';
3309
-									$last_value = $value[ 'histo' ][ 'value' ];
3308
+									$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/>';
3309
+									$last_value = $value['histo']['value'];
3310 3310
 									$counter_for_line++;
3311 3311
 								}
3312 3312
 							}
@@ -3316,16 +3316,16 @@  discard block
 block discarded – undo
3316 3316
 						}
3317 3317
 					}
3318 3318
 					$lines .= '</tr>';
3319
-					$array_done[ $element_id ];
3319
+					$array_done[$element_id];
3320 3320
 				}
3321 3321
 			}
3322 3322
 
3323 3323
 			$response = '
3324
-				<form action="' . admin_url( 'admin-ajax.php' ) . '" method="POST" id="wps_put_histo_back" >
3324
+				<form action="' . admin_url('admin-ajax.php') . '" method="POST" id="wps_put_histo_back" >
3325 3325
 					<input type="text" name="action" value="wps_put_history_back" />
3326
-					' . wp_nonce_field( 'wps_put_history_back' ) . '
3326
+					' . wp_nonce_field('wps_put_history_back') . '
3327 3327
 					<table style="border-collapse: collapse;border:1px solid black;" cellpadding="0" cellspacing="0" >
3328
-						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __( 'Product', 'wpshop' ) . '</td>'.$more_header.'</tr>
3328
+						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __('Product', 'wpshop') . '</td>' . $more_header . '</tr>
3329 3329
 						' . $lines . '
3330 3330
 					</table>
3331 3331
 				</form><script type="text/javascript" >
@@ -3342,36 +3342,36 @@  discard block
 block discarded – undo
3342 3342
 
3343 3343
 
3344 3344
 	function wps_delete_picture_category() {
3345
-		check_ajax_referer( 'wps_delete_picture_category' );
3345
+		check_ajax_referer('wps_delete_picture_category');
3346 3346
 		$status = false; $response = '';
3347
-		$cat_id = ( !empty($_POST['cat_id']) ) ? (int) $_POST['cat_id'] : null;
3348
-		if( !empty($cat_id) ) {
3347
+		$cat_id = (!empty($_POST['cat_id'])) ? (int)$_POST['cat_id'] : null;
3348
+		if (!empty($cat_id)) {
3349 3349
 			// Get Category option
3350
-			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id );
3351
-			if( !empty($category_option) && !empty($category_option['wpshop_category_picture']) ) {
3352
-				unset( $category_option['wpshop_category_picture'] );
3353
-				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3354
-				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3350
+			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id);
3351
+			if (!empty($category_option) && !empty($category_option['wpshop_category_picture'])) {
3352
+				unset($category_option['wpshop_category_picture']);
3353
+				update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option);
3354
+				$response = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview"/>';
3355 3355
 				$status = true;
3356 3356
 			}
3357 3357
 			else {
3358
-				$response = __( 'Category options are not defined', 'wpshop');
3358
+				$response = __('Category options are not defined', 'wpshop');
3359 3359
 			}
3360 3360
 		}
3361 3361
 		else {
3362
-			$response = __( 'Category ID is not defined', 'wpshop');
3362
+			$response = __('Category ID is not defined', 'wpshop');
3363 3363
 		}
3364
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3364
+		echo json_encode(array('status' => $status, 'response' => $response));
3365 3365
 		wp_die();
3366 3366
 	}
3367
-	add_action( 'wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category' );
3367
+	add_action('wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category');
3368 3368
 
3369 3369
 	/* EAV */
3370 3370
 
3371 3371
 	/* ATTRIBUTES SET */
3372 3372
 
3373 3373
 	function saveNewAttributeSetSection() {
3374
-		check_ajax_referer( 'saveNewAttributeSetSection' );
3374
+		check_ajax_referer('saveNewAttributeSetSection');
3375 3375
 		global $wpdb;
3376 3376
 		$attributeSetSectionName = sanitize_text_field($_REQUEST['attributeSetSectionName']);
3377 3377
 		$elementIdentifier = (int)$_REQUEST['elementIdentifier'];
@@ -3379,37 +3379,37 @@  discard block
 block discarded – undo
3379 3379
 		$attributeSetInfos['id'] = '';
3380 3380
 		$attributeSetInfos['status'] = 'valid';
3381 3381
 		$attributeSetInfos['attribute_set_id'] = $elementIdentifier;
3382
-		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM ". WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3382
+		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3383 3383
 		$attributeSetInfos['position'] = $wpdb->get_var($query);
3384 3384
 		$attributeSetInfos['creation_date'] = date('Y-m-d H:i:s');
3385 3385
 		$attributeSetInfos['code'] = wpshop_tools::slugify($attributeSetSectionName, array('noAccent', 'noSpaces', 'lowerCase'));
3386 3386
 		$attributeSetInfos['name'] = $attributeSetSectionName;
3387 3387
 
3388
-		$more_script='';
3388
+		$more_script = '';
3389 3389
 		$attributeSetSectionCreation = wpshop_database::save($attributeSetInfos, WPSHOP_DBT_ATTRIBUTE_GROUP);
3390
-		if ( $attributeSetSectionCreation == 'done' ) {
3390
+		if ($attributeSetSectionCreation == 'done') {
3391 3391
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
3392
-			$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
3392
+			$more_script = 'wpshop_go_to("#attribute_group_' . $wpdb->insert_id . '")';
3393 3393
 		}
3394 3394
 		else {
3395 3395
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
3396 3396
 		}
3397 3397
 
3398
-		$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>';
3399
-		wp_die( wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script );
3398
+		$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>';
3399
+		wp_die(wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script);
3400 3400
 	}
3401
-	add_action( 'wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection' );
3401
+	add_action('wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection');
3402 3402
 
3403 3403
 	function editAttributeSetSection() {
3404
-		check_ajax_referer( 'editAttributeSetSection' );
3404
+		check_ajax_referer('editAttributeSetSection');
3405 3405
 		$attributeSetSectionName = sanitize_title($_REQUEST['attributeSetSectionName']);
3406 3406
 		$attributeSetSectionId = sanitize_key($_REQUEST['attributeSetSectionId']);
3407 3407
 		$attributeSetSectionDefault = sanitize_text_field($_REQUEST['attributeSetSectionDefault']);
3408 3408
 		$backend_display_type = sanitize_text_field($_REQUEST['attributeSetSectionDisplayType']);
3409 3409
 		$display_on_frontend = sanitize_text_field($_REQUEST['attributeSetSectionDisplayinFrontEnd']);
3410
-		$backend_display_type = in_array($backend_display_type, array('movable-tab','fixed-tab')) ? $backend_display_type : 'fixed-tab';
3410
+		$backend_display_type = in_array($backend_display_type, array('movable-tab', 'fixed-tab')) ? $backend_display_type : 'fixed-tab';
3411 3411
 
3412
-		if($attributeSetSectionDefault == 'yes'){
3412
+		if ($attributeSetSectionDefault == 'yes') {
3413 3413
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, array('last_update_date' => current_time('mysql', 0), 'default_group' => 'no'), array('attribute_set_id' => $elementIdentifier));
3414 3414
 		}
3415 3415
 		$attributeSetInfos = array();
@@ -3419,18 +3419,18 @@  discard block
 block discarded – undo
3419 3419
 		$attributeSetInfos['backend_display_type'] = $backend_display_type;
3420 3420
 		$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
3421 3421
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3422
-		if ( $attributeSetSectionCreation == 'done' )
3422
+		if ($attributeSetSectionCreation == 'done')
3423 3423
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
3424 3424
 		else
3425 3425
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
3426 3426
 		echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>';
3427 3427
 		wp_die();
3428 3428
 	}
3429
-	add_action( 'wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection' );
3429
+	add_action('wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection');
3430 3430
 
3431 3431
 	function deleteAttributeSetSection() {
3432
-		check_ajax_referer( 'deleteAttributeSetSection' );
3433
-		$attributeSetSectionId = (int) $_REQUEST['attributeSetSectionId'];
3432
+		check_ajax_referer('deleteAttributeSetSection');
3433
+		$attributeSetSectionId = (int)$_REQUEST['attributeSetSectionId'];
3434 3434
 		$attributeSetInfos = array();
3435 3435
 		$attributeSetInfos['status'] = 'deleted';
3436 3436
 		$attributeSetInfos['last_update_date'] = current_time('mysql', 0);
@@ -3439,21 +3439,21 @@  discard block
 block discarded – undo
3439 3439
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3440 3440
 
3441 3441
 		$more_script = '';
3442
-		if ( $attributeSetSectionCreation == 'done' ) {
3442
+		if ($attributeSetSectionCreation == 'done') {
3443 3443
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
3444
-			$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
3444
+			$more_script .= 'jQuery("#attribute_group_' . $attributeSetSectionId . '").remove();';
3445 3445
 		}
3446 3446
 		else
3447 3447
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
3448
-		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3448
+		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
3449 3449
 		wp_die();
3450 3450
 	}
3451
-	add_action( 'wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection' );
3451
+	add_action('wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection');
3452 3452
 
3453 3453
 	/* ATTRIBUTES UNIT */
3454 3454
 
3455 3455
 	function load_unit_interface() {
3456
-		check_ajax_referer( 'load_unit_interface' );
3456
+		check_ajax_referer('load_unit_interface');
3457 3457
 		?>
3458 3458
 		<div id="wpshop_unit_main_listing_interface">
3459 3459
 			<div class="wpshop_full_page_tabs">
@@ -3472,28 +3472,28 @@  discard block
 block discarded – undo
3472 3472
 
3473 3473
 		wp_die();
3474 3474
 	}
3475
-	add_action( 'wp_ajax_wps_attribute_unit_interface', 'load_unit_interface' );
3475
+	add_action('wp_ajax_wps_attribute_unit_interface', 'load_unit_interface');
3476 3476
 
3477 3477
 	function load_attribute_units() {
3478
-		check_ajax_referer( 'load_attribute_units' );
3479
-		wp_die( wpshop_attributes_unit::elementList() );
3478
+		check_ajax_referer('load_attribute_units');
3479
+		wp_die(wpshop_attributes_unit::elementList());
3480 3480
 	}
3481
-	add_action( 'wp_ajax_wps_attribute_unit_load', 'load_attribute_units' );
3481
+	add_action('wp_ajax_wps_attribute_unit_load', 'load_attribute_units');
3482 3482
 
3483 3483
 	function add_attribute_unit() {
3484
-		check_ajax_referer( 'add_attribute_unit' );
3485
-		wp_die( wpshop_attributes_unit::elementEdition( '' ) );
3484
+		check_ajax_referer('add_attribute_unit');
3485
+		wp_die(wpshop_attributes_unit::elementEdition(''));
3486 3486
 	}
3487
-	add_action( 'wp_ajax_wps_attribute_unit_add', 'add_attribute_unit' );
3487
+	add_action('wp_ajax_wps_attribute_unit_add', 'add_attribute_unit');
3488 3488
 
3489 3489
 	function edit_attribute_unit() {
3490
-		check_ajax_referer( 'edit_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3491
-		wp_die( wpshop_attributes_unit::elementEdition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3490
+		check_ajax_referer('edit_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3491
+		wp_die(wpshop_attributes_unit::elementEdition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3492 3492
 	}
3493
-	add_action( 'wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit' );
3493
+	add_action('wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit');
3494 3494
 
3495 3495
 	function save_new_attribute_unit() {
3496
-		check_ajax_referer( 'save_new_attribute_unit' );
3496
+		check_ajax_referer('save_new_attribute_unit');
3497 3497
 		$save_output = '';
3498 3498
 
3499 3499
 		$attribute_unit_informations['id'] = '';
@@ -3507,11 +3507,11 @@  discard block
 block discarded – undo
3507 3507
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3508 3508
 
3509 3509
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT);
3510
-		if($save_unit_result == 'done'){
3510
+		if ($save_unit_result == 'done') {
3511 3511
 			$save_output = wpshop_attributes_unit::elementList();
3512 3512
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
3513 3513
 		}
3514
-		else{
3514
+		else {
3515 3515
 			$save_output = wpshop_attributes_unit::elementEdition();
3516 3516
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
3517 3517
 		}
@@ -3519,10 +3519,10 @@  discard block
 block discarded – undo
3519 3519
 		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;
3520 3520
 		wp_die();
3521 3521
 	}
3522
-	add_action( 'wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit' );
3522
+	add_action('wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit');
3523 3523
 
3524 3524
 	function update_attribute_unit() {
3525
-		check_ajax_referer( 'update_attribute_unit' );
3525
+		check_ajax_referer('update_attribute_unit');
3526 3526
 		$save_output = '';
3527 3527
 
3528 3528
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['id']);
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
3535 3535
 		$attribute_unit_informations['change_rate'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['change_rate']);
3536 3536
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3537 3537
 
3538
-		if ( $attribute_unit_informations['is_default_of_group'] == 'yes' ) {
3538
+		if ($attribute_unit_informations['is_default_of_group'] == 'yes') {
3539 3539
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array(
3540 3540
 				'is_default_of_group' => 'no'
3541 3541
 			), array(
@@ -3543,8 +3543,8 @@  discard block
 block discarded – undo
3543 3543
 			));
3544 3544
 		}
3545 3545
 
3546
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3547
-		if ( $save_unit_result == 'done' ) {
3546
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3547
+		if ($save_unit_result == 'done') {
3548 3548
 			$save_output = wpshop_attributes_unit::elementList();
3549 3549
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
3550 3550
 		}
@@ -3556,17 +3556,17 @@  discard block
 block discarded – undo
3556 3556
 		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;
3557 3557
 		wp_die();
3558 3558
 	}
3559
-	add_action( 'wp_ajax_wps_attribute_unit_update', 'update_attribute_unit' );
3559
+	add_action('wp_ajax_wps_attribute_unit_update', 'update_attribute_unit');
3560 3560
 
3561 3561
 	function delete_attribute_unit() {
3562
-		check_ajax_referer( 'delete_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3562
+		check_ajax_referer('delete_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3563 3563
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3564 3564
 		$save_output = '';
3565 3565
 
3566 3566
 		$attribute_unit_informations['status'] = 'deleted';
3567 3567
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3568 3568
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
3569
-		if ( $save_unit_result == 'done' ) {
3569
+		if ($save_unit_result == 'done') {
3570 3570
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
3571 3571
 		}
3572 3572
 		else {
@@ -3576,30 +3576,30 @@  discard block
 block discarded – undo
3576 3576
 		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();
3577 3577
 		wp_die();
3578 3578
 	}
3579
-	add_action( 'wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit' );
3579
+	add_action('wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit');
3580 3580
 
3581 3581
 	/* ATTRIBUTES UNIT GROUP */
3582 3582
 
3583 3583
 	function load_attribute_unit_groups() {
3584
-		check_ajax_referer( 'load_attribute_unit_groups' );
3585
-		wp_die( wpshop_attributes_unit::unit_group_list() );
3584
+		check_ajax_referer('load_attribute_unit_groups');
3585
+		wp_die(wpshop_attributes_unit::unit_group_list());
3586 3586
 	}
3587
-	add_action( 'wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups' );
3587
+	add_action('wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups');
3588 3588
 
3589 3589
 	function add_attribute_unit_group() {
3590
-		check_ajax_referer( 'add_attribute_unit_group' );
3591
-		wp_die( wpshop_attributes_unit::unit_group_edition( '' ) );
3590
+		check_ajax_referer('add_attribute_unit_group');
3591
+		wp_die(wpshop_attributes_unit::unit_group_edition(''));
3592 3592
 	}
3593
-	add_action( 'wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group' );
3593
+	add_action('wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group');
3594 3594
 
3595 3595
 	function edit_attribute_unit_group() {
3596
-		check_ajax_referer( 'edit_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? $_REQUEST['elementIdentifier'] : '' ) );
3597
-		wp_die( wpshop_attributes_unit::unit_group_edition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3596
+		check_ajax_referer('edit_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? $_REQUEST['elementIdentifier'] : ''));
3597
+		wp_die(wpshop_attributes_unit::unit_group_edition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3598 3598
 	}
3599
-	add_action( 'wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group' );
3599
+	add_action('wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group');
3600 3600
 
3601 3601
 	function save_new_attribute_unit_group() {
3602
-		check_ajax_referer( 'save_new_attribute_unit_group' );
3602
+		check_ajax_referer('save_new_attribute_unit_group');
3603 3603
 		$save_output = '';
3604 3604
 
3605 3605
 		$attribute_unit_informations['id'] = '';
@@ -3608,11 +3608,11 @@  discard block
 block discarded – undo
3608 3608
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3609 3609
 
3610 3610
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3611
-		if($save_unit_result == 'done'){
3611
+		if ($save_unit_result == 'done') {
3612 3612
 			$save_output = wpshop_attributes_unit::unit_group_list();
3613 3613
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
3614 3614
 		}
3615
-		else{
3615
+		else {
3616 3616
 			$save_output = wpshop_attributes_unit::unit_group_edition();
3617 3617
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
3618 3618
 		}
@@ -3620,10 +3620,10 @@  discard block
 block discarded – undo
3620 3620
 		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;
3621 3621
 		wp_die();
3622 3622
 	}
3623
-	add_action( 'wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group' );
3623
+	add_action('wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group');
3624 3624
 
3625 3625
 	function update_attribute_unit_group() {
3626
-		check_ajax_referer( 'update_attribute_unit_group' );
3626
+		check_ajax_referer('update_attribute_unit_group');
3627 3627
 		$save_output = '';
3628 3628
 
3629 3629
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['id']);
@@ -3631,12 +3631,12 @@  discard block
 block discarded – undo
3631 3631
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3632 3632
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3633 3633
 
3634
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3635
-		if($save_unit_result == 'done'){
3634
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3635
+		if ($save_unit_result == 'done') {
3636 3636
 			$save_output = wpshop_attributes_unit::unit_group_list();
3637 3637
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
3638 3638
 		}
3639
-		else{
3639
+		else {
3640 3640
 			$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
3641 3641
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
3642 3642
 		}
@@ -3644,65 +3644,65 @@  discard block
 block discarded – undo
3644 3644
 		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;
3645 3645
 		wp_die();
3646 3646
 	}
3647
-	add_action( 'wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group' );
3647
+	add_action('wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group');
3648 3648
 
3649 3649
 	function delete_attribute_unit_group() {
3650
-		check_ajax_referer( 'delete_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3650
+		check_ajax_referer('delete_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3651 3651
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3652 3652
 		$save_output = '';
3653 3653
 
3654 3654
 		$attribute_unit_informations['status'] = 'deleted';
3655 3655
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3656 3656
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3657
-		if($save_unit_result == 'done'){
3657
+		if ($save_unit_result == 'done') {
3658 3658
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
3659 3659
 		}
3660
-		else{
3660
+		else {
3661 3661
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
3662 3662
 		}
3663 3663
 
3664 3664
 		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();
3665 3665
 		wp_die();
3666 3666
 	}
3667
-	add_action( 'wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group' );
3667
+	add_action('wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group');
3668 3668
 
3669 3669
 	function products_by_criteria() {
3670
-		check_ajax_referer( 'products_by_criteria' );
3670
+		check_ajax_referer('products_by_criteria');
3671 3671
 		$attr = !empty($_REQUEST['attr']) ? sanitize_text_field($_REQUEST['attr']) : '';
3672 3672
 		// If a filter by attribute is found, recalcul the products that matching it
3673
-		if(!empty($attr)) {
3674
-			$att = explode(':',$attr);
3675
-			$products_id = wpshop_products::get_products_matching_attribute($att[0],$att[1]);
3673
+		if (!empty($attr)) {
3674
+			$att = explode(':', $attr);
3675
+			$products_id = wpshop_products::get_products_matching_attribute($att[0], $att[1]);
3676 3676
 		}
3677
-		$products_id = !empty($products_id) ? $products_id : sanitize_text_field( $_REQUEST['pid'] );
3678
-		$page_number = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'page_number' ] ) && is_int( (int) $_REQUEST['page_number'] ) ? (int) $_REQUEST['page_number'] : 0;
3677
+		$products_id = !empty($products_id) ? $products_id : sanitize_text_field($_REQUEST['pid']);
3678
+		$page_number = !empty($_REQUEST) && !empty($_REQUEST['page_number']) && is_int((int)$_REQUEST['page_number']) ? (int)$_REQUEST['page_number'] : 0;
3679 3679
 
3680
-		$criteria = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'criteria' ] ) ? sanitize_text_field( $_REQUEST[ 'criteria' ] ) : null;
3681
-		$cid = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'cid' ] ) && is_int( (int)$_REQUEST[ 'cid' ] ) ? (int)$_REQUEST[ 'cid' ] : null;
3682
-		$display_type = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'display_type' ] ) ? sanitize_text_field( $_REQUEST[ 'display_type' ] ) : null;
3683
-		$order = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'order' ] ) ? sanitize_text_field( $_REQUEST[ 'order' ] ) : null;
3684
-		$products_per_page = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'products_per_page' ] ) && is_int( (int)$_REQUEST[ 'products_per_page' ] ) ? (int)$_REQUEST[ 'products_per_page' ] : 0;
3680
+		$criteria = !empty($_REQUEST) && !empty($_REQUEST['criteria']) ? sanitize_text_field($_REQUEST['criteria']) : null;
3681
+		$cid = !empty($_REQUEST) && !empty($_REQUEST['cid']) && is_int((int)$_REQUEST['cid']) ? (int)$_REQUEST['cid'] : null;
3682
+		$display_type = !empty($_REQUEST) && !empty($_REQUEST['display_type']) ? sanitize_text_field($_REQUEST['display_type']) : null;
3683
+		$order = !empty($_REQUEST) && !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null;
3684
+		$products_per_page = !empty($_REQUEST) && !empty($_REQUEST['products_per_page']) && is_int((int)$_REQUEST['products_per_page']) ? (int)$_REQUEST['products_per_page'] : 0;
3685 3685
 
3686
-		$data = wpshop_products::wpshop_get_product_by_criteria( $criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page );
3687
-		if($data[0]) {
3686
+		$data = wpshop_products::wpshop_get_product_by_criteria($criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page);
3687
+		if ($data[0]) {
3688 3688
 			echo json_encode(array(true, do_shortcode($data[1])));
3689
-		} else echo json_encode(array(false,__('No product found','wpshop')));
3689
+		} else echo json_encode(array(false, __('No product found', 'wpshop')));
3690 3690
 		wp_die();
3691 3691
 	}
3692
-	add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' );
3693
-	add_action( 'wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria' );
3692
+	add_action('wp_ajax_wps_products_by_criteria', 'products_by_criteria');
3693
+	add_action('wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria');
3694 3694
 
3695 3695
 	function ajax_sendMessage() {
3696
-		check_ajax_referer( 'sendMessage' );
3697
-		$post_id = !empty($_REQUEST['postid']) ? (int) $_REQUEST['postid'] : null;
3696
+		check_ajax_referer('sendMessage');
3697
+		$post_id = !empty($_REQUEST['postid']) ? (int)$_REQUEST['postid'] : null;
3698 3698
 		$title = !empty($_REQUEST['title']) ? sanitize_title($_REQUEST['title']) : '';
3699 3699
 		$message = !empty($_REQUEST['message']) ? sanitize_text_field($_REQUEST['message']) : '';
3700
-		$recipient = !empty($_REQUEST['recipient']) ? (array) $_REQUEST['recipient'] : array();
3701
-		if ( isset($post_id) && isset($title) && isset($message) && !empty($recipient) ) {
3700
+		$recipient = !empty($_REQUEST['recipient']) ? (array)$_REQUEST['recipient'] : array();
3701
+		if (isset($post_id) && isset($title) && isset($message) && !empty($recipient)) {
3702 3702
 			$user_info = get_userdata($recipient);
3703 3703
 			$first_name = $user_info->user_firstname;
3704 3704
 			$last_name = $user_info->user_lastname;
3705
-			$data = array('customer_first_name'=>$first_name,'customer_last_name'=>$last_name);
3705
+			$data = array('customer_first_name'=>$first_name, 'customer_last_name'=>$last_name);
3706 3706
 
3707 3707
 			$wps_message_ctr = new wps_message_ctr();
3708 3708
 
@@ -3711,73 +3711,73 @@  discard block
 block discarded – undo
3711 3711
 			$message = $wps_message_ctr->customMessage($message, $data);
3712 3712
 
3713 3713
 			if (!empty($user_info->user_email)) {
3714
-				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$post_id, $object=array());
3714
+				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save = true, $model_id = $post_id, $object = array());
3715 3715
 				$array = array('result' => true, 'message' => '');
3716 3716
 			}
3717
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
3717
+			else $array = array('result' => true, 'message' => __('An error occured', 'wpshop'));
3718 3718
 		}
3719 3719
 		else {
3720
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3720
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3721 3721
 		}
3722 3722
 
3723 3723
 		echo json_encode($array);
3724 3724
 		wp_die();
3725 3725
 	}
3726
-	add_action( 'wp_ajax_wps_ajax_send_message', 'ajax_sendMessage' );
3726
+	add_action('wp_ajax_wps_ajax_send_message', 'ajax_sendMessage');
3727 3727
 
3728 3728
 	function ajax_resendMessage() {
3729
-		check_ajax_referer( 'resendMessage' );
3730
-		$message_id = !empty($_REQUEST['messageid']) ? (array) $_REQUEST['messageid'] : array();
3729
+		check_ajax_referer('resendMessage');
3730
+		$message_id = !empty($_REQUEST['messageid']) ? (array)$_REQUEST['messageid'] : array();
3731 3731
 		if (isset($message_id)) {
3732
-			$ids = explode('-',$message_id);
3732
+			$ids = explode('-', $message_id);
3733 3733
 			$postid = $ids[0];
3734
-			$date = $ids[1].'-'.$ids[2];
3734
+			$date = $ids[1] . '-' . $ids[2];
3735 3735
 			$arraykey = $ids[3];
3736 3736
 
3737
-			$historic = get_post_meta($postid, 'wpshop_messages_histo_'.$date, true);
3737
+			$historic = get_post_meta($postid, 'wpshop_messages_histo_' . $date, true);
3738 3738
 
3739 3739
 			if (isset($historic[$arraykey])) {
3740 3740
 				$historic[$arraykey]['mess_dispatch_date'][] = current_time('mysql', 0);
3741
-				update_post_meta($postid, 'wpshop_messages_histo_'.$date, $historic);
3741
+				update_post_meta($postid, 'wpshop_messages_histo_' . $date, $historic);
3742 3742
 
3743 3743
 				$data = $historic[$arraykey];
3744 3744
 				$wps_message_ctr = new wps_message_ctr();
3745
-				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
3745
+				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save = false, $object = array());
3746 3746
 
3747 3747
 				$array = array('result' => true, 'message' => '');
3748 3748
 			}
3749 3749
 			else {
3750
-				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3750
+				$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3751 3751
 			}
3752 3752
 		}
3753 3753
 		else {
3754
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3754
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3755 3755
 		}
3756 3756
 
3757 3757
 		echo json_encode($array);
3758 3758
 		wp_die();
3759 3759
 	}
3760
-	add_action( 'wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage' );
3760
+	add_action('wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage');
3761 3761
 
3762 3762
 	function related_products() {
3763
-		check_ajax_referer( 'related_products' );
3763
+		check_ajax_referer('related_products');
3764 3764
 		$search = sanitize_text_field($_REQUEST['search']);
3765 3765
 		$data = wpshop_products::product_list(false, $search);
3766
-		$array=array();
3766
+		$array = array();
3767 3767
 		foreach ($data as $d) {
3768 3768
 			$array[] = array('id' => $d->ID, 'name' => $d->post_title);
3769 3769
 		}
3770 3770
 		echo json_encode($array);
3771 3771
 		wp_die();
3772 3772
 	}
3773
-	add_action( 'wp_ajax_wps_related_products', 'related_products' );
3773
+	add_action('wp_ajax_wps_related_products', 'related_products');
3774 3774
 
3775 3775
 	function applyCoupon() {
3776
-		check_ajax_referer( 'applyCoupon' );
3776
+		check_ajax_referer('applyCoupon');
3777 3777
 		$wps_coupon_ctr = new wps_coupon_ctr();
3778 3778
 		$coupon_code = sanitize_text_field($_REQUEST['coupon_code']);
3779 3779
 		$result = $wps_coupon_ctr->applyCoupon($coupon_code);
3780
-		if ($result['status']===true) {
3780
+		if ($result['status'] === true) {
3781 3781
 			$wps_cart_ctr = new wps_cart();
3782 3782
 			$order = $wps_cart_ctr->calcul_cart_information(array());
3783 3783
 			$wps_cart_ctr->store_cart_in_session($order);
@@ -3785,6 +3785,6 @@  discard block
 block discarded – undo
3785 3785
 		} else echo json_encode(array(false, $result['message']));
3786 3786
 		wp_die();
3787 3787
 	}
3788
-	add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' );
3788
+	add_action('wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon');
3789 3789
 
3790 3790
 ?>
Please login to merge, or discard this patch.
Braces   +113 added lines, -201 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
 * Ajax request management file
4 6
 *
@@ -466,12 +468,10 @@  discard block
 block discarded – undo
466 468
 					wpshop_payment::set_payment_transaction_number($order_id, $transaction_id);
467 469
 				}
468 470
 				$result = json_encode(array(true,''));
469
-			}
470
-			else {
471
+			} else {
471 472
 				$result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop')));
472 473
 			}
473
-		}
474
-		else {
474
+		} else {
475 475
 			$result = json_encode(array(false,__('Bad order identifier', 'wpshop')));
476 476
 		}
477 477
 		echo json_encode($result);
@@ -488,8 +488,7 @@  discard block
 block discarded – undo
488 488
 		if ( !empty($order_id) ) {
489 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" data-nonce="' . esc_attr( wp_create_nonce( 'wpshop_change_order_state' ) ) . '" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />'));
490 490
 
491
-		}
492
-		else {
491
+		} else {
493 492
 			$result = json_encode(array(false, __('Order reference error', 'wpshop')));
494 493
 		}
495 494
 		echo json_encode($result);
@@ -528,16 +527,14 @@  discard block
 block discarded – undo
528 527
 				$output_shipping_box = ob_get_clean();
529 528
 
530 529
 				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
531
-			}
532
-			else {
530
+			} else {
533 531
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
534 532
 
535 533
 				$result = array(true, $order_state, __($order_status[$order_state], 'wpshop'));
536 534
 			}
537 535
 			update_post_meta($order_id, '_order_postmeta', $order);
538 536
 			update_post_meta($order_id, '_wpshop_order_status', $order_state);
539
-		}
540
-		else {
537
+		} else {
541 538
 			$result = array(false, __('Incorrect order request', 'wpshop'));
542 539
 		}
543 540
 
@@ -623,8 +620,7 @@  discard block
 block discarded – undo
623 620
 			unset($tpl_component);
624 621
 
625 622
 			echo json_encode(array(true, str_replace('optionsUpdate', 'options', $output)));
626
-		}
627
-		else {
623
+		} else {
628 624
 			echo json_encode(array(false, __('The value you entered already exist', 'wpshop')));
629 625
 		}
630 626
 		die();
@@ -669,13 +665,11 @@  discard block
 block discarded – undo
669 665
 				);
670 666
 				$new_option_id = wp_insert_post($new_post);
671 667
 				$input_def['valueToPut'] = 'index';
672
-			}
673
-			else {
668
+			} else {
674 669
 				$result_status = false;
675 670
 				$result = __('This value already exist for this attribute', 'wpshop');
676 671
 			}
677
-		}
678
-		else {
672
+		} else {
679 673
 			/**	Check if the given value does not exist	*/
680 674
 			$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE (label = %s OR value = %s) AND attribute_id = %d AND status = 'valid'", str_replace(",", ".", $attribute_options_label), $attribute_options_value, $attribute->id);
681 675
 			$existing_values = $wpdb->get_results($query);
@@ -691,8 +685,7 @@  discard block
 block discarded – undo
691 685
 				/**	Add the new value into database	*/
692 686
 				$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $attribute->id, 'position' => $position, 'label' => str_replace(",", ".", stripslashes($attribute_options_label)), 'value' => stripslashes($attribute_options_value)));
693 687
 				$new_option_id = $wpdb->insert_id;
694
-			}
695
-			else {
688
+			} else {
696 689
 				$result_status = false;
697 690
 				$result = __('This value already exist for this attribute', 'wpshop');
698 691
 			}
@@ -843,8 +836,7 @@  discard block
 block discarded – undo
843 836
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
844 837
 			$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>';
845 838
 			$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" />';
846
-		}
847
-		else {
839
+		} else {
848 840
 			$result .= '<input type="hidden" value="' . $attribute->default_value . '" name="internal_data" id="internal_data" />';
849 841
 
850 842
 			unset($input_def);
@@ -901,8 +893,7 @@  discard block
 block discarded – undo
901 893
 					}
902 894
 				}
903 895
 			}
904
-		}
905
-		else {
896
+		} else {
906 897
 			$post_list = query_posts(array('post_type' => $internal_data_type));
907 898
 			if (!empty($post_list)) {
908 899
 				$p=1;
@@ -911,8 +902,7 @@  discard block
 block discarded – undo
911 902
 					$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));
912 903
 					if(is_int($last_insert) && $delete_items_of_entity){
913 904
 						wp_delete_post($post->ID, true);
914
-					}
915
-					else{
905
+					} else{
916 906
 						$error = true;
917 907
 					}
918 908
 					$p++;
@@ -976,13 +966,11 @@  discard block
 block discarded – undo
976 966
 				}
977 967
 				$result = true;
978 968
 				$result_output = '<p class="wpshop_duplicate_attribute_result" ><a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&action=edit&id=' . $new_attribute_id) . '" >' . __('Edit the new attribute', 'wpshop') . '</a></p>';
979
-			}
980
-			else {
969
+			} else {
981 970
 				$result = false;
982 971
 				$result_output = __('An error occured while duplicating attribute', 'wpshop');
983 972
 			}
984
-		}
985
-		else {
973
+		} else {
986 974
 			$result = false;
987 975
 			$result_output = __('This attribute has already been duplicate to this entity', 'wpshop');
988 976
 		}
@@ -1012,8 +1000,7 @@  discard block
 block discarded – undo
1012 1000
 			/* Test if we want display the group unit list OR the unit list */
1013 1001
 			if ( $selected_list == 'group unit' ) {
1014 1002
 				$list = wpshop_attributes_unit::get_unit_group();
1015
-			}
1016
-			else {
1003
+			} else {
1017 1004
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1018 1005
 			}
1019 1006
 
@@ -1021,8 +1008,7 @@  discard block
 block discarded – undo
1021 1008
 				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1022 1009
 			}
1023 1010
 			$result = array(true, $response);
1024
-		}
1025
-		else {
1011
+		} else {
1026 1012
 			$result = array(false, __('Incorrect order request', 'wpshop'));
1027 1013
 		}
1028 1014
 
@@ -1061,14 +1047,12 @@  discard block
 block discarded – undo
1061 1047
 								$sub_modif .= $column_name;
1062 1048
 								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1063 1049
 									$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" />';
1064
-								}
1065
-								else{
1050
+								} else{
1066 1051
 									$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" />';
1067 1052
 									$error_nb++;
1068 1053
 									if ( !empty($error_list[$plugin_db_version]) ) {
1069 1054
 										$error_list[$plugin_db_version] += 1;
1070
-									}
1071
-									else {
1055
+									} else {
1072 1056
 										$error_list[$plugin_db_version] = 1;
1073 1057
 									}
1074 1058
 								}
@@ -1086,8 +1070,7 @@  discard block
 block discarded – undo
1086 1070
 								$sub_modif .= $column_name;
1087 1071
 								if(empty($columns) || ($columns->Field != $column_name)){
1088 1072
 									$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" />';
1089
-								}
1090
-								else{
1073
+								} else{
1091 1074
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1092 1075
 									$error_nb++;
1093 1076
 									$error_list[$plugin_db_version] += 1;
@@ -1109,8 +1092,7 @@  discard block
 block discarded – undo
1109 1092
 									$changed_key = 'type';
1110 1093
 									if($columns->Type == $field_infos['type']){
1111 1094
 										$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" />';
1112
-									}
1113
-									else{
1095
+									} else{
1114 1096
 										$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" />';
1115 1097
 										$error_nb++;
1116 1098
 										$error_list[$plugin_db_version] += 1;
@@ -1122,8 +1104,7 @@  discard block
 block discarded – undo
1122 1104
 									$changed_key = 'original_name';
1123 1105
 									if($columns->Field == $field_infos['field']){
1124 1106
 										$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" />';
1125
-									}
1126
-									else{
1107
+									} else{
1127 1108
 										$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" />';
1128 1109
 										$error_nb++;
1129 1110
 										$error_list[$plugin_db_version] += 1;
@@ -1146,8 +1127,7 @@  discard block
 block discarded – undo
1146 1127
 								$sub_modif .= $column_name;
1147 1128
 								if((empty($columns)) || ($columns->Column_name != $column_name)){
1148 1129
 									$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" />';
1149
-								}
1150
-								else{
1130
+								} else{
1151 1131
 									$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" />';
1152 1132
 									$error_nb++;
1153 1133
 									$error_list[$plugin_db_version] += 1;
@@ -1166,8 +1146,7 @@  discard block
 block discarded – undo
1166 1146
 								$sub_modif .= $column_name;
1167 1147
 								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1168 1148
 									$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" />';
1169
-								}
1170
-								else{
1149
+								} else{
1171 1150
 									$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" />';
1172 1151
 									$error_nb++;
1173 1152
 									$error_list[$plugin_db_version] += 1;
@@ -1186,14 +1165,12 @@  discard block
 block discarded – undo
1186 1165
 							$table_exists = $wpdb->query($query);
1187 1166
 							if($table_exists == 1){
1188 1167
 								$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" />';
1189
-							}
1190
-							else{
1168
+							} else{
1191 1169
 								$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" />';
1192 1170
 								$error_nb++;
1193 1171
 								if ( !empty($error_list[$plugin_db_version]) ) {
1194 1172
 									$error_list[$plugin_db_version] += 1;
1195
-								}
1196
-								else {
1173
+								} else {
1197 1174
 									$error_list[$plugin_db_version] = 1;
1198 1175
 								}
1199 1176
 							}
@@ -1214,21 +1191,17 @@  discard block
 block discarded – undo
1214 1191
 								$error_nb++;
1215 1192
 								if ( !empty($error_list[$plugin_db_version]) ) {
1216 1193
 									$error_list[$plugin_db_version] += 1;
1217
-								}
1218
-								else {
1194
+								} else {
1219 1195
 									$error_list[$plugin_db_version] = 1;
1220 1196
 								}
1221
-							}
1222
-							elseif($table_exists == 1){
1197
+							} elseif($table_exists == 1){
1223 1198
 								$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" />';
1224
-							}
1225
-							else{
1199
+							} else{
1226 1200
 								$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" />';
1227 1201
 								$error_nb++;
1228 1202
 								if ( !empty($error_list[$plugin_db_version]) ) {
1229 1203
 									$error_list[$plugin_db_version] += 1;
1230
-								}
1231
-								else {
1204
+								} else {
1232 1205
 									$error_list[$plugin_db_version] = 1;
1233 1206
 								}
1234 1207
 							}
@@ -1250,24 +1223,20 @@  discard block
 block discarded – undo
1250 1223
 									$error_nb++;
1251 1224
 									if ( !empty($error_list[$plugin_db_version]) ) {
1252 1225
 										$error_list[$plugin_db_version] += 1;
1253
-									}
1254
-									else {
1226
+									} else {
1255 1227
 										$error_list[$plugin_db_version] = 1;
1256 1228
 									}
1257
-								}
1258
-								else{
1229
+								} else{
1259 1230
 									$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" />';
1260 1231
 									$warning_nb++;
1261 1232
 									if ( !empty($warning_list[$plugin_db_version]) ) {
1262 1233
 										$warning_list[$plugin_db_version] += 1;
1263
-									}
1264
-									else {
1234
+									} else {
1265 1235
 										$warning_list[$plugin_db_version] = 1;
1266 1236
 									}
1267 1237
 								}
1268 1238
 								$sub_modif .= $deleted_table_result;
1269
-							}
1270
-							else{
1239
+							} else{
1271 1240
 								$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" />';
1272 1241
 							}
1273 1242
 							$sub_modif .= ' / ';
@@ -1367,8 +1336,7 @@  discard block
 block discarded – undo
1367 1336
 
1368 1337
 					if ( $has_error ) {
1369 1338
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1370
-					}
1371
-					else {
1339
+					} else {
1372 1340
 						$output_ok .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1373 1341
 					}
1374 1342
 				}
@@ -1544,8 +1512,7 @@  discard block
 block discarded – undo
1544 1512
 										if ( $last_histo === false ) {
1545 1513
 											$has_error = true;
1546 1514
 											$error_count++;
1547
-										}
1548
-										else {
1515
+										} else {
1549 1516
 											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1550 1517
 										}
1551 1518
 									}
@@ -1564,8 +1531,7 @@  discard block
 block discarded – undo
1564 1531
 						if ( $new_value === false ) {
1565 1532
 							$has_error = true;
1566 1533
 							$error_count++;
1567
-						}
1568
-						else {
1534
+						} else {
1569 1535
 							/**	Save new atribute values in product metadata	*/
1570 1536
 							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1571 1537
 							$current_product_metadata[$to_attribute->code] = $element->value;
@@ -1581,23 +1547,19 @@  discard block
 block discarded – undo
1581 1547
 					if ( !$has_error ) {
1582 1548
 						$response['status'] = true;
1583 1549
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1584
-					}
1585
-					else {
1550
+					} else {
1586 1551
 						$response['status'] = false;
1587 1552
 						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1588 1553
 					}
1589
-				}
1590
-				else {
1554
+				} else {
1591 1555
 					$response['status'] = false;
1592 1556
 					$response['error'] = __('There are no element corresponding to attribute choosen to copy from', 'wpshop');
1593 1557
 				}
1594
-			}
1595
-			else {
1558
+			} else {
1596 1559
 				$response['status'] = false;
1597 1560
 				$response['error'] = __('Both attribute must have same data type to be updated', 'wpshop');
1598 1561
 			}
1599
-		}
1600
-		else {
1562
+		} else {
1601 1563
 			$response['status'] = false;
1602 1564
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1603 1565
 		}
@@ -1696,8 +1658,7 @@  discard block
 block discarded – undo
1696 1658
 					if ( !empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes') ) {
1697 1659
 						if ( $wps_update_att_for_variation_required_state == 'yes') {
1698 1660
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1699
-						}
1700
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1661
+						} else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1701 1662
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1702 1663
 						}
1703 1664
 					}
@@ -1708,8 +1669,7 @@  discard block
 block discarded – undo
1708 1669
 						if ( !empty($text_from) && ($text_from != 'no_changes') ) {
1709 1670
 							if ( $text_from == 'yes' ) {
1710 1671
 								$meta_value['options']['price_display']['text_from'] = 'on';
1711
-							}
1712
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1672
+							} else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1713 1673
 								unset($meta_value['options']['price_display']['text_from']);
1714 1674
 							}
1715 1675
 						}
@@ -1718,8 +1678,7 @@  discard block
 block discarded – undo
1718 1678
 						if ( !empty($lower_price) && ($lower_price != 'no_changes') ) {
1719 1679
 							if ( $lower_price == 'yes' ) {
1720 1680
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1721
-							}
1722
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1681
+							} else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1723 1682
 								unset($meta_value['options']['price_display']['lower_price']);
1724 1683
 							}
1725 1684
 						}
@@ -1800,20 +1759,16 @@  discard block
 block discarded – undo
1800 1759
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1801 1760
 						}
1802 1761
 						$state = true;
1803
-					}
1804
-					else {
1762
+					} else {
1805 1763
 						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1806 1764
 					}
1807
-				}
1808
-				else {
1765
+				} else {
1809 1766
 					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1810 1767
 				}
1811
-			}
1812
-			else {
1768
+			} else {
1813 1769
 				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1814 1770
 			}
1815
-		}
1816
-		else {
1771
+		} else {
1817 1772
 			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1818 1773
 		}
1819 1774
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1841,12 +1796,10 @@  discard block
 block discarded – undo
1841 1796
 				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1842 1797
 					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1843 1798
 					$state = false;
1844
-				}
1845
-				else {
1799
+				} else {
1846 1800
 					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1847 1801
 				}
1848
-			}
1849
-			else {
1802
+			} else {
1850 1803
 				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1851 1804
 			}
1852 1805
 		}
@@ -1885,8 +1838,7 @@  discard block
 block discarded – undo
1885 1838
 							$submitOrderInfos = !empty( $_POST['submitOrderInfos'] ) ? (int) $_POST['submitOrderInfos'] : 0;
1886 1839
 							if( !empty($submitOrderInfos) ) {
1887 1840
 								$value = $attribute[$attribute->data_type][$attribute->code];
1888
-							}
1889
-							else {
1841
+							} else {
1890 1842
 								$value = '';
1891 1843
 								if ( $attribute->code != 'user_pass') {
1892 1844
 									$code = $attribute->code;
@@ -1957,16 +1909,14 @@  discard block
 block discarded – undo
1957 1909
 
1958 1910
 		if ( $wpshop_format_result ) {
1959 1911
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1960
-		}
1961
-		else {
1912
+		} else {
1962 1913
 			if ( !empty($data) ) {
1963 1914
 				$temp_data = $data;
1964 1915
 				unset( $data );
1965 1916
 				foreach ( $temp_data as $post) {
1966 1917
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1967 1918
 				}
1968
-			}
1969
-			else {
1919
+			} else {
1970 1920
 				$data = array();
1971 1921
 			}
1972 1922
 		}
@@ -2031,8 +1981,7 @@  discard block
 block discarded – undo
2031 1981
 				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
2032 1982
 				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
2033 1983
 				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
2034
-			}
2035
-			else {
1984
+			} else {
2036 1985
 				$product_title = $product->post_title;
2037 1986
 				$product_description = $product->post_content;
2038 1987
 				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
@@ -2046,8 +1995,7 @@  discard block
 block discarded – undo
2046 1995
 
2047 1996
 			echo json_encode( array(true) );
2048 1997
 			die();
2049
-		}
2050
-		else {
1998
+		} else {
2051 1999
 			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2052 2000
 		}
2053 2001
 
@@ -2064,8 +2012,7 @@  discard block
 block discarded – undo
2064 2012
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
2065 2013
 				$succes_message_box = ob_get_contents();
2066 2014
 				ob_end_clean();
2067
-			}
2068
-			else {
2015
+			} else {
2069 2016
 				$succes_message_box = wpshop_display::display_template_element($template_part, array('PRODUCT_ID' => $product_id));
2070 2017
 			}
2071 2018
 			unset($tpl_component);
@@ -2082,12 +2029,10 @@  discard block
 block discarded – undo
2082 2029
 
2083 2030
 				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2084 2031
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2085
-				}
2086
-				else {
2032
+				} else {
2087 2033
 					if( strstr( $new_pid, '__') ) {
2088 2034
 						$idp = $new_pid;
2089
-					}
2090
-					else {
2035
+					} else {
2091 2036
 						$idp = $product_to_add_to_cart[$new_pid]['id'];
2092 2037
 					}
2093 2038
 				}
@@ -2112,8 +2057,7 @@  discard block
 block discarded – undo
2112 2057
 			if ( !empty($related_products) ) {
2113 2058
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2114 2059
 				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2115
-			}
2116
-			else {
2060
+			} else {
2117 2061
 				$linked_products = '';
2118 2062
 			}
2119 2063
 
@@ -2123,8 +2067,7 @@  discard block
 block discarded – undo
2123 2067
 			$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') ) ) ) );
2124 2068
 
2125 2069
 			$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 );
2126
-		}
2127
-		else {
2070
+		} else {
2128 2071
 			$response = array( false, $return );
2129 2072
 		}
2130 2073
 
@@ -2170,8 +2113,7 @@  discard block
 block discarded – undo
2170 2113
 				}
2171 2114
 				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2172 2115
 				$response[] = $return;
2173
-			}
2174
-			else {
2116
+			} else {
2175 2117
 				$response[] = false;
2176 2118
 				$response[] = __('Parameters error.','wpshop');
2177 2119
 			}
@@ -2322,16 +2264,13 @@  discard block
 block discarded – undo
2322 2264
 				$permalink_option = get_option('permalink_structure');
2323 2265
 				if ( !empty($permalink_option) ) {
2324 2266
 					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2325
-				}
2326
-				else {
2267
+				} else {
2327 2268
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2328 2269
 				}
2329
-			}
2330
-			else {
2270
+			} else {
2331 2271
 				if ( !empty($_SESSION['cart']) ) {
2332 2272
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2333
-				}
2334
-				else {
2273
+				} else {
2335 2274
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2336 2275
 				}
2337 2276
 			}
@@ -2391,9 +2330,7 @@  discard block
 block discarded – undo
2391 2330
 			$retour .= '<div class="wpshop_cls"></div>';
2392 2331
 			$result = json_encode( array(true, $retour) );
2393 2332
 
2394
-		}
2395
-
2396
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2333
+		} elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2397 2334
 			$order_id = !empty( $_REQUEST['order_id'] ) ? (int) $_REQUEST['order_id'] : 0;
2398 2335
  			$order_info_postmeta = get_post_meta($order_id, '_order_info', true);
2399 2336
 
@@ -2409,8 +2346,7 @@  discard block
 block discarded – undo
2409 2346
  			}
2410 2347
 
2411 2348
  			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2412
- 		}
2413
-		else {
2349
+ 		} else {
2414 2350
 				// Check the attribute set id of Billing Address
2415 2351
 				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2416 2352
 				$attribute_set_id = $wpdb->get_var($query);
@@ -2472,8 +2408,7 @@  discard block
 block discarded – undo
2472 2408
 							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2473 2409
 							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2474 2410
 							$attribute_option_id = $wpdb->get_var( $query );
2475
-						}
2476
-						else {
2411
+						} else {
2477 2412
 							$entity_args = array(
2478 2413
 								'post_type' 	 => $attribute_default_value['default_value'],
2479 2414
 								'post_title'  	 => $value,
@@ -2482,8 +2417,7 @@  discard block
 block discarded – undo
2482 2417
 							);
2483 2418
 							$attribute_option_id = wp_insert_post($entity_args);
2484 2419
 						}
2485
-					}
2486
-					else {
2420
+					} else {
2487 2421
 						$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) );
2488 2422
 						$attribute_option_id = $wpdb->insert_id;
2489 2423
 					}
@@ -2572,8 +2506,7 @@  discard block
 block discarded – undo
2572 2506
 			}
2573 2507
 
2574 2508
 			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2575
-		}
2576
-		else {
2509
+		} else {
2577 2510
 			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2578 2511
 		}
2579 2512
 
@@ -2613,20 +2546,17 @@  discard block
 block discarded – undo
2613 2546
 				if ( !empty($available_payement_method[0]) ) {
2614 2547
 					if ( $cart_type=='quotation' ) {
2615 2548
 						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2616
-					}
2617
-					else {
2549
+					} else {
2618 2550
 						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2619 2551
 					}
2620 2552
 				}
2621
-			}
2622
-			else {
2553
+			} else {
2623 2554
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2624 2555
 			}
2625 2556
 			if( $address_type == 'billing_address') {
2626 2557
 				$billing_option = get_option( 'wpshop_billing_address' );
2627 2558
 				$address_option = $billing_option['choice'];
2628
-			}
2629
-			else {
2559
+			} else {
2630 2560
 				$shipping_address_option = get_option('wpshop_shipping_address_choice');
2631 2561
 				$address_option = $shipping_address_option['choice'];
2632 2562
 			}
@@ -2638,8 +2568,7 @@  discard block
 block discarded – undo
2638 2568
 
2639 2569
 			$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>';
2640 2570
 			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2641
-		}
2642
-		else {
2571
+		} else {
2643 2572
 			$result = json_encode( array(false, 'missing_informations') );
2644 2573
 		}
2645 2574
 		echo $result;
@@ -2708,13 +2637,11 @@  discard block
 block discarded – undo
2708 2637
 					wps_address::save_address_infos( $shipping_address);
2709 2638
 				}
2710 2639
 				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2711
-			}
2712
-			else {
2640
+			} else {
2713 2641
 				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2714 2642
 			}
2715 2643
 
2716
-		}
2717
-		else {
2644
+		} else {
2718 2645
 			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2719 2646
 		}
2720 2647
 		echo $result;
@@ -2742,8 +2669,7 @@  discard block
 block discarded – undo
2742 2669
 			$wps_message = new wps_message_ctr();
2743 2670
 			$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) );
2744 2671
 			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2745
-		}
2746
-		else {
2672
+		} else {
2747 2673
 			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2748 2674
 		}
2749 2675
 		echo json_encode($result);
@@ -2770,8 +2696,7 @@  discard block
 block discarded – undo
2770 2696
 			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2771 2697
 			update_post_meta( $element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2772 2698
 			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2773
-		}
2774
-		else {
2699
+		} else {
2775 2700
 			$result = '';
2776 2701
 		}
2777 2702
 		echo $result;
@@ -2856,8 +2781,7 @@  discard block
 block discarded – undo
2856 2781
 						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2857 2782
 							$manage_stock_checking_bool = true;
2858 2783
 						}
2859
-					}
2860
-					else {
2784
+					} else {
2861 2785
 						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2862 2786
 							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2863 2787
 							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
@@ -2880,8 +2804,7 @@  discard block
 block discarded – undo
2880 2804
 					/** Checking stock **/
2881 2805
 					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 ) ) {
2882 2806
 						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2883
-					}
2884
-					else {
2807
+					} else {
2885 2808
 						$add_to_cart_checking = true;
2886 2809
 						$add_to_cart_checking_message = __('Some products cannot be added to cart because they are out of stock', 'wpshop');
2887 2810
 					}
@@ -3005,12 +2928,10 @@  discard block
 block discarded – undo
3005 2928
 
3006 2929
 				$response = __( 'Direct payment link has been send', 'wpshop' );
3007 2930
 				$status = true;
3008
-			}
3009
-			else {
2931
+			} else {
3010 2932
 				$response = __( 'An error was occured', 'wpshop' );
3011 2933
 			}
3012
-		}
3013
-		else {
2934
+		} else {
3014 2935
 			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
3015 2936
 		}
3016 2937
 		echo json_encode( array( 'status' => $status, 'response' => $response) );
@@ -3097,8 +3018,7 @@  discard block
 block discarded – undo
3097 3018
 					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3098 3019
 					$wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3099 3020
 					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3100
-				}
3101
-				else {
3021
+				} else {
3102 3022
 					$common_datas = array(
3103 3023
 						'value_id' => null,
3104 3024
 						'entity_type_id' => 5,
@@ -3266,8 +3186,7 @@  discard block
 block discarded – undo
3266 3186
 						if( !empty($element_definition['content'][$att]) ) {
3267 3187
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3268 3188
 							$controller_rows_array[ $att ] = true;
3269
-						}
3270
-						else {
3189
+						} else {
3271 3190
 							$formatted_datas[$element_id]['content'][$att] = array();
3272 3191
 						}
3273 3192
 					}
@@ -3297,8 +3216,7 @@  discard block
 block discarded – undo
3297 3216
 										if( $current_attribute->data_type_to_use == 'internal' ) {
3298 3217
 											$current_val = get_the_title($current_val);
3299 3218
 											$old_val = get_the_title($old_val);
3300
-										}
3301
-										else {
3219
+										} else {
3302 3220
 											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3303 3221
 											$old_val = $wpdb->get_var( $query );
3304 3222
 											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
@@ -3353,12 +3271,10 @@  discard block
 block discarded – undo
3353 3271
 				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3354 3272
 				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3355 3273
 				$status = true;
3356
-			}
3357
-			else {
3274
+			} else {
3358 3275
 				$response = __( 'Category options are not defined', 'wpshop');
3359 3276
 			}
3360
-		}
3361
-		else {
3277
+		} else {
3362 3278
 			$response = __( 'Category ID is not defined', 'wpshop');
3363 3279
 		}
3364 3280
 		echo json_encode( array( 'status' => $status, 'response' => $response) );
@@ -3390,8 +3306,7 @@  discard block
 block discarded – undo
3390 3306
 		if ( $attributeSetSectionCreation == 'done' ) {
3391 3307
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
3392 3308
 			$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
3393
-		}
3394
-		else {
3309
+		} else {
3395 3310
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
3396 3311
 		}
3397 3312
 
@@ -3419,10 +3334,11 @@  discard block
 block discarded – undo
3419 3334
 		$attributeSetInfos['backend_display_type'] = $backend_display_type;
3420 3335
 		$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
3421 3336
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3422
-		if ( $attributeSetSectionCreation == 'done' )
3423
-			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
3424
-		else
3425
-			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
3337
+		if ( $attributeSetSectionCreation == 'done' ) {
3338
+					$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
3339
+		} else {
3340
+					$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
3341
+		}
3426 3342
 		echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>';
3427 3343
 		wp_die();
3428 3344
 	}
@@ -3442,9 +3358,9 @@  discard block
 block discarded – undo
3442 3358
 		if ( $attributeSetSectionCreation == 'done' ) {
3443 3359
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
3444 3360
 			$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
3361
+		} else {
3362
+					$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
3445 3363
 		}
3446
-		else
3447
-			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
3448 3364
 		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3449 3365
 		wp_die();
3450 3366
 	}
@@ -3510,8 +3426,7 @@  discard block
 block discarded – undo
3510 3426
 		if($save_unit_result == 'done'){
3511 3427
 			$save_output = wpshop_attributes_unit::elementList();
3512 3428
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
3513
-		}
3514
-		else{
3429
+		} else{
3515 3430
 			$save_output = wpshop_attributes_unit::elementEdition();
3516 3431
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
3517 3432
 		}
@@ -3547,8 +3462,7 @@  discard block
 block discarded – undo
3547 3462
 		if ( $save_unit_result == 'done' ) {
3548 3463
 			$save_output = wpshop_attributes_unit::elementList();
3549 3464
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
3550
-		}
3551
-		else {
3465
+		} else {
3552 3466
 			$save_output = wpshop_attributes_unit::elementEdition($attributeUnitId);
3553 3467
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit saving', 'wpshop');
3554 3468
 		}
@@ -3568,8 +3482,7 @@  discard block
 block discarded – undo
3568 3482
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
3569 3483
 		if ( $save_unit_result == 'done' ) {
3570 3484
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
3571
-		}
3572
-		else {
3485
+		} else {
3573 3486
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit deletion', 'wpshop');
3574 3487
 		}
3575 3488
 
@@ -3611,8 +3524,7 @@  discard block
 block discarded – undo
3611 3524
 		if($save_unit_result == 'done'){
3612 3525
 			$save_output = wpshop_attributes_unit::unit_group_list();
3613 3526
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
3614
-		}
3615
-		else{
3527
+		} else{
3616 3528
 			$save_output = wpshop_attributes_unit::unit_group_edition();
3617 3529
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
3618 3530
 		}
@@ -3635,8 +3547,7 @@  discard block
 block discarded – undo
3635 3547
 		if($save_unit_result == 'done'){
3636 3548
 			$save_output = wpshop_attributes_unit::unit_group_list();
3637 3549
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
3638
-		}
3639
-		else{
3550
+		} else{
3640 3551
 			$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
3641 3552
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
3642 3553
 		}
@@ -3656,8 +3567,7 @@  discard block
 block discarded – undo
3656 3567
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3657 3568
 		if($save_unit_result == 'done'){
3658 3569
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
3659
-		}
3660
-		else{
3570
+		} else{
3661 3571
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
3662 3572
 		}
3663 3573
 
@@ -3686,7 +3596,9 @@  discard block
 block discarded – undo
3686 3596
 		$data = wpshop_products::wpshop_get_product_by_criteria( $criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page );
3687 3597
 		if($data[0]) {
3688 3598
 			echo json_encode(array(true, do_shortcode($data[1])));
3689
-		} else echo json_encode(array(false,__('No product found','wpshop')));
3599
+		} else {
3600
+			echo json_encode(array(false,__('No product found','wpshop')));
3601
+		}
3690 3602
 		wp_die();
3691 3603
 	}
3692 3604
 	add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' );
@@ -3713,10 +3625,10 @@  discard block
 block discarded – undo
3713 3625
 			if (!empty($user_info->user_email)) {
3714 3626
 				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$post_id, $object=array());
3715 3627
 				$array = array('result' => true, 'message' => '');
3628
+			} else {
3629
+				$array = array('result' => true, 'message' => __('An error occured','wpshop'));
3716 3630
 			}
3717
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
3718
-		}
3719
-		else {
3631
+		} else {
3720 3632
 			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3721 3633
 		}
3722 3634
 
@@ -3745,12 +3657,10 @@  discard block
 block discarded – undo
3745 3657
 				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
3746 3658
 
3747 3659
 				$array = array('result' => true, 'message' => '');
3748
-			}
3749
-			else {
3660
+			} else {
3750 3661
 				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3751 3662
 			}
3752
-		}
3753
-		else {
3663
+		} else {
3754 3664
 			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3755 3665
 		}
3756 3666
 
@@ -3782,7 +3692,9 @@  discard block
 block discarded – undo
3782 3692
 			$order = $wps_cart_ctr->calcul_cart_information(array());
3783 3693
 			$wps_cart_ctr->store_cart_in_session($order);
3784 3694
 			echo json_encode(array(true, ''));
3785
-		} else echo json_encode(array(false, $result['message']));
3695
+		} else {
3696
+			echo json_encode(array(false, $result['message']));
3697
+		}
3786 3698
 		wp_die();
3787 3699
 	}
3788 3700
 	add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' );
Please login to merge, or discard this patch.
includes/librairies/payments/payment.class.php 2 patches
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$wpshop_paypal = new wpshop_paypal();
22 22
 		// If the CIC payment method is active
23
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
24
-		if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) {
23
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
24
+		if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) {
25 25
 			$wpshop_cic = new wpshop_CIC();
26 26
 		}
27
-		wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse');
27
+		wpshop_tools::create_custom_hook('wpshop_bankserver_reponse');
28 28
 
29 29
 	}
30 30
 
31 31
 	public static function get_success_payment_url() {
32
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) );
32
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id')));
33 33
 		return self::construct_url_parameters($url, 'paymentResult', 'success');
34 34
 	}
35 35
 
36 36
 	public static function get_cancel_payment_url() {
37
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) );
37
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id')));
38 38
 		return $url;
39 39
 	}
40 40
 
41 41
 	public static function construct_url_parameters($url, $param, $value) {
42 42
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
43
+		if ($interoguation_marker_pos === false)
44
+			return $url . '?' . $param . '=' . $value;
45
+		else return $url . '&' . $param . '=' . $value;
46 46
 	}
47 47
 
48 48
 	/**
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
 	public static function wpshop_payment_result() {
52 52
 		global $wpdb;
53 53
 		$user_ID = get_current_user_id();
54
-		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
-		$order_post_id = $wpdb->get_var( $query );
56
-		if ( !empty($order_post_id) ) {
57
-			$order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true);
58
-			if ( !empty($order_postmeta) ) {
59
-				switch ( $order_postmeta ) {
54
+		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
+		$order_post_id = $wpdb->get_var($query);
56
+		if (!empty($order_post_id)) {
57
+			$order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true);
58
+			if (!empty($order_postmeta)) {
59
+				switch ($order_postmeta) {
60 60
 					case 'awaiting_payment':
61
-						echo __('We wait your payment.','wpshop');
61
+						echo __('We wait your payment.', 'wpshop');
62 62
 					break;
63 63
 					case 'completed':
64
-						echo __('Thank you ! Your payment has been recorded.','wpshop');
64
+						echo __('Thank you ! Your payment has been recorded.', 'wpshop');
65 65
 					break;
66 66
 					case 'partially_paid':
67
-						echo __('Thank you ! Your first payment has been recorded.','wpshop');
67
+						echo __('Thank you ! Your first payment has been recorded.', 'wpshop');
68 68
 					break;
69 69
 					default:
70
-						echo __('Your payment and your order has been cancelled.','wpshop');
70
+						echo __('Your payment and your order has been cancelled.', 'wpshop');
71 71
 					break;
72 72
 				}
73 73
 			}
@@ -88,56 +88,56 @@  discard block
 block discarded – undo
88 88
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89 89
 	 * @return string The different payment method
90 90
 	 */
91
-	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
91
+	function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
92 92
 		$output = '';
93 93
 		/**	Get available payment method	*/
94 94
 		$paymentMethod = get_option('wpshop_paymentMethod', array());
95 95
 
96
-		if(!empty($order_id) && is_numeric($order_id)) {
97
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
96
+		if (!empty($order_id) && is_numeric($order_id)) {
97
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
98 98
 		}
99 99
 
100 100
 		if ($cart_type == 'cart') {
101 101
 			$payment_methods = array();
102
-			if(!empty($paymentMethod['paypal'])) {
102
+			if (!empty($paymentMethod['paypal'])) {
103 103
 				$payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'),
104 104
 														'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png',
105
-														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop')
105
+														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop')
106 106
 								 );
107 107
 			}
108
-			if(!empty($paymentMethod['checks'])) {
108
+			if (!empty($paymentMethod['checks'])) {
109 109
 				$payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'),
110 110
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
111
-						'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop')
111
+						'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop')
112 112
 				);
113 113
 			}
114
-			if(!empty($paymentMethod['banktransfer'])) {
114
+			if (!empty($paymentMethod['banktransfer'])) {
115 115
 				$payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'),
116 116
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
117
-						'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop')
117
+						'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop')
118 118
 				);
119 119
 			}
120
-			if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
120
+			if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
121 121
 				$payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'),
122 122
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg',
123
-						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop')
123
+						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop')
124 124
 				);
125 125
 			}
126 126
 			$payment_methods = apply_filters('wpshop_payment_method', $payment_methods);
127 127
 
128 128
 			$payment_method_table = array();
129 129
 
130
-			if ( !empty( $paymentMethod['display_position'] ) ) {
130
+			if (!empty($paymentMethod['display_position'])) {
131 131
 				$position_determinated = false;
132
-				foreach ( $paymentMethod['display_position'] as $key => $position) {
133
-					if ( $position != null) {
132
+				foreach ($paymentMethod['display_position'] as $key => $position) {
133
+					if ($position != null) {
134 134
 						$position_determinated = true;
135 135
 					}
136 136
 				}
137
-				if ( $position_determinated ) {
138
-					for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) {
139
-						foreach ( $paymentMethod['display_position'] as $key => $position ) {
140
-							if ( $position == $i  && !empty($paymentMethod[$key])) {
137
+				if ($position_determinated) {
138
+					for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) {
139
+						foreach ($paymentMethod['display_position'] as $key => $position) {
140
+							if ($position == $i && !empty($paymentMethod[$key])) {
141 141
 								if ($key == 'checks') {
142 142
 									$key = 'check';
143 143
 								}
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 					$payment_methods = $payment_method_table;
149 149
 				}
150 150
 			}
151
-			if (!empty($payment_methods) ) {
151
+			if (!empty($payment_methods)) {
152 152
 
153
-				foreach( $payment_methods as  $payment_method_identifier =>  $payment_method_def ) {
153
+				foreach ($payment_methods as  $payment_method_identifier =>  $payment_method_def) {
154 154
 					$tpl_component = array();
155 155
 					$checked = $active = '';
156 156
 					$payment_identifier_for_test = $payment_method_identifier;
157 157
 					if ($payment_method_identifier == 'check') {
158 158
 						$payment_identifier_for_test = 'checks';
159 159
 					}
160
-					if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
160
+					if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
161 161
 						$checked = ' checked="checked"';
162 162
 						$active = ' active';
163 163
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active;
166 166
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked;
167 167
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168
-					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
168
+					if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) {
169
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : '';
170 170
 					}
171 171
 					else {
172
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
172
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : '';
173 173
 					}
174 174
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
175 175
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name'];
@@ -180,32 +180,32 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 		}
182 182
 
183
-		return array( $output, $paymentMethod['mode'] );
183
+		return array($output, $paymentMethod['mode']);
184 184
 	}
185 185
 
186 186
 
187
-	public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
188
-		$payment_option = get_option( 'wps_payment_mode' );
187
+	public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
188
+		$payment_option = get_option('wps_payment_mode');
189 189
 		$output = '';
190
-		if(!empty($order_id) && is_numeric($order_id)) {
191
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
190
+		if (!empty($order_id) && is_numeric($order_id)) {
191
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
192 192
 		}
193
-		if( $cart_type == 'cart' ) {
194
-			if ( !empty($payment_option) && !empty($payment_option['mode']) ) {
195
-				foreach( $payment_option['mode'] as $payment_id => $payment_config ) {
196
-					if( !empty($payment_config['active']) ) {
197
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : '');
198
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : '');
193
+		if ($cart_type == 'cart') {
194
+			if (!empty($payment_option) && !empty($payment_option['mode'])) {
195
+				foreach ($payment_option['mode'] as $payment_id => $payment_config) {
196
+					if (!empty($payment_config['active'])) {
197
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : '');
198
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : '');
199 199
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id;
200 200
 
201
-						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
201
+						if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) {
202
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : '';
203 203
 						}
204 204
 						else {
205
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
205
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : '';
206 206
 						}
207
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
208
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : '';
207
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : '';
208
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : '';
209 209
 						$output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id));
210 210
 						unset($tpl_component);
211 211
 					}
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$wps_message = new wps_message_ctr();
229 229
 
230
-		if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
-			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' );
232
-			$first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
233
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
230
+		if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
232
+			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
233
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
234 234
 
235 235
 			// Envoie du message de confirmation de paiement au client
236
-			switch($order['payment_method']) {
236
+			switch ($order['payment_method']) {
237 237
 				case 'check':
238 238
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']));
239 239
 				break;
@@ -250,24 +250,24 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 
253
-	function setOrderPaymentStatus( $order_id, $payment_status ) {
253
+	function setOrderPaymentStatus($order_id, $payment_status) {
254 254
 		/**	Get order main information	*/
255 255
 		$order = get_post_meta($order_id, '_order_postmeta', true);
256 256
 		$send_email = false;
257 257
 
258
-		if ( !empty($order) ) {
258
+		if (!empty($order)) {
259 259
 			/**	Change order status to given status	*/
260 260
 			$order['order_status'] = strtolower($payment_status);
261 261
 			/**	Put order status into a single meta, allowing to use it easily later	*/
262 262
 			update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
263 263
 
264 264
 			/**	In case the set status is completed, make specific treatment: add the completed date	*/
265
-			if ( $payment_status == 'completed' ) {
265
+			if ($payment_status == 'completed') {
266 266
 				/**	Read order items list, if not empty and check if each item is set to manage stock or not */
267 267
 				if (!empty($order['order_items'])) {
268 268
 					foreach ($order['order_items'] as $o) {
269
-						$product = wpshop_products::get_product_data( $o['item_id'] );
270
-						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) {
269
+						$product = wpshop_products::get_product_data($o['item_id']);
270
+						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) {
271 271
 							wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']);
272 272
 						}
273 273
 					}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			/**	Send email to customer when specific case need it	*/
284
-			if ( $send_email ) {
284
+			if ($send_email) {
285 285
 				/**	Get information about customer that make the order	*/
286 286
 				$order_info = get_post_meta($order_id, '_order_info', true);
287 287
 				$mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']);
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
 	/**
296 296
 	* Get payment method
297 297
 	*/
298
-	function get_payment_method($post_id){
299
-		$pm = __('Nc','wpshop');
298
+	function get_payment_method($post_id) {
299
+		$pm = __('Nc', 'wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
301
-		if ( !empty($order_postmeta['payment_method']) ) {
302
-			switch($order_postmeta['payment_method']){
301
+		if (!empty($order_postmeta['payment_method'])) {
302
+			switch ($order_postmeta['payment_method']) {
303 303
 				case 'check':
304
-					$pm = __('Check','wpshop');
304
+					$pm = __('Check', 'wpshop');
305 305
 				break;
306 306
 				case 'paypal':
307
-					$pm = __('Paypal','wpshop');
307
+					$pm = __('Paypal', 'wpshop');
308 308
 				break;
309 309
 				case 'banktransfer':
310
-					$pm = __('Bank transfer','wpshop');
310
+					$pm = __('Bank transfer', 'wpshop');
311 311
 				break;
312 312
 				case 'cic':
313
-					$pm = __('Credit card','wpshop');
313
+					$pm = __('Credit card', 'wpshop');
314 314
 				break;
315 315
 				default:
316
-					$pm = __('Nc','wpshop');
316
+					$pm = __('Nc', 'wpshop');
317 317
 				break;
318 318
 			}
319 319
 		}
@@ -333,38 +333,38 @@  discard block
 block discarded – undo
333 333
 
334 334
 		$paymentMethod = $paymentMethod['mode'];
335 335
 		$payment_validation .= '
336
-<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" >
337
-	<input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
-	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
336
+<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" >
337
+	<input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
+	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
339 339
 
340
-		if(!empty($order_postmeta['payment_method'])){
340
+		if (!empty($order_postmeta['payment_method'])) {
341 341
 			$payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>';
342 342
 		}
343 343
 
344
-		if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
344
+		if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
345 345
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>';
346 346
 			$display_button = true;
347 347
 		}
348 348
 
349
-		if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
349
+		if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
350 350
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>';
351 351
 			$display_button = true;
352 352
 		}
353 353
 
354
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
355
-		if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) {
354
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
355
+		if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) {
356 356
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>';
357 357
 			$display_button = true;
358 358
 		}
359 359
 
360
-		if(empty($payment_transaction)){
361
-			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />';
360
+		if (empty($payment_transaction)) {
361
+			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />';
362 362
 			$display_button = true;
363 363
 		}
364 364
 
365
-		if($display_button){
365
+		if ($display_button) {
366 366
 			$payment_validation .= '
367
-		<br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>';
367
+		<br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>';
368 368
 		}
369 369
 
370 370
 		$payment_validation .= '
@@ -379,21 +379,21 @@  discard block
 block discarded – undo
379 379
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380 380
 	 * @return array The amount to pay / A html output with amount to pay and different information
381 381
 	 */
382
-	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
382
+	function partial_payment_calcul($current_order_total, $for = 'for_all') {
383 383
 		$output = '';
384 384
 		$tpl_component = array();
385 385
 
386 386
 		/**	Get current configuration	*/
387 387
 		$partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array()));
388
-		if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) {
388
+		if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) {
389 389
 			$amount_of_partial_payment = 0;
390
-			if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) {
390
+			if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) {
391 391
 				$amount_of_partial_payment = $partial_payment_configuration[$for]['value'];
392 392
 			}
393 393
 
394 394
 			$partial_amount_to_pay = 0;
395 395
 			$type_of_partial_payment = null;
396
-			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) {
396
+			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) {
397 397
 				switch ($partial_payment_configuration[$for]['type']) {
398 398
 					case 'percentage':
399 399
 						$type_of_partial_payment = '%';
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	function set_payment_transaction_number($order_id, $transaction_number) {
454 454
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
455 455
 
456
-		if ( !empty($order_postmeta['order_payment']['received']) ) {
456
+		if (!empty($order_postmeta['order_payment']['received'])) {
457 457
 			if (count($order_postmeta['order_payment']['received']) == 1) {
458 458
 				$order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number;
459 459
 			}
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param integer $order_id
469 469
 	 */
470
-	function save_payment_return_data( $order_id ) {
470
+	function save_payment_return_data($order_id) {
471 471
 		$data = wpshop_tools::getMethode();
472 472
 
473
-		$current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true);
473
+		$current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true);
474 474
 		$current_payment_return[] = $data;
475 475
 
476 476
 		update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return);
@@ -484,23 +484,23 @@  discard block
 block discarded – undo
484 484
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
485 485
 	 * @return array The order new meta informations
486 486
 	 */
487
-	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
488
-
489
-		$order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null;
490
-		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null;
491
-		$order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null;
492
-		$order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id();
493
-		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null;
494
-		$order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null;
495
-		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null;
487
+	public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) {
488
+
489
+		$order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null;
490
+		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null;
491
+		$order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null;
492
+		$order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id();
493
+		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null;
494
+		$order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null;
495
+		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null;
496 496
 		$order_meta['order_payment']['received'][$payment_index]['comment'] = '';
497 497
 
498 498
 		$order_info = get_post_meta($order_id, '_order_info', true);
499
-		if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
499
+		if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
500 500
 
501 501
 			/**	Generate an invoice number for the current payment. Check if the payment is complete or not	*/
502
-			if ( empty($order_meta['order_invoice_ref']) ) {
503
-				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id );
502
+			if (empty($order_meta['order_invoice_ref'])) {
503
+				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id);
504 504
 			}
505 505
 		}
506 506
 
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 * @param string $payment_method
514 514
 	 * @return integer $key : array id of [order_payment][received] in the order postmeta
515 515
 	 */
516
-	public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) {
516
+	public static function get_order_waiting_payment_array_id($oid, $payment_method) {
517 517
 		$key = 0;
518
-		$order_meta = get_post_meta( $oid, '_order_postmeta', true);
519
-		if ( !empty($order_meta) ) {
520
-			$key = count( $order_meta['order_payment']['received'] );
521
-			foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) {
522
-				if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) {
518
+		$order_meta = get_post_meta($oid, '_order_postmeta', true);
519
+		if (!empty($order_meta)) {
520
+			$key = count($order_meta['order_payment']['received']);
521
+			foreach ($order_meta['order_payment']['received'] as $k => $payment_test) {
522
+				if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) {
523 523
 					$key = $k;
524 524
 				}
525 525
 			}
@@ -534,52 +534,52 @@  discard block
 block discarded – undo
534 534
 	 * @param array $params_array
535 535
 	 * @return string
536 536
 	 */
537
-	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) {
537
+	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) {
538 538
 		global $wpshop_payment; global $wpdb;
539
-		$order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true);
539
+		$order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true);
540 540
 
541 541
 		$wps_message = new wps_message_ctr();
542
-		if ( !empty($order_meta) ) {
542
+		if (!empty($order_meta)) {
543 543
 			$order_info = get_post_meta($order_id, '_order_info', true);
544
-			$user_data = get_userdata( $order_meta['customer_id'] );
545
-			$email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : '';
544
+			$user_data = get_userdata($order_meta['customer_id']);
545
+			$email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : '';
546 546
 // 			$email = ( !empty($order_info) &&  !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ;
547
-			$first_name = (!empty($order_info) && !empty($order_info['billing']) &&  !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
548
-			$last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
547
+			$first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
548
+			$last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
549 549
 
550
-			$key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']);
550
+			$key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']);
551 551
 			$order_grand_total = $order_meta['order_grand_total'];
552
-			$total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 );
553
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
554
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
552
+			$total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0);
553
+			foreach ($order_meta['order_payment']['received'] as $received) {
554
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
555 555
 			}
556 556
 			$order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received;
557
-			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response );
557
+			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response);
558 558
 
559 559
 			if ($bank_response == 'completed') {
560 560
 
561
-				if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) {
561
+				if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) {
562 562
 					$payment_status = 'completed';
563 563
 
564
-					$order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : ( empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref'] ) ;
564
+					$order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : (empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref']);
565 565
 					$order_meta['order_invoice_date'] = current_time('mysql', 0);
566 566
 
567 567
 					if (!empty($order_meta['order_items'])) {
568 568
 						foreach ($order_meta['order_items'] as $item_id => $o) {
569 569
 							$pid = $o['item_id'];
570
-							if (strpos($item_id,'__') !== false) {
571
-								$product_data_id = explode( '__', $item_id );
572
-								$pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid;
570
+							if (strpos($item_id, '__') !== false) {
571
+								$product_data_id = explode('__', $item_id);
572
+								$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid;
573 573
 							}
574
-							$product = wpshop_products::get_product_data( $pid );
575
-							if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
576
-								$parent_def = wpshop_products::get_parent_variation ( $pid );
574
+							$product = wpshop_products::get_product_data($pid);
575
+							if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
576
+								$parent_def = wpshop_products::get_parent_variation($pid);
577 577
 								$parent_post = $parent_def['parent_post'];
578
-								$product = wpshop_products::get_product_data( $parent_post->ID );
578
+								$product = wpshop_products::get_product_data($parent_post->ID);
579 579
 							}
580 580
 
581
-							if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) {
582
-								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid );
581
+							if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
582
+								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid);
583 583
 							}
584 584
 						}
585 585
 					}
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 					update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0));
589 589
 
590 590
 					// Send confirmation e-mail to administrator
591
-					if ( empty($_SESSION['wps-pos-addon']) ) {
591
+					if (empty($_SESSION['wps-pos-addon'])) {
592 592
 						$email_option = get_option('wpshop_emails');
593
-						if(  !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){
594
-							wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data );
593
+						if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) {
594
+							wpshop_checkout::send_order_email_to_administrator($order_id, $user_data);
595 595
 						}
596 596
 					}
597 597
 
598 598
 					// POS Status
599
-					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
599
+					if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') {
600 600
 						$payment_status = 'pos';
601 601
 					}
602 602
 				}
@@ -605,27 +605,27 @@  discard block
 block discarded – undo
605 605
 				}
606 606
 
607 607
 				$order_meta['order_status'] = $payment_status;
608
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
608
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
609 609
 				$save_metadata = false;
610 610
 
611
-				$allow_send_invoice = get_option( 'wpshop_send_invoice' );
612
-				$invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, empty( $order_meta['order_payment']['received'][$key]['invoice_ref'] ) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : '';
611
+				$allow_send_invoice = get_option('wpshop_send_invoice');
612
+				$invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref']) : '';
613 613
 
614
-				$email_option = get_option( 'wpshop_emails' );
614
+				$email_option = get_option('wpshop_emails');
615 615
 
616
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
617
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
616
+				$shipping_mode_option = get_option('wps_shipping_mode');
617
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
618 618
 
619
-				$payment_method_option = get_option( 'wps_payment_mode' );
620
-				$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode'])  && !empty($order_meta['order_payment']['customer_choice']['method'])  && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
619
+				$payment_method_option = get_option('wps_payment_mode');
620
+				$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
621 621
 
622
-				if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed'
623
-						&& ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) {
624
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method ) );
622
+				if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed'
623
+						&& (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) {
624
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method));
625 625
 				}
626 626
 
627
-				if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) {
628
-					$wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
627
+				if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) {
628
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
629 629
 				}
630 630
 			}
631 631
 			else {
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 
635 635
 			$order_meta['order_status'] = $payment_status;
636 636
 
637
-			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
638
-			if( $save_metadata ) {
639
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
637
+			update_post_meta($order_id, '_wpshop_order_status', $payment_status);
638
+			if ($save_metadata) {
639
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
640 640
 			}
641 641
 		}
642
-		do_action( 'wps_after_check_order_payment_total_amount', $order_id );
643
-		if ( ! $save_metadata ) {
642
+		do_action('wps_after_check_order_payment_total_amount', $order_id);
643
+		if (!$save_metadata) {
644 644
 			return $order_meta;
645 645
 		}
646 646
 	}
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 	 * @param integer $order_id The order identifier we want to get the old transaction reference for
654 654
 	 * @return integer
655 655
 	 */
656
-	public static function get_payment_transaction_number_old_way($order_id){
656
+	public static function get_payment_transaction_number_old_way($order_id) {
657 657
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
658 658
 		$transaction_indentifier = 0;
659
-		if(!empty($order_postmeta['payment_method'])){
660
-			switch($order_postmeta['payment_method']){
659
+		if (!empty($order_postmeta['payment_method'])) {
660
+			switch ($order_postmeta['payment_method']) {
661 661
 				case 'check':
662 662
 					$transaction_indentifier = get_post_meta($order_id, '_order_check_number', true);
663 663
 					break;
@@ -676,26 +676,26 @@  discard block
 block discarded – undo
676 676
 		return $transaction_indentifier;
677 677
 	}
678 678
 
679
-	public static function reverify_payment_invoice_ref( $order_id, $index_payment ) {
679
+	public static function reverify_payment_invoice_ref($order_id, $index_payment) {
680 680
 		$status = false;
681
-		$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
682
-		if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) {
681
+		$order_meta = get_post_meta($order_id, '_order_postmeta', true);
682
+		if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) {
683 683
 			$order_invoice = $invoice_ref = false;
684 684
 
685
-			end( $order_meta['order_payment']['received'] );
686
-			$last_payment = key( $order_meta['order_payment']['received'] );
687
-			if( $last_payment == $index_payment ) {
685
+			end($order_meta['order_payment']['received']);
686
+			$last_payment = key($order_meta['order_payment']['received']);
687
+			if ($last_payment == $index_payment) {
688 688
 				$payments = 0;
689
-				foreach( $order_meta['order_payment']['received'] as $payment ) {
690
-					$payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0;
689
+				foreach ($order_meta['order_payment']['received'] as $payment) {
690
+					$payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0;
691 691
 				}
692
-				if( $order_meta['order_grand_total'] <= $payments ) {
693
-					if( $order_meta['order_status'] == 'partially_paid' ) {
694
-						$order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true );
692
+				if ($order_meta['order_grand_total'] <= $payments) {
693
+					if ($order_meta['order_status'] == 'partially_paid') {
694
+						$order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true);
695 695
 						$order_meta['order_status'] = 'completed';
696
-						$status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' );
696
+						$status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed');
697 697
 					}
698
-					if( !empty( $order_meta['order_invoice_ref'] ) ) {
698
+					if (!empty($order_meta['order_invoice_ref'])) {
699 699
 						$invoice_ref = $order_meta['order_invoice_ref'];
700 700
 						$status = true;
701 701
 					} else {
@@ -706,16 +706,16 @@  discard block
 block discarded – undo
706 706
 				$status = true;
707 707
 			}
708 708
 
709
-			if( $status ) {
710
-				if( empty( $invoice_ref ) ) {
711
-					$invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id );
712
-					if( $order_invoice ) {
709
+			if ($status) {
710
+				if (empty($invoice_ref)) {
711
+					$invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id);
712
+					if ($order_invoice) {
713 713
 						$order_meta['order_invoice_ref'] = $invoice_ref;
714 714
 					}
715 715
 				}
716 716
 
717 717
 				$order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref;
718
-				$status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta );
718
+				$status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta);
719 719
 			}
720 720
 		}
721 721
 		return $status;
Please login to merge, or discard this patch.
Braces   +12 added lines, -12 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
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -40,9 +42,11 @@  discard block
 block discarded – undo
40 42
 
41 43
 	public static function construct_url_parameters($url, $param, $value) {
42 44
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
45
+		if($interoguation_marker_pos===false) {
46
+					return $url.'?'.$param.'='.$value;
47
+		} else {
48
+			return $url.'&'.$param.'='.$value;
49
+		}
46 50
 	}
47 51
 
48 52
 	/**
@@ -167,8 +171,7 @@  discard block
 block discarded – undo
167 171
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168 172
 					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169 173
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
170
-					}
171
-					else {
174
+					} else {
172 175
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
173 176
 					}
174 177
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
@@ -200,8 +203,7 @@  discard block
 block discarded – undo
200 203
 
201 204
 						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202 205
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
203
-						}
204
-						else {
206
+						} else {
205 207
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
206 208
 						}
207 209
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
@@ -599,8 +601,7 @@  discard block
 block discarded – undo
599 601
 					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
600 602
 						$payment_status = 'pos';
601 603
 					}
602
-				}
603
-				else {
604
+				} else {
604 605
 					$payment_status = 'partially_paid';
605 606
 				}
606 607
 
@@ -627,8 +628,7 @@  discard block
 block discarded – undo
627 628
 				if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) {
628 629
 					$wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
629 630
 				}
630
-			}
631
-			else {
631
+			} else {
632 632
 				$payment_status = $bank_response;
633 633
 			}
634 634
 
Please login to merge, or discard this patch.
templates/backend/order-private-comments/wps_orders_private_comments.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 ?>
3 3
 <div>
4 4
 	<div>
5
-		<label for="textarea_order_private_comment"><?php _e( 'Write your notification and send it to your customer', 'wpshop'); ?> :</label>
5
+		<label for="textarea_order_private_comment"><?php _e('Write your notification and send it to your customer', 'wpshop'); ?> :</label>
6 6
 		<div class="wps-form">
7 7
 			<textarea id="textarea_order_private_comment" name="order_private_comment"></textarea>
8 8
 		</div>
9
-		<a data-nonce="<?php echo wp_create_nonce( 'wpshop_add_private_comment_to_order' ); ?>" href="#" class="wps-bton-first-mini-rounded addPrivateComment order_<?php echo $post->ID; ?>"><?php _e('Add the comment','wpshop'); ?></a>
9
+		<a data-nonce="<?php echo wp_create_nonce('wpshop_add_private_comment_to_order'); ?>" href="#" class="wps-bton-first-mini-rounded addPrivateComment order_<?php echo $post->ID; ?>"><?php _e('Add the comment', 'wpshop'); ?></a>
10 10
 	</div>
11 11
 
12 12
 	<div id="wps_private_messages_container">
13
-		<?php if( !empty($post) && !empty($post->ID) ) :
13
+		<?php if (!empty($post) && !empty($post->ID)) :
14 14
 		$oid = $post->ID;
15
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments") );
15
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments"));
16 16
 		endif; ?>
17 17
 	</div>
18 18
 </div>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 ?>
3 5
 <div>
4 6
 	<div>
Please login to merge, or discard this patch.
includes/modules/wps_orders/controller/wps_orders_in_back_office.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_orders_in_back_office {
3 3
 
4 4
 	function __construct() {
5 5
 		// Template loading
6 6
 		$this->template_dir = WPS_ORDERS_PATH . WPS_ORDERS_DIR . "/templates/";
7
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes') );
7
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
8 8
 
9 9
 		// Ajax actions
10
-		add_action('wp_ajax_wpshop_add_private_comment_to_order', array( $this, 'wpshop_add_private_comment_to_order' ) );
11
-		add_action('wp_ajax_wps_order_refresh_product_listing', array( $this, 'refresh_product_list' ) );
12
-		add_action('wp_ajax_wps_add_product_to_order_admin', array( $this, 'wps_add_product_to_order_admin' ) );
13
-		add_action('wp_ajax_wps_refresh_cart_order', array( $this, 'refresh_cart_order' ) );
14
-		add_action('wp_ajax_wps_refresh_payments_order', array( $this, 'refresh_payments_order' ) );
15
-		add_action('wp_ajax_wps_update_product_qty_in_admin', array( $this, 'wps_update_product_qty_in_admin' ) );
16
-		add_action('wp_ajax_wps_order_load_product_variations', array( $this, 'wps_order_load_product_variations' ) );
17
-		add_action('wp_ajax_wps-orders-update-cart-informations', array( $this, 'wps_orders_update_cart_informations' ) );
18
-		add_action('wp_ajax_wps_reverify_payment_invoice_ref', array( $this, 'wps_reverify_payment_invoice_ref' ) );
10
+		add_action('wp_ajax_wpshop_add_private_comment_to_order', array($this, 'wpshop_add_private_comment_to_order'));
11
+		add_action('wp_ajax_wps_order_refresh_product_listing', array($this, 'refresh_product_list'));
12
+		add_action('wp_ajax_wps_add_product_to_order_admin', array($this, 'wps_add_product_to_order_admin'));
13
+		add_action('wp_ajax_wps_refresh_cart_order', array($this, 'refresh_cart_order'));
14
+		add_action('wp_ajax_wps_refresh_payments_order', array($this, 'refresh_payments_order'));
15
+		add_action('wp_ajax_wps_update_product_qty_in_admin', array($this, 'wps_update_product_qty_in_admin'));
16
+		add_action('wp_ajax_wps_order_load_product_variations', array($this, 'wps_order_load_product_variations'));
17
+		add_action('wp_ajax_wps-orders-update-cart-informations', array($this, 'wps_orders_update_cart_informations'));
18
+		add_action('wp_ajax_wps_reverify_payment_invoice_ref', array($this, 'wps_reverify_payment_invoice_ref'));
19 19
 
20 20
 		// WP General actions
21
-		add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts' ) );
22
-		add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts_texts' ), 20 );
23
-		add_action( 'save_post', array( $this, 'save_order_custom_informations' ), 10, 2 );
21
+		add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts'));
22
+		add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts_texts'), 20);
23
+		add_action('save_post', array($this, 'save_order_custom_informations'), 10, 2);
24 24
 
25 25
 		// WP Filters
26 26
 		//add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'wps_notif_user_on_order_saving'), 100, 2 );
@@ -31,52 +31,52 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function wps_orders_scripts() {
33 33
 		global $current_screen;
34
-		if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) )
34
+		if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER), true))
35 35
 			return;
36 36
 
37
-		wp_enqueue_style( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css' );
38
-		wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js' );
37
+		wp_enqueue_style('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css');
38
+		wp_enqueue_script('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js');
39 39
 	}
40 40
 
41 41
 	function wps_orders_scripts_texts() {
42
-		wp_localize_script( 'wps_orders_backend', 'message_confirm_reload', __( 'Are you sure you want to refresh your browser?', 'wpshop' ) );
43
-		wp_localize_script( 'wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __( 'Error detected.', 'wpshop' ) );
42
+		wp_localize_script('wps_orders_backend', 'message_confirm_reload', __('Are you sure you want to refresh your browser?', 'wpshop'));
43
+		wp_localize_script('wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __('Error detected.', 'wpshop'));
44 44
 	}
45 45
 	/**
46 46
 	 * Add meta boxes
47 47
 	 */
48 48
 	function add_meta_boxes() {
49 49
 		global $post;
50
-		$order_meta = get_post_meta( $post->ID, '_order_postmeta', true );
50
+		$order_meta = get_post_meta($post->ID, '_order_postmeta', true);
51 51
 		/** Box  Order Payments **/
52
-		if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) {
53
-			add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> '.__('Order payment', 'wpshop'),array($this, 'display_order_payments_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
52
+		if (!in_array($post->post_status, array('auto-draft'))) {
53
+			add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> ' . __('Order payment', 'wpshop'), array($this, 'display_order_payments_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
54 54
 		}
55 55
 		/**	Box for customer order comment */
56
-		if ( ! empty( $post->post_excerpt ) ) {
57
-			add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> '.__('Order customer comment', 'wpshop'),array( $this, 'order_customer_comment_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
56
+		if (!empty($post->post_excerpt)) {
57
+			add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> ' . __('Order customer comment', 'wpshop'), array($this, 'order_customer_comment_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
58 58
 		}
59 59
 		/** Historic sales **/
60
-		add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array( $this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low');
60
+		add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array($this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low');
61 61
 		/**	Box with the complete order content	*/
62 62
 		$payment_started = false;
63
-		if ( ! empty( $order_meta['order_payment'] ) && ! empty( $order_meta['order_payment']['received'] ) ) {
64
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
65
-				if ( empty( $received['received_amount'] ) ) {
63
+		if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received'])) {
64
+			foreach ($order_meta['order_payment']['received'] as $received) {
65
+				if (empty($received['received_amount'])) {
66 66
 					continue;
67 67
 				}
68 68
 				$payment_started = true;
69 69
 				break;
70 70
 			}
71 71
 		}
72
-		if ( ! $payment_started ) {
73
-			add_meta_box( 'wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __( 'Product List', 'wpshop' ), array( $this, 'wps_products_listing_for_quotation' ), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low' );
72
+		if (!$payment_started) {
73
+			add_meta_box('wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __('Product List', 'wpshop'), array($this, 'wps_products_listing_for_quotation'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
74 74
 		}
75 75
 		/**	Box with the complete order content	*/
76
-		add_meta_box( 'wpshop_order_content', '<span class="dashicons dashicons-cart"></span> '.__('Order content', 'wpshop'), array( $this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
76
+		add_meta_box('wpshop_order_content', '<span class="dashicons dashicons-cart"></span> ' . __('Order content', 'wpshop'), array($this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
77 77
 		/** Box Private order comments **/
78
-		if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) {
79
-			add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> '.__('Comments', 'wpshop'), array( $this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
78
+		if (!in_array($post->post_status, array('auto-draft'))) {
79
+			add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> ' . __('Comments', 'wpshop'), array($this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
80 80
 		}
81 81
 	}
82 82
 
@@ -84,65 +84,65 @@  discard block
 block discarded – undo
84 84
 	 * METABOX CONTENT - Display Customer comments on order in administration panel
85 85
 	 * @param object $order
86 86
 	 */
87
-	function order_customer_comment_box( $order ) {
88
-		if ( ! empty($order) && ! empty($order->ID) ) {
89
-			require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box") );
87
+	function order_customer_comment_box($order) {
88
+		if (!empty($order) && !empty($order->ID)) {
89
+			require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box"));
90 90
 		}
91 91
 	}
92 92
 
93 93
 	/**
94 94
 	 * METABOX CONTENT - Display an order historic of product in administration product panel
95 95
 	 */
96
-	function meta_box_product_sale_informations () {
96
+	function meta_box_product_sale_informations() {
97 97
  		global $post;
98 98
  		$product_id = $post->ID;
99
- 		$variations = wpshop_products::get_variation( $product_id );
100
- 		$order_status = unserialize( WPSHOP_ORDER_STATUS );
101
- 		$color_label = array( 'awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu');
99
+ 		$variations = wpshop_products::get_variation($product_id);
100
+ 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
101
+ 		$color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu');
102 102
  		// Get datas
103 103
  		$sales_informations = array();
104 104
  		/** Query **/
105
- 		$data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";';
106
- 		$query_args = array( 'posts_per_page' => 10, 'paged' => absint( isset( $_GET['paged_sales'] ) ? $_GET['paged_sales'] : 1 ), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) );
107
- 		$orders = new WP_Query( $query_args );
108
- 		if ( ! empty($orders) && ! empty($orders->posts) ) {
109
- 			foreach( $orders->posts as $order ) {
110
- 				$order_meta = get_post_meta( $order->ID, '_order_postmeta', true );
111
- 				$order_info = get_post_meta( $order->ID, '_order_info', true );
105
+ 		$data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";';
106
+ 		$query_args = array('posts_per_page' => 10, 'paged' => absint(isset($_GET['paged_sales']) ? $_GET['paged_sales'] : 1), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE')));
107
+ 		$orders = new WP_Query($query_args);
108
+ 		if (!empty($orders) && !empty($orders->posts)) {
109
+ 			foreach ($orders->posts as $order) {
110
+ 				$order_meta = get_post_meta($order->ID, '_order_postmeta', true);
111
+ 				$order_info = get_post_meta($order->ID, '_order_info', true);
112 112
  				$sales_informations[] = array(
113
- 						'order_key' => ( ! empty($order_meta) && ! empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '',
114
- 						'order_date' => ( ! empty($order_meta) && ! empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '',
115
- 						'customer_firstname' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '',
116
- 						'customer_name' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '',
117
- 						'customer_email' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '',
113
+ 						'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '',
114
+ 						'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '',
115
+ 						'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '',
116
+ 						'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '',
117
+ 						'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : '',
118 118
  						'order_id' => $order->ID,
119 119
  						'order_status' => $order_meta['order_status']
120 120
  				);
121 121
  			}
122 122
  		}
123 123
  		// Display results
124
- 		require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic") );
124
+ 		require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic"));
125 125
  	}
126 126
 
127 127
 	/**
128 128
 	 * METABOX CONTENT - Payments Box in Orders panel
129 129
 	 * @param string $order
130 130
 	 */
131
-	function display_order_payments_box( $order ) {
131
+	function display_order_payments_box($order) {
132 132
 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
133 133
 		$order_postmeta = get_post_meta($order->ID, '_order_postmeta', true);
134
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box") );
134
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box"));
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * METABOX CONTENT - Display an lsiting of products to make quotation in backend
139 139
 	 */
140
-	function wps_products_listing_for_quotation( $post ) {
141
-		$letters = array( 'ALL', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
142
-		$current_letter = sanitize_title( $letters[0] );
140
+	function wps_products_listing_for_quotation($post) {
141
+		$letters = array('ALL', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
142
+		$current_letter = sanitize_title($letters[0]);
143 143
 		$wps_product_mdl = new wps_product_mdl();
144
-		$products = $wps_product_mdl->get_products_by_letter( $current_letter );
145
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing") );
144
+		$products = $wps_product_mdl->get_products_by_letter($current_letter);
145
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing"));
146 146
 	}
147 147
 
148 148
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	function meta_box_private_comment() {
152 152
 		global $post;
153
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments") );
153
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments"));
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	function meta_box_order_content() {
160 160
 		global $post_id;
161
-		unset( $_SESSION['cart'] );
162
-		echo do_shortcode( '[wps_cart oid="' .$post_id. '" cart_type="admin-panel"]');
161
+		unset($_SESSION['cart']);
162
+		echo do_shortcode('[wps_cart oid="' . $post_id . '" cart_type="admin-panel"]');
163 163
 	}
164 164
 
165 165
 
@@ -171,72 +171,72 @@  discard block
 block discarded – undo
171 171
 	 * @param integer $post_id The current saved post id / L'identifiant post qui vient d'être sauvegardé.
172 172
 	 * @param WP_Post $post The entire post currently saved / Le post qui vient d'être sauvegardé.
173 173
 	 */
174
-	public function save_order_custom_informations( $post_id, $post ) {
175
-		if ( ( WPSHOP_NEWTYPE_IDENTIFIER_ORDER !== $post->post_type ) || ( 'auto-draft' === $post->post_status ) || wp_is_post_revision( $post_id ) ) {
174
+	public function save_order_custom_informations($post_id, $post) {
175
+		if ((WPSHOP_NEWTYPE_IDENTIFIER_ORDER !== $post->post_type) || ('auto-draft' === $post->post_status) || wp_is_post_revision($post_id)) {
176 176
 			return;
177 177
 		}
178 178
 
179 179
 		$user_id = get_current_user_id();
180
-		$customer_id = ( ! empty( $_REQUEST['wps_customer_id'] ) ) ? (int) $_REQUEST['wps_customer_id'] : wps_customer_ctr::get_customer_id_by_author_id( $user_id );
180
+		$customer_id = (!empty($_REQUEST['wps_customer_id'])) ? (int)$_REQUEST['wps_customer_id'] : wps_customer_ctr::get_customer_id_by_author_id($user_id);
181 181
 
182 182
 		// Récupération des informations actuelles de la commande / Get order's current information.
183
-		$order_meta = get_post_meta( $post_id, '_order_postmeta', true );
183
+		$order_meta = get_post_meta($post_id, '_order_postmeta', true);
184 184
 
185 185
 		// Affectation du client de la commande / Affect customer to order.
186
-		remove_action( 'save_post', array( $this, 'save_order_custom_informations' ) );
187
-		wp_update_post( array( 'ID' => $post_id, 'post_parent' => $customer_id ) );
188
-		if ( empty( $order_meta['customer_id'] ) ) {
189
-			update_post_meta( $post_id, '_wpshop_order_customer_id', $user_id );
186
+		remove_action('save_post', array($this, 'save_order_custom_informations'));
187
+		wp_update_post(array('ID' => $post_id, 'post_parent' => $customer_id));
188
+		if (empty($order_meta['customer_id'])) {
189
+			update_post_meta($post_id, '_wpshop_order_customer_id', $user_id);
190 190
 			$order_meta['customer_id'] = $user_id;
191 191
 		}
192 192
 
193
-		if ( empty( $order_meta['order_key'] ) ) {
194
-			$order_meta['order_key'] = ! empty( $order_meta['order_key'] ) ? $order_meta['order_key'] : ( ! empty( $order_meta['order_status'] ) && ( $order_meta['order_status'] != 'awaiting_payment' ) ? wpshop_orders::get_new_order_reference() : '');
195
-			$order_meta['order_temporary_key'] = ( isset( $order_meta['order_temporary_key'] ) && ( $order_meta['order_temporary_key'] != '') ) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference();
193
+		if (empty($order_meta['order_key'])) {
194
+			$order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status'] != 'awaiting_payment') ? wpshop_orders::get_new_order_reference() : '');
195
+			$order_meta['order_temporary_key'] = (isset($order_meta['order_temporary_key']) && ($order_meta['order_temporary_key'] != '')) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference();
196 196
 		}
197 197
 		$order_meta['order_status'] = (isset($order_meta['order_status']) && ($order_meta['order_status'] != '')) ? $order_meta['order_status'] : 'awaiting_payment';
198 198
 		$order_meta['order_date'] = (isset($order_meta['order_date']) && ($order_meta['order_date'] != '')) ? $order_meta['order_date'] : current_time('mysql', 0);
199
-		$order_meta['order_currency'] = wpshop_tools::wpshop_get_currency( true );
199
+		$order_meta['order_currency'] = wpshop_tools::wpshop_get_currency(true);
200 200
 
201
-		$billing_adress_id = ( ! empty( $_REQUEST['wps_order_selected_address'] ) && ! empty( $_REQUEST['wps_order_selected_address']['billing'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['billing'] : 0;
201
+		$billing_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['billing'])) ? (int)$_REQUEST['wps_order_selected_address']['billing'] : 0;
202 202
 
203
-		if ( ! empty( $billing_adress_id ) ) {
204
-			$order_informations = get_post_meta( $post_id, '_order_info', true );
205
-			$order_informations = ( ! empty( $order_informations ) ) ? $order_informations : array();
206
-			$billing_address_option = get_option( 'wpshop_billing_address' );
207
-			$billing_address_option = ( ! empty( $billing_address_option ) && ! empty( $billing_address_option['choice'] ) ) ? $billing_address_option['choice'] : '';
203
+		if (!empty($billing_adress_id)) {
204
+			$order_informations = get_post_meta($post_id, '_order_info', true);
205
+			$order_informations = (!empty($order_informations)) ? $order_informations : array();
206
+			$billing_address_option = get_option('wpshop_billing_address');
207
+			$billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : '';
208 208
 
209 209
 			// Billing datas
210
-			$order_informations['billing'] = array( 'id' => $billing_address_option,
210
+			$order_informations['billing'] = array('id' => $billing_address_option,
211 211
 				'address_id' => $billing_adress_id,
212
-				'address' => get_post_meta( $billing_adress_id, '_wpshop_address_metadata', true )
212
+				'address' => get_post_meta($billing_adress_id, '_wpshop_address_metadata', true)
213 213
 			);
214 214
 			// Shipping datas
215
-			$shipping_adress_id = ( ! empty( $_REQUEST['wps_order_selected_address'] ) && ! empty( $_REQUEST['wps_order_selected_address']['shipping'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['shipping'] : 0;
215
+			$shipping_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['shipping'])) ? (int)$_REQUEST['wps_order_selected_address']['shipping'] : 0;
216 216
 
217
-			if( ! empty( $shipping_adress_id ) ) {
218
-				$shipping_address_option = get_option( 'wpshop_shipping_address_choice' );
219
-				$shipping_address_option = ( ! empty($shipping_address_option) && ! empty($shipping_address_option['choice']) ) ? $shipping_address_option['choice'] : '';
220
-				$order_informations['shipping'] = array( 'id' => $shipping_address_option,
217
+			if (!empty($shipping_adress_id)) {
218
+				$shipping_address_option = get_option('wpshop_shipping_address_choice');
219
+				$shipping_address_option = (!empty($shipping_address_option) && !empty($shipping_address_option['choice'])) ? $shipping_address_option['choice'] : '';
220
+				$order_informations['shipping'] = array('id' => $shipping_address_option,
221 221
 					'address_id' => $shipping_adress_id,
222
-					'address' => get_post_meta( $shipping_adress_id, '_wpshop_address_metadata', true )
222
+					'address' => get_post_meta($shipping_adress_id, '_wpshop_address_metadata', true)
223 223
 				);
224 224
 			}
225
-			update_post_meta( $post_id, '_order_info', $order_informations );
225
+			update_post_meta($post_id, '_order_info', $order_informations);
226 226
 		}
227 227
 
228
-		$wpshop_admin_order_payment_received = ! empty( $_REQUEST['wpshop_admin_order_payment_received'] ) ? (array) $_REQUEST['wpshop_admin_order_payment_received'] : array();
229
-		$wpshop_admin_order_payment_received['method'] = ! empty( $wpshop_admin_order_payment_received['method'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['method'] ) : '';
230
-		$wpshop_admin_order_payment_received['payment_reference'] = ! empty( $wpshop_admin_order_payment_received['payment_reference'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['payment_reference'] ) : '';
231
-		$wpshop_admin_order_payment_received['date'] = ! empty( $wpshop_admin_order_payment_received['date'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['date'] ) : '';
232
-		$wpshop_admin_order_payment_received['received_amount'] = ! empty( $wpshop_admin_order_payment_received['received_amount'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['received_amount'] ) : '';
233
-		$action_triggered_from = ! empty( $_REQUEST['action_triggered_from'] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : '';
234
-		$wshop_admin_order_payment_reference = ! empty( $_REQUEST['wpshop_admin_order_payment_reference'] ) ? sanitize_text_field( $_REQUEST['wpshop_admin_order_payment_reference'] ) : '';
228
+		$wpshop_admin_order_payment_received = !empty($_REQUEST['wpshop_admin_order_payment_received']) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array();
229
+		$wpshop_admin_order_payment_received['method'] = !empty($wpshop_admin_order_payment_received['method']) ? sanitize_text_field($wpshop_admin_order_payment_received['method']) : '';
230
+		$wpshop_admin_order_payment_received['payment_reference'] = !empty($wpshop_admin_order_payment_received['payment_reference']) ? sanitize_text_field($wpshop_admin_order_payment_received['payment_reference']) : '';
231
+		$wpshop_admin_order_payment_received['date'] = !empty($wpshop_admin_order_payment_received['date']) ? sanitize_text_field($wpshop_admin_order_payment_received['date']) : '';
232
+		$wpshop_admin_order_payment_received['received_amount'] = !empty($wpshop_admin_order_payment_received['received_amount']) ? sanitize_text_field($wpshop_admin_order_payment_received['received_amount']) : '';
233
+		$action_triggered_from = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : '';
234
+		$wshop_admin_order_payment_reference = !empty($_REQUEST['wpshop_admin_order_payment_reference']) ? sanitize_text_field($_REQUEST['wpshop_admin_order_payment_reference']) : '';
235 235
 
236 236
 		// Ajout des informations de paiements / Add payment informations.
237
-		if ( ! empty( $wpshop_admin_order_payment_received ) && ! empty( $wpshop_admin_order_payment_received['method'] )
238
-				&& ! empty( $wpshop_admin_order_payment_received['date'] ) && ! empty( $wpshop_admin_order_payment_received['received_amount'] ) &&
239
-				( ( 'add_payment' == $action_triggered_from ) || ! empty( $wshop_admin_order_payment_reference ) ) ) {
237
+		if (!empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method'])
238
+				&& !empty($wpshop_admin_order_payment_received['date']) && !empty($wpshop_admin_order_payment_received['received_amount']) &&
239
+				(('add_payment' == $action_triggered_from) || !empty($wshop_admin_order_payment_reference))) {
240 240
 
241 241
 			$received_payment_amount = $wpshop_admin_order_payment_received['received_amount'];
242 242
 
@@ -247,40 +247,40 @@  discard block
 block discarded – undo
247 247
 				'status' 						=> 'payment_received',
248 248
 				'author' 						=> $user_id,
249 249
 				'payment_reference' => $wpshop_admin_order_payment_received['payment_reference'],
250
-				'date' 							=> current_time( 'mysql', 0 ),
250
+				'date' 							=> current_time('mysql', 0),
251 251
 				'received_amount' 	=> $received_payment_amount,
252 252
 			);
253
-			$order_meta = wpshop_payment::check_order_payment_total_amount( $post_id, $params_array, 'completed', $order_meta, false );
253
+			$order_meta = wpshop_payment::check_order_payment_total_amount($post_id, $params_array, 'completed', $order_meta, false);
254 254
 		}
255 255
 
256 256
 		//Round final amount
257
-		$order_meta['order_grand_total'] = number_format( round($order_meta['order_grand_total'], 2), 2, '.', '');
258
-		$order_meta['order_total_ttc'] = number_format( round($order_meta['order_total_ttc'], 2), 2, '.', '');
259
-		$order_meta['order_amount_to_pay_now'] = number_format( round($order_meta['order_amount_to_pay_now'], 2), 2, '.', '');
257
+		$order_meta['order_grand_total'] = number_format(round($order_meta['order_grand_total'], 2), 2, '.', '');
258
+		$order_meta['order_total_ttc'] = number_format(round($order_meta['order_total_ttc'], 2), 2, '.', '');
259
+		$order_meta['order_amount_to_pay_now'] = number_format(round($order_meta['order_amount_to_pay_now'], 2), 2, '.', '');
260 260
 
261 261
 		// Payment Pre-Fill
262
-		if ( empty( $order_meta['order_payment'] ) ) {
262
+		if (empty($order_meta['order_payment'])) {
263 263
 			$order_meta['order_payment']['customer_choice']['method'] = '';
264
-			$order_meta['order_payment']['received'][] = array('waited_amount' => ( ! empty($order_meta) && ! empty($order_meta['order_grand_total']) ) ? number_format($order_meta['order_grand_total'],2,'.', '') : 0 );
264
+			$order_meta['order_payment']['received'][] = array('waited_amount' => (!empty($order_meta) && !empty($order_meta['order_grand_total'])) ? number_format($order_meta['order_grand_total'], 2, '.', '') : 0);
265 265
 		}
266 266
 
267
-		$data['post_ID'] = ! empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0;
268
-		$data['markascanceled_order_hidden_indicator'] = ! empty( $_REQUEST['markascanceled_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['markascanceled_order_hidden_indicator'] ) : '';
269
-		$data['resendordertocustomer_order_hidden_indicator'] = ! empty( $_REQUEST['resendordertocustomer_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['resendordertocustomer_order_hidden_indicator'] ) : '';
270
-		$data['action_triggered_from'] = ! empty( $_REQUEST['action_triggered_from' ] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : '';
271
-		$data['notif_the_customer'] = ! empty( $_REQUEST['notif_the_customer' ] ) ? sanitize_text_field( $_REQUEST['notif_the_customer'] ) : '';
267
+		$data['post_ID'] = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0;
268
+		$data['markascanceled_order_hidden_indicator'] = !empty($_REQUEST['markascanceled_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['markascanceled_order_hidden_indicator']) : '';
269
+		$data['resendordertocustomer_order_hidden_indicator'] = !empty($_REQUEST['resendordertocustomer_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['resendordertocustomer_order_hidden_indicator']) : '';
270
+		$data['action_triggered_from'] = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : '';
271
+		$data['notif_the_customer'] = !empty($_REQUEST['notif_the_customer']) ? sanitize_text_field($_REQUEST['notif_the_customer']) : '';
272 272
 
273 273
 		// Apply a filter to make credit, notificate the customer and generate billing actions
274
-		$order_meta = apply_filters( 'wps_order_saving_admin_extra_action', $order_meta, $data );
274
+		$order_meta = apply_filters('wps_order_saving_admin_extra_action', $order_meta, $data);
275 275
 
276 276
 		// Save Shipping informations & Order status.
277
-		if ( isset( $order_meta['order_shipping_date'] ) ) {
278
-			update_post_meta( $post_id, '_wpshop_order_shipping_date', $order_meta['order_shipping_date'] );
277
+		if (isset($order_meta['order_shipping_date'])) {
278
+			update_post_meta($post_id, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']);
279 279
 		}
280
-		update_post_meta( $post_id, '_wpshop_order_status', $order_meta['order_status'] );
280
+		update_post_meta($post_id, '_wpshop_order_status', $order_meta['order_status']);
281 281
 
282 282
 		// Save Metadata
283
-		update_post_meta( $post_id, '_order_postmeta', $order_meta );
283
+		update_post_meta($post_id, '_order_postmeta', $order_meta);
284 284
 	}
285 285
 
286 286
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param array $posted_datas
291 291
 	 * @return array
292 292
 	 */
293
-	function wps_notif_user_on_order_saving( $order_metadata, $posted_datas ) {
294
-		if( ! empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer']=='on' ) {
293
+	function wps_notif_user_on_order_saving($order_metadata, $posted_datas) {
294
+		if (!empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer'] == 'on') {
295 295
 			$wps_message = new wps_message_ctr();
296 296
 			/*	Get order current content	*/
297 297
 			$user = get_post_meta($posted_datas['post_ID'], '_order_info', true);
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
 			$first_name = $user['billing']['address']['address_first_name'];
301 301
 			$last_name = $user['billing']['address']['address_last_name'];
302 302
 
303
-			$object = array('object_type'=>'order','object_id'=>(int)$_REQUEST['post_ID']);
303
+			$object = array('object_type'=>'order', 'object_id'=>(int)$_REQUEST['post_ID']);
304 304
 			/* Envoie du message de confirmation de commande au client	*/
305
-			if ( empty( $order_metadata['order_key'] ) ) {
305
+			if (empty($order_metadata['order_key'])) {
306 306
 				$wps_message->wpshop_prepared_email($email,
307 307
 						'WPSHOP_QUOTATION_UPDATE_MESSAGE',
308
-						array(  'order_id' => $object['object_id'],
308
+						array('order_id' => $object['object_id'],
309 309
 							    'customer_first_name' => $first_name,
310 310
 								'customer_last_name' => $last_name,
311 311
 								'order_date' => current_time('mysql', 0),
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				$wps_message->wpshop_prepared_email(
321 321
 						$email,
322 322
 						'WPSHOP_ORDER_UPDATE_MESSAGE',
323
-						array(  'customer_first_name' => $first_name,
323
+						array('customer_first_name' => $first_name,
324 324
 								'customer_last_name' => $last_name,
325 325
 								'order_key' => $order_metadata['order_key'],
326 326
 								'order_billing_address' => '',
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 								'order_addresses' => '',
329 329
 								'order_addresses' => '',
330 330
 								'order_billing_address' => '',
331
-								'order_shipping_address' => '' ),
331
+								'order_shipping_address' => ''),
332 332
 						$object);
333 333
 			}
334 334
 		}
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
 	 * AJAX - Add a private comment to order
340 340
 	 */
341 341
 	function wpshop_add_private_comment_to_order() {
342
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
342
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
343 343
 
344
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) )
344
+		if (!wp_verify_nonce($_wpnonce, 'wpshop_add_private_comment_to_order'))
345 345
 			wp_die();
346 346
 
347 347
 		$status = false; $result = '';
348
-		$order_id = ( ! empty($_POST['oid']) ) ? intval($_POST['oid']) : null;
349
-		$comment = ( ! empty($_POST['comment']) ) ? wpshop_tools::varSanitizer($_POST['comment']) : null;
350
-		$send_email = ( ! empty($_POST['send_email']) ) ? wpshop_tools::varSanitizer($_POST['send_email']) : null;
351
-		$copy_to_administrator = ( ! empty($_POST['copy_to_administrator']) ) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null;
348
+		$order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null;
349
+		$comment = (!empty($_POST['comment'])) ? wpshop_tools::varSanitizer($_POST['comment']) : null;
350
+		$send_email = (!empty($_POST['send_email'])) ? wpshop_tools::varSanitizer($_POST['send_email']) : null;
351
+		$copy_to_administrator = (!empty($_POST['copy_to_administrator'])) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null;
352 352
 
353
-		if ( ! empty($comment) && ! empty($order_id) ) {
353
+		if (!empty($comment) && !empty($order_id)) {
354 354
 			$wps_back_office_orders_mdl = new wps_back_office_orders_mdl();
355
-			$new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator );
356
-			if($new_comment) {
357
-				$order_private_comment = get_post_meta( $order_id, '_order_private_comments', true );
355
+			$new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator);
356
+			if ($new_comment) {
357
+				$order_private_comment = get_post_meta($order_id, '_order_private_comments', true);
358 358
 				$oid = $order_id;
359 359
 				ob_start();
360
-				require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments") );
360
+				require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments"));
361 361
 				$result = ob_get_contents();
362 362
 				ob_end_clean();
363 363
 				$status = true;
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 			$result = __('An error was occured', 'wpshop');
368 368
 		}
369 369
 
370
-		$response = array( 'status' => $status, 'response' => $result );
371
-		echo json_encode( $response );
370
+		$response = array('status' => $status, 'response' => $result);
371
+		echo json_encode($response);
372 372
 		wp_die();
373 373
 	}
374 374
 
@@ -376,34 +376,34 @@  discard block
 block discarded – undo
376 376
 	 * AJAX - Refresh product listing in order back-office
377 377
 	 */
378 378
 	function refresh_product_list() {
379
-		$_wpnonce = ! empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
380
-		$letter = ( ! empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : '';
381
-		$research = ! empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : '';
379
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
380
+		$letter = (!empty($_POST['letter'])) ? sanitize_title($_POST['letter']) : '';
381
+		$research = !empty($_POST['research']) ? sanitize_text_field($_POST['research']) : '';
382 382
 
383
-		if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) )
383
+		if (!wp_verify_nonce($_wpnonce, 'refresh_product_list_' . strtolower($letter)))
384 384
 			wp_die();
385 385
 
386 386
 		$status = false; $response = '';
387
-		$oid = ! empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0;
387
+		$oid = !empty($_POST['oid']) ? (int)$_POST['oid'] : 0;
388 388
 
389
-		if( ! empty($oid) ) {
390
-			$post = get_post( $oid );
389
+		if (!empty($oid)) {
390
+			$post = get_post($oid);
391 391
 		}
392
-		if( ! empty($letter) ) {
392
+		if (!empty($letter)) {
393 393
 			$current_letter = $letter;
394 394
 			$wps_product_mdl = new wps_product_mdl();
395
-			if( ! empty( $research ) ) {
396
-				$products = $wps_product_mdl->get_products_by_title_or_barcode( $research, strlen( $research ) >= 8 && ctype_digit( $research ) );
395
+			if (!empty($research)) {
396
+				$products = $wps_product_mdl->get_products_by_title_or_barcode($research, strlen($research) >= 8 && ctype_digit($research));
397 397
 			} else {
398
-				$products = $wps_product_mdl->get_products_by_letter( $letter );
398
+				$products = $wps_product_mdl->get_products_by_letter($letter);
399 399
 			}
400 400
 			ob_start();
401
-			require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table") );
401
+			require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table"));
402 402
 			$response = ob_get_contents();
403 403
 			ob_end_clean();
404 404
 			$status = true;
405 405
 		}
406
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
406
+		echo json_encode(array('status' => $status, 'response' => $response));
407 407
 		wp_die();
408 408
 	}
409 409
 
@@ -411,38 +411,38 @@  discard block
 block discarded – undo
411 411
 	 * AJAX - Add product to order in back-office panel
412 412
 	 */
413 413
 	function wps_add_product_to_order_admin() {
414
-		check_ajax_referer( 'wps_add_product_to_order_admin' );
414
+		check_ajax_referer('wps_add_product_to_order_admin');
415 415
 
416 416
 		$status = false; $response = ''; $product_have_variations = false;
417 417
 		// Sended vars
418
-		$product_id = ( ! empty($_POST['pid']) ) ? intval( $_POST['pid']) : null;
419
-		$order_id = ( ! empty($_POST['oid']) ) ? intval( $_POST['oid']) : null;
420
-		$product_qty = ( ! empty($_POST['qty']) ) ? intval( $_POST['qty']) : 1;
418
+		$product_id = (!empty($_POST['pid'])) ? intval($_POST['pid']) : null;
419
+		$order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null;
420
+		$product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 1;
421 421
 
422
-		if( ! empty($order_id) && ! empty($product_id) ) {
422
+		if (!empty($order_id) && !empty($product_id)) {
423 423
 			$wps_orders = new wps_orders_ctr();
424 424
 			$product_datas = wpshop_products::get_product_data($product_id, false, '"publish", "free_product"');
425 425
 			// Check if product have variations
426
-			$have_variations_checking = wpshop_products::get_variation( $product_id );
427
-			if( ! empty($have_variations_checking) ) {
426
+			$have_variations_checking = wpshop_products::get_variation($product_id);
427
+			if (!empty($have_variations_checking)) {
428 428
 				$product_have_variations = true;
429 429
 			}
430 430
 			else {
431 431
 				// Get Metadatas
432
-				$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
432
+				$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
433 433
 				// Calcul cart informations
434 434
 				$wps_cart = new wps_cart();
435
-				$order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false );
435
+				$order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false);
436 436
 				// Update Metadatas
437
-				update_post_meta( $order_id, '_order_postmeta', $order_metadata );
437
+				update_post_meta($order_id, '_order_postmeta', $order_metadata);
438 438
 				$status = true;
439 439
 			}
440 440
 			$status = true;
441 441
 		}
442 442
 
443
-		$_wpnonce = wp_create_nonce( 'wps_order_load_product_variations' );
443
+		$_wpnonce = wp_create_nonce('wps_order_load_product_variations');
444 444
 
445
-		echo json_encode( array( '_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations ) );
445
+		echo json_encode(array('_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations));
446 446
 		wp_die();
447 447
 	}
448 448
 
@@ -450,15 +450,15 @@  discard block
 block discarded – undo
450 450
 	 * AJAX - Refresh cart in administration
451 451
 	 */
452 452
 	function refresh_cart_order() {
453
-		check_ajax_referer( 'wps_reload_cart' );
453
+		check_ajax_referer('wps_reload_cart');
454 454
 
455 455
 		$status = false; $response = '';
456
-		$order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null;
457
-		if( ! empty($order_id) ) {
458
-			$response = do_shortcode( '[wps_cart oid="' .$order_id. '" cart_type="admin-panel"]');
456
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
457
+		if (!empty($order_id)) {
458
+			$response = do_shortcode('[wps_cart oid="' . $order_id . '" cart_type="admin-panel"]');
459 459
 			$status = true;
460 460
 		}
461
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
461
+		echo json_encode(array('status' => $status, 'response' => $response));
462 462
 		wp_die();
463 463
 	}
464 464
 
@@ -466,17 +466,17 @@  discard block
 block discarded – undo
466 466
 	 * AJAX - Refresh cart in administration
467 467
 	 */
468 468
 	function refresh_payments_order() {
469
-		check_ajax_referer( 'wps_reload_cart' );
469
+		check_ajax_referer('wps_reload_cart');
470 470
 		$status = false; $response = '';
471
-		$order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null;
472
-		if( ! empty($order_id) ) {
471
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
472
+		if (!empty($order_id)) {
473 473
 			ob_start();
474
-			echo $this->display_order_payments_box( get_post( $order_id ) );
474
+			echo $this->display_order_payments_box(get_post($order_id));
475 475
 			$response = ob_get_contents();
476 476
 			ob_end_clean();
477 477
 			$status = true;
478 478
 		}
479
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
479
+		echo json_encode(array('status' => $status, 'response' => $response));
480 480
 		wp_die();
481 481
 	}
482 482
 
@@ -484,25 +484,25 @@  discard block
 block discarded – undo
484 484
 	 * AJAX - Update product Quantity in Back-office Panel
485 485
 	 */
486 486
 	function wps_update_product_qty_in_admin() {
487
-		check_ajax_referer( 'wps_reload_cart' );
487
+		check_ajax_referer('wps_reload_cart');
488 488
 
489 489
 		$status = false; $response = '';
490
-		$product_id = ( ! empty($_POST['product_id']) ) ? wpshop_tools::varSanitizer( $_POST['product_id'] ) : null;
491
-		$order_id = ( ! empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
492
-		$product_qty = ( ! empty($_POST['qty']) ) ? intval( $_POST['qty'] ) : 0;
490
+		$product_id = (!empty($_POST['product_id'])) ? wpshop_tools::varSanitizer($_POST['product_id']) : null;
491
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
492
+		$product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 0;
493 493
 
494
-		if( ! empty($product_id) && ! empty($order_id) ) {
494
+		if (!empty($product_id) && !empty($order_id)) {
495 495
 			// Get Metadatas
496
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
496
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
497 497
 			// Calcul cart informations
498 498
 			$wps_cart = new wps_cart();
499
-			$order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false );
499
+			$order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false);
500 500
 			// Update Metadatas
501
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
501
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
502 502
 			$status = true;
503 503
 		}
504 504
 
505
-		echo json_encode( array( 'status' => $status ) );
505
+		echo json_encode(array('status' => $status));
506 506
 		wp_die();
507 507
 	}
508 508
 
@@ -510,15 +510,15 @@  discard block
 block discarded – undo
510 510
 	 * AJAX - Load Product Variations in ThickBox on Add product to order action
511 511
 	 */
512 512
 	function wps_order_load_product_variations() {
513
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
513
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
514 514
 
515
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) )
515
+		if (!wp_verify_nonce($_wpnonce, 'wps_order_load_product_variations'))
516 516
 			wp_die();
517 517
 
518
-		$product_id = ( ! empty($_GET['pid']) ) ? intval( $_GET['pid']) : null;
519
-		$order_id = ( ! empty($_GET['oid']) ) ? intval( $_GET['oid']) : null;
520
-		$qty = ( ! empty($_GET['qty']) ) ? intval( $_GET['qty']) : 1;
521
-		echo '<div class="wps-boxed"><span class="wps-h5">'.__( 'Select your variations', 'wpshop' ).'</span>'.wpshop_products::wpshop_variation($product_id, true, $order_id, $qty ).'<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' .__( 'Add to cart', 'wpshop' ). '</a>'.'</div>';
518
+		$product_id = (!empty($_GET['pid'])) ? intval($_GET['pid']) : null;
519
+		$order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null;
520
+		$qty = (!empty($_GET['qty'])) ? intval($_GET['qty']) : 1;
521
+		echo '<div class="wps-boxed"><span class="wps-h5">' . __('Select your variations', 'wpshop') . '</span>' . wpshop_products::wpshop_variation($product_id, true, $order_id, $qty) . '<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' . __('Add to cart', 'wpshop') . '</a>' . '</div>';
522 522
 		wp_die();
523 523
 	}
524 524
 
@@ -526,67 +526,67 @@  discard block
 block discarded – undo
526 526
 	 * AJAX - Update cart informations
527 527
 	 */
528 528
 	function wps_orders_update_cart_informations() {
529
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
529
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
530 530
 
531
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) )
531
+		if (!wp_verify_nonce($_wpnonce, 'wps_orders_update_cart_informations'))
532 532
 			wp_die();
533 533
 
534 534
 		$status = false;
535
-		$order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : '';
535
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : '';
536 536
 		$shipping_cost = isset($_POST['shipping_cost']) ? wpshop_tools::varSanitizer($_POST['shipping_cost']) : '';
537 537
 		$discount_value = isset($_POST['discount_amount']) ? wpshop_tools::varSanitizer($_POST['discount_amount']) : '';
538 538
 		$discount_type = isset($_POST['discount_type']) ? wpshop_tools::varSanitizer($_POST['discount_type']) : '';
539 539
 
540 540
 
541
-		if( ! empty($order_id) ) {
542
-			$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
541
+		if (!empty($order_id)) {
542
+			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
543 543
 			$order_meta['order_shipping_cost'] = $shipping_cost;
544 544
 
545 545
 			//Add discounts if exists
546
-			if( isset($discount_value) && ! empty($discount_type) ) {
546
+			if (isset($discount_value) && !empty($discount_type)) {
547 547
 				$order_meta['order_discount_type'] = $discount_type;
548 548
 				$order_meta['order_discount_value'] = $discount_value;
549 549
 			}
550 550
 			$wps_cart = new wps_cart();
551
-			$order_meta = $wps_cart->calcul_cart_information( array(), '', $order_meta, true );
552
-			update_post_meta( $order_id, '_order_postmeta', $order_meta );
551
+			$order_meta = $wps_cart->calcul_cart_information(array(), '', $order_meta, true);
552
+			update_post_meta($order_id, '_order_postmeta', $order_meta);
553 553
 			$status = true;
554 554
 		}
555 555
 
556
-		echo json_encode( array( 'status' => $status) );
556
+		echo json_encode(array('status' => $status));
557 557
 		wp_die();
558 558
 	}
559 559
 
560 560
 	function wps_reverify_payment_invoice_ref() {
561
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
561
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
562 562
 
563
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) )
563
+		if (!wp_verify_nonce($_wpnonce, 'wps_reverify_payment_invoice_ref'))
564 564
 			wp_die();
565 565
 
566 566
 		$status = true;
567
-		$inputs = ! empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false;
567
+		$inputs = !empty($_POST['inputs']) ? (array)$_POST['inputs'] : false;
568 568
 
569 569
 		if (!$inputs)
570 570
 			$status = false;
571 571
 
572
-		if( $status ) {
572
+		if ($status) {
573 573
 			$inputs_clone = $inputs;
574 574
 			$inputs = array();
575
-			foreach( $inputs_clone as $var ) {
576
-				if( isset( $var['key'] ) && isset( $var['value'] ) ) {
575
+			foreach ($inputs_clone as $var) {
576
+				if (isset($var['key']) && isset($var['value'])) {
577 577
 					$inputs[$var['key']] = $var['value'];
578 578
 				}
579 579
 			}
580 580
 
581
-			( isset( $inputs['order_id'] ) ) ? $order_id = $inputs['order_id'] : $status = $order_id = false;
582
-			( isset( $inputs['index_payment'] ) ) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false;
581
+			(isset($inputs['order_id'])) ? $order_id = $inputs['order_id'] : $status = $order_id = false;
582
+			(isset($inputs['index_payment'])) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false;
583 583
 		}
584 584
 
585
-		if( $status ) {
586
-			$status = wpshop_payment::reverify_payment_invoice_ref( $order_id, $index_payment );
585
+		if ($status) {
586
+			$status = wpshop_payment::reverify_payment_invoice_ref($order_id, $index_payment);
587 587
 		}
588 588
 
589
-		echo json_encode( array( 'status' => $status ) );
589
+		echo json_encode(array('status' => $status));
590 590
 		wp_die();
591 591
 	}
592 592
 
Please login to merge, or discard this patch.
modules/wps_shipping/templates/backend/order-shipping-informations.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <ul id="wps-order-shipping-informations">
2
-	<li><strong><?php _e('Order shipping date','wpshop') ?> :</strong><?php echo ( empty($order_postmeta['order_shipping_date']) ? __('Unknow','wpshop') : mysql2date('d F Y H:i:s', $order_postmeta['order_shipping_date'],true) ); ?></li>
3
-	<li><strong><?php _e('Tracking number','wpshop'); ?> :</strong> <?php echo ( !empty($order_postmeta['order_trackingNumber']) ) ? $order_postmeta['order_trackingNumber'] : __('Unknow','wpshop'); ?></li>
4
-	<li><strong><?php _e('Tracking link','wpshop'); ?> :</strong> <?php echo ( !empty($order_postmeta['order_trackingLink']) ) ? $order_postmeta['order_trackingLink'] : __('Unknow','wpshop'); ?></li>
2
+	<li><strong><?php _e('Order shipping date', 'wpshop') ?> :</strong><?php echo (empty($order_postmeta['order_shipping_date']) ? __('Unknow', 'wpshop') : mysql2date('d F Y H:i:s', $order_postmeta['order_shipping_date'], true)); ?></li>
3
+	<li><strong><?php _e('Tracking number', 'wpshop'); ?> :</strong> <?php echo (!empty($order_postmeta['order_trackingNumber'])) ? $order_postmeta['order_trackingNumber'] : __('Unknow', 'wpshop'); ?></li>
4
+	<li><strong><?php _e('Tracking link', 'wpshop'); ?> :</strong> <?php echo (!empty($order_postmeta['order_trackingLink'])) ? $order_postmeta['order_trackingLink'] : __('Unknow', 'wpshop'); ?></li>
5 5
 </ul>
Please login to merge, or discard this patch.
includes/modules/wps_shipping/templates/backend/order-shipping-infos.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- if( !empty($shipping_method_name) ) : ?>
3
-	<div class="wps-alert-info"><strong><?php _e( 'Selected shipping method', 'wpshop'); ?></strong> : <?php echo $shipping_method_name; ?></div>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ if (!empty($shipping_method_name)) : ?>
3
+	<div class="wps-alert-info"><strong><?php _e('Selected shipping method', 'wpshop'); ?></strong> : <?php echo $shipping_method_name; ?></div>
4 4
 <?php else : ?>
5
-	<div class="wps-alert-info"><?php _e( 'No selected shipping method', 'wpshop'); ?></div>
5
+	<div class="wps-alert-info"><?php _e('No selected shipping method', 'wpshop'); ?></div>
6 6
 <?php endif; ?>
7 7
 
8 8
 <div class="wps-boxed">
9
-	<span class="wps-h5"><?php _e( 'Shipping informations', 'wpshop');?></span>
10
-	<?php if ( !empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'shipped' ) : ?>
9
+	<span class="wps-h5"><?php _e('Shipping informations', 'wpshop'); ?></span>
10
+	<?php if (!empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'shipped') : ?>
11 11
 			<div><a data-id="<?php echo $order->ID; ?>" class="wps-bton-first-mini-rounded markAsShipped order_<?php echo $order->ID; ?>" data-nonce="<?php echo wp_create_nonce("wpshop_dialog_inform_shipping_number"); ?>"><?php _e('Mark as shipped', 'wpshop'); ?></a></div>
12 12
 	<?php else : ?>
13 13
 		<div>
14
-			<?php require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, 'backend', 'order-shipping-informations' ) ); ?>
14
+			<?php require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, 'backend', 'order-shipping-informations')); ?>
15 15
 		</div>
16 16
 <?php endif; ?>
17 17
 
18
-<?php if ( !empty($order_postmeta['order_invoice_ref']) ) : ?>
19
-	<div><a href="<?php echo admin_url( 'admin-post.php?action=wps_invoice&order_id='.$order->ID.'&invoice_ref='.$order_postmeta['order_invoice_ref'].'&bon_colisage=ok&mode=pdf' ); ?>" target="_blank" class="wps-bton-second-mini-rounded" ><?php _e('Download the product list', 'wpshop'); ?></a></div>
18
+<?php if (!empty($order_postmeta['order_invoice_ref'])) : ?>
19
+	<div><a href="<?php echo admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_invoice_ref'] . '&bon_colisage=ok&mode=pdf'); ?>" target="_blank" class="wps-bton-second-mini-rounded" ><?php _e('Download the product list', 'wpshop'); ?></a></div>
20 20
 <?php endif; ?>
21 21
 </div>
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,17 +1,25 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
  if( !empty($shipping_method_name) ) : ?>
3 5
 	<div class="wps-alert-info"><strong><?php _e( 'Selected shipping method', 'wpshop'); ?></strong> : <?php echo $shipping_method_name; ?></div>
4
-<?php else : ?>
5
-	<div class="wps-alert-info"><?php _e( 'No selected shipping method', 'wpshop'); ?></div>
6
+<?php else {
7
+	: ?>
8
+	<div class="wps-alert-info"><?php _e( 'No selected shipping method', 'wpshop');
9
+}
10
+?></div>
6 11
 <?php endif; ?>
7 12
 
8 13
 <div class="wps-boxed">
9 14
 	<span class="wps-h5"><?php _e( 'Shipping informations', 'wpshop');?></span>
10 15
 	<?php if ( !empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'shipped' ) : ?>
11 16
 			<div><a data-id="<?php echo $order->ID; ?>" class="wps-bton-first-mini-rounded markAsShipped order_<?php echo $order->ID; ?>" data-nonce="<?php echo wp_create_nonce("wpshop_dialog_inform_shipping_number"); ?>"><?php _e('Mark as shipped', 'wpshop'); ?></a></div>
12
-	<?php else : ?>
17
+	<?php else {
18
+	: ?>
13 19
 		<div>
14
-			<?php require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, 'backend', 'order-shipping-informations' ) ); ?>
20
+			<?php require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, 'backend', 'order-shipping-informations' ) );
21
+}
22
+?>
15 23
 		</div>
16 24
 <?php endif; ?>
17 25
 
Please login to merge, or discard this patch.
includes/modules/wps_barcode/controller/wps_barcode_metabox.ctr.php 1 patch
Spacing   +137 added lines, -138 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 class wps_barcode_metabox {
4 4
 	public function __construct() {
5
-		add_action( 'add_meta_boxes', array($this, 'add_meta_box'), 10, 10 );
6
-		add_action( 'admin_enqueue_scripts', array($this, 'add_scripts') );
5
+		add_action('add_meta_boxes', array($this, 'add_meta_box'), 10, 10);
6
+		add_action('admin_enqueue_scripts', array($this, 'add_scripts'));
7 7
 	}
8 8
 
9 9
 	/**
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	public function add_scripts() {
13 13
 		global $current_screen;
14
-	    if ( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_ORDER, WPSHOP_NEWTYPE_IDENTIFIER_COUPON ), true ) )
14
+	    if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_ORDER, WPSHOP_NEWTYPE_IDENTIFIER_COUPON), true))
15 15
 	        return;
16 16
 
17
-		wp_enqueue_script( 'jquery' );
18
-		wp_enqueue_script( 'wps_barcode_printelement',  WPS_BARCODE_JSCRIPTS.'/jquery.printElement.js' );
19
-		wp_enqueue_script( 'wps_barcode',  WPS_BARCODE_JSCRIPTS.'/wps.backend.wps_barcode.js' );
17
+		wp_enqueue_script('jquery');
18
+		wp_enqueue_script('wps_barcode_printelement', WPS_BARCODE_JSCRIPTS . '/jquery.printElement.js');
19
+		wp_enqueue_script('wps_barcode', WPS_BARCODE_JSCRIPTS . '/wps.backend.wps_barcode.js');
20 20
 	}
21 21
 
22 22
 	/**
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
 		$conf = get_option('wps_barcode');
29 29
 
30
-		$post = get_post( get_the_ID() );
31
-		if ( !empty($post) ) {
32
-			$query = $wpdb->prepare( "
30
+		$post = get_post(get_the_ID());
31
+		if (!empty($post)) {
32
+			$query = $wpdb->prepare("
33 33
 				SELECT *
34 34
 				FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . "
35 35
 				WHERE entity_id = %d
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 						SELECT id
38 38
 						FROM " . WPSHOP_DBT_ATTRIBUTE . "
39 39
 						WHERE code = %s
40
-					)" , $post->ID, 'barcode' );
41
-				$result = $wpdb->get_results( $query, ARRAY_A );
40
+					)" , $post->ID, 'barcode');
41
+				$result = $wpdb->get_results($query, ARRAY_A);
42 42
 
43 43
 				/*add_meta_box('wps_barcode_product', __('Barcode Manager', 'wps_barcode' ),
44 44
 				array( $this, 'meta_box_product' ), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT,
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 
74 74
 		/*Select value of barcode*/
75 75
 		$result = $wpdb->get_results(
76
-				'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.
77
-				' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE.
78
-				' WHERE code = "barcode") AND entity_id="'.$post_ID.'"', ARRAY_A);
76
+				'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR .
77
+				' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE .
78
+				' WHERE code = "barcode") AND entity_id="' . $post_ID . '"', ARRAY_A);
79 79
 		$meta = !empty($result) ? $result[0]['value'] : '';
80 80
 
81 81
 		/*Get price of product*/
82
-		$result = $wpdb->get_results('SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.
83
-				' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE.
84
-				' WHERE code="'.WPSHOP_PRODUCT_PRICE_TTC.'") AND entity_id='.$post_ID, ARRAY_A);
82
+		$result = $wpdb->get_results('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL .
83
+				' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE .
84
+				' WHERE code="' . WPSHOP_PRODUCT_PRICE_TTC . '") AND entity_id=' . $post_ID, ARRAY_A);
85 85
 
86
-		if ( !empty($result) && $result[0]['value'] >= 0) {
86
+		if (!empty($result) && $result[0]['value'] >= 0) {
87 87
 			$price = $result[0]['value'];
88 88
 
89 89
 			/*Get title of product*/
@@ -91,28 +91,28 @@  discard block
 block discarded – undo
91 91
 			$ref = substr($post['post_title'], 0, 10);
92 92
 
93 93
 			chdir('..');
94
-			chdir( plugin_dir_path(__FILE__) );
94
+			chdir(plugin_dir_path(__FILE__));
95 95
 			chdir('..');
96 96
 
97 97
 			$conf = get_option('wps_barcode');
98 98
 
99
-			if ( isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on' ) {
99
+			if (isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on') {
100 100
 				echo $ajax->generate_image($barcode, $meta, __('product', 'wps_barcode'),
101 101
 						$price, $ref);
102 102
 			}
103 103
 			else {
104
-				echo '<p style="text-align: center"><button class="button '.
105
-					'button-primary button-large" type="button"'.
106
-					'id="display_barcode" data-nonce=' . wp_create_nonce( 'imgProduct' ) . '>'.
107
-					__('Display', 'wps_barcode').'</button></p>';
104
+				echo '<p style="text-align: center"><button class="button ' .
105
+					'button-primary button-large" type="button"' .
106
+					'id="display_barcode" data-nonce=' . wp_create_nonce('imgProduct') . '>' .
107
+					__('Display', 'wps_barcode') . '</button></p>';
108 108
 			}
109 109
 		}
110 110
 		else {
111 111
 			$conf = get_option('wps_barcode');
112 112
 
113
-			if ( $conf['generate_barcode'] === 'true' ) {
114
-				echo '<p>'.sprintf( __('None bardcode generated as you did create %s.',
115
-					'wps_barcode'), __('product', 'wps_barcode')).'</p>';
113
+			if ($conf['generate_barcode'] === 'true') {
114
+				echo '<p>' . sprintf(__('None bardcode generated as you did create %s.',
115
+					'wps_barcode'), __('product', 'wps_barcode')) . '</p>';
116 116
 			}
117 117
 		}
118 118
 	}
@@ -132,21 +132,20 @@  discard block
 block discarded – undo
132 132
 		$country = '000';
133 133
 		$result = get_post_meta($post_ID);
134 134
 
135
-		if ( !empty($result) ) {
136
-			$order_postmeta = isset( $result['_order_postmeta'] ) ? unserialize($result['_order_postmeta'][0]) : array();
135
+		if (!empty($result)) {
136
+			$order_postmeta = isset($result['_order_postmeta']) ? unserialize($result['_order_postmeta'][0]) : array();
137 137
 
138
-			if ( !empty($order_postmeta['order_invoice_date']) ) {
138
+			if (!empty($order_postmeta['order_invoice_date'])) {
139 139
 				$conf = get_option('wps_barcode');
140 140
 				if ($conf['type'] === 'internal') {
141 141
 					$type = $conf['internal_invoice_client'];
142 142
 
143 143
 					$order_date = isset($order_postmeta['order_invoice_date']) ?
144
-						$order_postmeta['order_invoice_date'] :
145
-						$order_postmeta['order_date'];
144
+						$order_postmeta['order_invoice_date'] : $order_postmeta['order_date'];
146 145
 					$pDate = new DateTime($order_date);
147 146
 					$date = $pDate->format('my');
148 147
 
149
-					if ( empty($order_postmeta['order_invoice_ref']) ) {
148
+					if (empty($order_postmeta['order_invoice_ref'])) {
150 149
 						$continue = false;
151 150
 					}
152 151
 					else {
@@ -155,9 +154,9 @@  discard block
 block discarded – undo
155 154
 					}
156 155
 				}
157 156
 				if ($continue === true) {
158
-					$code = $type.$date.$id;
157
+					$code = $type . $date . $id;
159 158
 
160
-					if ( empty($result['_order_barcode']) ) {
159
+					if (empty($result['_order_barcode'])) {
161 160
 						$meta = $barcode->checksum($code);
162 161
 						add_post_meta($post_ID, '_order_barcode', $meta);
163 162
 					}
@@ -166,32 +165,32 @@  discard block
 block discarded – undo
166 165
 					}
167 166
 
168 167
 					chdir('..');
169
-					chdir( plugin_dir_path(__FILE__) );
168
+					chdir(plugin_dir_path(__FILE__));
170 169
 					chdir('..');
171 170
 					$order_meta = unserialize($result['_order_postmeta'][0]);
172
-					$title = ( !empty($order_meta['order_invoice_ref']) ) ? $order_meta['order_invoice_ref'] : $order_meta['order_key'];
171
+					$title = (!empty($order_meta['order_invoice_ref'])) ? $order_meta['order_invoice_ref'] : $order_meta['order_key'];
173 172
 					$price = $order_meta['order_grand_total'];
174 173
 
175 174
 
176
-					if ( isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on' ) {
175
+					if (isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on') {
177 176
 						$this->generate_image($barcode, $meta[0], __('order client', 'wps_barcode'),
178
-							$price, $title );
177
+							$price, $title);
179 178
 					}
180 179
 				}
181 180
 				else {
182
-					echo '<p>'.__('None bardcode generated as customer can not get his bill.',
183
-							'wps_barcode').'</p>';
181
+					echo '<p>' . __('None bardcode generated as customer can not get his bill.',
182
+							'wps_barcode') . '</p>';
184 183
 				}
185 184
 
186 185
 			}
187 186
 			else {
188
-				echo '<p>'.__('None bardcode generated as customer can not get his bill.',
189
-						'wps_barcode').'</p>';
187
+				echo '<p>' . __('None bardcode generated as customer can not get his bill.',
188
+						'wps_barcode') . '</p>';
190 189
 			}
191 190
 		}
192 191
 		else {
193
-			echo '<p>'.sprintf( __('None bardcode generated as you did create %s.',
194
-					'wps_barcode'), 'order client').'</p>';
192
+			echo '<p>' . sprintf(__('None bardcode generated as you did create %s.',
193
+					'wps_barcode'), 'order client') . '</p>';
195 194
 		}
196 195
 	}
197 196
 
@@ -210,14 +209,14 @@  discard block
 block discarded – undo
210 209
 		$country = '000';
211 210
 		$result = get_post_meta($post_ID);
212 211
 
213
-		if ( !empty($result) ) {
214
-			if ( empty($result['wpshop_coupon_barcode']) ) {
212
+		if (!empty($result)) {
213
+			if (empty($result['wpshop_coupon_barcode'])) {
215 214
 				$conf = get_option('wps_barcode');
216 215
 				if ($conf['type'] === 'internal') {
217 216
 					$type = $conf['internal_coupons'];
218 217
 
219
-					$query = $wpdb->get_results('SELECT post_date FROM '.
220
-							$table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A);
218
+					$query = $wpdb->get_results('SELECT post_date FROM ' .
219
+							$table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A);
221 220
 
222 221
 					$pDate = new DateTime($query[0]['post_date']);
223 222
 					$date = $pDate->format('my');
@@ -225,13 +224,13 @@  discard block
 block discarded – undo
225 224
 
226 225
 				$len = strlen($post_ID);
227 226
 				$ref = '';
228
-				if ( $len < 5 ) {
229
-					for ($i=0; $i <= $len; $i++) {
227
+				if ($len < 5) {
228
+					for ($i = 0; $i <= $len; $i++) {
230 229
 						$ref .= '0';
231 230
 					}
232 231
 				}
233
-				$id = $ref.$post_ID;
234
-				$code = $type.$date.$id;
232
+				$id = $ref . $post_ID;
233
+				$code = $type . $date . $id;
235 234
 				$meta = $barcode->checksum($code);
236 235
 				add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta);
237 236
 			}
@@ -239,24 +238,24 @@  discard block
 block discarded – undo
239 238
 				$meta = $result['wpshop_coupon_barcode'][0];
240 239
 			}
241 240
 
242
-			$query = $wpdb->get_results('SELECT post_title FROM '.
243
-					$table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A);
241
+			$query = $wpdb->get_results('SELECT post_title FROM ' .
242
+					$table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A);
244 243
 
245 244
 			$post = get_post($post_ID, ARRAY_A);
246
-			if ( isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on' ) {
245
+			if (isset($conf['generate_barcode']) && $conf['generate_barcode'] === 'on') {
247 246
 				$ajax->generate_image($barcode, $meta, __('coupon', 'wps_barcode'),
248 247
 					$result['wpshop_coupon_discount_value'][0], $query[0]['post_title'], $post_ID);
249 248
 			}
250 249
 			else {
251
-				echo '<p style="text-align: center"><button class="button '.
252
-					'button-primary button-large" type="button"'.
253
-					'id="display_barcode">'.
254
-					__('Display', 'wps_barcode').'</button></p>';
250
+				echo '<p style="text-align: center"><button class="button ' .
251
+					'button-primary button-large" type="button"' .
252
+					'id="display_barcode">' .
253
+					__('Display', 'wps_barcode') . '</button></p>';
255 254
 			}
256 255
 		}
257 256
 		else {
258
-			echo '<p>'.__('None bardcode generated as coupon has not created.',
259
-					'wps_barcode').'</p>';
257
+			echo '<p>' . __('None bardcode generated as coupon has not created.',
258
+					'wps_barcode') . '</p>';
260 259
 		}
261 260
 	}
262 261
 
@@ -269,44 +268,44 @@  discard block
 block discarded – undo
269 268
 	 * @param string $title Title of product
270 269
 	 */
271 270
 	public function generate_image(&$barcode, $meta, $type, $price, $title, $post_ID = 0) {
272
-		if ( !extension_loaded('gd') ) {
273
-			return '<p>'.__('Library GD is requiered.', 'wps_barcode').'</p>';
271
+		if (!extension_loaded('gd')) {
272
+			return '<p>' . __('Library GD is requiered.', 'wps_barcode') . '</p>';
274 273
 		}
275
-		if ( !empty($meta) ) {
274
+		if (!empty($meta)) {
276 275
 			$barcode->setGenerateCode($meta);
277 276
 			$binCode = $barcode->getBinCode();
278 277
 
279 278
 			$px = 3.779528;
280
-			$x = round(66*$px); //249.449 px
281
-			$y = round(50*$px); //188.976 px
282
-			$bar_size = round(63.393/72); //0.880 px
279
+			$x = round(66 * $px); //249.449 px
280
+			$y = round(50 * $px); //188.976 px
281
+			$bar_size = round(63.393 / 72); //0.880 px
283 282
 
284 283
 			$len = 0;
285 284
 			$test = '';
286 285
 
287
-			while ($len !== strlen($binCode) ) {
288
-				$test .= substr($binCode, $len, 7).' ';
289
-				$len = $len+7;
286
+			while ($len !== strlen($binCode)) {
287
+				$test .= substr($binCode, $len, 7) . ' ';
288
+				$len = $len + 7;
290 289
 			}
291 290
 
292 291
 			$im = imagecreate($x, $y);
293 292
 			$background_color = imagecolorallocate($im, 255, 255, 255);
294
-			$start = round(5.79*$px); //21.883
293
+			$start = round(5.79 * $px); //21.883
295 294
 
296 295
 			/*Write First left guard*/
297
-			$this->imgNormalGuard($im, $start, $start+$bar_size,
296
+			$this->imgNormalGuard($im, $start, $start + $bar_size,
298 297
 					imagecolorallocate($im, 0, 0, 0));
299
-			$this->imgNormalGuard($im, $start+($bar_size*2),
300
-					$start+($bar_size*3), imagecolorallocate($im, 255, 255, 255));
301
-			$this->imgNormalGuard($im, $start+($bar_size*4),
302
-					$start+($bar_size*5), imagecolorallocate($im, 0, 0, 0));
298
+			$this->imgNormalGuard($im, $start + ($bar_size * 2),
299
+					$start + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255));
300
+			$this->imgNormalGuard($im, $start + ($bar_size * 4),
301
+					$start + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0));
303 302
 
304
-			$pos = $start+($bar_size*7);
305
-			$newPos = $pos+$bar_size;
303
+			$pos = $start + ($bar_size * 7);
304
+			$newPos = $pos + $bar_size;
306 305
 
307 306
 			/*Write left barcode*/
308
-			for ($i=0; $i<42 ; $i++) {
309
-				if( substr($binCode, $i, 1) === '0' ) {
307
+			for ($i = 0; $i < 42; $i++) {
308
+				if (substr($binCode, $i, 1) === '0') {
310 309
 					$color = imagecolorallocate($im, 255, 255, 255);
311 310
 				}
312 311
 				else {
@@ -314,128 +313,128 @@  discard block
 block discarded – undo
314 313
 				}
315 314
 
316 315
 				$this->imgSymbole($im, $pos, $newPos, $color);
317
-				$newPos = $pos+$bar_size;
318
-				$pos = $newPos+$bar_size;
316
+				$newPos = $pos + $bar_size;
317
+				$pos = $newPos + $bar_size;
319 318
 			}
320 319
 
321 320
 			/*Writer center guard*/
322 321
 			$pos = $newPos;
323
-			$this->imgNormalGuard($im, $pos, $newPos+$bar_size,
322
+			$this->imgNormalGuard($im, $pos, $newPos + $bar_size,
324 323
 					imagecolorallocate($im, 255, 255, 255));
325
-			$this->imgNormalGuard($im, $pos+($bar_size*2),
326
-					$newPos+($bar_size*3), imagecolorallocate($im, 0, 0, 0));
327
-			$this->imgNormalGuard($im, $pos+($bar_size*4),
328
-					$newPos+($bar_size*5), imagecolorallocate($im, 255, 255, 255));
329
-			$this->imgNormalGuard($im, $pos+($bar_size*6),
330
-					$newPos+($bar_size*7), imagecolorallocate($im, 0, 0, 0));
331
-			$this->imgNormalGuard($im, $pos+($bar_size*8),
332
-					$newPos+($bar_size*9), imagecolorallocate($im, 255, 255, 255));
324
+			$this->imgNormalGuard($im, $pos + ($bar_size * 2),
325
+					$newPos + ($bar_size * 3), imagecolorallocate($im, 0, 0, 0));
326
+			$this->imgNormalGuard($im, $pos + ($bar_size * 4),
327
+					$newPos + ($bar_size * 5), imagecolorallocate($im, 255, 255, 255));
328
+			$this->imgNormalGuard($im, $pos + ($bar_size * 6),
329
+					$newPos + ($bar_size * 7), imagecolorallocate($im, 0, 0, 0));
330
+			$this->imgNormalGuard($im, $pos + ($bar_size * 8),
331
+					$newPos + ($bar_size * 9), imagecolorallocate($im, 255, 255, 255));
333 332
 
334
-			$pos = $newPos+($bar_size*10);
333
+			$pos = $newPos + ($bar_size * 10);
335 334
 
336 335
 			/*Write right barcode*/
337
-			for ($i=42; $i<84 ; $i++) {
338
-				if( substr($binCode, $i, 1) === '0' ) {
336
+			for ($i = 42; $i < 84; $i++) {
337
+				if (substr($binCode, $i, 1) === '0') {
339 338
 					$color = imagecolorallocate($im, 255, 255, 255);
340 339
 				}
341 340
 				else {
342 341
 					$color = imagecolorallocate($im, 0, 0, 0);
343 342
 				}
344 343
 
345
-				$newPos = $pos+$bar_size;
344
+				$newPos = $pos + $bar_size;
346 345
 
347 346
 				$this->imgSymbole($im, $pos, $newPos, $color);
348
-				$pos = $newPos+$bar_size;
347
+				$pos = $newPos + $bar_size;
349 348
 			}
350 349
 
351 350
 			/*Write right guard*/
352
-			$pos = $newPos+$bar_size;
353
-			$this->imgNormalGuard($im, $pos, $pos+$bar_size,
351
+			$pos = $newPos + $bar_size;
352
+			$this->imgNormalGuard($im, $pos, $pos + $bar_size,
354 353
 					imagecolorallocate($im, 0, 0, 0));
355
-			$this->imgNormalGuard($im, $pos+($bar_size*2),
356
-					$pos+($bar_size*3), imagecolorallocate($im, 255, 255, 255));
357
-			$this->imgNormalGuard($im, $pos+($bar_size*4),
358
-					$pos+($bar_size*5), imagecolorallocate($im, 0, 0, 0));
354
+			$this->imgNormalGuard($im, $pos + ($bar_size * 2),
355
+					$pos + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255));
356
+			$this->imgNormalGuard($im, $pos + ($bar_size * 4),
357
+					$pos + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0));
359 358
 
360 359
 			$textSize = 16;
361 360
 			$font = 'assets/fonts/arialbd.ttf';
362
-			imagettftext($im, $textSize, 0, 8, $y-$start-5,
361
+			imagettftext($im, $textSize, 0, 8, $y - $start - 5,
363 362
 			imagecolorallocate($im, 0, 0, 0), $font, substr($meta, 0, 1));
364 363
 
365 364
 			$continue = true;
366 365
 			$i = 28; $j = 0;
367 366
 
368 367
 			/*Write left number code*/
369
-			while ($j<5) {
370
-				$j=$j+1;
371
-				imagettftext($im, $textSize, 0, $i, $y-$start-5,
368
+			while ($j < 5) {
369
+				$j = $j + 1;
370
+				imagettftext($im, $textSize, 0, $i, $y - $start - 5,
372 371
 				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1));
373
-				$i = $i+14;
372
+				$i = $i + 14;
374 373
 			}
375 374
 
376 375
 			/*Write right number code*/
377
-			while ($j<11) {
378
-				$j=$j+1;
379
-				imagettftext($im, $textSize, 0, $i+6, $y-$start-5,
376
+			while ($j < 11) {
377
+				$j = $j + 1;
378
+				imagettftext($im, $textSize, 0, $i + 6, $y - $start - 5,
380 379
 					imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1));
381
-				$i = $i+15;
380
+				$i = $i + 15;
382 381
 			}
383
-			imagettftext($im, $textSize, 0, $i+4, $y-$start-5,
384
-				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j+1, 1));
382
+			imagettftext($im, $textSize, 0, $i + 4, $y - $start - 5,
383
+				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j + 1, 1));
385 384
 
386 385
 			/*Write ref product and price*/
387 386
 			$textSize = 12;
388 387
 			$currency = (wpshop_tools::wpshop_get_currency() === '&euro;') ? "€" : wpshop_tools::wpshop_get_currency();
389 388
 
390
-			if ( $type === __('coupon', 'wps_barcode') ) {
389
+			if ($type === __('coupon', 'wps_barcode')) {
391 390
 				$coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type');
392
-				if ( $coupon_postmeta[0] === 'percent' ) {
393
-					$price = $price.' %';
391
+				if ($coupon_postmeta[0] === 'percent') {
392
+					$price = $price . ' %';
394 393
 				}
395 394
 				else {
396
-					$price = sprintf( number_format( $price, 2 ). ' '.$currency);
395
+					$price = sprintf(number_format($price, 2) . ' ' . $currency);
397 396
 				}
398 397
 			}
399 398
 			else {
400
-				$price = sprintf( number_format( $price, 2 ). ' '.$currency);
399
+				$price = sprintf(number_format($price, 2) . ' ' . $currency);
401 400
 			}
402 401
 
403
-			imagettftext($im, $textSize, 0, 20, round(6*$px),
402
+			imagettftext($im, $textSize, 0, 20, round(6 * $px),
404 403
 				imagecolorallocate($im, 0, 0, 0), $font, $title);
405
-			imagettftext($im, $textSize, 0, ($x/2)+40, round(6*$px),
404
+			imagettftext($im, $textSize, 0, ($x / 2) + 40, round(6 * $px),
406 405
 				imagecolorallocate($im, 0, 0, 0), $font, $price);
407 406
 
408 407
 			ob_start();
409 408
 			imagepng($im);
410 409
 			$img = ob_get_clean();
411 410
 
412
-			echo '<p><img src="data:image/png;base64,'.base64_encode($img).
411
+			echo '<p><img src="data:image/png;base64,' . base64_encode($img) .
413 412
 				'" id="barcode" width="160" height="90" /></p>';
414 413
 
415
-			echo '<p style="text-align: right"><button class="button '.
416
-					'button-primary button-large" type="button"'.
417
-					'id="print_barcode">'.
418
-					__('Print', 'wps_barcode').'</button></p>';
414
+			echo '<p style="text-align: right"><button class="button ' .
415
+					'button-primary button-large" type="button"' .
416
+					'id="print_barcode">' .
417
+					__('Print', 'wps_barcode') . '</button></p>';
419 418
 
420
-			wp_mkdir_p( WPS_BARCODE_UPLOAD );
419
+			wp_mkdir_p(WPS_BARCODE_UPLOAD);
421 420
 
422
-			file_put_contents(WPS_BARCODE_UPLOAD.$meta.'.png', $img);
421
+			file_put_contents(WPS_BARCODE_UPLOAD . $meta . '.png', $img);
423 422
 
424 423
 			/*Generate ODT File*/
425 424
 			try {
426
-				if( !class_exists('Odf') ) {
427
-					require_once(WPS_BARCODE_PATH.'/librairies/odtphp/odf.php');
425
+				if (!class_exists('Odf')) {
426
+					require_once(WPS_BARCODE_PATH . '/librairies/odtphp/odf.php');
428 427
 				}
429
-				$odf = new Odf(WPS_BARCODE_PATH.'assets/medias/avery_a4_991_677.ott');
430
-				$odf->setImage('barcode', WPS_BARCODE_UPLOAD.$meta.'.png');
431
-				$odf->saveToDisk(WPS_BARCODE_UPLOAD.$meta.'.odt');
428
+				$odf = new Odf(WPS_BARCODE_PATH . 'assets/medias/avery_a4_991_677.ott');
429
+				$odf->setImage('barcode', WPS_BARCODE_UPLOAD . $meta . '.png');
430
+				$odf->saveToDisk(WPS_BARCODE_UPLOAD . $meta . '.odt');
432 431
 			} catch (Exception $e) {
433 432
 				echo __('Generation problem', 'wps_barcode');
434 433
 			}
435 434
 		}
436 435
 		else {
437
-			echo '<p>'.sprintf( __('None bardcode generated as you did create %s.',
438
-					'wps_barcode'), $type).'</p>';
436
+			echo '<p>' . sprintf(__('None bardcode generated as you did create %s.',
437
+					'wps_barcode'), $type) . '</p>';
439 438
 		}
440 439
 	}
441 440
 
@@ -451,7 +450,7 @@  discard block
 block discarded – undo
451 450
 	 * @param integer $color Color of rectangle
452 451
 	 */
453 452
 	private function imgNormalGuard(&$image, $pos, $size, $color) {
454
-		imagefilledrectangle($image, $pos, 180*0.25,$size, 180-10, $color );
453
+		imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 10, $color);
455 454
 	}
456 455
 
457 456
 	/**
@@ -462,7 +461,7 @@  discard block
 block discarded – undo
462 461
 	 * @param integer $color Color of rectangle
463 462
 	 */
464 463
 	private function imgSymbole(&$image, $pos, $size, $color) {
465
-		imagefilledrectangle($image, $pos, 180*0.25,$size, 180-40, $color );
464
+		imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 40, $color);
466 465
 	}
467 466
 
468 467
 }
Please login to merge, or discard this patch.
includes/modules/wps_download_file/controller/wps_download_file_ctr.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
1
+<?php if (!defined('ABSPATH')) {
2 2
 	exit;
3 3
 }
4 4
 
5 5
 class wps_download_file_ctr {
6 6
 
7 7
 	public function __construct() {
8
-		add_action( 'admin_post_wps_download_file', array( $this, 'wps_download_file' ) );
9
-		add_action( 'admin_post_nopriv_wps_download_file', array( $this, 'wps_download_file' ) );
10
-		add_action( 'wps_after_check_order_payment_total_amount', array( $this, 'wps_after_check_order_payment_total_amount' ) );
8
+		add_action('admin_post_wps_download_file', array($this, 'wps_download_file'));
9
+		add_action('admin_post_nopriv_wps_download_file', array($this, 'wps_download_file'));
10
+		add_action('wps_after_check_order_payment_total_amount', array($this, 'wps_after_check_order_payment_total_amount'));
11 11
 	}
12 12
 
13
-	public static function get_product_download_link( $oid, $item ) {
13
+	public static function get_product_download_link($oid, $item) {
14 14
 		global $wpdb;
15 15
 
16 16
 		$parent_def = array();
17 17
 		$item_id = $item['item_id'];
18
-		$item_post_type = get_post_type( $item['item_id'] );
19
-		if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) {
20
-			$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );
21
-			if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) {
18
+		$item_post_type = get_post_type($item['item_id']);
19
+		if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) {
20
+			$parent_def = wpshop_products::get_parent_variation($item['item_id']);
21
+			if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
22 22
 				$parent_post = $parent_def['parent_post'];
23 23
 				$item_id = $parent_post->ID;
24 24
 				$item_title = $parent_post->post_title;
@@ -28,53 +28,53 @@  discard block
 block discarded – undo
28 28
 		$download_link = false;
29 29
 		$item_id_for_download = null;
30 30
 		/** Check if the product or the head product is a download product  */
31
-		if ( ! empty( $parent_def ) ) {
31
+		if (!empty($parent_def)) {
32 32
 			$parent_meta = $parent_def['parent_post_meta'];
33
-			if ( ! empty( $parent_meta['is_downloadable_'] ) ) {
34
-				$query = $wpdb->prepare( 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'] );
35
-				$downloadable_option_value = $wpdb->get_var( $query );
36
-				if ( empty( $downloadable_option_value ) ) {
33
+			if (!empty($parent_meta['is_downloadable_'])) {
34
+				$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_']);
35
+				$downloadable_option_value = $wpdb->get_var($query);
36
+				if (empty($downloadable_option_value)) {
37 37
 					$item['item_is_downloadable_'] = 'No';
38 38
 				} else {
39 39
 					$item['item_is_downloadable_'] = $downloadable_option_value;
40 40
 				}
41 41
 			}
42 42
 		}
43
-		if ( empty( $item['item_is_downloadable_'] ) ) {
44
-			$product_data = wpshop_products::get_product_data( $item['item_id'] );
45
-			if ( empty( $product_data['is_downloadable_'] ) ) {
43
+		if (empty($item['item_is_downloadable_'])) {
44
+			$product_data = wpshop_products::get_product_data($item['item_id']);
45
+			if (empty($product_data['is_downloadable_'])) {
46 46
 				$item['item_is_downloadable_'] = 'No';
47 47
 			} else {
48 48
 				$item['item_is_downloadable_'] = $product_data['is_downloadable_'];
49 49
 			}
50 50
 		}
51
-		if ( strtolower( __( $item['item_is_downloadable_'], 'wpshop' ) ) === strtolower( __( 'Yes', 'wpshop' ) ) ) {
51
+		if (strtolower(__($item['item_is_downloadable_'], 'wpshop')) === strtolower(__('Yes', 'wpshop'))) {
52 52
 			$item_id_for_download = $item_id;
53 53
 		}
54
-		if ( isset( $item['item_meta']['variations'] ) ) {
55
-			foreach ( $item['item_meta']['variations'] as $variation_id => $variation ) {
56
-				if ( isset( $variation['item_meta']['is_downloadable_'] ) ) {
54
+		if (isset($item['item_meta']['variations'])) {
55
+			foreach ($item['item_meta']['variations'] as $variation_id => $variation) {
56
+				if (isset($variation['item_meta']['is_downloadable_'])) {
57 57
 					$item_id_for_download = $item_id . '__' . $variation_id;
58 58
 				}
59 59
 			}
60 60
 		}
61 61
 		/** In case there is a item identifier defined for download */
62
-		if ( null !== $item_id_for_download ) {
63
-			$cid = (int) get_post_meta( $oid, '_wpshop_order_customer_id', true );
64
-			$cid = ! empty( $cid ) ? $cid : get_current_user_id();
65
-			$download_codes = get_user_meta( $cid, '_order_download_codes_' . $oid, true );
62
+		if (null !== $item_id_for_download) {
63
+			$cid = (int)get_post_meta($oid, '_wpshop_order_customer_id', true);
64
+			$cid = !empty($cid) ? $cid : get_current_user_id();
65
+			$download_codes = get_user_meta($cid, '_order_download_codes_' . $oid, true);
66 66
 			/** Check if the current product exist into download code list, if not check if there is a composition between parent product and children product  */
67
-			if ( empty( $download_codes[ $item_id_for_download ] ) ) {
68
-				$item_id_component = explode( '__', $item_id_for_download );
69
-				if ( ! empty( $item_id_component ) && ( $item_id_component[0] !== $item_id_for_download ) ) {
67
+			if (empty($download_codes[$item_id_for_download])) {
68
+				$item_id_component = explode('__', $item_id_for_download);
69
+				if (!empty($item_id_component) && ($item_id_component[0] !== $item_id_for_download)) {
70 70
 					$item_id_for_download = $item_id_component[0];
71
-				} elseif ( ! empty( $download_codes[ $item['item_id'] ] ) ) {
71
+				} elseif (!empty($download_codes[$item['item_id']])) {
72 72
 					$item_id_for_download = $item['item_id'];
73 73
 				}
74 74
 			}
75 75
 			//var_dump($download_codes);
76
-			if ( ! empty( $download_codes ) && ! empty( $download_codes[ $item_id_for_download ] ) && ! empty( $download_codes[ $item_id_for_download ]['download_code'] ) ) {
77
-				$download_link = admin_url( 'admin-post.php?action=wps_download_file&amp;oid=' . $oid . '&amp;download=' . $download_codes[ $item_id_for_download ]['download_code'] );
76
+			if (!empty($download_codes) && !empty($download_codes[$item_id_for_download]) && !empty($download_codes[$item_id_for_download]['download_code'])) {
77
+				$download_link = admin_url('admin-post.php?action=wps_download_file&amp;oid=' . $oid . '&amp;download=' . $download_codes[$item_id_for_download]['download_code']);
78 78
 			}
79 79
 		}
80 80
 		//exit();
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	public function wps_download_file() {
86
-		$download = ! empty( $_GET['download'] ) ? sanitize_text_field( $_GET['download'] ) : '';
87
-		$oid = ! empty( $_GET['oid'] ) ? (int) $_GET['oid'] : 0;
86
+		$download = !empty($_GET['download']) ? sanitize_text_field($_GET['download']) : '';
87
+		$oid = !empty($_GET['oid']) ? (int)$_GET['oid'] : 0;
88 88
 
89
-		if ( ! empty( $download ) && ! empty( $oid ) ) {
89
+		if (!empty($download) && !empty($oid)) {
90 90
 			$variation_id = '';
91
-			$order = get_post_meta( $oid, '_order_postmeta', true );
92
-			if ( ! empty( $order ) && ! empty( $order['customer_id'] ) ) {
93
-				$download_codes = get_user_meta( $order['customer_id'], '_order_download_codes_' . $oid, true );
94
-				if ( ! empty( $download_codes ) && is_array( $download_codes ) ) {
95
-					foreach ( $download_codes as $downloadable_product_id => $d ) {
91
+			$order = get_post_meta($oid, '_order_postmeta', true);
92
+			if (!empty($order) && !empty($order['customer_id'])) {
93
+				$download_codes = get_user_meta($order['customer_id'], '_order_download_codes_' . $oid, true);
94
+				if (!empty($download_codes) && is_array($download_codes)) {
95
+					foreach ($download_codes as $downloadable_product_id => $d) {
96 96
 						$is_encrypted = false;
97
-						if ( $d['download_code'] === $download ) {
97
+						if ($d['download_code'] === $download) {
98 98
 							 wpshop_tools::create_custom_hook('encrypt_actions_for_downloadable_product', array(
99 99
 								 'order_id' => $oid,
100 100
 								 'download_product_id' => $downloadable_product_id,
101 101
 
102
-							 ) );
102
+							 ));
103 103
 
104
-							if ( get_post_type( $downloadable_product_id ) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
105
-								$parent_def = wpshop_products::get_parent_variation( $downloadable_product_id );
106
-								if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) {
104
+							if (get_post_type($downloadable_product_id) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
105
+								$parent_def = wpshop_products::get_parent_variation($downloadable_product_id);
106
+								if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
107 107
 									$parent_post = $parent_def['parent_post'];
108 108
 									$variation_id = $downloadable_product_id;
109 109
 									$downloadable_product_id = $parent_post->ID;
110 110
 								}
111 111
 							} else {
112
-								  $downloadable_product_id = explode( '__', $downloadable_product_id );
113
-								 $downloadable_product_id = isset( $downloadable_product_id[1] ) ? $downloadable_product_id[1] : $downloadable_product_id[0];
112
+								  $downloadable_product_id = explode('__', $downloadable_product_id);
113
+								 $downloadable_product_id = isset($downloadable_product_id[1]) ? $downloadable_product_id[1] : $downloadable_product_id[0];
114 114
 							}
115 115
 
116 116
 							$link = wpshop_attributes::get_attribute_option_output(
@@ -121,50 +121,50 @@  discard block
 block discarded – undo
121 121
 								'is_downloadable_', 'file_url', $order
122 122
 							);
123 123
 
124
-							if ( false !== $link ) {
124
+							if (false !== $link) {
125 125
 								$uploads = wp_upload_dir();
126 126
 								$basedir = $uploads['basedir'];
127
-								$pos = strpos( $link, 'uploads' );
128
-								$link = $basedir . substr( $link,$pos + 7 );
127
+								$pos = strpos($link, 'uploads');
128
+								$link = $basedir . substr($link, $pos + 7);
129 129
 								/** If plugin is encrypted */
130
-								$encrypted_plugin_path = get_post_meta( $oid, '_download_file_path_' . $oid . '_' . ( ( ! empty( $variation_id ) && get_post_type( $variation_id ) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) ? $variation_id : $downloadable_product_id ), true );
131
-								if ( ! empty( $encrypted_plugin_path ) ) {
130
+								$encrypted_plugin_path = get_post_meta($oid, '_download_file_path_' . $oid . '_' . ((!empty($variation_id) && get_post_type($variation_id) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ? $variation_id : $downloadable_product_id), true);
131
+								if (!empty($encrypted_plugin_path)) {
132 132
 									$link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path;
133 133
 									$is_encrypted = true;
134 134
 								}
135 135
 
136
-								$overload_force_download = apply_filters( 'wps_download_file_overload_force_download', false );
137
-								if ( ! $overload_force_download ) {
138
-									wpshop_tools::forceDownload( $link, $is_encrypted );
136
+								$overload_force_download = apply_filters('wps_download_file_overload_force_download', false);
137
+								if (!$overload_force_download) {
138
+									wpshop_tools::forceDownload($link, $is_encrypted);
139 139
 								} else {
140
-									wpshop_tools::wpshop_safe_redirect( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $link ) );
140
+									wpshop_tools::wpshop_safe_redirect(str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $link));
141 141
 								}
142 142
 							}
143 143
 						}// End if().
144 144
 					}// End foreach().
145 145
 				}// End if().
146 146
 			} else {
147
-				wp_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' ) ) ) );
147
+				wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))));
148 148
 			}// End if().
149 149
 		}// End if().
150
-		esc_html_e( 'Impossible to download the file you requested', 'wpshop' );
150
+		esc_html_e('Impossible to download the file you requested', 'wpshop');
151 151
 	}
152 152
 
153
-	public function wps_after_check_order_payment_total_amount( $order_id ) {
154
-		$order_meta = ( ! empty( $order_meta ) ) ? false : get_post_meta( $order_id, '_order_postmeta', true );
153
+	public function wps_after_check_order_payment_total_amount($order_id) {
154
+		$order_meta = (!empty($order_meta)) ? false : get_post_meta($order_id, '_order_postmeta', true);
155 155
 		/** Check if the order content a downloadable product **/
156
-		if ( ! empty( $order_meta ) && ! empty( $order_meta['order_items'] ) && ! empty( $order_meta['order_status'] ) && 'completed' === $order_meta['order_status'] ) {
157
-			foreach ( $order_meta['order_items'] as $key_value => $item ) {
158
-				$link = self::get_product_download_link( $order_id, $item );
159
-				if ( false === $link ) {
156
+		if (!empty($order_meta) && !empty($order_meta['order_items']) && !empty($order_meta['order_status']) && 'completed' === $order_meta['order_status']) {
157
+			foreach ($order_meta['order_items'] as $key_value => $item) {
158
+				$link = self::get_product_download_link($order_id, $item);
159
+				if (false === $link) {
160 160
 					\eoxia\log_class::exec(
161 161
 						get_class(),
162 162
 						get_class(),
163 163
 						sprintf(
164
-							__( 'Failure returned at order link generation. UserID : <b>%1$d</b>, ProductID : <b>%2$d</d>, UserMeta : <pre>%3$s</pre>', 'wpshop' ),
165
-							(int) get_current_user_id(),
166
-							(int) $item['item_id'],
167
-							get_user_meta( (int) $order_meta['customer_id'], '_order_download_codes_' . $order_id, true )
164
+							__('Failure returned at order link generation. UserID : <b>%1$d</b>, ProductID : <b>%2$d</d>, UserMeta : <pre>%3$s</pre>', 'wpshop'),
165
+							(int)get_current_user_id(),
166
+							(int)$item['item_id'],
167
+							get_user_meta((int)$order_meta['customer_id'], '_order_download_codes_' . $order_id, true)
168 168
 						),
169 169
 						array(
170 170
 							'object_id' => $order_id,
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 						0
173 173
 					);
174 174
 				} else {
175
-					$user_data = get_userdata( $order_meta['customer_id'] );
176
-					$order_info = get_post_meta( $order_id, '_order_info', true );
177
-					$email = ( ! empty( $user_data ) && ! empty( $user_data->user_email ) ) ? $user_data->user_email : '';
178
-					$first_name = ( ! empty( $order_info ) && ! empty( $order_info['billing'] ) && ! empty( $order_info['billing']['address']['address_first_name'] ) ? $order_info['billing']['address']['address_first_name'] : '' );
179
-					$last_name = ( ! empty( $order_info ) && ! empty( $order_info['billing'] ) && ! empty( $order_info['billing']['address']['address_last_name'] ) ? $order_info['billing']['address']['address_last_name'] : '' );
180
-					$link = '<a href="' . esc_url( $link ) . '" target="_blank">' . __( 'Download the product', 'wpshop' ) . '</a>';
175
+					$user_data = get_userdata($order_meta['customer_id']);
176
+					$order_info = get_post_meta($order_id, '_order_info', true);
177
+					$email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : '';
178
+					$first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
179
+					$last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
180
+					$link = '<a href="' . esc_url($link) . '" target="_blank">' . __('Download the product', 'wpshop') . '</a>';
181 181
 					$wps_message = new wps_message_ctr();
182 182
 					$wps_message->wpshop_prepared_email(
183 183
 						$email,
Please login to merge, or discard this patch.
wps_product/modules/wps-mass-interface3/include/class-mass-interface3.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @package wps-mass-interface3
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 * @method __construct
63 63
 	 */
64 64
 	public function __construct() {
65
-		add_action( 'admin_menu', array( $this, 'mass_init' ), 350 );
66
-		add_action( 'wp_ajax_wps_mass_3_new', array( $this, 'ajax_new' ) );
67
-		add_action( 'wp_ajax_wps_mass_3_save', array( $this, 'ajax_save' ) );
68
-		add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
65
+		add_action('admin_menu', array($this, 'mass_init'), 350);
66
+		add_action('wp_ajax_wps_mass_3_new', array($this, 'ajax_new'));
67
+		add_action('wp_ajax_wps_mass_3_save', array($this, 'ajax_save'));
68
+		add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3);
69 69
 	}
70 70
 	/**
71 71
 	 * Page Initialisation
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 	 * @return void
75 75
 	 */
76 76
 	public function mass_init() {
77
-		$page = ( isset( $_GET['page'] ) && strpos( $_GET['page'] , 'mass_edit_interface3_att_set_' ) !== false ) ? $_GET['page'] : 'mass_edit_interface3_att_set_1';
77
+		$page = (isset($_GET['page']) && strpos($_GET['page'], 'mass_edit_interface3_att_set_') !== false) ? $_GET['page'] : 'mass_edit_interface3_att_set_1';
78 78
 		$this->hook = add_submenu_page(
79 79
 			'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT,
80
-			__( 'Mass product edit', 'wpshop' ),
81
-			__( 'Mass product edit', 'wpshop' ),
80
+			__('Mass product edit', 'wpshop'),
81
+			__('Mass product edit', 'wpshop'),
82 82
 			'manage_options',
83 83
 			$page,
84
-			array( $this, 'mass_interface' )
84
+			array($this, 'mass_interface')
85 85
 		);
86
-		add_action( "load-{$this->hook}", array( $this, 'mass_interface_screen_option' ) );
87
-		add_action( "admin_print_scripts-{$this->hook}", array( $this, 'scripts' ) );
88
-		add_action( "admin_print_styles-{$this->hook}", array( $this, 'styles' ) );
86
+		add_action("load-{$this->hook}", array($this, 'mass_interface_screen_option'));
87
+		add_action("admin_print_scripts-{$this->hook}", array($this, 'scripts'));
88
+		add_action("admin_print_styles-{$this->hook}", array($this, 'styles'));
89 89
 	}
90 90
 	/**
91 91
 	 * Page content.
@@ -94,48 +94,48 @@  discard block
 block discarded – undo
94 94
 	 * @return void Direct display.
95 95
 	 */
96 96
 	public function mass_interface() {
97
-		$wp_list_table = $this->wp_list_table( $this->hook );
97
+		$wp_list_table = $this->wp_list_table($this->hook);
98 98
 		$wp_list_table->prepare_items(); ?>
99 99
 		<div class="wrap">
100 100
 		<h1 class="wp-heading-inline"><?php
101
-		echo esc_html( $this->post_type_object->labels->name );
101
+		echo esc_html($this->post_type_object->labels->name);
102 102
 		?></h1>
103 103
 		<?php
104
-		if ( current_user_can( $this->post_type_object->cap->create_posts ) ) {
105
-			echo ' <a href="#addPost" class="page-title-action" data-nonce="' . esc_attr( wp_create_nonce( 'add_post-' . sanitize_title( get_class() ) ) ) . '">';
106
-			echo esc_html( $this->post_type_object->labels->add_new ) . '</a>';
104
+		if (current_user_can($this->post_type_object->cap->create_posts)) {
105
+			echo ' <a href="#addPost" class="page-title-action" data-nonce="' . esc_attr(wp_create_nonce('add_post-' . sanitize_title(get_class()))) . '">';
106
+			echo esc_html($this->post_type_object->labels->add_new) . '</a>';
107 107
 		}
108 108
 		?>
109 109
 		<hr class="wp-header-end">
110
-		<?php echo '<input type="hidden" id="hook" value="' . esc_attr( $this->hook ) . '">'; ?>
110
+		<?php echo '<input type="hidden" id="hook" value="' . esc_attr($this->hook) . '">'; ?>
111 111
 		<form id="posts-filter" method="get">
112 112
 		<?php $wp_list_table->views(); ?>
113
-		<?php $wp_list_table->search_box( $this->post_type_object->labels->search_items, 'post' ); ?>
113
+		<?php $wp_list_table->search_box($this->post_type_object->labels->search_items, 'post'); ?>
114 114
 		<input type="hidden" name="page" value="<?php
115
-		echo esc_attr( str_replace(
115
+		echo esc_attr(str_replace(
116 116
 			"{$wp_list_table->screen->post_type}_page_",
117 117
 			'',
118 118
 			$wp_list_table->screen->id
119
-		) ); ?>">
120
-		<input type="hidden" name="post_type" value="<?php echo esc_attr( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); ?>">
119
+		)); ?>">
120
+		<input type="hidden" name="post_type" value="<?php echo esc_attr(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); ?>">
121 121
 		</form>
122 122
 		<?php $wp_list_table->display(); ?>
123 123
 		<table style="display:none;">
124 124
 		 <tbody id="posts-add">
125
-		  <tr id="inline-edit" class="inline-edit-row inline-edit-row-post <?php echo esc_attr( "inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}" ); ?>" style="display: none">
126
-		   <td colspan="<?php echo esc_attr( $wp_list_table->get_column_count() ); ?>" class="colspanchange">
125
+		  <tr id="inline-edit" class="inline-edit-row inline-edit-row-post <?php echo esc_attr("inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}"); ?>" style="display: none">
126
+		   <td colspan="<?php echo esc_attr($wp_list_table->get_column_count()); ?>" class="colspanchange">
127 127
 			<fieldset class="inline-edit-col">
128
-			 <legend class="inline-edit-legend"><?php echo esc_html( $this->post_type_object->labels->add_new ) ?></legend>
128
+			 <legend class="inline-edit-legend"><?php echo esc_html($this->post_type_object->labels->add_new) ?></legend>
129 129
 			 <div class="inline-edit-col">
130 130
 		   <label>
131
-			<span class="title"><?php esc_html_e( 'Title' ); ?></span>
131
+			<span class="title"><?php esc_html_e('Title'); ?></span>
132 132
 			<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
133 133
 		   </label>
134 134
 			 </div>
135 135
 			</fieldset>
136 136
 			<p class="submit inline-edit-save">
137
-			 <button type="button" class="button cancel alignleft"><?php esc_html_e( 'Cancel' ); ?></button>
138
-			 <button type="button" class="button button-primary save alignright"><?php echo esc_html( $this->post_type_object->labels->add_new ); ?></button>
137
+			 <button type="button" class="button cancel alignleft"><?php esc_html_e('Cancel'); ?></button>
138
+			 <button type="button" class="button button-primary save alignright"><?php echo esc_html($this->post_type_object->labels->add_new); ?></button>
139 139
 			 <span class="spinner"></span>
140 140
 			 <span class="error" style="display:none"></span>
141 141
 			 <br class="clear" />
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 	 * @return void
155 155
 	 */
156 156
 	public function mass_interface_screen_option() {
157
-		add_action( 'admin_notices', array( $this, 'ajax_admin_notice' ) );
158
-		add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 );
159
-		$this->wp_list_table( $this->hook );
157
+		add_action('admin_notices', array($this, 'ajax_admin_notice'));
158
+		add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2);
159
+		$this->wp_list_table($this->hook);
160 160
 	}
161 161
 	/**
162 162
 	 * Instance WPS_Mass_List_Table.
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 * @param  string $screen Current screen.
166 166
 	 * @return WPS_Mass_List_Table Table class.
167 167
 	 */
168
-	public function wp_list_table( $screen ) {
169
-		if ( is_null( $this->wp_list_table ) ) {
170
-			$this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
171
-			include_once( WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php' );
168
+	public function wp_list_table($screen) {
169
+		if (is_null($this->wp_list_table)) {
170
+			$this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
171
+			include_once(WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php');
172 172
 			$this->wp_list_table = new WPS_Mass_List_Table(
173 173
 				array(
174 174
 					'screen' => $screen,
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 					'heading_list'       => $this->post_type_object->labels->items_list,
183 183
 				)
184 184
 			);
185
-			$class = sanitize_title( get_class() );
185
+			$class = sanitize_title(get_class());
186 186
 			$this->wp_list_table->screen->add_option(
187 187
 				'per_page', array(
188 188
 					'default' => 20,
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 * @param  WP_Screen $screen Current screen.
201 201
 	 * @return array Return of filter.
202 202
 	 */
203
-	public function hidden_columns( $hidden, $screen ) {
204
-		$wp_list_table = $this->wp_list_table( $this->hook );
205
-		if ( $screen === $wp_list_table->screen ) {
206
-			$hidden = array_diff( array_flip( $wp_list_table->get_columns() ), $this->default_show_columns );
203
+	public function hidden_columns($hidden, $screen) {
204
+		$wp_list_table = $this->wp_list_table($this->hook);
205
+		if ($screen === $wp_list_table->screen) {
206
+			$hidden = array_diff(array_flip($wp_list_table->get_columns()), $this->default_show_columns);
207 207
 			$hidden[] = 'thumbnail';
208 208
 		}
209 209
 		return $hidden;
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $option Actual option to save.
217 217
 	 * @param  mixed  $value  Actual value to save.
218 218
 	 */
219
-	public function set_screen_option( $string, $option, $value ) {
220
-		$class = sanitize_title( get_class() );
221
-		if ( "{$class}_per_page" === $option ) {
222
-			$value = (int) $value;
223
-			if ( $value < 1 || $value > 999 ) {
219
+	public function set_screen_option($string, $option, $value) {
220
+		$class = sanitize_title(get_class());
221
+		if ("{$class}_per_page" === $option) {
222
+			$value = (int)$value;
223
+			if ($value < 1 || $value > 999) {
224 224
 				$string = false;
225 225
 			}
226 226
 			return $value;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @return void Direct display.
235 235
 	 */
236 236
 	public function ajax_admin_notice() {
237
-		printf( '<div class="%1$s"><p></p></div>', esc_attr( 'hidden is-dismissible notice' ) );
237
+		printf('<div class="%1$s"><p></p></div>', esc_attr('hidden is-dismissible notice'));
238 238
 	}
239 239
 	/**
240 240
 	 * Enqueue scripts.
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
 	 * @return void
244 244
 	 */
245 245
 	public function scripts() {
246
-		wp_deregister_script( 'wpes_chosen_js' );
246
+		wp_deregister_script('wpes_chosen_js');
247 247
 		wp_enqueue_script(
248 248
 			'jquery_chosen_js',
249 249
 			WPS_PDCT_MASS_CHOSEN_JS . 'chosen.jquery.min.js',
250
-			array( 'jquery' ),
250
+			array('jquery'),
251 251
 			true
252 252
 		);
253 253
 		wp_enqueue_script(
254 254
 			'mass_interface3-ajax',
255 255
 			WPS_PDCT_MASS_JS . 'wps-mass-interface3.js',
256
-			array( 'jquery', 'jquery-form' ),
256
+			array('jquery', 'jquery-form'),
257 257
 			true
258 258
 		);
259 259
 		wp_enqueue_media();
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 	 * @return void
266 266
 	 */
267 267
 	public function styles() {
268
-		wp_register_style( 'jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css' );
269
-		wp_register_style( 'mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css' );
270
-		wp_enqueue_style( 'jquery_chosen_css' );
271
-		wp_enqueue_style( 'mass_interface3_css' );
272
-		wp_dequeue_style( 'wpshop_main_css' );
268
+		wp_register_style('jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css');
269
+		wp_register_style('mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css');
270
+		wp_enqueue_style('jquery_chosen_css');
271
+		wp_enqueue_style('mass_interface3_css');
272
+		wp_dequeue_style('wpshop_main_css');
273 273
 	}
274 274
 	/**
275 275
 	 * Change default url for set_url_scheme(). See pagination & get_views. Impossible to re-use set_url_sheme inner.
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @param  string        $url    Given url.
279 279
 	 * @param  string | null $scheme Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', 'relative', 'rest', 'rpc', or null.
280 280
 	 */
281
-	public function set_current_url( $url, $scheme ) {
281
+	public function set_current_url($url, $scheme) {
282 282
 		/*
283 283
 		Remove_filter( 'set_url_scheme', array( $this, 'set_current_url' ), 10 );
284 284
 		$url = set_url_sheme( esc_url( $_POST['current_url'] ) );
@@ -293,23 +293,23 @@  discard block
 block discarded – undo
293 293
 	 * @return void JSON with all elements to update.
294 294
 	 */
295 295
 	public function ajax_new() {
296
-		check_ajax_referer( 'add_post-' . sanitize_title( get_class() ) );
297
-		add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 );
298
-		add_filter( 'set_url_scheme', array( $this, 'set_current_url' ), 10, 2 );
299
-		$wp_list_table = $this->wp_list_table( sanitize_title( $_POST['hook'] ) );
296
+		check_ajax_referer('add_post-' . sanitize_title(get_class()));
297
+		add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2);
298
+		add_filter('set_url_scheme', array($this, 'set_current_url'), 10, 2);
299
+		$wp_list_table = $this->wp_list_table(sanitize_title($_POST['hook']));
300 300
 		$wpshop_product_attribute = array();
301
-		foreach ( $wp_list_table->request_items_columns() as $key_var => $var ) {
302
-			$wpshop_product_attribute[ $var['data'] ][ $key_var ] = null;
301
+		foreach ($wp_list_table->request_items_columns() as $key_var => $var) {
302
+			$wpshop_product_attribute[$var['data']][$key_var] = null;
303 303
 		}
304 304
 		$new_product_id = wp_insert_post(
305 305
 			array(
306 306
 				'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT,
307 307
 				'post_status' => 'publish',
308
-				'post_title' => sanitize_text_field( $_POST['title'] ),
308
+				'post_title' => sanitize_text_field($_POST['title']),
309 309
 			)
310 310
 		);
311
-		if ( ! empty( $new_product_id ) ) {
312
-			update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view );
311
+		if (!empty($new_product_id)) {
312
+			update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view);
313 313
 			$product_class = new wpshop_products();
314 314
 			$product_class->save_product_custom_informations(
315 315
 				$new_product_id, array(
@@ -321,30 +321,30 @@  discard block
 block discarded – undo
321 321
 				)
322 322
 			);
323 323
 		} else {
324
-			wp_die( 1 );
324
+			wp_die(1);
325 325
 		}
326
-		$data = $wp_list_table->request( $new_product_id );
327
-		$per_page = $wp_list_table->screen->get_option( 'per_page', 'option' );
326
+		$data = $wp_list_table->request($new_product_id);
327
+		$per_page = $wp_list_table->screen->get_option('per_page', 'option');
328 328
 		$wp_list_table->column_headers();
329 329
 		$wp_list_table->items = true;
330 330
 		ob_start();
331 331
 		$wp_list_table->views();
332 332
 		$subsubsub = ob_get_clean();
333 333
 		ob_start();
334
-		$wp_list_table->display_tablenav( 'top' );
334
+		$wp_list_table->display_tablenav('top');
335 335
 		$tablenav_top = ob_get_clean();
336 336
 		ob_start();
337
-		$wp_list_table->display_tablenav( 'bottom' );
337
+		$wp_list_table->display_tablenav('bottom');
338 338
 		$tablenav_bottom = ob_get_clean();
339 339
 		ob_start();
340
-		$wp_list_table->single_row( $data[0] );
341
-		wp_send_json_success( array(
340
+		$wp_list_table->single_row($data[0]);
341
+		wp_send_json_success(array(
342 342
 			'row' => ob_get_clean(),
343 343
 			'per_page' => $per_page,
344 344
 			'tablenav_top' => $tablenav_top,
345 345
 			'tablenav_bottom' => $tablenav_bottom,
346 346
 			'subsubsub' => $subsubsub,
347
-		) );
347
+		));
348 348
 	}
349 349
 	/**
350 350
 	 * Ajax callback for save selected elements.
@@ -353,22 +353,22 @@  discard block
 block discarded – undo
353 353
 	 * @return void JSON with number of saved elements (not used).
354 354
 	 */
355 355
 	public function ajax_save() {
356
-		check_ajax_referer( 'bulk-save-mass-edit-interface-3' );
356
+		check_ajax_referer('bulk-save-mass-edit-interface-3');
357 357
 		$i = 0;
358 358
 		$product_class = new wpshop_products();
359
-		if ( ! empty( $_REQUEST['cb'] ) ) {
360
-			foreach ( $_REQUEST['cb'] as $id ) {
361
-				$id = intval( $id );
362
-				if ( isset( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) ) {
363
-					intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] );
364
-					update_post_meta( $id, '_thumbnail_id', intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) );
365
-					unset( $_REQUEST[ 'row_' . $id ]['thumbnail'] );
359
+		if (!empty($_REQUEST['cb'])) {
360
+			foreach ($_REQUEST['cb'] as $id) {
361
+				$id = intval($id);
362
+				if (isset($_REQUEST['row_' . $id]['thumbnail'])) {
363
+					intval($_REQUEST['row_' . $id]['thumbnail']);
364
+					update_post_meta($id, '_thumbnail_id', intval($_REQUEST['row_' . $id]['thumbnail']));
365
+					unset($_REQUEST['row_' . $id]['thumbnail']);
366 366
 				}
367
-				if ( ! empty( $_REQUEST[ 'row_' . $id ] ) ) {
367
+				if (!empty($_REQUEST['row_' . $id])) {
368 368
 					$product_class->save_product_custom_informations(
369 369
 						$id,
370 370
 						array_merge(
371
-							$_REQUEST[ 'row_' . $id ],
371
+							$_REQUEST['row_' . $id],
372 372
 							array(
373 373
 								'post_ID' => $id,
374 374
 								'product_id' => $id,
Please login to merge, or discard this patch.