Completed
Pull Request — master (#2)
by Jimmy
1003:35 queued 970:52
created
includes/modules/wps_shipping/controller/wps_shipping_mode_ajax_actions.php 2 patches
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_shipping_mode_ajax_actions {
3 3
 
4 4
 	function __construct() {
5 5
 		/** Ajax Actions **/
6
-		add_action('wp_ajax_save_shipping_rule',array( $this, 'wpshop_ajax_save_shipping_rule'));
7
-		add_action('wp_ajax_display_shipping_rules',array( $this, 'wpshop_ajax_display_shipping_rules'));
8
-		add_action('wp_ajax_delete_shipping_rule',array( $this, 'wpshop_ajax_delete_shipping_rule'));
9
-		add_action('wp_ajax_wps_add_new_shipping_mode',array( $this, 'wps_add_new_shipping_mode'));
10
-		add_action('wp_ajax_wps_reload_shipping_mode',array( $this, 'wps_reload_shipping_mode'));
11
-		add_action('wp_ajax_wps_calculate_shipping_cost',array( $this, 'wps_calculate_shipping_cost'));
12
-		add_action( 'wp_ajax_wps_load_shipping_methods', array(&$this, 'wps_load_shipping_methods') );
6
+		add_action('wp_ajax_save_shipping_rule', array($this, 'wpshop_ajax_save_shipping_rule'));
7
+		add_action('wp_ajax_display_shipping_rules', array($this, 'wpshop_ajax_display_shipping_rules'));
8
+		add_action('wp_ajax_delete_shipping_rule', array($this, 'wpshop_ajax_delete_shipping_rule'));
9
+		add_action('wp_ajax_wps_add_new_shipping_mode', array($this, 'wps_add_new_shipping_mode'));
10
+		add_action('wp_ajax_wps_reload_shipping_mode', array($this, 'wps_reload_shipping_mode'));
11
+		add_action('wp_ajax_wps_calculate_shipping_cost', array($this, 'wps_calculate_shipping_cost'));
12
+		add_action('wp_ajax_wps_load_shipping_methods', array(&$this, 'wps_load_shipping_methods'));
13 13
 	}
14 14
 
15 15
 	/**
16 16
 	 * AJAX - Save custom Rules
17 17
 	 **/
18
-	function wpshop_ajax_save_shipping_rule(){
19
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
18
+	function wpshop_ajax_save_shipping_rule() {
19
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
20 20
 
21
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_shipping_rule' ) )
21
+		if (!wp_verify_nonce($_wpnonce, 'wpshop_ajax_save_shipping_rule'))
22 22
 			wp_die();
23 23
 
24 24
 		global $wpdb;
25 25
 		$wps_shipping = new wps_shipping();
26 26
 		$status = false;
27 27
 		$reponse = array();
28
-		$fees_data = ( !empty($_POST['fees_data']) ) ?  sanitize_text_field( $_POST['fees_data'] ) : null;
29
-		$weight_rule = ( !empty($_POST['weight_rule']) ) ? wpshop_tools::varSanitizer( $_POST['weight_rule'] ) : null;
30
-		$shipping_price = ( !empty($_POST['shipping_price']) ) ? wpshop_tools::varSanitizer( $_POST['shipping_price'] ) : 0;
31
-		$selected_country = ( !empty($_POST['selected_country']) ) ? wpshop_tools::varSanitizer( $_POST['selected_country'] ) : null;
32
-		$shipping_rules = $wps_shipping->shipping_fees_string_2_array( stripslashes($fees_data) );
28
+		$fees_data = (!empty($_POST['fees_data'])) ? sanitize_text_field($_POST['fees_data']) : null;
29
+		$weight_rule = (!empty($_POST['weight_rule'])) ? wpshop_tools::varSanitizer($_POST['weight_rule']) : null;
30
+		$shipping_price = (!empty($_POST['shipping_price'])) ? wpshop_tools::varSanitizer($_POST['shipping_price']) : 0;
31
+		$selected_country = (!empty($_POST['selected_country'])) ? wpshop_tools::varSanitizer($_POST['selected_country']) : null;
32
+		$shipping_rules = $wps_shipping->shipping_fees_string_2_array(stripslashes($fees_data));
33 33
 
34
-		$weight_defaut_unity_option = get_option ('wpshop_shop_default_weight_unity');
35
-		$query = $wpdb->prepare('SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
36
-		$unity = $wpdb->get_var( $query );
34
+		$weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity');
35
+		$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
36
+		$unity = $wpdb->get_var($query);
37 37
 
38
-		$weight_rule = ( !empty($unity) && $unity == 'kg' ) ? $weight_rule * 1000 : $weight_rule;
38
+		$weight_rule = (!empty($unity) && $unity == 'kg') ? $weight_rule * 1000 : $weight_rule;
39 39
 		//Check if this shipping rule (same country and same weight) already exist in the shipping rules definition
40
-		if( !empty($shipping_rules) ) {
40
+		if (!empty($shipping_rules)) {
41 41
 			$existing_country = false;
42 42
 			$tab_key = -1;
43
-			foreach ( $shipping_rules as $key=>$shipping_rule) {
44
-				if ( $shipping_rule['destination'] == $selected_country) {
43
+			foreach ($shipping_rules as $key=>$shipping_rule) {
44
+				if ($shipping_rule['destination'] == $selected_country) {
45 45
 					$existing_country = true;
46 46
 					$tab_key = $key;
47 47
 				}
48 48
 			}
49
-			if ( $existing_country && $tab_key > -1) {
49
+			if ($existing_country && $tab_key > -1) {
50 50
 				$shipping_rules[$tab_key]['fees'][$weight_rule] = $shipping_price;
51 51
 			}
52 52
 			else {
53
-				$shipping_rules[] = array( 'destination' => $selected_country, 'rule' => 'weight', 'fees' => array($weight_rule => $shipping_price) );
53
+				$shipping_rules[] = array('destination' => $selected_country, 'rule' => 'weight', 'fees' => array($weight_rule => $shipping_price));
54 54
 			}
55 55
 			$status = true;
56 56
 		}
57 57
 		else {
58
-			$shipping_rules = array( '0' => array('destination' => $selected_country, 'rule' => 'weight', 'fees' => array( $weight_rule => $shipping_price)) );
58
+			$shipping_rules = array('0' => array('destination' => $selected_country, 'rule' => 'weight', 'fees' => array($weight_rule => $shipping_price)));
59 59
 			$status = true;
60 60
 		}
61
-		$reponse = array('status' => $status, 'reponse' => $wps_shipping->shipping_fees_array_2_string( $shipping_rules ) );
61
+		$reponse = array('status' => $status, 'reponse' => $wps_shipping->shipping_fees_array_2_string($shipping_rules));
62 62
 		echo json_encode($reponse);
63 63
 		die();
64 64
 	}
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
 	 * AJAX - Delete Custom shipping Rule
68 68
 	 */
69 69
 	function wpshop_ajax_delete_shipping_rule() {
70
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
70
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
71 71
 
72
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_shipping_rule' ) )
72
+		if (!wp_verify_nonce($_wpnonce, 'wpshop_ajax_delete_shipping_rule'))
73 73
 			wp_die();
74 74
 
75 75
 		global $wpdb;
76 76
 		$wps_shipping = new wps_shipping();
77
-		$fees_data = ( !empty($_POST['fees_data']) ) ? sanitize_text_field( $_POST['fees_data'] ) : null;
78
-		$country_and_weight =  ( !empty($_POST['country_and_weight']) ) ? (int) $_POST['country_and_weight'] : null;
77
+		$fees_data = (!empty($_POST['fees_data'])) ? sanitize_text_field($_POST['fees_data']) : null;
78
+		$country_and_weight = (!empty($_POST['country_and_weight'])) ? (int)$_POST['country_and_weight'] : null;
79 79
 		$datas = explode("|", $country_and_weight);
80 80
 		$country = $datas[0];
81 81
 		$weight = $datas[1];
82 82
 		$shipping_mode_id = $datas[2];
83 83
 
84
-		$shipping_rules = $wps_shipping->shipping_fees_string_2_array( stripslashes($fees_data) );
84
+		$shipping_rules = $wps_shipping->shipping_fees_string_2_array(stripslashes($fees_data));
85 85
 
86 86
 		/** Check the default weight unity **/
87 87
 // 		$weight_unity_id = get_option('wpshop_shop_default_weight_unity');
@@ -94,30 +94,30 @@  discard block
 block discarded – undo
94 94
 // 			}
95 95
 // 		}
96 96
 
97
-		if ( array_key_exists($country, $shipping_rules) ) {
98
-			if ( array_key_exists((string)$weight, $shipping_rules[$country]['fees']) ) {
97
+		if (array_key_exists($country, $shipping_rules)) {
98
+			if (array_key_exists((string)$weight, $shipping_rules[$country]['fees'])) {
99 99
 				unset($shipping_rules[$country]['fees'][$weight]);
100 100
 			}
101
-			if ( empty($shipping_rules[$country]['fees']) ) {
101
+			if (empty($shipping_rules[$country]['fees'])) {
102 102
 				unset($shipping_rules[$country]);
103 103
 			}
104 104
 
105 105
 		}
106
-		foreach ( $shipping_rules as $k=>$shipping_rule ) {
107
-			if ( !isset($shipping_rule['fees']) ) {
106
+		foreach ($shipping_rules as $k=>$shipping_rule) {
107
+			if (!isset($shipping_rule['fees'])) {
108 108
 				unset($shipping_rules[$k]);
109 109
 			}
110 110
 		}
111 111
 
112 112
 		$status = true;
113 113
 
114
-		if ( !empty($shipping_rules) ) {
115
-			$rules = $wps_shipping->shipping_fees_array_2_string( $shipping_rules );
114
+		if (!empty($shipping_rules)) {
115
+			$rules = $wps_shipping->shipping_fees_array_2_string($shipping_rules);
116 116
 		}
117 117
 		else {
118 118
 			$rules = '';
119 119
 		}
120
-		$reponse = array('status' => $status, 'reponse' => $rules );
120
+		$reponse = array('status' => $status, 'reponse' => $rules);
121 121
 		echo json_encode($reponse);
122 122
 		die();
123 123
 	}
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 	/**
126 126
 	 * AJAX - Display Created custom shipping rules
127 127
 	 */
128
-	function wpshop_ajax_display_shipping_rules () {
129
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
128
+	function wpshop_ajax_display_shipping_rules() {
129
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
130 130
 
131
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_display_shipping_rules' ) )
131
+		if (!wp_verify_nonce($_wpnonce, 'wpshop_ajax_display_shipping_rules'))
132 132
 			wp_die();
133 133
 
134 134
 		$status = false;
135
-		$fees_data = ( !empty($_POST['fees_data']) ) ? sanitize_text_field( $_POST['fees_data'] ) : null;
136
-		$shipping_mode_id = ( !empty($_POST['shipping_mode_id']) ) ? (int) $_POST['shipping_mode_id'] : null;
135
+		$fees_data = (!empty($_POST['fees_data'])) ? sanitize_text_field($_POST['fees_data']) : null;
136
+		$shipping_mode_id = (!empty($_POST['shipping_mode_id'])) ? (int)$_POST['shipping_mode_id'] : null;
137 137
 		$result = '';
138
-		if( !empty($fees_data) ) {
138
+		if (!empty($fees_data)) {
139 139
 			$wps_shipping_mode_ctr = new wps_shipping_mode_ctr();
140
-			$result = $wps_shipping_mode_ctr->generate_shipping_rules_table( $fees_data, $shipping_mode_id );
140
+			$result = $wps_shipping_mode_ctr->generate_shipping_rules_table($fees_data, $shipping_mode_id);
141 141
 			$status = true;
142 142
 		}
143 143
 		else {
@@ -155,38 +155,38 @@  discard block
 block discarded – undo
155 155
 	 * AJAX - Reload shippig mode interface
156 156
 	 */
157 157
 	function wps_reload_shipping_mode() {
158
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
158
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
159 159
 
160
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_shipping_mode' ) )
160
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_shipping_mode'))
161 161
 			wp_die();
162 162
 
163 163
 		$status = false; $allow_order = true;
164 164
 		$result = '';
165
-		$address_id = !empty( $_POST['address_id'] ) ? (int) $_POST['address_id'] : 0;
166
-		if ( !empty($address_id) ) {
165
+		$address_id = !empty($_POST['address_id']) ? (int)$_POST['address_id'] : 0;
166
+		if (!empty($address_id)) {
167 167
 			$_SESSION['shipping_address'] = $address_id;
168 168
 		}
169
-		$shipping_address_id = ( !empty($_SESSION['shipping_address']) ) ? $_SESSION['shipping_address'] : '';
170
-		if ( !empty($shipping_address_id) ) {
169
+		$shipping_address_id = (!empty($_SESSION['shipping_address'])) ? $_SESSION['shipping_address'] : '';
170
+		if (!empty($shipping_address_id)) {
171 171
 			//$result = self::generate_shipping_mode_for_an_address();
172 172
 			$wps_shipping_mode_ctr = new wps_shipping_mode_ctr();
173 173
 // 			$shipping_modes = $wps_shipping_mode_ctr->generate_shipping_mode_for_an_address( intval($_POST['address_id']) );
174 174
 
175 175
 			$status = $allow_order = $shipping_modes[0];
176
-			if( empty( $shipping_modes[0]) || $shipping_modes[0] == false ) {
176
+			if (empty($shipping_modes[0]) || $shipping_modes[0] == false) {
177 177
 				$status = false;
178 178
 			}
179 179
 
180 180
 			$result = $shipping_modes[1];
181 181
 
182
-			if ( $status == false ) {
182
+			if ($status == false) {
183 183
 				$allow_order = false;
184
-				$result = '<div class="error_bloc">' .__('Sorry ! You can\'t order on this shop, because we don\'t ship in your country.', 'wpshop' ). '</div>';
184
+				$result = '<div class="error_bloc">' . __('Sorry ! You can\'t order on this shop, because we don\'t ship in your country.', 'wpshop') . '</div>';
185 185
 			}
186 186
 
187 187
 		}
188
-		$response = array('status' => $status, 'response' => $result, 'allow_order' => $allow_order );
189
-		echo json_encode( $response );
188
+		$response = array('status' => $status, 'response' => $result, 'allow_order' => $allow_order);
189
+		echo json_encode($response);
190 190
 		die();
191 191
 	}
192 192
 
@@ -194,26 +194,26 @@  discard block
 block discarded – undo
194 194
 	 * AJAX - Calculate Shipping cost
195 195
 	 */
196 196
 	function wps_calculate_shipping_cost() {
197
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
197
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
198 198
 
199
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_calculate_shipping_cost' ) )
199
+		if (!wp_verify_nonce($_wpnonce, 'wps_calculate_shipping_cost'))
200 200
 			wp_die();
201 201
 
202 202
 		$status = false;
203 203
 		$result = '';
204 204
 		$chosen_method = !empty($_POST['chosen_method']) ? wpshop_tools::varSanitizer($_POST['chosen_method']) : null;
205 205
 
206
-		if( !empty($chosen_method) ) {
206
+		if (!empty($chosen_method)) {
207 207
 			$_SESSION['shipping_method'] = $chosen_method;
208 208
 			$wps_cart = new wps_cart();
209
-			$order = $wps_cart->calcul_cart_information( array() );
209
+			$order = $wps_cart->calcul_cart_information(array());
210 210
 			$wps_cart->store_cart_in_session($order);
211 211
 
212 212
 			$status = true;
213 213
 		}
214 214
 
215
-		$response = array('status' => $status );
216
-		echo json_encode( $response );
215
+		$response = array('status' => $status);
216
+		echo json_encode($response);
217 217
 		die();
218 218
 	}
219 219
 
@@ -221,71 +221,71 @@  discard block
 block discarded – undo
221 221
 	 * AJAX - (New checkout Tunnel ) Load available shipping modes
222 222
 	 */
223 223
 	function wps_load_shipping_methods() {
224
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
224
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
225 225
 
226
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_load_shipping_methods' ) )
226
+		if (!wp_verify_nonce($_wpnonce, 'wps_load_shipping_methods'))
227 227
 			wp_die();
228 228
 
229 229
 		$status = true; $response = '';
230
-		$shipping_address_id = ( !empty($_POST['shipping_address']) ) ? intval( $_POST['shipping_address'] ) : null;
231
-		if ( !empty($shipping_address_id) ) {
230
+		$shipping_address_id = (!empty($_POST['shipping_address'])) ? intval($_POST['shipping_address']) : null;
231
+		if (!empty($shipping_address_id)) {
232 232
 			// Check if element is an address
233 233
 			$check_address_type = get_post($shipping_address_id);
234
-			if ( !empty($check_address_type) && $check_address_type->post_author == get_current_user_id() && $check_address_type->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) {
234
+			if (!empty($check_address_type) && $check_address_type->post_author == get_current_user_id() && $check_address_type->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) {
235 235
 				// Get address metadatas
236
-				$address_metadata = get_post_meta( $shipping_address_id, '_wpshop_address_metadata', true );
237
-				if( !empty($address_metadata) && !empty($address_metadata['country']) ) {
236
+				$address_metadata = get_post_meta($shipping_address_id, '_wpshop_address_metadata', true);
237
+				if (!empty($address_metadata) && !empty($address_metadata['country'])) {
238 238
 					$country = $address_metadata['country'];
239 239
 					$postcode = $address_metadata['postcode'];
240
-					$shipping_methods = get_option( 'wps_shipping_mode' );
240
+					$shipping_methods = get_option('wps_shipping_mode');
241 241
 					$available_shipping_methods = array();
242
-					if( !empty($shipping_methods) && !empty($shipping_methods['modes']) ) {
242
+					if (!empty($shipping_methods) && !empty($shipping_methods['modes'])) {
243 243
 						// Check all shipping methods
244
-						foreach( $shipping_methods['modes'] as $shipping_method_id => $shipping_method ){
245
-							if ( empty($shipping_method['limit_destination']) || ( empty($shipping_method['limit_destination']['country']) || ( !empty($shipping_method['limit_destination']['country']) && in_array($country, $shipping_method['limit_destination']['country']) ) ) ) {
246
-								$available_shipping_methods[ $shipping_method_id ] = $shipping_method;
244
+						foreach ($shipping_methods['modes'] as $shipping_method_id => $shipping_method) {
245
+							if (empty($shipping_method['limit_destination']) || (empty($shipping_method['limit_destination']['country']) || (!empty($shipping_method['limit_destination']['country']) && in_array($country, $shipping_method['limit_destination']['country'])))) {
246
+								$available_shipping_methods[$shipping_method_id] = $shipping_method;
247 247
 							}
248 248
 						}
249
-						if( !empty($available_shipping_methods) ) {
250
-							foreach( $available_shipping_methods as $shipping_mode_id => $shipping_mode ) {
249
+						if (!empty($available_shipping_methods)) {
250
+							foreach ($available_shipping_methods as $shipping_mode_id => $shipping_mode) {
251 251
 								ob_start();
252
-								require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, WPS_SHIPPING_MODE_PATH . WPS_SHIPPING_MODE_DIR . "/templates/","frontend", "shipping-mode", "element") );
252
+								require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, WPS_SHIPPING_MODE_PATH . WPS_SHIPPING_MODE_DIR . "/templates/", "frontend", "shipping-mode", "element"));
253 253
 								$response .= ob_get_contents();
254 254
 								ob_end_clean();
255 255
 
256 256
 							}
257 257
 						}
258 258
 						else {
259
-							$response = '<div class="wps-alert-error">' .__( 'No shipping method available for your shipping address', 'wpshop' ). '</div>';
259
+							$response = '<div class="wps-alert-error">' . __('No shipping method available for your shipping address', 'wpshop') . '</div>';
260 260
 						}
261 261
 
262 262
 					}
263 263
 					else {
264
-						$response = '<div class="wps-alert-info">' .__( 'No shipping method available', 'wpshop' ). '</div>';
264
+						$response = '<div class="wps-alert-info">' . __('No shipping method available', 'wpshop') . '</div>';
265 265
 					}
266 266
 				}
267 267
 			}
268 268
 		}
269 269
 		else {
270
-			$response = '<div class="wps-alert-info">' .__( 'Please select a shipping address to choose a shipping method', 'wpshop' ). '</div>';
270
+			$response = '<div class="wps-alert-info">' . __('Please select a shipping address to choose a shipping method', 'wpshop') . '</div>';
271 271
 		}
272
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
272
+		echo json_encode(array('status' => $status, 'response' => $response));
273 273
 		die();
274 274
 	}
275 275
 
276 276
 
277 277
 	function wps_add_new_shipping_mode() {
278
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
278
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
279 279
 
280
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_add_new_shipping_mode' ) )
280
+		if (!wp_verify_nonce($_wpnonce, 'wps_add_new_shipping_mode'))
281 281
 			wp_die();
282 282
 
283 283
 		$status = false; $reponse = '';
284 284
 
285
-		$k = 'wps_custom_shipping_mode_'.time();
285
+		$k = 'wps_custom_shipping_mode_' . time();
286 286
 		$shipping_mode = array();
287 287
 		ob_start();
288
-		require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, WPS_SHIPPING_MODE_PATH . WPS_SHIPPING_MODE_DIR . "/templates/", "backend", "shipping-mode") );
288
+		require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, WPS_SHIPPING_MODE_PATH . WPS_SHIPPING_MODE_DIR . "/templates/", "backend", "shipping-mode"));
289 289
 		$response .= ob_get_contents();
290 290
 		ob_end_clean();
291 291
 
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 		jQuery("select.chosen_select").chosen( WPSHOP_CHOSEN_ATTRS );
294 294
 	} );</script>';
295 295
 
296
-		$status = ( !empty($response) ) ? true : false;
296
+		$status = (!empty($response)) ? true : false;
297 297
 
298
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
298
+		echo json_encode(array('status' => $status, 'response' => $response));
299 299
 		wp_die();
300 300
 	}
301 301
 }
Please login to merge, or discard this patch.
Braces   +31 added lines, -29 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
 class wps_shipping_mode_ajax_actions {
3 5
 
4 6
 	function __construct() {
@@ -18,8 +20,9 @@  discard block
 block discarded – undo
18 20
 	function wpshop_ajax_save_shipping_rule(){
19 21
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
20 22
 
21
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_shipping_rule' ) )
22
-			wp_die();
23
+		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_shipping_rule' ) ) {
24
+					wp_die();
25
+		}
23 26
 
24 27
 		global $wpdb;
25 28
 		$wps_shipping = new wps_shipping();
@@ -48,13 +51,11 @@  discard block
 block discarded – undo
48 51
 			}
49 52
 			if ( $existing_country && $tab_key > -1) {
50 53
 				$shipping_rules[$tab_key]['fees'][$weight_rule] = $shipping_price;
51
-			}
52
-			else {
54
+			} else {
53 55
 				$shipping_rules[] = array( 'destination' => $selected_country, 'rule' => 'weight', 'fees' => array($weight_rule => $shipping_price) );
54 56
 			}
55 57
 			$status = true;
56
-		}
57
-		else {
58
+		} else {
58 59
 			$shipping_rules = array( '0' => array('destination' => $selected_country, 'rule' => 'weight', 'fees' => array( $weight_rule => $shipping_price)) );
59 60
 			$status = true;
60 61
 		}
@@ -69,8 +70,9 @@  discard block
 block discarded – undo
69 70
 	function wpshop_ajax_delete_shipping_rule() {
70 71
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
71 72
 
72
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_shipping_rule' ) )
73
-			wp_die();
73
+		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_shipping_rule' ) ) {
74
+					wp_die();
75
+		}
74 76
 
75 77
 		global $wpdb;
76 78
 		$wps_shipping = new wps_shipping();
@@ -113,8 +115,7 @@  discard block
 block discarded – undo
113 115
 
114 116
 		if ( !empty($shipping_rules) ) {
115 117
 			$rules = $wps_shipping->shipping_fees_array_2_string( $shipping_rules );
116
-		}
117
-		else {
118
+		} else {
118 119
 			$rules = '';
119 120
 		}
120 121
 		$reponse = array('status' => $status, 'reponse' => $rules );
@@ -128,8 +129,9 @@  discard block
 block discarded – undo
128 129
 	function wpshop_ajax_display_shipping_rules () {
129 130
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
130 131
 
131
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_display_shipping_rules' ) )
132
-			wp_die();
132
+		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_display_shipping_rules' ) ) {
133
+					wp_die();
134
+		}
133 135
 
134 136
 		$status = false;
135 137
 		$fees_data = ( !empty($_POST['fees_data']) ) ? sanitize_text_field( $_POST['fees_data'] ) : null;
@@ -139,8 +141,7 @@  discard block
 block discarded – undo
139 141
 			$wps_shipping_mode_ctr = new wps_shipping_mode_ctr();
140 142
 			$result = $wps_shipping_mode_ctr->generate_shipping_rules_table( $fees_data, $shipping_mode_id );
141 143
 			$status = true;
142
-		}
143
-		else {
144
+		} else {
144 145
 			$status = true;
145 146
 			$result = __('No shipping rules are created', 'wpshop');
146 147
 		}
@@ -157,8 +158,9 @@  discard block
 block discarded – undo
157 158
 	function wps_reload_shipping_mode() {
158 159
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
159 160
 
160
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_shipping_mode' ) )
161
-			wp_die();
161
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_shipping_mode' ) ) {
162
+					wp_die();
163
+		}
162 164
 
163 165
 		$status = false; $allow_order = true;
164 166
 		$result = '';
@@ -196,8 +198,9 @@  discard block
 block discarded – undo
196 198
 	function wps_calculate_shipping_cost() {
197 199
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
198 200
 
199
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_calculate_shipping_cost' ) )
200
-			wp_die();
201
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_calculate_shipping_cost' ) ) {
202
+					wp_die();
203
+		}
201 204
 
202 205
 		$status = false;
203 206
 		$result = '';
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 	function wps_load_shipping_methods() {
224 227
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
225 228
 
226
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_load_shipping_methods' ) )
227
-			wp_die();
229
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_load_shipping_methods' ) ) {
230
+					wp_die();
231
+		}
228 232
 
229 233
 		$status = true; $response = '';
230 234
 		$shipping_address_id = ( !empty($_POST['shipping_address']) ) ? intval( $_POST['shipping_address'] ) : null;
@@ -254,19 +258,16 @@  discard block
 block discarded – undo
254 258
 								ob_end_clean();
255 259
 
256 260
 							}
257
-						}
258
-						else {
261
+						} else {
259 262
 							$response = '<div class="wps-alert-error">' .__( 'No shipping method available for your shipping address', 'wpshop' ). '</div>';
260 263
 						}
261 264
 
262
-					}
263
-					else {
265
+					} else {
264 266
 						$response = '<div class="wps-alert-info">' .__( 'No shipping method available', 'wpshop' ). '</div>';
265 267
 					}
266 268
 				}
267 269
 			}
268
-		}
269
-		else {
270
+		} else {
270 271
 			$response = '<div class="wps-alert-info">' .__( 'Please select a shipping address to choose a shipping method', 'wpshop' ). '</div>';
271 272
 		}
272 273
 		echo json_encode( array( 'status' => $status, 'response' => $response) );
@@ -277,8 +278,9 @@  discard block
 block discarded – undo
277 278
 	function wps_add_new_shipping_mode() {
278 279
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
279 280
 
280
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_add_new_shipping_mode' ) )
281
-			wp_die();
281
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_add_new_shipping_mode' ) ) {
282
+					wp_die();
283
+		}
282 284
 
283 285
 		$status = false; $reponse = '';
284 286
 
Please login to merge, or discard this patch.
includes/modules/wps_help/controller/wps_help_bubble_ctr.php 2 patches
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for wpshop help
4 4
  *
@@ -19,54 +19,54 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		/**	Call style for administration	*/
22
-		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_css' ) );
22
+		add_action('admin_enqueue_scripts', array(&$this, 'admin_css'));
23 23
 
24 24
 		/**	Include the different javascript	*/
25
-		add_action( 'admin_init', array(&$this, 'admin_js') );
25
+		add_action('admin_init', array(&$this, 'admin_js'));
26 26
 
27 27
 		/**	Add the scripts into admin footer for future use	*/
28
-		add_action( 'admin_print_footer_scripts', array( &$this, 'wps_dashboard_help') );
28
+		add_action('admin_print_footer_scripts', array(&$this, 'wps_dashboard_help'));
29 29
 
30 30
 		/** Ajax actions **/
31
-		add_action( 'wp_ajax_close_wps_help_window', array( &$this, 'wps_ajax_close_wps_help_window' ) );
31
+		add_action('wp_ajax_close_wps_help_window', array(&$this, 'wps_ajax_close_wps_help_window'));
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * Include stylesheets
36 36
 	 */
37 37
 	function admin_css() {
38
-		wp_enqueue_style( 'wp-pointer' );
38
+		wp_enqueue_style('wp-pointer');
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * Load the different javascript librairies
43 43
 	 */
44 44
 	function admin_js() {
45
-		wp_enqueue_script( 'wp-pointer' );
45
+		wp_enqueue_script('wp-pointer');
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * AJAX - Save into current user meta the different help that have to be closed next time the user will be logged in
50 50
 	 */
51 51
 	function wps_ajax_close_wps_help_window() {
52
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
52
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
53 53
 
54
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) )
54
+		if (!wp_verify_nonce($_wpnonce, 'wps_ajax_close_wps_help_window'))
55 55
 			wp_die();
56 56
 
57 57
 		$status = false;
58 58
 		$result = '';
59
-		$pointer_id = !empty( $_POST['pointer_id']) ? wpshop_tools::varSanitizer( $_POST['pointer_id'] ) : '';
60
-		if ( !empty($pointer_id) ) {
61
-			$seen_help_windows = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
62
-			$seen_help_windows[ $pointer_id ] = true;
59
+		$pointer_id = !empty($_POST['pointer_id']) ? wpshop_tools::varSanitizer($_POST['pointer_id']) : '';
60
+		if (!empty($pointer_id)) {
61
+			$seen_help_windows = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
62
+			$seen_help_windows[$pointer_id] = true;
63 63
 
64
-			update_user_meta( get_current_user_id(), '_wps_closed_help', $seen_help_windows);
64
+			update_user_meta(get_current_user_id(), '_wps_closed_help', $seen_help_windows);
65 65
 			$status = true;
66 66
 		}
67 67
 
68
-		$response = array( 'status' => $status, 'response' => $result );
69
-		wp_die( json_encode( $response ) );
68
+		$response = array('status' => $status, 'response' => $result);
69
+		wp_die(json_encode($response));
70 70
 	}
71 71
 
72 72
 	/**
@@ -79,118 +79,118 @@  discard block
 block discarded – undo
79 79
 		/**	Get current screen in order to load messages only in required pages	*/
80 80
 		$current_screen = get_current_screen();
81 81
 		$current_screen->id = 'disable';
82
-		switch ( $current_screen->id ) {
82
+		switch ($current_screen->id) {
83 83
 			case 'toplevel_page_wpshop_dashboard':
84
-				$help_cases[ 'download_newsletter_contacts' ]		= array( 'edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts' );
84
+				$help_cases['download_newsletter_contacts'] = array('edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts');
85 85
 			break;
86 86
 
87 87
 			case 'wpshop_product':
88
-				$help_cases[ 'product_page_categories' ] 			= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
89
-				$help_cases[ 'product_datas_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
90
-				$help_cases[ 'product_display_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab' );
91
-				$help_cases[ 'product_variations' ] 				= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button' );
92
-				$help_cases[ 'product_variations_configuration' ] 	= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button' );
93
-				$help_cases[ 'add_product_automaticly_to_cart' ] 	= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options' );
88
+				$help_cases['product_page_categories'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
89
+				$help_cases['product_datas_configuration'] = array('edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
90
+				$help_cases['product_display_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab');
91
+				$help_cases['product_variations'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button');
92
+				$help_cases['product_variations_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button');
93
+				$help_cases['add_product_automaticly_to_cart'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options');
94 94
 			break;
95 95
 
96 96
 			case 'edit-wpshop_product_category':
97
-				$help_cases[ 'category_filterable_attributes' ] 	= array( 'edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container' );
98
-				$help_cases[ 'category_picture' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload' );
97
+				$help_cases['category_filterable_attributes'] = array('edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container');
98
+				$help_cases['category_picture'] = array('edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload');
99 99
 			break;
100 100
 
101 101
 			case 'wpshop_shop_order':
102
-				$help_cases[ 'order_customer_comment' ] 			= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment' );
103
-				$help_cases[ 'order_notification_message' ] 		= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments' );
104
-				$help_cases[ 'order_shipping_box' ] 				= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping' );
102
+				$help_cases['order_customer_comment'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment');
103
+				$help_cases['order_notification_message'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments');
104
+				$help_cases['order_shipping_box'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping');
105 105
 			break;
106 106
 
107 107
 			case 'wpshop_shop_message':
108
-				$help_cases[ 'message_historic' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo' );
108
+				$help_cases['message_historic'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo');
109 109
 			break;
110 110
 
111 111
 			case 'settings_page_wpshop_option':
112
-				$help_cases[ 'options_payment_part' ] 				= array ('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container' );
112
+				$help_cases['options_payment_part'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container');
113 113
 			break;
114 114
 		}
115 115
 
116
-		if ( !empty( $help_cases ) ) {
116
+		if (!empty($help_cases)) {
117 117
 			/** Get help data seen by user **/
118
-			$closed_help_window = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
118
+			$closed_help_window = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
119 119
 
120 120
 			/**	Read the different help cases	*/
121
-			foreach( $help_cases as $help_id => $help_case ) {
122
-				if ( empty( $closed_help_window ) || ( !empty( $closed_help_window ) && !array_key_exists( $help_id, $closed_help_window ) ) ){
123
-					switch( $help_id ) {
121
+			foreach ($help_cases as $help_id => $help_case) {
122
+				if (empty($closed_help_window) || (!empty($closed_help_window) && !array_key_exists($help_id, $closed_help_window))) {
123
+					switch ($help_id) {
124 124
 						case 'download_newsletter_contacts' :
125
-							$pointer_content  = '<h3>' .__( 'Customers information download', 'wpshop'). '</h3>';
126
-							$pointer_content .= '<p>' .__( 'You can download emails of customers who accept to receive your commercials offers or your partners commercials offers by newsletter', 'wpshop'). '</p>';
125
+							$pointer_content  = '<h3>' . __('Customers information download', 'wpshop') . '</h3>';
126
+							$pointer_content .= '<p>' . __('You can download emails of customers who accept to receive your commercials offers or your partners commercials offers by newsletter', 'wpshop') . '</p>';
127 127
 							break;
128 128
 
129 129
 						case 'product_page_categories' :
130
-							$pointer_content  = '<h3>' .__( 'WPShop Categories', 'wpshop'). '</h3>';
131
-							$pointer_content .= '<p>' .__( 'You can classify your products by category.', 'wpshop'). '<br/></p>';
132
-							$pointer_content .= '<p><a href="' .admin_url('edit-tags.php?taxonomy=wpshop_product_category&post_type=wpshop_product'). '" class="button-primary" target="_blank">' .__('Create my WPShop categories', 'wpshop' ). '</a></p>';
130
+							$pointer_content  = '<h3>' . __('WPShop Categories', 'wpshop') . '</h3>';
131
+							$pointer_content .= '<p>' . __('You can classify your products by category.', 'wpshop') . '<br/></p>';
132
+							$pointer_content .= '<p><a href="' . admin_url('edit-tags.php?taxonomy=wpshop_product_category&post_type=wpshop_product') . '" class="button-primary" target="_blank">' . __('Create my WPShop categories', 'wpshop') . '</a></p>';
133 133
 							break;
134 134
 
135 135
 						case 'product_datas_configuration' :
136
-							$pointer_content  = '<h3>' .__( 'Product configurations', 'wpshop'). '</h3>';
137
-							$pointer_content .= '<p>' .__( 'Here, you can configure your product (Price, weight, reference and all attributes you want to create and affect to products', 'wpshop'). '</p>';
136
+							$pointer_content  = '<h3>' . __('Product configurations', 'wpshop') . '</h3>';
137
+							$pointer_content .= '<p>' . __('Here, you can configure your product (Price, weight, reference and all attributes you want to create and affect to products', 'wpshop') . '</p>';
138 138
 							break;
139 139
 
140 140
 						case 'product_display_configuration' :
141
-							$pointer_content  = '<h3>' .__( 'Product display configurations', 'wpshop'). '</h3>';
142
-							$pointer_content .= '<p>' .__( 'Here, you can manage what elements you want to display on your product page', 'wpshop' ). '</p>';
141
+							$pointer_content  = '<h3>' . __('Product display configurations', 'wpshop') . '</h3>';
142
+							$pointer_content .= '<p>' . __('Here, you can manage what elements you want to display on your product page', 'wpshop') . '</p>';
143 143
 							break;
144 144
 
145 145
 						case 'product_variations' :
146
-							$pointer_content  = '<h3>' .__( 'Product variations', 'wpshop'). '</h3>';
147
-							$pointer_content .= '<p>' .__( 'Here, you can generate your product variations.', 'wpshop'). '</p><br/>';
148
-							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/configurer-un-produit-avec-des-options/" class="button-primary" target="_blank">' .__('Read the tutorial', 'wpshop').'</a></p>';
146
+							$pointer_content  = '<h3>' . __('Product variations', 'wpshop') . '</h3>';
147
+							$pointer_content .= '<p>' . __('Here, you can generate your product variations.', 'wpshop') . '</p><br/>';
148
+							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/configurer-un-produit-avec-des-options/" class="button-primary" target="_blank">' . __('Read the tutorial', 'wpshop') . '</a></p>';
149 149
 							break;
150 150
 
151 151
 						case 'product_variations_configuration' :
152
-							$pointer_content  = '<h3>' .__( 'Variations configuration', 'wpshop'). '</h3>';
153
-							$pointer_content .= '<p>' .__( 'Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop'). '</p>';
152
+							$pointer_content  = '<h3>' . __('Variations configuration', 'wpshop') . '</h3>';
153
+							$pointer_content .= '<p>' . __('Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop') . '</p>';
154 154
 							break;
155 155
 
156 156
 						case 'add_product_automaticly_to_cart' :
157
-							$pointer_content  = '<h3>' .__('Add product to cart', 'wpshop'). '</h3>';
158
-							$pointer_content .= '<p>' .__( 'If you check this checkbox, this produc will be add automaticly to cart. This functionnality is helpful if you want to bill fees for example.', 'wpshop' ). '</p>';
157
+							$pointer_content  = '<h3>' . __('Add product to cart', 'wpshop') . '</h3>';
158
+							$pointer_content .= '<p>' . __('If you check this checkbox, this produc will be add automaticly to cart. This functionnality is helpful if you want to bill fees for example.', 'wpshop') . '</p>';
159 159
 							break;
160 160
 
161 161
 						case 'category_filterable_attributes' :
162
-							$pointer_content  = '<h3>' .__('Filterable search', 'wpshop'). '</h3>';
163
-							$pointer_content .= '<p>' .__( 'You can add a filter search to your WPShop, here will be display all available attributes for a filter search in this category', 'wpshop' ). '</p><br/>';
164
-							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" class="button-primary" target="_blank">' .__('Read the filter search tutorial', 'wpshop').'</a></p>';
162
+							$pointer_content  = '<h3>' . __('Filterable search', 'wpshop') . '</h3>';
163
+							$pointer_content .= '<p>' . __('You can add a filter search to your WPShop, here will be display all available attributes for a filter search in this category', 'wpshop') . '</p><br/>';
164
+							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" class="button-primary" target="_blank">' . __('Read the filter search tutorial', 'wpshop') . '</a></p>';
165 165
 							break;
166 166
 
167 167
 						case 'category_picture' :
168
-							$pointer_content  = '<h3>' .__('Category image', 'wpshop'). '</h3>';
169
-							$pointer_content .= '<p>' .__( 'You can add a picture to illustrate your category', 'wpshop' ). '</p>';
168
+							$pointer_content  = '<h3>' . __('Category image', 'wpshop') . '</h3>';
169
+							$pointer_content .= '<p>' . __('You can add a picture to illustrate your category', 'wpshop') . '</p>';
170 170
 							break;
171 171
 
172 172
 						case 'order_customer_comment' :
173
-							$pointer_content  = '<h3>' .__('Order customer comment', 'wpshop'). '</h3>';
174
-							$pointer_content .= '<p>' .__( 'Here is displayed the customer comment wrote during the order', 'wpshop' ). '</p>';
173
+							$pointer_content  = '<h3>' . __('Order customer comment', 'wpshop') . '</h3>';
174
+							$pointer_content .= '<p>' . __('Here is displayed the customer comment wrote during the order', 'wpshop') . '</p>';
175 175
 							break;
176 176
 
177 177
 						case 'message_historic' :
178
-							$pointer_content  = '<h3>' .__('Message Historic', 'wpshop'). '</h3>';
179
-							$pointer_content .= '<p>' .__( 'This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop' ). '</p>';
178
+							$pointer_content  = '<h3>' . __('Message Historic', 'wpshop') . '</h3>';
179
+							$pointer_content .= '<p>' . __('This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop') . '</p>';
180 180
 							break;
181 181
 
182 182
 						case 'order_notification_message' :
183
-							$pointer_content  = '<h3>' .__('Order notification', 'wpshop'). '</h3>';
184
-							$pointer_content .= '<p>' .__( 'You can add a private comment to the order or send an comment to customer about this order', 'wpshop' ). '</p>';
183
+							$pointer_content  = '<h3>' . __('Order notification', 'wpshop') . '</h3>';
184
+							$pointer_content .= '<p>' . __('You can add a private comment to the order or send an comment to customer about this order', 'wpshop') . '</p>';
185 185
 							break;
186 186
 
187 187
 						case 'order_shipping_box' :
188
-							$pointer_content  = '<h3>' .__('Shipping actions', 'wpshop'). '</h3>';
189
-							$pointer_content .= '<p>' .__( 'Here, you can manage your shipping actions, download the shipping slip.', 'wpshop' ). '</p>';
188
+							$pointer_content  = '<h3>' . __('Shipping actions', 'wpshop') . '</h3>';
189
+							$pointer_content .= '<p>' . __('Here, you can manage your shipping actions, download the shipping slip.', 'wpshop') . '</p>';
190 190
 							break;
191 191
 
192 192
 						case 'options_payment_part' :
193
-							$pointer_content  = '<h3>' .__('Payment configuration', 'wpshop'). '</h3><p>' .__( 'You can manage your payment methods (Change name, add description, add a logo and apply configurations ). You can add others payment methods', 'wpshop' ). '</p><br/><p><a href="http://shop.eoxia.com/boutique/shop/modules-wpshop/modules-de-paiement/" class="button-primary" target="_blank">' .__('See available payment methods', 'wpshop').'</a></p>';
193
+							$pointer_content = '<h3>' . __('Payment configuration', 'wpshop') . '</h3><p>' . __('You can manage your payment methods (Change name, add description, add a logo and apply configurations ). You can add others payment methods', 'wpshop') . '</p><br/><p><a href="http://shop.eoxia.com/boutique/shop/modules-wpshop/modules-de-paiement/" class="button-primary" target="_blank">' . __('See available payment methods', 'wpshop') . '</a></p>';
194 194
 							break;
195 195
 
196 196
 						default :
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 							break;
199 199
 					}
200 200
 
201
-					require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container_bubble' ) );
201
+					require(wpshop_tools::get_template_part(WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container_bubble'));
202 202
 				}
203 203
 			}
204 204
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for wpshop help
4 6
  *
@@ -51,8 +53,9 @@  discard block
 block discarded – undo
51 53
 	function wps_ajax_close_wps_help_window() {
52 54
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
53 55
 
54
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) )
55
-			wp_die();
56
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) ) {
57
+					wp_die();
58
+		}
56 59
 
57 60
 		$status = false;
58 61
 		$result = '';
Please login to merge, or discard this patch.
includes/modules/wps_help/controller/wps_help_ctr.php 2 patches
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for wpshop help
4 4
  *
@@ -19,54 +19,54 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		/**	Call style for administration	*/
22
-		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_css' ) );
22
+		add_action('admin_enqueue_scripts', array(&$this, 'admin_css'));
23 23
 
24 24
 		/**	Include the different javascript	*/
25
-		add_action( 'admin_init', array(&$this, 'admin_js') );
25
+		add_action('admin_init', array(&$this, 'admin_js'));
26 26
 
27 27
 		/**	Add the scripts into admin footer for future use	*/
28
-		add_action( 'admin_print_footer_scripts', array( &$this, 'wps_dashboard_help') );
28
+		add_action('admin_print_footer_scripts', array(&$this, 'wps_dashboard_help'));
29 29
 
30 30
 		/** Ajax actions **/
31
-		add_action( 'wp_ajax_close_wps_help_window', array( &$this, 'wps_ajax_close_wps_help_window' ) );
31
+		add_action('wp_ajax_close_wps_help_window', array(&$this, 'wps_ajax_close_wps_help_window'));
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * Include stylesheets
36 36
 	 */
37 37
 	function admin_css() {
38
-		wp_enqueue_style( 'wp-pointer' );
38
+		wp_enqueue_style('wp-pointer');
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * Load the different javascript librairies
43 43
 	 */
44 44
 	function admin_js() {
45
-		wp_enqueue_script( 'wp-pointer' );
45
+		wp_enqueue_script('wp-pointer');
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * AJAX - Save into current user meta the different help that have to be closed next time the user will be logged in
50 50
 	 */
51 51
 	function wps_ajax_close_wps_help_window() {
52
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
52
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
53 53
 
54
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) )
54
+		if (!wp_verify_nonce($_wpnonce, 'wps_ajax_close_wps_help_window'))
55 55
 			wp_die();
56 56
 
57 57
 		$status = false;
58 58
 		$result = '';
59
-		$pointer_id = !empty( $_POST['pointer_id']) ? wpshop_tools::varSanitizer( $_POST['pointer_id'] ) : '';
60
-		if ( !empty($pointer_id) ) {
61
-			$seen_help_windows = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
62
-			$seen_help_windows[ $pointer_id ] = true;
59
+		$pointer_id = !empty($_POST['pointer_id']) ? wpshop_tools::varSanitizer($_POST['pointer_id']) : '';
60
+		if (!empty($pointer_id)) {
61
+			$seen_help_windows = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
62
+			$seen_help_windows[$pointer_id] = true;
63 63
 
64
-			update_user_meta( get_current_user_id(), '_wps_closed_help', $seen_help_windows);
64
+			update_user_meta(get_current_user_id(), '_wps_closed_help', $seen_help_windows);
65 65
 			$status = true;
66 66
 		}
67 67
 
68
-		$response = array( 'status' => $status, 'response' => $result );
69
-		wp_die( json_encode( $response ) );
68
+		$response = array('status' => $status, 'response' => $result);
69
+		wp_die(json_encode($response));
70 70
 	}
71 71
 
72 72
 	/**
@@ -78,118 +78,118 @@  discard block
 block discarded – undo
78 78
 
79 79
 		/**	Get current screen in order to load messages only in required pages	*/
80 80
 		$current_screen = get_current_screen();
81
-		switch ( $current_screen->id ) {
81
+		switch ($current_screen->id) {
82 82
 			case 'toplevel_page_wpshop_dashboard':
83
-				$help_cases[ 'download_newsletter_contacts' ]		= array( 'edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts' );
83
+				$help_cases['download_newsletter_contacts'] = array('edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts');
84 84
 			break;
85 85
 
86 86
 			case 'wpshop_product':
87
-				$help_cases[ 'product_page_categories' ] 			= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
88
-				$help_cases[ 'product_datas_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
89
-				$help_cases[ 'product_display_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab' );
90
-				$help_cases[ 'product_variations' ] 				= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button' );
91
-				$help_cases[ 'product_variations_configuration' ] 	= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button' );
92
-				$help_cases[ 'add_product_automaticly_to_cart' ] 	= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options' );
87
+				$help_cases['product_page_categories'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
88
+				$help_cases['product_datas_configuration'] = array('edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
89
+				$help_cases['product_display_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab');
90
+				$help_cases['product_variations'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button');
91
+				$help_cases['product_variations_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button');
92
+				$help_cases['add_product_automaticly_to_cart'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options');
93 93
 			break;
94 94
 
95 95
 			case 'edit-wpshop_product_category':
96
-				$help_cases[ 'category_filterable_attributes' ] 	= array( 'edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container' );
97
-				$help_cases[ 'category_picture' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload' );
96
+				$help_cases['category_filterable_attributes'] = array('edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container');
97
+				$help_cases['category_picture'] = array('edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload');
98 98
 			break;
99 99
 
100 100
 			case 'wpshop_shop_order':
101
-				$help_cases[ 'order_customer_comment' ] 			= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment' );
102
-				$help_cases[ 'order_notification_message' ] 		= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments' );
103
-				$help_cases[ 'order_shipping_box' ] 				= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping' );
101
+				$help_cases['order_customer_comment'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment');
102
+				$help_cases['order_notification_message'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments');
103
+				$help_cases['order_shipping_box'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping');
104 104
 			break;
105 105
 
106 106
 			case 'wpshop_shop_message':
107
-				$help_cases[ 'message_historic' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo' );
107
+				$help_cases['message_historic'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo');
108 108
 			break;
109 109
 
110 110
 			case 'settings_page_wpshop_option':
111
-				$help_cases[ 'options_payment_part' ] 				= array ('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container' );
111
+				$help_cases['options_payment_part'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container');
112 112
 			break;
113 113
 		}
114 114
 
115
-		if ( !empty( $help_cases ) ) {
115
+		if (!empty($help_cases)) {
116 116
 			/** Get help data seen by user **/
117
-			$closed_help_window = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
117
+			$closed_help_window = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
118 118
 
119 119
 			/**	Read the different help cases	*/
120
-			foreach( $help_cases as $help_id => $help_case ) {
121
-				if ( empty( $closed_help_window ) || ( !empty( $closed_help_window ) && !array_key_exists( $help_id, $closed_help_window ) ) ){
122
-					switch( $help_id ) {
120
+			foreach ($help_cases as $help_id => $help_case) {
121
+				if (empty($closed_help_window) || (!empty($closed_help_window) && !array_key_exists($help_id, $closed_help_window))) {
122
+					switch ($help_id) {
123 123
 						case 'download_newsletter_contacts' :
124
-							$pointer_content  = '<h3>' .__( 'Customers information download', 'wpshop'). '</h3>';
125
-							$pointer_content .= '<p>' .__( 'You can download emails of customers who accept to receive your commercials offers or your partners commercials offers by newsletter', 'wpshop'). '</p>';
124
+							$pointer_content  = '<h3>' . __('Customers information download', 'wpshop') . '</h3>';
125
+							$pointer_content .= '<p>' . __('You can download emails of customers who accept to receive your commercials offers or your partners commercials offers by newsletter', 'wpshop') . '</p>';
126 126
 							break;
127 127
 
128 128
 						case 'product_page_categories' :
129
-							$pointer_content  = '<h3>' .__( 'WPShop Categories', 'wpshop'). '</h3>';
130
-							$pointer_content .= '<p>' .__( 'You can classify your products by category.', 'wpshop'). '<br/></p>';
131
-							$pointer_content .= '<p><a href="' .admin_url('edit-tags.php?taxonomy=wpshop_product_category&post_type=wpshop_product'). '" class="button-primary" target="_blank">' .__('Create my WPShop categories', 'wpshop' ). '</a></p>';
129
+							$pointer_content  = '<h3>' . __('WPShop Categories', 'wpshop') . '</h3>';
130
+							$pointer_content .= '<p>' . __('You can classify your products by category.', 'wpshop') . '<br/></p>';
131
+							$pointer_content .= '<p><a href="' . admin_url('edit-tags.php?taxonomy=wpshop_product_category&post_type=wpshop_product') . '" class="button-primary" target="_blank">' . __('Create my WPShop categories', 'wpshop') . '</a></p>';
132 132
 							break;
133 133
 
134 134
 						case 'product_datas_configuration' :
135
-							$pointer_content  = '<h3>' .__( 'Product configurations', 'wpshop'). '</h3>';
136
-							$pointer_content .= '<p>' .__( 'Here, you can configure your product (Price, weight, reference and all attributes you want to create and affect to products', 'wpshop'). '</p>';
135
+							$pointer_content  = '<h3>' . __('Product configurations', 'wpshop') . '</h3>';
136
+							$pointer_content .= '<p>' . __('Here, you can configure your product (Price, weight, reference and all attributes you want to create and affect to products', 'wpshop') . '</p>';
137 137
 							break;
138 138
 
139 139
 						case 'product_display_configuration' :
140
-							$pointer_content  = '<h3>' .__( 'Product display configurations', 'wpshop'). '</h3>';
141
-							$pointer_content .= '<p>' .__( 'Here, you can manage what elements you want to display on your product page', 'wpshop' ). '</p>';
140
+							$pointer_content  = '<h3>' . __('Product display configurations', 'wpshop') . '</h3>';
141
+							$pointer_content .= '<p>' . __('Here, you can manage what elements you want to display on your product page', 'wpshop') . '</p>';
142 142
 							break;
143 143
 
144 144
 						case 'product_variations' :
145
-							$pointer_content  = '<h3>' .__( 'Product variations', 'wpshop'). '</h3>';
146
-							$pointer_content .= '<p>' .__( 'Here, you can generate your product variations.', 'wpshop'). '</p><br/>';
147
-							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/configurer-un-produit-avec-des-options/" class="button-primary" target="_blank">' .__('Read the tutorial', 'wpshop').'</a></p>';
145
+							$pointer_content  = '<h3>' . __('Product variations', 'wpshop') . '</h3>';
146
+							$pointer_content .= '<p>' . __('Here, you can generate your product variations.', 'wpshop') . '</p><br/>';
147
+							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/configurer-un-produit-avec-des-options/" class="button-primary" target="_blank">' . __('Read the tutorial', 'wpshop') . '</a></p>';
148 148
 							break;
149 149
 
150 150
 						case 'product_variations_configuration' :
151
-							$pointer_content  = '<h3>' .__( 'Variations configuration', 'wpshop'). '</h3>';
152
-							$pointer_content .= '<p>' .__( 'Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop'). '</p>';
151
+							$pointer_content  = '<h3>' . __('Variations configuration', 'wpshop') . '</h3>';
152
+							$pointer_content .= '<p>' . __('Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop') . '</p>';
153 153
 							break;
154 154
 
155 155
 						case 'add_product_automaticly_to_cart' :
156
-							$pointer_content  = '<h3>' .__('Add product to cart', 'wpshop'). '</h3>';
157
-							$pointer_content .= '<p>' .__( 'If you check this checkbox, this produc will be add automaticly to cart. This functionnality is helpful if you want to bill fees for example.', 'wpshop' ). '</p>';
156
+							$pointer_content  = '<h3>' . __('Add product to cart', 'wpshop') . '</h3>';
157
+							$pointer_content .= '<p>' . __('If you check this checkbox, this produc will be add automaticly to cart. This functionnality is helpful if you want to bill fees for example.', 'wpshop') . '</p>';
158 158
 							break;
159 159
 
160 160
 						case 'category_filterable_attributes' :
161
-							$pointer_content  = '<h3>' .__('Filterable search', 'wpshop'). '</h3>';
162
-							$pointer_content .= '<p>' .__( 'You can add a filter search to your WPShop, here will be display all available attributes for a filter search in this category', 'wpshop' ). '</p><br/>';
163
-							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" class="button-primary" target="_blank">' .__('Read the filter search tutorial', 'wpshop').'</a></p>';
161
+							$pointer_content  = '<h3>' . __('Filterable search', 'wpshop') . '</h3>';
162
+							$pointer_content .= '<p>' . __('You can add a filter search to your WPShop, here will be display all available attributes for a filter search in this category', 'wpshop') . '</p><br/>';
163
+							$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" class="button-primary" target="_blank">' . __('Read the filter search tutorial', 'wpshop') . '</a></p>';
164 164
 							break;
165 165
 
166 166
 						case 'category_picture' :
167
-							$pointer_content  = '<h3>' .__('Category image', 'wpshop'). '</h3>';
168
-							$pointer_content .= '<p>' .__( 'You can add a picture to illustrate your category', 'wpshop' ). '</p>';
167
+							$pointer_content  = '<h3>' . __('Category image', 'wpshop') . '</h3>';
168
+							$pointer_content .= '<p>' . __('You can add a picture to illustrate your category', 'wpshop') . '</p>';
169 169
 							break;
170 170
 
171 171
 						case 'order_customer_comment' :
172
-							$pointer_content  = '<h3>' .__('Order customer comment', 'wpshop'). '</h3>';
173
-							$pointer_content .= '<p>' .__( 'Here is displayed the customer comment wrote during the order', 'wpshop' ). '</p>';
172
+							$pointer_content  = '<h3>' . __('Order customer comment', 'wpshop') . '</h3>';
173
+							$pointer_content .= '<p>' . __('Here is displayed the customer comment wrote during the order', 'wpshop') . '</p>';
174 174
 							break;
175 175
 
176 176
 						case 'message_historic' :
177
-							$pointer_content  = '<h3>' .__('Message Historic', 'wpshop'). '</h3>';
178
-							$pointer_content .= '<p>' .__( 'This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop' ). '</p>';
177
+							$pointer_content  = '<h3>' . __('Message Historic', 'wpshop') . '</h3>';
178
+							$pointer_content .= '<p>' . __('This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop') . '</p>';
179 179
 							break;
180 180
 
181 181
 						case 'order_notification_message' :
182
-							$pointer_content  = '<h3>' .__('Order notification', 'wpshop'). '</h3>';
183
-							$pointer_content .= '<p>' .__( 'You can add a private comment to the order or send an comment to customer about this order', 'wpshop' ). '</p>';
182
+							$pointer_content  = '<h3>' . __('Order notification', 'wpshop') . '</h3>';
183
+							$pointer_content .= '<p>' . __('You can add a private comment to the order or send an comment to customer about this order', 'wpshop') . '</p>';
184 184
 							break;
185 185
 
186 186
 						case 'order_shipping_box' :
187
-							$pointer_content  = '<h3>' .__('Shipping actions', 'wpshop'). '</h3>';
188
-							$pointer_content .= '<p>' .__( 'Here, you can manage your shipping actions, download the shipping slip.', 'wpshop' ). '</p>';
187
+							$pointer_content  = '<h3>' . __('Shipping actions', 'wpshop') . '</h3>';
188
+							$pointer_content .= '<p>' . __('Here, you can manage your shipping actions, download the shipping slip.', 'wpshop') . '</p>';
189 189
 							break;
190 190
 
191 191
 						case 'options_payment_part' :
192
-							$pointer_content  = '<h3>' .__('Payment configuration', 'wpshop'). '</h3><p>' .__( 'You can manage your payment methods (Change name, add description, add a logo and apply configurations ). You can add others payment methods', 'wpshop' ). '</p><br/><p><a href="http://shop.eoxia.com/boutique/shop/modules-wpshop/modules-de-paiement/" class="button-primary" target="_blank">' .__('See available payment methods', 'wpshop').'</a></p>';
192
+							$pointer_content = '<h3>' . __('Payment configuration', 'wpshop') . '</h3><p>' . __('You can manage your payment methods (Change name, add description, add a logo and apply configurations ). You can add others payment methods', 'wpshop') . '</p><br/><p><a href="http://shop.eoxia.com/boutique/shop/modules-wpshop/modules-de-paiement/" class="button-primary" target="_blank">' . __('See available payment methods', 'wpshop') . '</a></p>';
193 193
 							break;
194 194
 
195 195
 						default :
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 							break;
198 198
 					}
199 199
 
200
-					require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container' ) );
200
+					require(wpshop_tools::get_template_part(WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container'));
201 201
 				}
202 202
 			}
203 203
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for wpshop help
4 6
  *
@@ -51,8 +53,9 @@  discard block
 block discarded – undo
51 53
 	function wps_ajax_close_wps_help_window() {
52 54
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
53 55
 
54
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) )
55
-			wp_die();
56
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) ) {
57
+					wp_die();
58
+		}
56 59
 
57 60
 		$status = false;
58 61
 		$result = '';
Please login to merge, or discard this patch.
wps-pos-addon/templates/backend/customers/metabox-selected-customer.php 2 patches
Spacing   +20 added lines, -20 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
 <div class="wpspos-customer-selected" >
4
-	<?php if ( !empty( $customer_infos ) ) : ?>
4
+	<?php if (!empty($customer_infos)) : ?>
5 5
 		<div class="customer_info wps-boxed">
6
-			<span class="wps-h4"><?php _e( 'Account', 'wpshop' ); ?></span>
6
+			<span class="wps-h4"><?php _e('Account', 'wpshop'); ?></span>
7 7
 			<div class="wps-form-group"><?php _e('Customer last name', 'wps-pos-i18n')?> : <?php echo $customer_infos->last_name; ?></div>
8 8
 			<div class="wps-form-group"><?php _e('Customer first name', 'wps-pos-i18n')?> : <?php echo $customer_infos->first_name; ?></div>
9 9
 			<div class="wps-form-group"><?php _e('Customer email', 'wps-pos-i18n')?> : <?php echo $customer_infos->user_email; ?></div>
@@ -11,45 +11,45 @@  discard block
 block discarded – undo
11 11
 		</div>
12 12
 
13 13
 		<div class="customer_address wps-boxed">
14
-			<span class="wps-h4"><?php _e( 'Billing address', 'wpshop' ); ?></span>
14
+			<span class="wps-h4"><?php _e('Billing address', 'wpshop'); ?></span>
15 15
 			<?php
16
-				$billing_option = get_option( 'wpshop_billing_address' );
17
-				$addresses_customer = wps_address::get_addresses_list_no_hidden_attributes( $customer_id );
18
-				if( !empty($addresses_customer[$billing_option['choice']]) ) {
16
+				$billing_option = get_option('wpshop_billing_address');
17
+				$addresses_customer = wps_address::get_addresses_list_no_hidden_attributes($customer_id);
18
+				if (!empty($addresses_customer[$billing_option['choice']])) {
19 19
 					$billing = reset($addresses_customer[$billing_option['choice']]);
20 20
 					//echo '<strong>' . $billing['address_title']['value'] . '</strong>' . '' . '<br>';
21
-					echo @( __( wpshop_attributes::get_attribute_type_select_option_info($billing['civility']['value'], 'label', 'custom') ) . ' <strong>' . $billing['address_first_name']['value'] . ' ' . $billing['address_last_name']['value'] . '</strong><br>' );
22
-					echo @( $billing['address']['value'] . '<br>' );
23
-					echo @( $billing['city']['value'] . ' ' . $billing['postcode']['value'] . ' ' . $billing['country']['value'] ) . '<br>';
21
+					echo @(__(wpshop_attributes::get_attribute_type_select_option_info($billing['civility']['value'], 'label', 'custom')) . ' <strong>' . $billing['address_first_name']['value'] . ' ' . $billing['address_last_name']['value'] . '</strong><br>');
22
+					echo @($billing['address']['value'] . '<br>');
23
+					echo @($billing['city']['value'] . ' ' . $billing['postcode']['value'] . ' ' . $billing['country']['value']) . '<br>';
24 24
 				}
25 25
 			?>
26 26
 		</div>
27 27
 
28 28
 		<div class="order_historic wps-boxed">
29 29
 			<a href="#" class="toggle-historic dashicons dashicons-arrow-down alignright"></a>
30
-			<span class="wps-h4"><?php _e( 'Historic', 'wpshop' ); ?></span>
30
+			<span class="wps-h4"><?php _e('Historic', 'wpshop'); ?></span>
31 31
 			<?php
32
-				foreach( $this->get_orders_customer( 3, $customer_id ) as $order ) {
32
+				foreach ($this->get_orders_customer(3, $customer_id) as $order) {
33 33
 			?>
34 34
 			<div class="wps-form-group toggle-historic-group">
35
-				<a href="#" class="lnk_load_order" data-nonce="<?php echo wp_create_nonce( 'wps_pos_process_checkout' ); ?>" data-oid="<?php echo $order->ID; ?>" data-cid="<?php echo $customer_id; ?>">
35
+				<a href="#" class="lnk_load_order" data-nonce="<?php echo wp_create_nonce('wps_pos_process_checkout'); ?>" data-oid="<?php echo $order->ID; ?>" data-cid="<?php echo $customer_id; ?>">
36 36
 					<?php
37
-					if( $order->_order_postmeta['order_key'] ) {
38
-						if( $order->_order_postmeta['order_invoice_ref'] ) {
37
+					if ($order->_order_postmeta['order_key']) {
38
+						if ($order->_order_postmeta['order_invoice_ref']) {
39 39
 							$link = $order->_order_postmeta['order_invoice_ref'];
40 40
 						} else {
41 41
 							$link = $order->_order_postmeta['order_key'];
42 42
 						}
43 43
 					} else {
44
-						$link = __( 'Order summary ', 'wpshop' );
44
+						$link = __('Order summary ', 'wpshop');
45 45
 					}
46 46
 					echo $link;
47 47
 					?>
48 48
 				</a>
49
-				<span class="price_order"><?php echo number_format( round($order->_order_postmeta['order_grand_total'], 2), 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency( false ); ?></span>
50
-				<span class="date_order"><?php echo date("d/m/Y | H:i:s", strtotime( $order->_order_postmeta['order_date'] ) ); ?></span>
49
+				<span class="price_order"><?php echo number_format(round($order->_order_postmeta['order_grand_total'], 2), 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false); ?></span>
50
+				<span class="date_order"><?php echo date("d/m/Y | H:i:s", strtotime($order->_order_postmeta['order_date'])); ?></span>
51 51
 				<?php
52
-					if( $order->_order_postmeta['order_invoice_ref'] ) {
52
+					if ($order->_order_postmeta['order_invoice_ref']) {
53 53
 					?>
54 54
 				<span class="invoice_order">
55 55
 					<a href="<?php echo WPSHOP_TEMPLATES_URL; ?>invoice.php?order_id=<?php echo $order->ID; ?>&invoice_ref=<?php echo $order->_order_postmeta['order_invoice_ref']; ?>" target="_blank" role="button">
@@ -69,6 +69,6 @@  discard block
 block discarded – undo
69 69
 		</div>
70 70
 
71 71
 	<?php else : ?>
72
-		<?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' ); ?>
72
+		<?php _e('Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n'); ?>
73 73
 	<?php endif; ?>
74 74
 </div>
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 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
 <div class="wpspos-customer-selected" >
4 6
 	<?php if ( !empty( $customer_infos ) ) : ?>
@@ -68,7 +70,10 @@  discard block
 block discarded – undo
68 70
 			?>
69 71
 		</div>
70 72
 
71
-	<?php else : ?>
72
-		<?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' ); ?>
73
+	<?php else {
74
+	: ?>
75
+		<?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' );
76
+}
77
+?>
73 78
 	<?php endif; ?>
74 79
 </div>
Please login to merge, or discard this patch.
includes/modules/wps-pos-addon/controller/wps-pos-order.ctr.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for product into point of sale management plugin
4 4
  *
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		/**	Call dashboard metaboxes	*/
22
-		add_action( 'admin_init', array( $this, 'dashboard_metaboxes' ) );
22
+		add_action('admin_init', array($this, 'dashboard_metaboxes'));
23 23
 
24 24
 		/**	Point d'accroche AJAX / AJAX listeners	*/
25 25
 		/**	Affichage du content de la commande / Display the order content	*/
26
-		add_action( 'wp_ajax_wps-pos-display-order-content', array(&$this, 'wps_pos_order_content' ) );
26
+		add_action('wp_ajax_wps-pos-display-order-content', array(&$this, 'wps_pos_order_content'));
27 27
 		/**	Affichage du formulaire de finalisation de la commande / Display order finalization form	*/
28
-		add_action( 'wp_ajax_wpspos-finalize-order', array( &$this, 'wps_pos_finalize_order' ) );
28
+		add_action('wp_ajax_wpspos-finalize-order', array(&$this, 'wps_pos_finalize_order'));
29 29
 		/**	Save order into database	*/
30
-		add_action( 'wp_ajax_wpspos-finish-order', array( &$this, 'wps_pos_process_checkout' ) );
30
+		add_action('wp_ajax_wpspos-finish-order', array(&$this, 'wps_pos_process_checkout'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 		/**	Create metaboxes for left side	*/
40 40
 
41 41
 		/**	Create metaboxes for right side	*/
42
-		add_meta_box( 'wpspos-dashboard-order-metabox', '<span class="dashicons dashicons-cart"></span> ' . __( 'Order summary', 'wps-pos-i18n' ), array( $this, 'dashboard_order_metabox' ), 'wpspos-dashboard', 'wpspos-dashboard-right' );
42
+		add_meta_box('wpspos-dashboard-order-metabox', '<span class="dashicons dashicons-cart"></span> ' . __('Order summary', 'wps-pos-i18n'), array($this, 'dashboard_order_metabox'), 'wpspos-dashboard', 'wpspos-dashboard-right');
43 43
 	}
44 44
 
45 45
 	/**
46 46
 	 * WP CUSTOM METABOX - Display a custom metabox for order summary output
47 47
 	 */
48 48
 	function dashboard_order_metabox() {
49
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'metabox', 'order' ) );
49
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'metabox', 'order'));
50 50
 	}
51 51
 
52 52
 	/**
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
 		$result = $selected_variation_list = '';
62 62
 		$price_piloting_option = get_option('wpshop_shop_price_piloting');
63 63
 
64
-		$order_id = ( !empty( $_POST['order_id'] ) ) ? (int) $_POST['order_id'] : null;
64
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
65 65
 
66
-		if ( !empty( $_SESSION['cart'] ) || isset( $order_id ) ) {
66
+		if (!empty($_SESSION['cart']) || isset($order_id)) {
67 67
 			/* if ( empty( $_SESSION[ 'cart' ][ 'customer_id' ]) ) {
68 68
 				$result = __( 'No customer selected for the order, please choose a customer from left hand side list for continue this order', 'wps-pos-i18n' );
69 69
 			}
70 70
 			else  */
71
-			if( isset( $order_id ) ) {
72
-				$order = get_post_meta( $order_id, '_order_postmeta', true );
71
+			if (isset($order_id)) {
72
+				$order = get_post_meta($order_id, '_order_postmeta', true);
73 73
 
74 74
 				/**	Get current order content	*/
75 75
 				$cart_content = $order;
76 76
 				$order_items = $order['order_items'];
77 77
 
78 78
 				/**	In case there are item into order, include the order content display	*/
79
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'content' ) );
80
-			} elseif ( !empty( $_SESSION['cart']['order_items'] ) ) {
79
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'content'));
80
+			} elseif (!empty($_SESSION['cart']['order_items'])) {
81 81
 				/**	Get current order content	*/
82 82
 				$cart_content = $_SESSION['cart'];
83 83
 				$order_items = $cart_content['order_items'];
84 84
 
85 85
 				/**	In case there are item into order, include the order content display	*/
86
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'content' ) );
86
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'content'));
87 87
 			}
88 88
 			else {
89
-				$result = __( 'The order is currently empty', 'wps-pos-i18n' );
89
+				$result = __('The order is currently empty', 'wps-pos-i18n');
90 90
 			}
91 91
 		}
92 92
 
@@ -97,32 +97,32 @@  discard block
 block discarded – undo
97 97
 	 * AJAX - Affiche le contenu de la commande actuelle / Display current order content
98 98
 	 */
99 99
 	function wps_pos_order_content() {
100
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
100
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
101 101
 
102
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_order_content' ) )
102
+		if (!wp_verify_nonce($_wpnonce, 'wps_pos_order_content'))
103 103
 			wp_die();
104 104
 
105
-		wp_die( $this->display_wps_pos_order_content() );
105
+		wp_die($this->display_wps_pos_order_content());
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * AJAX - Affiche l'interface de finalisation de commande
110 110
 	 */
111 111
 	function wps_pos_finalize_order() {
112
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
112
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
113 113
 
114
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_finalize_order' ) )
114
+		if (!wp_verify_nonce($_wpnonce, 'wps_pos_finalize_order'))
115 115
 			wp_die();
116 116
 
117 117
 		/**	Get current order content	*/
118
-		$current_order_id = ( !empty( $_GET ) && !empty( $_GET[ 'order_id' ] ) && is_int( (int)$_GET[ 'order_id' ] ) ) ? (int)$_GET[ 'order_id' ] : null;
119
-		if ( !empty( $current_order_id) ) {
120
-			$cart_content = get_post_meta( $current_order_id, '_order_postmeta', true );
118
+		$current_order_id = (!empty($_GET) && !empty($_GET['order_id']) && is_int((int)$_GET['order_id'])) ? (int)$_GET['order_id'] : null;
119
+		if (!empty($current_order_id)) {
120
+			$cart_content = get_post_meta($current_order_id, '_order_postmeta', true);
121 121
 		}
122
-		elseif( !empty( $_SESSION['cart']['order_items'] ) ) {
122
+		elseif (!empty($_SESSION['cart']['order_items'])) {
123 123
 			$cart_content = $_SESSION['cart'];
124 124
 		}
125
-		if( !empty( $cart_content['order_items'] ) ) {
125
+		if (!empty($cart_content['order_items'])) {
126 126
 			$order_items = $cart_content['order_items'];
127 127
 
128 128
 			/* if( !empty($_SESSION['wpspos_is_receipt']) || !empty($_SESSION['wpspos_is_quotation']) ) {
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'finalization-no_receipt' ) );
135 135
 			} else { */
136 136
 				/**	In case there are item into order, include the order content display	*/
137
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'finalization' ) );
137
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'finalization'));
138 138
 			// }
139 139
 
140 140
 		}
141 141
 		else {
142
-			$result = __( 'The order is currently empty', 'wps-pos-i18n' );
142
+			$result = __('The order is currently empty', 'wps-pos-i18n');
143 143
 		}
144 144
 		wp_die();
145 145
 	}
@@ -148,49 +148,49 @@  discard block
 block discarded – undo
148 148
 	 * AJAX - Traite la commande / Process checkout
149 149
 	 */
150 150
 	function wps_pos_process_checkout() {
151
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
151
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
152 152
 
153
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_process_checkout' ) )
153
+		if (!wp_verify_nonce($_wpnonce, 'wps_pos_process_checkout'))
154 154
 			wp_die();
155 155
 
156 156
 		$status = false;
157 157
 		$output = $message = '';
158 158
 
159
-		$order_id = ( !empty( $_POST['order_id'] ) ) ? (int) $_POST['order_id'] : null;
160
-		$new_order = empty( $order_id );
161
-		$payment_method = ( !empty( $_POST['wpspos-payment-method']) ) ? sanitize_text_field( $_POST['wpspos-payment-method'] ) : null;
162
-		$customer_id = ( !empty( $_POST['customer_id'] ) ) ? (int) $_POST['customer_id'] : ( !empty( $_SESSION[ 'cart' ][ 'customer_id' ] ) ) ? (int) $_SESSION[ 'cart' ][ 'customer_id' ] : null;
163
-		$payment_amount = ( !empty( $_POST['wps-pos-total-order-amount'] ) ) ? wpshop_tools::varSanitizer( $_POST['wps-pos-total-order-amount'] ) : null;
164
-		$received_payment_amount = ( !empty( $_POST['wpspos-order-received-amount'] ) ) ? wpshop_tools::varSanitizer( $_POST['wpspos-order-received-amount'] ) : $payment_amount;
159
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
160
+		$new_order = empty($order_id);
161
+		$payment_method = (!empty($_POST['wpspos-payment-method'])) ? sanitize_text_field($_POST['wpspos-payment-method']) : null;
162
+		$customer_id = (!empty($_POST['customer_id'])) ? (int)$_POST['customer_id'] : (!empty($_SESSION['cart']['customer_id'])) ? (int)$_SESSION['cart']['customer_id'] : null;
163
+		$payment_amount = (!empty($_POST['wps-pos-total-order-amount'])) ? wpshop_tools::varSanitizer($_POST['wps-pos-total-order-amount']) : null;
164
+		$received_payment_amount = (!empty($_POST['wpspos-order-received-amount'])) ? wpshop_tools::varSanitizer($_POST['wpspos-order-received-amount']) : $payment_amount;
165 165
 
166
-		if ( !empty( $customer_id ) ) {
167
-				if ( empty($order_id) && !empty( $payment_method ) ) {
166
+		if (!empty($customer_id)) {
167
+				if (empty($order_id) && !empty($payment_method)) {
168 168
 					$_SESSION['shipping_method'] = 'default_shipping_mode_for_pos';
169
-					$order_id = wpshop_checkout::process_checkout( $payment_method, '', $customer_id, $_SESSION['billing_address'], $_SESSION['shipping_address']);
170
-					wp_update_post( array('ID' => $order_id, 'post_parent' => get_current_user_id() ) );
169
+					$order_id = wpshop_checkout::process_checkout($payment_method, '', $customer_id, $_SESSION['billing_address'], $_SESSION['shipping_address']);
170
+					wp_update_post(array('ID' => $order_id, 'post_parent' => get_current_user_id()));
171 171
 				}
172 172
 
173
-				if ( !empty( $order_id ) ) {
173
+				if (!empty($order_id)) {
174 174
 					$status = true;
175 175
 
176
-					if ( !empty( $received_payment_amount ) /* && empty($_SESSION['wpspos_is_quotation']) && empty($_SESSION['wpspos_is_receipt']) */ ) {
176
+					if (!empty($received_payment_amount) /* && empty($_SESSION['wpspos_is_quotation']) && empty($_SESSION['wpspos_is_receipt']) */) {
177 177
 						$params_array = array(
178 178
 							'method' 			=> $payment_method,
179 179
 							'waited_amount' 	=> $payment_amount,
180
-							'status' 			=> 'payment_received' ,
180
+							'status' 			=> 'payment_received',
181 181
 							'author' 			=> $customer_id,
182 182
 							'payment_reference' => '',
183 183
 							'date' 				=> current_time('mysql', 0),
184
-							'received_amount' 	=> ( ( 'money' == $payment_method ) && ( number_format( (float)$received_payment_amount, 2, '.', '') > number_format( (float)$payment_amount, 2, '.', '') ) ) ? $payment_amount : $received_payment_amount ,
184
+							'received_amount' 	=> (('money' == $payment_method) && (number_format((float)$received_payment_amount, 2, '.', '') > number_format((float)$payment_amount, 2, '.', ''))) ? $payment_amount : $received_payment_amount,
185 185
 						);
186
-						wpshop_payment::check_order_payment_total_amount( $order_id, $params_array, 'completed' );
186
+						wpshop_payment::check_order_payment_total_amount($order_id, $params_array, 'completed');
187 187
 					}
188 188
 
189 189
 					/**	Get order content	*/
190
-					$order_postmeta = get_post_meta( $order_id, '_order_postmeta', true );
190
+					$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
191 191
 
192 192
 					ob_start();
193
-					require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'complete') );
193
+					require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'complete'));
194 194
 					$output = ob_get_contents();
195 195
 					ob_end_clean();
196 196
 
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 						$wps_cart->empty_cart();
201 201
 					}*/
202 202
 
203
-					$message = __( 'Order have been saved', 'wps-pos-i18n' );
203
+					$message = __('Order have been saved', 'wps-pos-i18n');
204 204
 				}
205 205
 				else {
206
-					$message = __( 'No order have been found', 'wps-pos-i18n' );
206
+					$message = __('No order have been found', 'wps-pos-i18n');
207 207
 				}
208 208
 			/*}
209 209
 			else {
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 			}*/
212 212
 		}
213 213
 		else {
214
-			$message = __( 'No customer has been selected for current order', 'wps-pos-i18n' );
214
+			$message = __('No customer has been selected for current order', 'wps-pos-i18n');
215 215
 		}
216 216
 
217
-		wp_die( json_encode( array( 'status' => $status, 'output' => $output, 'message' => $message, ) ) );
217
+		wp_die(json_encode(array('status' => $status, 'output' => $output, 'message' => $message,)));
218 218
 	}
219 219
 
220 220
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for product into point of sale management plugin
4 6
  *
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
 
85 87
 				/**	In case there are item into order, include the order content display	*/
86 88
 				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'order', 'content' ) );
87
-			}
88
-			else {
89
+			} else {
89 90
 				$result = __( 'The order is currently empty', 'wps-pos-i18n' );
90 91
 			}
91 92
 		}
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 	function wps_pos_order_content() {
100 101
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
101 102
 
102
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_order_content' ) )
103
-			wp_die();
103
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_order_content' ) ) {
104
+					wp_die();
105
+		}
104 106
 
105 107
 		wp_die( $this->display_wps_pos_order_content() );
106 108
 	}
@@ -111,15 +113,15 @@  discard block
 block discarded – undo
111 113
 	function wps_pos_finalize_order() {
112 114
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
113 115
 
114
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_finalize_order' ) )
115
-			wp_die();
116
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_finalize_order' ) ) {
117
+					wp_die();
118
+		}
116 119
 
117 120
 		/**	Get current order content	*/
118 121
 		$current_order_id = ( !empty( $_GET ) && !empty( $_GET[ 'order_id' ] ) && is_int( (int)$_GET[ 'order_id' ] ) ) ? (int)$_GET[ 'order_id' ] : null;
119 122
 		if ( !empty( $current_order_id) ) {
120 123
 			$cart_content = get_post_meta( $current_order_id, '_order_postmeta', true );
121
-		}
122
-		elseif( !empty( $_SESSION['cart']['order_items'] ) ) {
124
+		} elseif( !empty( $_SESSION['cart']['order_items'] ) ) {
123 125
 			$cart_content = $_SESSION['cart'];
124 126
 		}
125 127
 		if( !empty( $cart_content['order_items'] ) ) {
@@ -137,8 +139,7 @@  discard block
 block discarded – undo
137 139
 				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/order', 'finalization' ) );
138 140
 			// }
139 141
 
140
-		}
141
-		else {
142
+		} else {
142 143
 			$result = __( 'The order is currently empty', 'wps-pos-i18n' );
143 144
 		}
144 145
 		wp_die();
@@ -150,8 +151,9 @@  discard block
 block discarded – undo
150 151
 	function wps_pos_process_checkout() {
151 152
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
152 153
 
153
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_process_checkout' ) )
154
-			wp_die();
154
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_pos_process_checkout' ) ) {
155
+					wp_die();
156
+		}
155 157
 
156 158
 		$status = false;
157 159
 		$output = $message = '';
@@ -201,16 +203,14 @@  discard block
 block discarded – undo
201 203
 					}*/
202 204
 
203 205
 					$message = __( 'Order have been saved', 'wps-pos-i18n' );
204
-				}
205
-				else {
206
+				} else {
206 207
 					$message = __( 'No order have been found', 'wps-pos-i18n' );
207 208
 				}
208 209
 			/*}
209 210
 			else {
210 211
 				$message = __( 'Please choose a payment method for order', 'wps-pos-i18n' );
211 212
 			}*/
212
-		}
213
-		else {
213
+		} else {
214 214
 			$message = __( 'No customer has been selected for current order', 'wps-pos-i18n' );
215 215
 		}
216 216
 
Please login to merge, or discard this patch.
includes/modules/wps-pos-addon/controller/wps-pos-customer.ctr.php 2 patches
Spacing   +96 added lines, -96 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
  * Fichier du controlleur pour le module client du logiciel de caisse pour WP-Shop / Main controller file for customer into point of sale management plugin
4 4
  *
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 		$this->users = get_users();
26 26
 
27 27
 		/**	Call dashboard metaboxes	*/
28
-		add_action( 'admin_init', array( $this, 'dashboard_metaboxes' ) );
28
+		add_action('admin_init', array($this, 'dashboard_metaboxes'));
29 29
 
30 30
 		/**	Hook wordpress user search	*/
31
-		add_action( 'pre_user_query', array( $this, 'extended_user_search' ) );
31
+		add_action('pre_user_query', array($this, 'extended_user_search'));
32 32
 
33 33
 		/**	Point d'accroche AJAX / AJAX listeners	*/
34 34
 		/**	Choix d'un utilisateur comme propriatiare de la commande en cours / Set a customer as order owner	*/
35
-		add_action( 'wp_ajax_wpspos_set_customer_order', array( $this, 'ajax_pos_customer_choice' ) );
35
+		add_action('wp_ajax_wpspos_set_customer_order', array($this, 'ajax_pos_customer_choice'));
36 36
 		/**	Recherche parmis les utilisateurs existants / search into existing user list	*/
37
-		add_action( 'wp_ajax_wpspos-customer-search', array( $this, 'ajax_pos_customer_search' ) );
37
+		add_action('wp_ajax_wpspos-customer-search', array($this, 'ajax_pos_customer_search'));
38 38
 	}
39 39
 
40 40
 	/**
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param WP_Object $user_query L'objet contenant la requête actuelle de recherche de client / Current user query
44 44
 	 */
45
-	function extended_user_search ( $user_query ) {
45
+	function extended_user_search($user_query) {
46 46
 		global $wps_pos_addon_menu;
47 47
 		$screen = get_current_screen();
48 48
 
49
-		if ( !empty( $screen ) && !empty( $screen->id ) && $screen->id == $wps_pos_addon_menu ) {
50
-			$user_query->query_where = str_replace( "AND (user_login LIKE", "OR (user_login LIKE", $user_query->query_where );
49
+		if (!empty($screen) && !empty($screen->id) && $screen->id == $wps_pos_addon_menu) {
50
+			$user_query->query_where = str_replace("AND (user_login LIKE", "OR (user_login LIKE", $user_query->query_where);
51 51
 		}
52 52
 	}
53 53
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 
68 68
 		/**	Create metaboxes for right side	*/
69 69
 		ob_start();
70
-		require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox_title', 'selected' ) );
70
+		require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox_title', 'selected'));
71 71
 		$metabox_title = ob_get_contents();
72 72
 		ob_end_clean();
73
-		add_meta_box( 'wpspos-dashboard-order-customer-metabox', $metabox_title, array( $this, 'metabox_customer' ), 'wpspos-dashboard', 'wpspos-dashboard-right' );
73
+		add_meta_box('wpspos-dashboard-order-customer-metabox', $metabox_title, array($this, 'metabox_customer'), 'wpspos-dashboard', 'wpspos-dashboard-right');
74 74
 	}
75 75
 
76 76
 	/**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array La liste des utilisateurs correspondant à la lettre donnée / The customer list corresponding to given letter
82 82
 	 */
83
-	function get_customer_by_alphabet( $letter ) {
83
+	function get_customer_by_alphabet($letter) {
84 84
 		$users_list = array();
85 85
 
86 86
 		/** Get the default customer **/
87
-		$default_customer_option = get_option( 'wpshop_pos_addon_default_customer_id' );
88
-		if ( !empty($default_customer_option) ) {
87
+		$default_customer_option = get_option('wpshop_pos_addon_default_customer_id');
88
+		if (!empty($default_customer_option)) {
89 89
 			$default_user = get_user_by('id', $default_customer_option);
90
-			if ( !empty($default_user) ) {
90
+			if (!empty($default_user)) {
91 91
 				$user_infos = array(
92 92
 					'ID' => $default_user->ID,
93 93
 					'last_name' => get_user_meta($default_user->ID, 'last_name', true),
@@ -98,28 +98,28 @@  discard block
 block discarded – undo
98 98
 			}
99 99
 		}
100 100
 
101
-		if ( !empty($letter) ) {
102
-			foreach ( $this->users as $user ) {
103
-				if ( !empty( $user ) && !empty( $user->roles ) && !empty( $user->roles[0] ) && ( $user->roles[0] != 'Administrator' ) ) {
101
+		if (!empty($letter)) {
102
+			foreach ($this->users as $user) {
103
+				if (!empty($user) && !empty($user->roles) && !empty($user->roles[0]) && ($user->roles[0] != 'Administrator')) {
104 104
 					$user_infos = array();
105 105
 
106 106
 					/** Check the username, if last name and first name are empty we select email **/
107
-					$last_name_meta = get_user_meta( $user->ID, 'last_name', true);
108
-					$first_name_meta = get_user_meta( $user->ID, 'first_name', true);
107
+					$last_name_meta = get_user_meta($user->ID, 'last_name', true);
108
+					$first_name_meta = get_user_meta($user->ID, 'first_name', true);
109 109
 					$user_data = $user->data;
110 110
 					$email_data = $user_data->user_email;
111 111
 
112
-					if ( !empty($last_name_meta) ) {
112
+					if (!empty($last_name_meta)) {
113 113
 						$user_name = $last_name_meta;
114 114
 					}
115
-					elseif( !empty( $first_name_meta)) {
115
+					elseif (!empty($first_name_meta)) {
116 116
 						$user_name = $first_name_meta;
117 117
 					}
118 118
 					else {
119 119
 						$user_name = $email_data;
120 120
 					}
121 121
 
122
-					if ( $letter == __('ALL', 'wps-pos-i18n') || (strtolower(substr($user_name, 0, 1)) == strtolower($letter) && $user_name != __('Default', 'wps-pos-i18n') ) ) {
122
+					if ($letter == __('ALL', 'wps-pos-i18n') || (strtolower(substr($user_name, 0, 1)) == strtolower($letter) && $user_name != __('Default', 'wps-pos-i18n'))) {
123 123
 						$user_infos = array(
124 124
 							'ID' => $user->ID,
125 125
 							'last_name' => $last_name_meta,
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return string La liste des utilisateurs sous forme HTML / HTML output for customer list
144 144
 	 */
145
-	function display_customer_list( $letter ) {
145
+	function display_customer_list($letter) {
146 146
 		$output = '';
147 147
 
148
-		if ( !empty($letter) ) {
149
-			$customer_list = $this->get_customer_by_alphabet( $letter);
148
+		if (!empty($letter)) {
149
+			$customer_list = $this->get_customer_by_alphabet($letter);
150 150
 			$tpl_component = array();
151 151
 			$element = '';
152
-			if ( !empty($customer_list) ) {
152
+			if (!empty($customer_list)) {
153 153
 				ob_start();
154
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'customers' ) );
154
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'customers'));
155 155
 				$output = ob_get_contents();
156 156
 				ob_end_clean();
157 157
 			}
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 	 * @param integer $customer_id
166 166
 	 * @return integer billing address ID
167 167
 	 */
168
-	function check_customer_billing_address( $customer_id ) {
168
+	function check_customer_billing_address($customer_id) {
169 169
 		global $wpdb;
170 170
 		$billing_address_id = 0;
171 171
 		$billing_option = get_option('wpshop_billing_address');
172
-		if ( !empty($customer_id) ) {
173
-			$query = $wpdb->prepare('SELECT * FROM '.$wpdb->posts .' WHERE post_author = %d AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
174
-			$customer_addresses = $wpdb->get_results( $query );
175
-			if ( !empty($customer_addresses) && is_array($customer_addresses) ) {
176
-				if (!empty($billing_option) && !empty($billing_option['choice']) ) {
172
+		if (!empty($customer_id)) {
173
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
174
+			$customer_addresses = $wpdb->get_results($query);
175
+			if (!empty($customer_addresses) && is_array($customer_addresses)) {
176
+				if (!empty($billing_option) && !empty($billing_option['choice'])) {
177 177
 					$billing_address_entity_id = $billing_option['choice'];
178
-					foreach( $customer_addresses as $customer_address ) {
178
+					foreach ($customer_addresses as $customer_address) {
179 179
 						$address_post_meta = get_post_meta($customer_address->ID, '_wpshop_address_attribute_set_id', true);
180
-						if ( $address_post_meta == $billing_address_entity_id ) {
180
+						if ($address_post_meta == $billing_address_entity_id) {
181 181
 							$billing_address_id = $customer_address->ID;
182 182
 							continue;
183 183
 						}
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 					'post_parent' => $customer_id,
203 203
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS,
204 204
 				);
205
-				$billing_address_id = wp_insert_post( $address_post );
206
-				update_post_meta( $billing_address_id, '_wpshop_address_metadata', $billing_address);
207
-				update_post_meta($billing_address_id, '_wpshop_address_attribute_set_id', $billing_option['choice'] );
205
+				$billing_address_id = wp_insert_post($address_post);
206
+				update_post_meta($billing_address_id, '_wpshop_address_metadata', $billing_address);
207
+				update_post_meta($billing_address_id, '_wpshop_address_attribute_set_id', $billing_option['choice']);
208 208
 			}
209 209
 		}
210 210
 		return $billing_address_id;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	 * @param integer $customer_id
216 216
 	 * @return array of objects order
217 217
 	 */
218
-	function get_orders_customer( $per_page, $customer_id ) {
219
-		if( !isset( $this->wps_orders_customer ) ) {
218
+	function get_orders_customer($per_page, $customer_id) {
219
+		if (!isset($this->wps_orders_customer)) {
220 220
 			$this->wps_orders_customer = array();
221 221
 		}
222
-		if( !isset( $this->wps_orders_customer[$customer_id] ) ) {
222
+		if (!isset($this->wps_orders_customer[$customer_id])) {
223 223
 			$args = array(
224 224
 					'posts_per_page' 	=> $per_page,
225 225
 					'post_type'			=> WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
@@ -228,28 +228,28 @@  discard block
 block discarded – undo
228 228
 						'relation' 			=> 'AND',
229 229
 						array(
230 230
 								'key' 			=> '_order_postmeta',
231
-								'value' 		=> serialize( 'customer_id' ) . serialize( $customer_id ),
231
+								'value' 		=> serialize('customer_id') . serialize($customer_id),
232 232
 								'compare' 		=> 'LIKE',
233 233
 						),
234 234
 						array(
235 235
 							'relation' 			=> 'OR',
236 236
 							array(
237 237
 									'key'			=> '_order_postmeta',
238
-									'value' 		=> serialize( 'order_status' ) . serialize( 'pos' ),
238
+									'value' 		=> serialize('order_status') . serialize('pos'),
239 239
 									'compare' 		=> 'LIKE',
240 240
 							),
241 241
 							array(
242 242
 									'key'			=> '_order_postmeta',
243
-									'value' 		=> serialize( 'shipping_method' ) . serialize( 'default_shipping_mode_for_pos' ),
243
+									'value' 		=> serialize('shipping_method') . serialize('default_shipping_mode_for_pos'),
244 244
 									'compare' 		=> 'LIKE',
245 245
 							),
246 246
 						),
247 247
 					),
248 248
 			);
249
-			$query = new WP_Query( $args );
249
+			$query = new WP_Query($args);
250 250
 			$orders = $query->posts;
251
-			foreach( $orders as $order ) {
252
-				$order->_order_postmeta = get_post_meta( $order->ID, '_order_postmeta', true );
251
+			foreach ($orders as $order) {
252
+				$order->_order_postmeta = get_post_meta($order->ID, '_order_postmeta', true);
253 253
 			}
254 254
 			$this->wps_orders_customer[$customer_id] = $orders;
255 255
 		}
@@ -262,20 +262,20 @@  discard block
 block discarded – undo
262 262
 	function metabox_customers() {
263 263
 		global $wpdb;
264 264
 
265
-		$available_letters = array();//$wpdb->get_var( $query );
265
+		$available_letters = array(); //$wpdb->get_var( $query );
266 266
 
267 267
 		/**	Check the first letter available for product to choose the good one when displaying default interface	*/
268
-		$letters_having_customers = array();//array_unique( explode( ',', $available_letters ) );
269
-		sort( $letters_having_customers );
268
+		$letters_having_customers = array(); //array_unique( explode( ',', $available_letters ) );
269
+		sort($letters_having_customers);
270 270
 
271
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox', 'customers' ) );
271
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox', 'customers'));
272 272
 	}
273 273
 
274 274
 	/**
275 275
 	 * WP CUSTOM METABOX - Affichage de la boite contant les informations du client sélectionné pour la commande / Display the metabox for displaying the selected customer for current order
276 276
 	 */
277 277
 	function metabox_customer() {
278
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox', 'customer' ) );
278
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox', 'customer'));
279 279
 	}
280 280
 
281 281
 	/**
@@ -283,27 +283,27 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @param integer $customer_id L'identifiant du client que l'on souhaite afficher / The customer identifier that we want to display sumary for
285 285
 	 */
286
-	function display_selected_customer( $customer_id ) {
286
+	function display_selected_customer($customer_id) {
287 287
 		/**	Récupération des données de l'utilisateur / Get selected user account informations	*/
288
-		$customer_infos = get_userdata( (int) $customer_id );
288
+		$customer_infos = get_userdata((int)$customer_id);
289 289
 
290
-		$_SESSION[ 'wps-pos-addon' ] = 1;
290
+		$_SESSION['wps-pos-addon'] = 1;
291 291
 
292
-		$_SESSION[ 'billing_address' ] = $this->check_customer_billing_address( $customer_id );
293
-		$shipping_address_id = get_option( 'wpshop_pos_addon_shop_address' );
294
-		$_SESSION[ 'shipping_address' ] = ( !empty($shipping_address_id) && sanitize_key( $shipping_address_id ) ) ? $shipping_address_id : '';
292
+		$_SESSION['billing_address'] = $this->check_customer_billing_address($customer_id);
293
+		$shipping_address_id = get_option('wpshop_pos_addon_shop_address');
294
+		$_SESSION['shipping_address'] = (!empty($shipping_address_id) && sanitize_key($shipping_address_id)) ? $shipping_address_id : '';
295 295
 
296 296
 		/**	Inclusion du fichier d'affichage / Include the display file	*/
297
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox-selected', 'customer' ) );
297
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'metabox-selected', 'customer'));
298 298
 	}
299 299
 
300 300
 	/**
301 301
 	 * AJAX - Selection et affectation du client à la commande en cours / Set selected user as new order owner
302 302
 	 */
303 303
 	function ajax_pos_customer_choice() {
304
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
304
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
305 305
 
306
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_choice' ) )
306
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_customer_choice'))
307 307
 			wp_die();
308 308
 
309 309
 		$response = array(
@@ -311,42 +311,42 @@  discard block
 block discarded – undo
311 311
 			'element_type'	=> 'customer',
312 312
 			'output'		=> '',
313 313
 		);
314
-		$selected_customer = ( !empty( $_POST ) && !empty( $_POST[ 'customer' ] ) && is_int( (int) $_POST[ 'customer' ] ) ) ? (int) $_POST[ 'customer' ] : null;
314
+		$selected_customer = (!empty($_POST) && !empty($_POST['customer']) && is_int((int)$_POST['customer'])) ? (int)$_POST['customer'] : null;
315 315
 
316
-		if ( !empty( $selected_customer ) ) {
317
-			$_SESSION[ 'cart' ][ 'customer_id' ] = $selected_customer;
318
-			$response[ 'status' ] = true;
316
+		if (!empty($selected_customer)) {
317
+			$_SESSION['cart']['customer_id'] = $selected_customer;
318
+			$response['status'] = true;
319 319
 
320 320
 			/**	Affichage du client sélectionné pour la commande courante / Display selected customer account summary	*/
321 321
 			ob_start();
322
-			$this->display_selected_customer( $selected_customer );
323
-			$response[ 'output' ] = ob_get_contents();
322
+			$this->display_selected_customer($selected_customer);
323
+			$response['output'] = ob_get_contents();
324 324
 			ob_end_clean();
325 325
 		}
326 326
 		else {
327
-			$response[ 'output' ] = __( 'No customer has been selected, please choose a customer or create a new one before try to create a new order', 'wps-pos-i18n' );
327
+			$response['output'] = __('No customer has been selected, please choose a customer or create a new one before try to create a new order', 'wps-pos-i18n');
328 328
 		}
329 329
 
330
-		wp_die( json_encode( $response ) );
330
+		wp_die(json_encode($response));
331 331
 	}
332 332
 
333 333
 	/**
334 334
 	 * AJAX - Recherche dans la liste des clients du site / Search into website customer list
335 335
 	 */
336 336
 	function ajax_pos_customer_search() {
337
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
337
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
338 338
 
339
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_search' ) )
339
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_customer_search'))
340 340
 			wp_die();
341 341
 
342 342
 		global $wpdb;
343
-		$term = ( !empty( $_POST['term'] ) ) ? sanitize_text_field( $_POST['term'] ) : '';
343
+		$term = (!empty($_POST['term'])) ? sanitize_text_field($_POST['term']) : '';
344 344
 
345 345
 		/** Get the default customer **/
346
-		$default_customer_option = get_option( 'wpshop_pos_addon_default_customer_id' );
347
-		if ( !empty($default_customer_option) ) {
346
+		$default_customer_option = get_option('wpshop_pos_addon_default_customer_id');
347
+		if (!empty($default_customer_option)) {
348 348
 			$default_user = get_user_by('id', $default_customer_option);
349
-			if ( !empty($default_user) ) {
349
+			if (!empty($default_user)) {
350 350
 				$user_infos = array(
351 351
 					'ID' => $default_user->ID,
352 352
 					'last_name' => get_user_meta($default_user->ID, 'last_name', true),
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 			}
358 358
 		}
359 359
 
360
-		if ( false ) {
360
+		if (false) {
361 361
 			/**	Build the customer search	*/
362 362
 			$args = array(
363 363
 				'search'			=> "*" . $term . "*",
364
-				'search_columns'	=> array( 'user_login', 'user_email', 'user_nicename', ),
364
+				'search_columns'	=> array('user_login', 'user_email', 'user_nicename',),
365 365
 
366 366
 				'meta_query'		=> array(
367 367
 					'relation'	=> 'OR',
@@ -377,19 +377,19 @@  discard block
 block discarded – undo
377 377
 					),
378 378
 				),
379 379
 			);
380
-			$customer_search = new WP_User_Query( $args );
381
-			if ( !empty($customer_search->results) ) {
382
-				foreach ( $customer_search->results as $customer ) {
380
+			$customer_search = new WP_User_Query($args);
381
+			if (!empty($customer_search->results)) {
382
+				foreach ($customer_search->results as $customer) {
383 383
 					/** Check the username, if last name and first name are empty we select email **/
384
-					$last_name_meta = get_user_meta( $customer->ID, 'last_name', true);
385
-					$first_name_meta = get_user_meta( $customer->ID, 'first_name', true);
384
+					$last_name_meta = get_user_meta($customer->ID, 'last_name', true);
385
+					$first_name_meta = get_user_meta($customer->ID, 'first_name', true);
386 386
 					$user_data = $customer->data;
387 387
 					$email_data = $user_data->user_email;
388 388
 
389
-					if ( !empty($last_name_meta) ) {
389
+					if (!empty($last_name_meta)) {
390 390
 						$user_name = $last_name_meta;
391 391
 					}
392
-					elseif( !empty( $first_name_meta)) {
392
+					elseif (!empty($first_name_meta)) {
393 393
 						$user_name = $first_name_meta;
394 394
 					}
395 395
 					else {
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		}
408 408
 		else {
409 409
 			/**	Build the customer search	*/
410
-			$query = $wpdb->prepare( "
410
+			$query = $wpdb->prepare("
411 411
 				SELECT *
412 412
 				FROM {$wpdb->users} AS U
413 413
 					LEFT JOIN {$wpdb->usermeta} AS UM ON ( UM.user_id = U.ID )
@@ -424,20 +424,20 @@  discard block
 block discarded – undo
424 424
 						AND UM.meta_value LIKE '%%%s%%'
425 425
 					)
426 426
 				GROUP BY U.ID
427
-			", array( $term, $term, $term, $term, $term, ) );
428
-			$customer_search = $wpdb->get_results( $query );
429
-			if ( !empty( $customer_search ) ) {
430
-				foreach ( $customer_search as $customer ) {
427
+			", array($term, $term, $term, $term, $term,));
428
+			$customer_search = $wpdb->get_results($query);
429
+			if (!empty($customer_search)) {
430
+				foreach ($customer_search as $customer) {
431 431
 					/** Check the username, if last name and first name are empty we select email **/
432
-					$last_name_meta = get_user_meta( $customer->ID, 'last_name', true);
433
-					$first_name_meta = get_user_meta( $customer->ID, 'first_name', true);
434
-					$user_data = get_userdata( $customer->ID );
432
+					$last_name_meta = get_user_meta($customer->ID, 'last_name', true);
433
+					$first_name_meta = get_user_meta($customer->ID, 'first_name', true);
434
+					$user_data = get_userdata($customer->ID);
435 435
 					$email_data = $user_data->user_email;
436 436
 
437
-					if ( !empty($last_name_meta) ) {
437
+					if (!empty($last_name_meta)) {
438 438
 						$user_name = $last_name_meta;
439 439
 					}
440
-					elseif( !empty( $first_name_meta)) {
440
+					elseif (!empty($first_name_meta)) {
441 441
 						$user_name = $first_name_meta;
442 442
 					}
443 443
 					else {
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
 
457 457
 		/**	Display the customer list into metabox	*/
458 458
 		ob_start();
459
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'customers' ) );
459
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/customers', 'customers'));
460 460
 		$output = ob_get_contents();
461 461
 		ob_end_clean();
462 462
 
463
-		wp_die( $output );
463
+		wp_die($output);
464 464
 	}
465 465
 
466 466
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -23 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
  * Fichier du controlleur pour le module client du logiciel de caisse pour WP-Shop / Main controller file for customer into point of sale management plugin
4 6
  *
@@ -111,11 +113,9 @@  discard block
 block discarded – undo
111 113
 
112 114
 					if ( !empty($last_name_meta) ) {
113 115
 						$user_name = $last_name_meta;
114
-					}
115
-					elseif( !empty( $first_name_meta)) {
116
+					} elseif( !empty( $first_name_meta)) {
116 117
 						$user_name = $first_name_meta;
117
-					}
118
-					else {
118
+					} else {
119 119
 						$user_name = $email_data;
120 120
 					}
121 121
 
@@ -183,8 +183,7 @@  discard block
 block discarded – undo
183 183
 						}
184 184
 					}
185 185
 				}
186
-			}
187
-			else {
186
+			} else {
188 187
 				/** Create a billing address for this customer **/
189 188
 				$user_infos = get_user_by('id', $customer_id);
190 189
 				$billing_address = array();
@@ -303,8 +302,9 @@  discard block
 block discarded – undo
303 302
 	function ajax_pos_customer_choice() {
304 303
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
305 304
 
306
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_choice' ) )
307
-			wp_die();
305
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_choice' ) ) {
306
+					wp_die();
307
+		}
308 308
 
309 309
 		$response = array(
310 310
 			'status'		=> false,
@@ -322,8 +322,7 @@  discard block
 block discarded – undo
322 322
 			$this->display_selected_customer( $selected_customer );
323 323
 			$response[ 'output' ] = ob_get_contents();
324 324
 			ob_end_clean();
325
-		}
326
-		else {
325
+		} else {
327 326
 			$response[ 'output' ] = __( 'No customer has been selected, please choose a customer or create a new one before try to create a new order', 'wps-pos-i18n' );
328 327
 		}
329 328
 
@@ -336,8 +335,9 @@  discard block
 block discarded – undo
336 335
 	function ajax_pos_customer_search() {
337 336
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
338 337
 
339
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_search' ) )
340
-			wp_die();
338
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_customer_search' ) ) {
339
+					wp_die();
340
+		}
341 341
 
342 342
 		global $wpdb;
343 343
 		$term = ( !empty( $_POST['term'] ) ) ? sanitize_text_field( $_POST['term'] ) : '';
@@ -388,11 +388,9 @@  discard block
 block discarded – undo
388 388
 
389 389
 					if ( !empty($last_name_meta) ) {
390 390
 						$user_name = $last_name_meta;
391
-					}
392
-					elseif( !empty( $first_name_meta)) {
391
+					} elseif( !empty( $first_name_meta)) {
393 392
 						$user_name = $first_name_meta;
394
-					}
395
-					else {
393
+					} else {
396 394
 						$user_name = $email_data;
397 395
 					}
398 396
 
@@ -404,8 +402,7 @@  discard block
 block discarded – undo
404 402
 					);
405 403
 				}
406 404
 			}
407
-		}
408
-		else {
405
+		} else {
409 406
 			/**	Build the customer search	*/
410 407
 			$query = $wpdb->prepare( "
411 408
 				SELECT *
@@ -436,11 +433,9 @@  discard block
 block discarded – undo
436 433
 
437 434
 					if ( !empty($last_name_meta) ) {
438 435
 						$user_name = $last_name_meta;
439
-					}
440
-					elseif( !empty( $first_name_meta)) {
436
+					} elseif( !empty( $first_name_meta)) {
441 437
 						$user_name = $first_name_meta;
442
-					}
443
-					else {
438
+					} else {
444 439
 						$user_name = $email_data;
445 440
 					}
446 441
 
Please login to merge, or discard this patch.
includes/modules/wps-pos-addon/controller/wps-pos-product.ctr.php 2 patches
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for product into point of sale management plugin
4 4
  *
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		/**	Call dashboard metaboxes	*/
22
-		add_action( 'admin_init', array( $this, 'dashboard_metaboxes' ) );
22
+		add_action('admin_init', array($this, 'dashboard_metaboxes'));
23 23
 
24 24
 		/**	Point d'accroche AJAX / AJAX listeners	*/
25 25
 		/**	Vérification du type de produit avant ajout au panier / Check the product type before adding it into cart	*/
26 26
 		//add_action( 'wap_ajax_wps-pos-product-check-type', array( $this, 'ajax_pos_check_product_type' ) );
27 27
 		/**	Affiche le formulaire permettant de sélectionner la déclinaison du produit / Display the form allowing to choose product variation	*/
28
-		add_action( 'wp_ajax_wps-pos-product-variation-selection', array( $this, 'ajax_pos_product_variation_selection' ) );
28
+		add_action('wp_ajax_wps-pos-product-variation-selection', array($this, 'ajax_pos_product_variation_selection'));
29 29
 		/**	Lance la recherche de produit / Launch product search	*/
30
-		add_action( 'wp_ajax_wpspos-product-search', array( $this, 'ajax_pos_product_search' ) );
30
+		add_action('wp_ajax_wpspos-product-search', array($this, 'ajax_pos_product_search'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 
39 39
 		/**	Create metaboxes for left side	*/
40 40
 		ob_start();
41
-		require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'metabox_title', 'list' ) );
41
+		require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'metabox_title', 'list'));
42 42
 		$metabox_title = ob_get_contents();
43 43
 		ob_end_clean();
44
-		add_meta_box( 'wpspos-dashboard-product-metabox', $metabox_title, array( $this, 'dashboard_product_metabox' ), 'wpspos-dashboard', 'wpspos-dashboard-left' );
44
+		add_meta_box('wpspos-dashboard-product-metabox', $metabox_title, array($this, 'dashboard_product_metabox'), 'wpspos-dashboard', 'wpspos-dashboard-left');
45 45
 
46 46
 		/**	Create metaboxes for right side	*/
47 47
 	}
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 		global $wpdb;
54 54
 
55 55
 		/**	Get existing product first letter to only display letter with product as selectable	*/
56
-		$query = $wpdb->prepare( "SELECT GROUP_CONCAT( LEFT( UPPER( post_title ), 1 ) ) AS LETTER FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' );
57
-		$available_letters = $wpdb->get_var( $query );
56
+		$query = $wpdb->prepare("SELECT GROUP_CONCAT( LEFT( UPPER( post_title ), 1 ) ) AS LETTER FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
57
+		$available_letters = $wpdb->get_var($query);
58 58
 
59 59
 		/**	Check the first letter available for product to choose the good one when displaying default interface	*/
60
-		$letters_having_products = array_unique( explode( ',', $available_letters ) );
61
-		sort( $letters_having_products );
60
+		$letters_having_products = array_unique(explode(',', $available_letters));
61
+		sort($letters_having_products);
62 62
 
63
-		require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'metabox', 'product' ) );
63
+		require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'metabox', 'product'));
64 64
 	}
65 65
 
66 66
 	/**
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 * @param char $letter
69 69
 	 * @return string
70 70
 	 */
71
-	function get_product_table_by_alphabet( $letter ) {
71
+	function get_product_table_by_alphabet($letter) {
72 72
 		$output = '';
73 73
 
74
-		if ( !empty($letter) ) {
75
-			$product_list = $this->get_product_list_by_letter( $letter );
74
+		if (!empty($letter)) {
75
+			$product_list = $this->get_product_list_by_letter($letter);
76 76
 			$tpl_component = array();
77
-			if( !empty( $product_list ) ) {
77
+			if (!empty($product_list)) {
78 78
 				ob_start();
79
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products' ) );
79
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products'));
80 80
 				$output = ob_get_contents();
81 81
 				ob_end_clean();
82 82
 			}
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return array The list of product correspondaing to given alphabet letter
94 94
 	 */
95
-	function get_product_list_by_letter( $letter ) {
95
+	function get_product_list_by_letter($letter) {
96 96
 		/** INI SET **/
97
-		@set_time_limit( 120 );
97
+		@set_time_limit(120);
98 98
 
99 99
 		$product_list = array();
100 100
 		global $wpdb;
101
-		$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
102
-		if ( !empty( $letter) ) {
101
+		$price_piloting_option = get_option('wpshop_shop_price_piloting');
102
+		if (!empty($letter)) {
103 103
 
104
-			if ( $letter == __('ALL', 'wps-pos-i18n') ) {
105
-				$query = $wpdb->prepare( "
104
+			if ($letter == __('ALL', 'wps-pos-i18n')) {
105
+				$query = $wpdb->prepare("
106 106
 					SELECT P.ID, P.post_title, PM.meta_value
107 107
 					FROM {$wpdb->posts} AS P
108 108
 						INNER JOIN {$wpdb->postmeta} AS PM ON ( PM.post_id = P.ID )
109 109
 					WHERE P.post_type = %s
110 110
 						AND P.post_status = %s
111 111
 						AND PM.meta_key = %s
112
-					ORDER BY P.post_title", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish', '_wpshop_product_metadata' );
112
+					ORDER BY P.post_title", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish', '_wpshop_product_metadata');
113 113
 			}
114 114
 			else {
115
-				$query = $wpdb->prepare( "
115
+				$query = $wpdb->prepare("
116 116
 					SELECT P.ID, P.post_title, PM.meta_value
117 117
 					FROM {$wpdb->posts} AS P
118 118
 						INNER JOIN {$wpdb->postmeta} AS PM ON ( PM.post_id = P.ID )
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
 						AND P.post_status = %s
121 121
 						AND ( post_title LIKE %s OR post_title LIKE %s )
122 122
 						AND PM.meta_key = %s
123
-					ORDER BY P.post_title", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish', strtoupper( $letter ).'%', strtolower( $letter).'%', '_wpshop_product_metadata' );
123
+					ORDER BY P.post_title", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish', strtoupper($letter) . '%', strtolower($letter) . '%', '_wpshop_product_metadata');
124 124
 			}
125
-			$products = $wpdb->get_results( $query );
125
+			$products = $wpdb->get_results($query);
126 126
 
127
-			if ( !empty( $products ) && is_array( $products ) ) {
128
-				foreach ( $products as $product ) {
129
-					$product_post_meta = unserialize( $product->meta_value );
130
-					if ( !empty($product_post_meta) ) {
127
+			if (!empty($products) && is_array($products)) {
128
+				foreach ($products as $product) {
129
+					$product_post_meta = unserialize($product->meta_value);
130
+					if (!empty($product_post_meta)) {
131 131
 						//$product_variation_definition = get_post_meta( $product->ID, '_wpshop_variation_defining', true );
132 132
 						$product_list[] = array(
133 133
 							'ID' => $product->ID,
134 134
 							'product_name' => $product->post_title,
135
-							'product_price' => !empty( $product_post_meta ) && !empty( $product_post_meta[ 'product_price' ] ) ? number_format( (float)$product_post_meta['product_price'], 2, '.', '') : '',
136
-							'product_barcode' => !empty( $product_post_meta['barcode'] ) ? $product_post_meta['barcode'] : ''
135
+							'product_price' => !empty($product_post_meta) && !empty($product_post_meta['product_price']) ? number_format((float)$product_post_meta['product_price'], 2, '.', '') : '',
136
+							'product_barcode' => !empty($product_post_meta['barcode']) ? $product_post_meta['barcode'] : ''
137 137
 						);
138 138
 					}
139 139
 				}
@@ -147,37 +147,37 @@  discard block
 block discarded – undo
147 147
 	 * AJAX - Vérifie si le produit sur le point d'être ajouté à la commande est un produit simple ou un produit composé / Check if the selected produt is a simple one or a combined one
148 148
 	 */
149 149
 	function ajax_pos_check_product_type() {
150
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
150
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
151 151
 
152
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_check_product_type' ) )
152
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_check_product_type'))
153 153
 			wp_die();
154 154
 
155 155
 		$product_type = 'simple';
156 156
 
157
-		$product_id = ( !empty($_POST['product_id']) ) ? (int) $_POST['product_id'] : null;
158
-		if ( !empty($product_id) ) {
159
-			$product_post_meta = get_post_meta( $product_id, '_wpshop_variation_defining', true );
160
-			if ( !empty( $product_post_meta ) ) {
157
+		$product_id = (!empty($_POST['product_id'])) ? (int)$_POST['product_id'] : null;
158
+		if (!empty($product_id)) {
159
+			$product_post_meta = get_post_meta($product_id, '_wpshop_variation_defining', true);
160
+			if (!empty($product_post_meta)) {
161 161
 				$product_type = 'variations';
162 162
 			}
163 163
 		}
164 164
 
165
-		wp_die( json_encode( array( 'product_type' => $product_type, ) ) );
165
+		wp_die(json_encode(array('product_type' => $product_type,)));
166 166
 	}
167 167
 
168 168
 	/**
169 169
 	 * AJAX - Affiche le formulaire permettant de sélectionner la déclinaison du produit / Display the form allowing to choose product variation
170 170
 	 */
171 171
 	function ajax_pos_product_variation_selection() {
172
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
172
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
173 173
 
174
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_variation_selection' ) )
174
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_product_variation_selection'))
175 175
 			wp_die();
176 176
 
177 177
 		/**	Get the product identifier to display variation chooser	*/
178
-		$product_id = !empty( $_GET ) && !empty( $_GET[ 'product_id' ] ) && is_int( (int)$_GET[ 'product_id' ] ) ? (int)$_GET[ 'product_id' ] : null;
178
+		$product_id = !empty($_GET) && !empty($_GET['product_id']) && is_int((int)$_GET['product_id']) ? (int)$_GET['product_id'] : null;
179 179
 
180
-		require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'modal', 'variation' ) );
180
+		require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'modal', 'variation'));
181 181
 
182 182
 		wp_die();
183 183
 	}
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * AJAX - Lance la recherche de produit / Launch product search
187 187
 	 */
188 188
 	function ajax_pos_product_search() {
189
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
189
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
190 190
 
191
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) )
191
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_product_search'))
192 192
 			wp_die();
193 193
 
194 194
 		global $wpdb;
195 195
 
196
-		$term = !empty( $_POST ) && !empty( $_POST[ 'term' ] ) ? sanitize_text_field( $_POST[ 'term' ] ) : null;
196
+		$term = !empty($_POST) && !empty($_POST['term']) ? sanitize_text_field($_POST['term']) : null;
197 197
 		$response = array(
198 198
 			'status' => false,
199 199
 			'action' => '',
200 200
 		);
201
-		if ( !empty( $term ) ) {
201
+		if (!empty($term)) {
202 202
 
203 203
 			$more_query = "";
204 204
 			$query_args = array();
@@ -206,66 +206,66 @@  discard block
 block discarded – undo
206 206
 			$query_args[] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
207 207
 			$query_args[] = $term;
208 208
 
209
-			$search_in = !empty( $_POST[ 'search_in' ] ) ? sanitize_text_field( $_POST[ 'search_in' ] ) : '';
209
+			$search_in = !empty($_POST['search_in']) ? sanitize_text_field($_POST['search_in']) : '';
210 210
 
211
-			if ( empty( $search_in ) || ( 'only_barcode' != $search_in ) ) {
211
+			if (empty($search_in) || ('only_barcode' != $search_in)) {
212 212
 				$more_query = " OR P.post_title LIKE %s";
213 213
 				$query_args[] = '%' . $term . '%';
214 214
 			}
215
-			$query = $wpdb->prepare( "
215
+			$query = $wpdb->prepare("
216 216
 				SELECT *
217 217
 				FROM {$wpdb->posts} AS P
218 218
 					LEFT JOIN {$wpdb->postmeta} AS PM ON ( PM.post_id = P.ID )
219 219
 				WHERE P.post_type = %s
220 220
 					AND ( ( PM.meta_key = '_barcode' AND PM.meta_value = %s ) " . $more_query . " )
221
-				GROUP BY P.ID", $query_args );
222
-			$results = $wpdb->get_results( $query );
223
-
224
-			if ( !empty( $results ) ) {
225
-				if ( 1 < count( $results ) ) {
226
-					foreach ( $results as $product ) {
227
-						$product_post_meta = get_post_meta( $product->ID, '_wpshop_product_metadata', true );
228
-						if ( !empty($product_post_meta) ) {
221
+				GROUP BY P.ID", $query_args);
222
+			$results = $wpdb->get_results($query);
223
+
224
+			if (!empty($results)) {
225
+				if (1 < count($results)) {
226
+					foreach ($results as $product) {
227
+						$product_post_meta = get_post_meta($product->ID, '_wpshop_product_metadata', true);
228
+						if (!empty($product_post_meta)) {
229 229
 							$product_list[] = array(
230 230
 								'ID' => $product->ID,
231 231
 								'product_name' => $product->post_title,
232
-								'product_price' => number_format( (float)$product_post_meta['product_price'], 2, '.', ''),
233
-								'product_barcode' => !empty( $product_post_meta['barcode'] ) ? $product_post_meta['barcode'] : ''
232
+								'product_price' => number_format((float)$product_post_meta['product_price'], 2, '.', ''),
233
+								'product_barcode' => !empty($product_post_meta['barcode']) ? $product_post_meta['barcode'] : ''
234 234
 							);
235 235
 						}
236 236
 					}
237 237
 
238 238
 					ob_start();
239
-					require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products' ) );
239
+					require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products'));
240 240
 					$output = ob_get_contents();
241 241
 					ob_end_clean();
242 242
 				}
243 243
 				else {
244
-					$product_post_meta = get_post_meta( $results[ 0 ]->ID, '_wpshop_variation_defining', true );
245
-					if ( !empty( $product_post_meta ) ) {
246
-						$response[ 'action' ] = 'variation_selection';
244
+					$product_post_meta = get_post_meta($results[0]->ID, '_wpshop_variation_defining', true);
245
+					if (!empty($product_post_meta)) {
246
+						$response['action'] = 'variation_selection';
247 247
 					}
248 248
 					else {
249
-						$response[ 'action' ] = 'direct_to_cart';
249
+						$response['action'] = 'direct_to_cart';
250 250
 					}
251
-					$output = $results[ 0 ]->ID;
251
+					$output = $results[0]->ID;
252 252
 				}
253 253
 
254 254
 				/**	Build response to send	*/
255
-				$response[ 'status' ] = true;
256
-				$response[ 'output' ] = $output;
255
+				$response['status'] = true;
256
+				$response['output'] = $output;
257 257
 			}
258 258
 			else {
259 259
 				ob_start();
260
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found' ) );
261
-				$response[ 'output' ] = ob_get_contents();
260
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found'));
261
+				$response['output'] = ob_get_contents();
262 262
 				ob_end_clean();
263 263
 			}
264 264
 		}
265 265
 
266
-		$response['_wpnonce'] = wp_create_nonce( 'ajax_pos_product_variation_selection' );
266
+		$response['_wpnonce'] = wp_create_nonce('ajax_pos_product_variation_selection');
267 267
 
268
-		wp_die( json_encode( $response ) );
268
+		wp_die(json_encode($response));
269 269
 	}
270 270
 
271 271
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for product into point of sale management plugin
4 6
  *
@@ -110,8 +112,7 @@  discard block
 block discarded – undo
110 112
 						AND P.post_status = %s
111 113
 						AND PM.meta_key = %s
112 114
 					ORDER BY P.post_title", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish', '_wpshop_product_metadata' );
113
-			}
114
-			else {
115
+			} else {
115 116
 				$query = $wpdb->prepare( "
116 117
 					SELECT P.ID, P.post_title, PM.meta_value
117 118
 					FROM {$wpdb->posts} AS P
@@ -149,8 +150,9 @@  discard block
 block discarded – undo
149 150
 	function ajax_pos_check_product_type() {
150 151
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
151 152
 
152
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_check_product_type' ) )
153
-			wp_die();
153
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_check_product_type' ) ) {
154
+					wp_die();
155
+		}
154 156
 
155 157
 		$product_type = 'simple';
156 158
 
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	function ajax_pos_product_variation_selection() {
172 174
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
173 175
 
174
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_variation_selection' ) )
175
-			wp_die();
176
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_variation_selection' ) ) {
177
+					wp_die();
178
+		}
176 179
 
177 180
 		/**	Get the product identifier to display variation chooser	*/
178 181
 		$product_id = !empty( $_GET ) && !empty( $_GET[ 'product_id' ] ) && is_int( (int)$_GET[ 'product_id' ] ) ? (int)$_GET[ 'product_id' ] : null;
@@ -188,8 +191,9 @@  discard block
 block discarded – undo
188 191
 	function ajax_pos_product_search() {
189 192
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
190 193
 
191
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) )
192
-			wp_die();
194
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) ) {
195
+					wp_die();
196
+		}
193 197
 
194 198
 		global $wpdb;
195 199
 
@@ -239,13 +243,11 @@  discard block
 block discarded – undo
239 243
 					require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products' ) );
240 244
 					$output = ob_get_contents();
241 245
 					ob_end_clean();
242
-				}
243
-				else {
246
+				} else {
244 247
 					$product_post_meta = get_post_meta( $results[ 0 ]->ID, '_wpshop_variation_defining', true );
245 248
 					if ( !empty( $product_post_meta ) ) {
246 249
 						$response[ 'action' ] = 'variation_selection';
247
-					}
248
-					else {
250
+					} else {
249 251
 						$response[ 'action' ] = 'direct_to_cart';
250 252
 					}
251 253
 					$output = $results[ 0 ]->ID;
@@ -254,8 +256,7 @@  discard block
 block discarded – undo
254 256
 				/**	Build response to send	*/
255 257
 				$response[ 'status' ] = true;
256 258
 				$response[ 'output' ] = $output;
257
-			}
258
-			else {
259
+			} else {
259 260
 				ob_start();
260 261
 				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found' ) );
261 262
 				$response[ 'output' ] = ob_get_contents();
Please login to merge, or discard this patch.
modules/wps_customer_quick_add/controller/wps_customer_quick_add.ctr.php 2 patches
Spacing   +29 added lines, -29 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
  * Fichier du controlleur principal du module de création de client rapide / Controller file for quick customer creation
4 4
  *
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public function __construct() {
21 21
 		/**	Affiche un formulaire permettant de créer un client / Display a form allowing to add a new customer	*/
22
-		add_action( 'wp_ajax_wpspos-customer-quick-creation', array( $this, 'customer_creation' ) );
23
-		add_action( 'wp_ajax_wpspos-customer-quick-add', array( $this, 'create_customer' ) );
22
+		add_action('wp_ajax_wpspos-customer-quick-creation', array($this, 'customer_creation'));
23
+		add_action('wp_ajax_wpspos-customer-quick-add', array($this, 'create_customer'));
24 24
 	}
25 25
 
26 26
 
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 	 * AJAX - Charge le fomulaire d'ajout rapide d'un client / Load the form for new customer quick add
29 29
 	 */
30 30
 	function customer_creation() {
31
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
31
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
32 32
 
33
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) )
33
+		if (!wp_verify_nonce($_wpnonce, 'wps-customer-quick-nonce'))
34 34
 			wp_die();
35 35
 
36 36
 		// check_ajax_referer( 'wps-customer-quick-nonce', 'wps-nonce' );
37 37
 		global $wpdb;
38 38
 
39
-		$customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
40
-		$query = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id() );
41
-		$cid = $wpdb->get_var( $query );
39
+		$customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
40
+		$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id());
41
+		$cid = $wpdb->get_var($query);
42 42
 
43
-		$customer_attribute_set = !empty( $_GET ) && !empty( $_GET[ 'customer_set_id' ] ) ? (int)$_GET[ 'customer_set_id' ] : null;
43
+		$customer_attribute_set = !empty($_GET) && !empty($_GET['customer_set_id']) ? (int)$_GET['customer_set_id'] : null;
44 44
 
45
-		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails( $customer_attribute_set, "'valid'");
45
+		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails($customer_attribute_set, "'valid'");
46 46
 
47
-		require_once( wpshop_tools::get_template_part( WPSPOSCLTQUICK_DIR, WPSPOSCLTQUICK_TEMPLATES_MAIN_DIR, "backend", "customer", "creation" ) );
47
+		require_once(wpshop_tools::get_template_part(WPSPOSCLTQUICK_DIR, WPSPOSCLTQUICK_TEMPLATES_MAIN_DIR, "backend", "customer", "creation"));
48 48
 		wp_die( );
49 49
 	}
50 50
 
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 	 * AJAX - Création d'un nouveau client / Create a new customer
54 54
 	 */
55 55
 	function create_customer() {
56
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
56
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
57 57
 
58
-		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) )
58
+		if (!wp_verify_nonce($_wpnonce, 'create_customer'))
59 59
 			wp_die();
60 60
 
61 61
 		global $wpdb;
62 62
 		$response = array(
63 63
 			'status' => false,
64
-			'output' => __( 'An error occured while saving customer', 'wpshop' ),
64
+			'output' => __('An error occured while saving customer', 'wpshop'),
65 65
 			'customer_id' => -1,
66 66
 		);
67 67
 
68 68
 		/**	Check if a attribute set id have been sended in order to check if therer are some check to do on sended input	*/
69
-		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails( (int)$_POST[ 'wps-customer-account-set-id' ], "'valid'");
69
+		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails((int)$_POST['wps-customer-account-set-id'], "'valid'");
70 70
 
71 71
 		/**	Read sended values for checking	*/
72 72
 		$email_founded = false;
@@ -75,46 +75,46 @@  discard block
 block discarded – undo
75 75
 
76 76
 
77 77
 		$data = array(
78
-			'attribute' => !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array(),
78
+			'attribute' => !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array(),
79 79
 		);
80 80
 
81
-		$quick_add_customer = wps_customer_ctr::quick_add_customer( $data );
82
-		switch( $quick_add_customer ) {
81
+		$quick_add_customer = wps_customer_ctr::quick_add_customer($data);
82
+		switch ($quick_add_customer) {
83 83
 			case 1:
84
-				$response[ 'output' ] = __('An email address is required', 'wpshop');
84
+				$response['output'] = __('An email address is required', 'wpshop');
85 85
 				break;
86 86
 			case 2:
87
-				$response[ 'output' ] = __('An account is already created with this e-mail address', 'wpshop');
87
+				$response['output'] = __('An account is already created with this e-mail address', 'wpshop');
88 88
 				break;
89 89
 			case is_array($quick_add_customer):
90 90
 				/**	Build a response for customer first letter - Specific action (POS)	*/
91
-				if ( !empty($quick_add_customer['varchar']['last_name']) ) {
91
+				if (!empty($quick_add_customer['varchar']['last_name'])) {
92 92
 					$field_for_letter = $quick_add_customer['varchar']['last_name'];
93 93
 				}
94
-				elseif( !empty($quick_add_customer['varchar']['first_name']) ) {
94
+				elseif (!empty($quick_add_customer['varchar']['first_name'])) {
95 95
 					$field_for_letter = $quick_add_customer['varchar']['first_name'];
96 96
 				}
97 97
 				else {
98 98
 					$field_for_letter = $quick_add_customer['varchar']['user_email'];
99 99
 				}
100
-				$response[ 'letter' ] = substr( $field_for_letter, 0, 1);
100
+				$response['letter'] = substr($field_for_letter, 0, 1);
101 101
 
102 102
 				/**	Build response	*/
103
-				$response[ 'status' ] = true;
104
-				$response[ 'output' ] = __('Customer created succesfully', 'wpshop');
105
-				$response[ 'customer_id' ] = $quick_add_customer['integer']['ID'];
103
+				$response['status'] = true;
104
+				$response['output'] = __('Customer created succesfully', 'wpshop');
105
+				$response['customer_id'] = $quick_add_customer['integer']['ID'];
106 106
 
107 107
 				/** Create customer address from sended data **/
108 108
 				// $_REQUEST['user']['customer_id'] = (int)$quick_add_customer['integer']['ID'];
109 109
 				$attribute_to_save = $data['attribute'];
110
-				$customer_id = !empty( $_POST[ 'wps-customer-account-set-id' ] ) ? (int) $_POST[ 'wps-customer-account-set-id' ] : 0;
110
+				$customer_id = !empty($_POST['wps-customer-account-set-id']) ? (int)$_POST['wps-customer-account-set-id'] : 0;
111 111
 				// unset( $_POST['attribute'] );
112 112
 				// $_POST['attribute'][ (int)$_POST[ 'wps-customer-account-set-id' ] ] = $attribute_to_save;
113
-				wps_address::save_address_infos( $customer_id );
113
+				wps_address::save_address_infos($customer_id);
114 114
 				break;
115 115
 		}
116 116
 
117
-		wp_die( json_encode( $response ) );
117
+		wp_die(json_encode($response));
118 118
 	}
119 119
 
120 120
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -9 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
  * Fichier du controlleur principal du module de création de client rapide / Controller file for quick customer creation
4 6
  *
@@ -30,8 +32,9 @@  discard block
 block discarded – undo
30 32
 	function customer_creation() {
31 33
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
32 34
 
33
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) )
34
-			wp_die();
35
+		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) ) {
36
+					wp_die();
37
+		}
35 38
 
36 39
 		// check_ajax_referer( 'wps-customer-quick-nonce', 'wps-nonce' );
37 40
 		global $wpdb;
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	function create_customer() {
56 59
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
57 60
 
58
-		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) )
59
-			wp_die();
61
+		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) ) {
62
+					wp_die();
63
+		}
60 64
 
61 65
 		global $wpdb;
62 66
 		$response = array(
@@ -90,11 +94,9 @@  discard block
 block discarded – undo
90 94
 				/**	Build a response for customer first letter - Specific action (POS)	*/
91 95
 				if ( !empty($quick_add_customer['varchar']['last_name']) ) {
92 96
 					$field_for_letter = $quick_add_customer['varchar']['last_name'];
93
-				}
94
-				elseif( !empty($quick_add_customer['varchar']['first_name']) ) {
97
+				} elseif( !empty($quick_add_customer['varchar']['first_name']) ) {
95 98
 					$field_for_letter = $quick_add_customer['varchar']['first_name'];
96
-				}
97
-				else {
99
+				} else {
98 100
 					$field_for_letter = $quick_add_customer['varchar']['user_email'];
99 101
 				}
100 102
 				$response[ 'letter' ] = substr( $field_for_letter, 0, 1);
Please login to merge, or discard this patch.
modules/wps_product_quick_add/controller/wps_product_quick_add.ctr.php 2 patches
Spacing   +39 added lines, -39 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
  * Fichier du controlleur principal du module de création de produit rapide / Controller file for quick product creation
4 4
  *
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public function __construct() {
21 21
 		/**	Affiche un formulaire permettant de créer un produit / Display a form allowing to add a new product	*/
22
-		add_action( 'wp_ajax_wpspos-product-quick-creation', array( $this, 'product_creation' ) );
22
+		add_action('wp_ajax_wpspos-product-quick-creation', array($this, 'product_creation'));
23 23
 	//	add_action( 'wap_ajax_wpspos-product-quick-add-reload-attribute-list', array( $this, 'attribute_list_reload' ) );
24
-		add_action( 'wp_ajax_wpspos-product-quick-add', array( $this, 'create_product' ) );
24
+		add_action('wp_ajax_wpspos-product-quick-add', array($this, 'create_product'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param integer $chosen_set Le groupe d'attribut dont on veut afficher les champs / Attribute set we want display input for
31 31
 	 */
32
-	function display_attribute( $chosen_set = 0 ) {
33
-		require_once( wpshop_tools::get_template_part( WPSPOSPDTQUICK_DIR, WPSPOSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list" ) );
32
+	function display_attribute($chosen_set = 0) {
33
+		require_once(wpshop_tools::get_template_part(WPSPOSPDTQUICK_DIR, WPSPOSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list"));
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * AJAX - Charge le fomulaire d'ajout rapide d'un produit / Load the form for new product quick add
38 38
 	 */
39 39
 	function product_creation() {
40
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
40
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
41 41
 
42
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) )
42
+		if (!wp_verify_nonce($_wpnonce, 'wps-product-quick-nonce'))
43 43
 			wp_die();
44 44
 
45
-		require_once( wpshop_tools::get_template_part( WPSPOSPDTQUICK_DIR, WPSPOSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) );
45
+		require_once(wpshop_tools::get_template_part(WPSPOSPDTQUICK_DIR, WPSPOSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation"));
46 46
 		wp_die( );
47 47
 	}
48 48
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * AJAX - Recharge la liste des attributs du groupe sélectionné par l'administratuer pour la création du nouveau produit / Reload attribute list for the selected attribute set, choosen by administrator for new product creation
51 51
 	 */
52 52
 	function attribute_list_reload() {
53
-		$attribute_id = !empty( $_POST['attribute_set'] ) ? (int) $_POST['attribute_set'] : 0;
54
-		$this->display_attribute( $attribute_id );
53
+		$attribute_id = !empty($_POST['attribute_set']) ? (int)$_POST['attribute_set'] : 0;
54
+		$this->display_attribute($attribute_id);
55 55
 		wp_die( );
56 56
 	}
57 57
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 * AJAX - Création d'un nouveau produit / Create a new product
60 60
 	 */
61 61
 	function create_product() {
62
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
62
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
63 63
 
64
-		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) )
64
+		if (!wp_verify_nonce($_wpnonce, 'create_product'))
65 65
 			wp_die();
66 66
 
67 67
 		global $wpdb;
@@ -71,36 +71,36 @@  discard block
 block discarded – undo
71 71
 			'pid' => -1,
72 72
 		);
73 73
 
74
-		$post_title = ( !empty($_POST['post_title']) ) ? sanitize_text_field( $_POST['post_title'] ) : -1;
75
-		$post_content = ( !empty($_POST['post_content']) ) ? sanitize_text_field( $_POST['post_content'] ) : '';
76
-		$attributes = ( !empty($_POST['attribute']) ) ? (array)$_POST['attribute'] : array();
77
-		$id_attribute_set = ( !empty($_POST['wps-product-attribute-set']) ) ? (int)$_POST['wps-product-attribute-set'] : -1;
74
+		$post_title = (!empty($_POST['post_title'])) ? sanitize_text_field($_POST['post_title']) : -1;
75
+		$post_content = (!empty($_POST['post_content'])) ? sanitize_text_field($_POST['post_content']) : '';
76
+		$attributes = (!empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array();
77
+		$id_attribute_set = (!empty($_POST['wps-product-attribute-set'])) ? (int)$_POST['wps-product-attribute-set'] : -1;
78 78
 
79 79
 		$post_type = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
80
-		$attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity( wpshop_entities::get_entity_identifier_from_code( 'wpshop_product' ) );
81
-		foreach( $attribute_set_list as $attribute_set ) {
82
-			if( $id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product' ) {
80
+		$attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code('wpshop_product'));
81
+		foreach ($attribute_set_list as $attribute_set) {
82
+			if ($id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product') {
83 83
 				$post_type = 'free_product';
84 84
 			}
85 85
 		}
86 86
 
87
-		if( ( -1 != $post_title ) && ( -1 != $id_attribute_set ) ) {
88
-			$new_product_id = wp_insert_post( array(
87
+		if (( -1 != $post_title ) && ( -1 != $id_attribute_set )) {
88
+			$new_product_id = wp_insert_post(array(
89 89
 				'post_type' => $post_type,
90 90
 				'post_status' => 'publish',
91 91
 				'post_title' => $post_title,
92 92
 				'post_content' => $post_content,
93
-			) );
93
+			));
94 94
 
95
-			if( !is_wp_error( $new_product_id ) ) {
96
-				update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set );
97
-				$data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $new_product_id );
98
-				$data_to_save['wpshop_product_attribute'] = ( !empty($attributes) ) ? $attributes : array();
95
+			if (!is_wp_error($new_product_id)) {
96
+				update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set);
97
+				$data_to_save['post_ID'] = $data_to_save['product_id'] = intval($new_product_id);
98
+				$data_to_save['wpshop_product_attribute'] = (!empty($attributes)) ? $attributes : array();
99 99
 				$data_to_save['user_ID'] = get_current_user_id();
100 100
 				$data_to_save['action'] = 'editpost';
101 101
 
102 102
 				// Get current barcode
103
-				if(empty($data_to_save['wpshop_product_attribute']['varchar']['barcode'])) {
103
+				if (empty($data_to_save['wpshop_product_attribute']['varchar']['barcode'])) {
104 104
 					// Get current barcode
105 105
 					$wps_product_mdl = new wps_product_mdl();
106 106
 					$attid = wpshop_attributes::getElement('barcode', "'valid'", 'code')->id;
@@ -108,25 +108,25 @@  discard block
 block discarded – undo
108 108
 					$data_to_save['wpshop_product_attribute']['varchar']['barcode'] = $barcode_value;
109 109
 				}
110 110
 
111
-				$response[ 'pid' ] = $new_product_id;
112
-				$response[ 'status' ] = false;
113
-				$response[ 'output' ] = __('Product created partially!', 'wpshop');
114
-				$response[ 'letter' ] = substr( $post_title, 0, 1);
115
-				if( !empty( $new_product_id ) && !empty( $data_to_save['user_ID'] ) ) {
111
+				$response['pid'] = $new_product_id;
112
+				$response['status'] = false;
113
+				$response['output'] = __('Product created partially!', 'wpshop');
114
+				$response['letter'] = substr($post_title, 0, 1);
115
+				if (!empty($new_product_id) && !empty($data_to_save['user_ID'])) {
116 116
 					$product_class = new wpshop_products();
117
-					$product_class->save_product_custom_informations( $new_product_id, $data_to_save );
118
-					$response[ 'status' ] = true;
119
-					$response[ 'output' ] = __('Product created successfully.', 'wpshop');
117
+					$product_class->save_product_custom_informations($new_product_id, $data_to_save);
118
+					$response['status'] = true;
119
+					$response['output'] = __('Product created successfully.', 'wpshop');
120 120
 				}
121 121
 
122
-				$wps_quick_creation_hook = do_action( 'wps-new-product-quick-created', $new_product_id );
123
-				if ( !empty( $wps_quick_creation_hook ) ) {
124
-					$response[ '' ] = $wps_quick_creation_hook;
122
+				$wps_quick_creation_hook = do_action('wps-new-product-quick-created', $new_product_id);
123
+				if (!empty($wps_quick_creation_hook)) {
124
+					$response[''] = $wps_quick_creation_hook;
125 125
 				}
126 126
 			}
127 127
 		}
128 128
 
129
-		wp_die( json_encode( $response ) );
129
+		wp_die(json_encode($response));
130 130
 	}
131 131
 
132 132
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier du controlleur principal du module de création de produit rapide / Controller file for quick product creation
4 6
  *
@@ -39,8 +41,9 @@  discard block
 block discarded – undo
39 41
 	function product_creation() {
40 42
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
41 43
 
42
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) )
43
-			wp_die();
44
+		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) ) {
45
+					wp_die();
46
+		}
44 47
 
45 48
 		require_once( wpshop_tools::get_template_part( WPSPOSPDTQUICK_DIR, WPSPOSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) );
46 49
 		wp_die( );
@@ -61,8 +64,9 @@  discard block
 block discarded – undo
61 64
 	function create_product() {
62 65
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
63 66
 
64
-		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) )
65
-			wp_die();
67
+		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) ) {
68
+					wp_die();
69
+		}
66 70
 
67 71
 		global $wpdb;
68 72
 		$response = array(
Please login to merge, or discard this patch.