Completed
Push — master ( f10213...9f1064 )
by
unknown
14:10
created
includes/modules/wps_export/model/wps_export_mdl.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 	/**
5 5
 	 * Get customers with a term: all, newsletters_site, newsletters_site_partners, date(between 2 dates) or if order is higher than.
6 6
 	 * @param string $term
7
-	 * @param price/date $dt1 may be null
7
+	 * @param string|boolean $dt1 may be null
8 8
 	 * @param date $dt2 may be null
9 9
 	 * @return array
10 10
 	 */
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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
 class wps_export_mdl {
3 3
 
4 4
 	/**
@@ -8,88 +8,88 @@  discard block
 block discarded – undo
8 8
 	 * @param date $dt2 may be null
9 9
 	 * @return array
10 10
 	 */
11
-	function get_customers($term, $dt1=null, $dt2=null) {
11
+	function get_customers($term, $dt1 = null, $dt2 = null) {
12 12
 		global $wpdb;
13 13
 		$users;
14 14
 		switch ($term) {
15 15
 			case 'users_all':
16
-				$query = $wpdb->prepare( "SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1);
16
+				$query = $wpdb->prepare("SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1);
17 17
 				$list_users = $wpdb->get_results($query, OBJECT);
18 18
 				break;
19 19
 			case 'customers_all':
20
-				$query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER );
20
+				$query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER);
21 21
 				$list_users = $wpdb->get_results($query, OBJECT);
22 22
 				break;
23 23
 			case 'newsletters_site':
24
-				$query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;' );
24
+				$query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;');
25 25
 				$list_users = $wpdb->get_results($query, OBJECT);
26 26
 				break;
27 27
 			case 'newsletters_site_partners':
28
-				$query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;' );
28
+				$query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;');
29 29
 				$list_users = $wpdb->get_results($query, OBJECT);
30 30
 				break;
31 31
 			case 'date':
32
-				$query = $wpdb->prepare( "SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2))) );
32
+				$query = $wpdb->prepare("SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER, date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2))));
33 33
 				$list_users = $wpdb->get_results($query, OBJECT);
34 34
 				break;
35 35
 			case 'orders':
36
-				$query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER );
36
+				$query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", WPSHOP_NEWTYPE_IDENTIFIER_ORDER);
37 37
 				$list_users = $wpdb->get_results($query, OBJECT);
38 38
 				break;
39 39
 		}
40 40
 		$users_array = array();
41 41
 		$users_array[] = array(
42
-				'name' => __( 'Name', 'wps_export' ),
43
-				'first_name' => __( 'First name', 'wps_export' ),
44
-				'email' => __( 'Mail', 'wps_export' ),
45
-				'tel' => __( 'Phone', 'wps_export' ),
46
-				'registered' => __( 'Registered', 'wps_export' )
42
+				'name' => __('Name', 'wps_export'),
43
+				'first_name' => __('First name', 'wps_export'),
44
+				'email' => __('Mail', 'wps_export'),
45
+				'tel' => __('Phone', 'wps_export'),
46
+				'registered' => __('Registered', 'wps_export')
47 47
 				);
48
-		if ( !empty( $list_users ) ) {
48
+		if (!empty($list_users)) {
49 49
 			$billing_address_indicator = get_option('wpshop_billing_address');
50 50
 			$billing_address_indicator = $billing_address_indicator['choice'];
51
-			foreach( $list_users as $user_post ) {
52
-				if($term == 'orders') {
51
+			foreach ($list_users as $user_post) {
52
+				if ($term == 'orders') {
53 53
 					$vuser = false;
54 54
 				}
55
-				$user = get_userdata( $user_post->USER_ID );
55
+				$user = get_userdata($user_post->USER_ID);
56 56
 				$tmp_array = array();
57
-				$last_name = get_user_meta( $user->ID, 'last_name', true );
58
-				$first_name = get_user_meta( $user->ID, 'first_name', true );
59
-				if( empty($last_name) )
57
+				$last_name = get_user_meta($user->ID, 'last_name', true);
58
+				$first_name = get_user_meta($user->ID, 'first_name', true);
59
+				if (empty($last_name))
60 60
 					$last_name = $user->display_name;
61
-				if( empty($first_name) )
61
+				if (empty($first_name))
62 62
 					$first_name = '-';
63 63
 				$tmp_array['name'] = $last_name;
64 64
 				$tmp_array['first_name'] = $first_name;
65 65
 				$tmp_array['email'] = $user->user_email;
66 66
 				$tmp_array['tel'] = '';
67 67
 				$result = wps_address::get_addresses_list($user->ID);
68
-				if( !empty($result) && !empty($result[$billing_address_indicator]) ) {
69
-					foreach($result[$billing_address_indicator] as $address_id => $address_data) {
70
-						if( !empty($address_data['phone']) ) {
68
+				if (!empty($result) && !empty($result[$billing_address_indicator])) {
69
+					foreach ($result[$billing_address_indicator] as $address_id => $address_data) {
70
+						if (!empty($address_data['phone'])) {
71 71
 							$tmp_array['tel'] = $address_data['phone'];
72 72
 						}
73 73
 					}
74 74
 				}
75 75
 				$tmp_array['registered'] = date('d M Y H:i', strtotime($user->user_registered));
76 76
 				$posts_id = explode(',', $user_post->POST_ID);
77
-				$orders = get_posts( array(
77
+				$orders = get_posts(array(
78 78
 						'include'			=>	$posts_id,
79 79
 						'post_type'			=>	WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
80 80
 						'posts_per_page'	=>	-1
81 81
 					));
82
-				foreach( $orders as $order ) {
83
-					if($term == 'orders') {
84
-						$command = get_post_meta( $order->ID, '_order_postmeta', true );
85
-						if( ( !empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1 ) || ( !empty($dt2) && $dt2===true && $command['order_payment']['customer_choice']['method'] == 'free' ) ) {
82
+				foreach ($orders as $order) {
83
+					if ($term == 'orders') {
84
+						$command = get_post_meta($order->ID, '_order_postmeta', true);
85
+						if ((!empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1) || (!empty($dt2) && $dt2 === true && $command['order_payment']['customer_choice']['method'] == 'free')) {
86 86
 							$vuser = true;
87 87
 						}
88 88
 					}
89 89
 				}
90
-				if($term != 'orders') {
90
+				if ($term != 'orders') {
91 91
 					$users_array[] = $tmp_array;
92
-				} elseif($vuser) {
92
+				} elseif ($vuser) {
93 93
 					$users_array[] = $tmp_array;
94 94
 				}
95 95
 			}
@@ -104,66 +104,66 @@  discard block
 block discarded – undo
104 104
 	 * @param date $dt2
105 105
 	 * @return array
106 106
 	 */
107
-	function get_orders($term, $dt1=null, $dt2=null) {
107
+	function get_orders($term, $dt1 = null, $dt2 = null) {
108 108
 		$commands_array = array();
109 109
 		$commands_array[] = array(
110
-				'order_type' => __( 'Order type', 'wps_export' ),
111
-				'order_invoice_ref' => __( 'Identifier', 'wps_export' ),
112
-				'name' => __( 'Name', 'wps_export' ),
113
-				'first_name' => __( 'First name', 'wps_export' ),
114
-				'email' => __( 'Mail', 'wps_export' ),
115
-				'tel' => __( 'Phone', 'wps_export' ),
116
-				'date_order' => __( 'Order date', 'wps_export' ),
117
-				'order_total_et' => __( 'Products ET', 'wps_export' ),
118
-				'order_shipping_cost_et' => __( 'Shipping ET', 'wps_export' ),
119
-				'order_shipping_cost_ati' => __( 'Shipping ATI', 'wps_export' ),
120
-				'order_discount_amount' => __( 'Order discount', 'wps_export' ),
121
-				'order_grand_total' => __( 'Order ATI', 'wps_export' )
110
+				'order_type' => __('Order type', 'wps_export'),
111
+				'order_invoice_ref' => __('Identifier', 'wps_export'),
112
+				'name' => __('Name', 'wps_export'),
113
+				'first_name' => __('First name', 'wps_export'),
114
+				'email' => __('Mail', 'wps_export'),
115
+				'tel' => __('Phone', 'wps_export'),
116
+				'date_order' => __('Order date', 'wps_export'),
117
+				'order_total_et' => __('Products ET', 'wps_export'),
118
+				'order_shipping_cost_et' => __('Shipping ET', 'wps_export'),
119
+				'order_shipping_cost_ati' => __('Shipping ATI', 'wps_export'),
120
+				'order_discount_amount' => __('Order discount', 'wps_export'),
121
+				'order_grand_total' => __('Order ATI', 'wps_export')
122 122
 				);
123
-		$orders = get_posts( array(
123
+		$orders = get_posts(array(
124 124
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
125 125
 			'posts_per_page' => -1
126
-		) );
127
-		if ( !empty( $orders ) ) {
128
-			foreach( $orders as $order ) {
129
-				if( !empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2)) ) {
126
+		));
127
+		if (!empty($orders)) {
128
+			foreach ($orders as $order) {
129
+				if (!empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2))) {
130 130
 					$user = get_userdata($order->post_author);
131 131
 					$tmp_array = array();
132
-					$order_postmeta = get_post_meta( $order->ID, '_order_postmeta', true);
133
-					$tmp_array['order_type'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? __( 'Invoice', 'wps_export' ) : ( ( !empty($order_postmeta['order_key']) ) ? __( 'Order', 'wps_export' ) : __( 'Quotation', 'wps_export' ) );
134
-					$tmp_array['order_invoice_ref'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? $order_postmeta['order_invoice_ref'] : ( ( !empty($order_postmeta['order_key']) ) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key'] );
135
-					$tmp_array['name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'last_name', true ) : '';
136
-					$tmp_array['first_name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'first_name', true ) : '';
137
-					$tmp_array['email'] = ( !empty($user->user_email) ) ? $user->user_email : '';
132
+					$order_postmeta = get_post_meta($order->ID, '_order_postmeta', true);
133
+					$tmp_array['order_type'] = (!empty($order_postmeta['order_invoice_ref'])) ? __('Invoice', 'wps_export') : ((!empty($order_postmeta['order_key'])) ? __('Order', 'wps_export') : __('Quotation', 'wps_export'));
134
+					$tmp_array['order_invoice_ref'] = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ((!empty($order_postmeta['order_key'])) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key']);
135
+					$tmp_array['name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'last_name', true) : '';
136
+					$tmp_array['first_name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'first_name', true) : '';
137
+					$tmp_array['email'] = (!empty($user->user_email)) ? $user->user_email : '';
138 138
 					$tmp_array['tel'] = '';
139
-					$order_info = get_post_meta( $order->ID, '_order_info', true);
140
-					if( !empty($order_info) && !empty($order_info['billing']['address']['phone']) ) {
139
+					$order_info = get_post_meta($order->ID, '_order_info', true);
140
+					if (!empty($order_info) && !empty($order_info['billing']['address']['phone'])) {
141 141
 						$tmp_array['tel'] .= $order_info['billing']['address']['phone'];
142 142
 					}
143 143
 					$tmp_array['date_order'] = '';
144
-					if( !empty($order->post_date) ) {
145
-						$tmp_array['date_order'] = mysql2date( get_option( 'date_format' ), $order->post_date, true );
144
+					if (!empty($order->post_date)) {
145
+						$tmp_array['date_order'] = mysql2date(get_option('date_format'), $order->post_date, true);
146 146
 					}
147
-					$tmp_array['order_total_et'] = number_format( ( !empty($order_postmeta['order_total_ht']) ) ? $order_postmeta['order_total_ht'] : 0, 2, '.', '' );
147
+					$tmp_array['order_total_et'] = number_format((!empty($order_postmeta['order_total_ht'])) ? $order_postmeta['order_total_ht'] : 0, 2, '.', '');
148 148
 					//$tmp_array['order_total_ati'] = number_format( ( !empty($order_postmeta['order_total_ttc']) ) ? $order_postmeta['order_total_ttc'] : 0, 2, '.', '' );
149
-					$order_shipping_cost = ( !empty($order_postmeta['order_shipping_cost']) ) ? $order_postmeta['order_shipping_cost'] : 0;
150
-					$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
151
-					if( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) {
149
+					$order_shipping_cost = (!empty($order_postmeta['order_shipping_cost'])) ? $order_postmeta['order_shipping_cost'] : 0;
150
+					$price_piloting_option = get_option('wpshop_shop_price_piloting');
151
+					if (!empty($price_piloting_option) && $price_piloting_option == 'HT') {
152 152
 						$shipati = $order_shipping_cost * 1.2;
153 153
 						$shipet = $order_shipping_cost;
154 154
 					} else {
155 155
 						$shipet = $order_shipping_cost / 1.2;
156 156
 						$shipati = $order_shipping_cost;
157 157
 					}
158
-					$tmp_array['order_shipping_cost_et'] = number_format( $shipet, 2, '.', '' );
159
-					$tmp_array['order_shipping_cost_ati'] = number_format( $shipati, 2, '.', '' );
160
-					$tmp_array['order_discount_amount'] = number_format( ( !empty($order_postmeta['order_discount_amount_total_cart']) ) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', '' );
161
-					$tmp_array['order_grand_total'] = number_format( ( !empty($order_postmeta['order_grand_total']) ) ? $order_postmeta['order_grand_total'] : 0, 2, '.', '' );
158
+					$tmp_array['order_shipping_cost_et'] = number_format($shipet, 2, '.', '');
159
+					$tmp_array['order_shipping_cost_ati'] = number_format($shipati, 2, '.', '');
160
+					$tmp_array['order_discount_amount'] = number_format((!empty($order_postmeta['order_discount_amount_total_cart'])) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', '');
161
+					$tmp_array['order_grand_total'] = number_format((!empty($order_postmeta['order_grand_total'])) ? $order_postmeta['order_grand_total'] : 0, 2, '.', '');
162 162
 					$commands_array[] = $tmp_array;
163 163
 				}
164 164
 			}
165 165
 		}
166
-		$commands_array = apply_filters( 'wps_order_export_filter', $commands_array, $orders, $dt1, $dt2 );
166
+		$commands_array = apply_filters('wps_order_export_filter', $commands_array, $orders, $dt1, $dt2);
167 167
 		return $commands_array;
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
includes/modules/wps_product/model/wps_product_mdl.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -61,6 +61,7 @@
 block discarded – undo
61 61
 
62 62
 	/**
63 63
 	 * Return Products by a search
64
+	 * @param string $search
64 65
 	 */
65 66
 	function get_products_by_title_or_barcode( $search, $only_barcode = false ) {
66 67
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for product mass modification module
4 4
  *
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return array
23 23
 	 */
24
-	function get_product_atts_def( $product_id ) {
25
-		$product_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
26
-		$element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue( $product_entity_id, $product_id, WPSHOP_CURRENT_LOCALE, '', 'frontend' );
24
+	function get_product_atts_def($product_id) {
25
+		$product_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
26
+		$element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($product_entity_id, $product_id, WPSHOP_CURRENT_LOCALE, '', 'frontend');
27 27
 
28 28
 		$one_product = get_post_meta($product_id, WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
29
-		if(!empty($one_product)) {
29
+		if (!empty($one_product)) {
30 30
 			$array1 = (!empty($one_product['attribute_set_section'])) ? $one_product['attribute_set_section'] : array();
31 31
 			$array2 = $element_atribute_list[$product_id];
32 32
 			unset($element_atribute_list);
33
-			foreach($array2 as $key => $attribute_set_section) {
34
-				foreach($array1 as $code1 => $value){
35
-					if($code1 == $attribute_set_section['code']) {
33
+			foreach ($array2 as $key => $attribute_set_section) {
34
+				foreach ($array1 as $code1 => $value) {
35
+					if ($code1 == $attribute_set_section['code']) {
36 36
 						$element_atribute_list[$product_id][$key] = $attribute_set_section;
37 37
 					}
38 38
 				}
@@ -47,38 +47,38 @@  discard block
 block discarded – undo
47 47
 	 * @param integer $letter
48 48
 	 * @return array
49 49
 	 */
50
-	function get_products_by_letter( $letter = 'a' ) {
50
+	function get_products_by_letter($letter = 'a') {
51 51
 		global $wpdb;
52
-		if ( $letter == 'all' ) {
53
-			$query = $wpdb->prepare( 'SELECT ID, post_title FROM ' .$wpdb->posts. ' WHERE post_status = %s AND post_type = %s ORDER BY post_title ASC', 'publish', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
52
+		if ($letter == 'all') {
53
+			$query = $wpdb->prepare('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_status = %s AND post_type = %s ORDER BY post_title ASC', 'publish', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
54 54
 		}
55 55
 		else {
56
-			$query = $wpdb->prepare( 'SELECT ID, post_title FROM ' .$wpdb->posts. ' WHERE post_status = %s AND post_type = %s AND post_title LIKE %s ORDER BY post_title ASC', 'publish', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $letter.'%');
56
+			$query = $wpdb->prepare('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_status = %s AND post_type = %s AND post_title LIKE %s ORDER BY post_title ASC', 'publish', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $letter . '%');
57 57
 		}
58
-		$products = $wpdb->get_results( $query );
58
+		$products = $wpdb->get_results($query);
59 59
 		return $products;
60 60
 	}
61 61
 
62 62
 	/**
63 63
 	 * Return Products by a search
64 64
 	 */
65
-	function get_products_by_title_or_barcode( $search, $only_barcode = false ) {
65
+	function get_products_by_title_or_barcode($search, $only_barcode = false) {
66 66
 		global $wpdb;
67 67
 		$more_query = "";
68 68
 		$query_args = array();
69 69
 		$query_args[] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
70 70
 		$query_args[] = $search;
71
-		if ( !( (bool) $only_barcode ) ) {
71
+		if (!((bool)$only_barcode)) {
72 72
 			$more_query = " OR P.post_title LIKE %s";
73 73
 			$query_args[] = '%' . $search . '%';
74 74
 		}
75
-		$query = $wpdb->prepare( "
75
+		$query = $wpdb->prepare("
76 76
 			SELECT *
77 77
 			FROM {$wpdb->posts} AS P
78 78
 				LEFT JOIN {$wpdb->postmeta} AS PM ON ( PM.post_id = P.ID )
79 79
 			WHERE P.post_type = %s
80 80
 				AND ( ( PM.meta_key = '_barcode' AND PM.meta_value = %s ) " . $more_query . " )
81
-			GROUP BY P.ID", $query_args );
82
-		return $wpdb->get_results( $query );
81
+			GROUP BY P.ID", $query_args);
82
+		return $wpdb->get_results($query);
83 83
 	}
84 84
 }
Please login to merge, or discard this patch.
templates/backend/product-listing/wps_orders_product_listing_table.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,50 +1,50 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- $order_post_meta = !empty($post) ? get_post_meta( $post->ID, '_wpshop_order_status', true ) : ""; ?>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ $order_post_meta = !empty($post) ? get_post_meta($post->ID, '_wpshop_order_status', true) : ""; ?>
3 3
 <div class="wps-table">
4 4
 	<div class="wps-table-header wps-table-row">
5
-		<div class="wps-table-cell"><?php _e( 'Picture', 'wpshop'); ?></div>
6
-		<div class="wps-table-cell"><?php _e( 'Product reference', 'wpshop'); ?></div>
7
-		<div class="wps-table-cell"><?php _e( 'Product name', 'wpshop'); ?></div>
8
-		<div class="wps-table-cell"><?php _e( 'Price', 'wpshop'); ?></div>
5
+		<div class="wps-table-cell"><?php _e('Picture', 'wpshop'); ?></div>
6
+		<div class="wps-table-cell"><?php _e('Product reference', 'wpshop'); ?></div>
7
+		<div class="wps-table-cell"><?php _e('Product name', 'wpshop'); ?></div>
8
+		<div class="wps-table-cell"><?php _e('Price', 'wpshop'); ?></div>
9 9
 
10
-		<?php if ( 'completed' != $order_post_meta ) : ?>
11
-			<div class="wps-table-cell"><?php _e( 'Quantity', 'wpshop'); ?></div>
12
-			<div class="wps-table-cell"><?php _e( 'Add to order', 'wpshop'); ?></div>
10
+		<?php if ('completed' != $order_post_meta) : ?>
11
+			<div class="wps-table-cell"><?php _e('Quantity', 'wpshop'); ?></div>
12
+			<div class="wps-table-cell"><?php _e('Add to order', 'wpshop'); ?></div>
13 13
 		<?php endif; ?>
14 14
 	</div>
15
-	<?php if( !empty($products) ) : ?>
16
-	<?php foreach ( $products as $product ) :
15
+	<?php if (!empty($products)) : ?>
16
+	<?php foreach ($products as $product) :
17 17
 	$pid = $product->ID;
18 18
 	?>
19
-	<?php $product_metadata = get_post_meta( $product->ID, '_wpshop_product_metadata', true ); ?>
19
+	<?php $product_metadata = get_post_meta($product->ID, '_wpshop_product_metadata', true); ?>
20 20
 	<div class="wps-table-content wps-table-row">
21
-		<div class="wps-table-cell  wps-cart-item-img"><?php echo get_the_post_thumbnail( $product->ID, 'thumbnail' ); ?></div>
22
-		<div class="wps-table-cell"><?php echo ( !empty( $product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div>
21
+		<div class="wps-table-cell  wps-cart-item-img"><?php echo get_the_post_thumbnail($product->ID, 'thumbnail'); ?></div>
22
+		<div class="wps-table-cell"><?php echo (!empty($product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div>
23 23
 		<div class="wps-table-cell"><?php echo $product->post_title; ?></div>
24 24
 		<div class="wps-table-cell">
25 25
 		<?php
26 26
 			$product = wpshop_products::get_product_data($product->ID);
27
-			echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid') );
27
+			echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid'));
28 28
 		?>
29 29
 		</div>
30
-		<?php if ( 'completed' != $order_post_meta ) : ?>
30
+		<?php if ('completed' != $order_post_meta) : ?>
31 31
 			<div class="wps-table-cell">
32
-				<a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a>
32
+				<a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a>
33 33
 				<input id="wps-cart-product-qty-<?php echo $pid; ?>" class="wps-cart-product-qty" type="text" value="1" name="french-hens" size="3" style="text-align : center">
34
-				<a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a>
34
+				<a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a>
35 35
 			</div>
36 36
 			<div class="wps-table-cell">
37
-				<a href="#" data-nonce="<?php echo wp_create_nonce( 'wps_add_product_to_order_admin' ); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e( 'Add to order', 'wpshop'); ?></a>
37
+				<a href="#" data-nonce="<?php echo wp_create_nonce('wps_add_product_to_order_admin'); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e('Add to order', 'wpshop'); ?></a>
38 38
 			</div>
39 39
 		<?php endif; ?>
40 40
 	</div>
41 41
 	<?php endforeach; ?>
42 42
 	<?php else :
43
-		if( !empty( $research ) ) : ?>
44
-		<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research ); ?></div>
43
+		if (!empty($research)) : ?>
44
+		<div class="wps-alert-info"><?php printf(__('No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research); ?></div>
45 45
 	<?php else :
46
-			$letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __('ALL', 'wpshop' ); ?>
47
-			<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper( $letter_display ) ); ?></div>
46
+			$letter_display = (strtoupper($current_letter) != 'ALL') ? $current_letter : __('ALL', 'wpshop'); ?>
47
+			<div class="wps-alert-info"><?php printf(__('No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper($letter_display)); ?></div>
48 48
 	<?php endif;
49 49
 		endif; ?>
50 50
 </div>
Please login to merge, or discard this patch.
Braces   +13 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
  $order_post_meta = !empty($post) ? get_post_meta( $post->ID, '_wpshop_order_status', true ) : ""; ?>
3 5
 <div class="wps-table">
4 6
 	<div class="wps-table-header wps-table-row">
@@ -39,11 +41,17 @@  discard block
 block discarded – undo
39 41
 		<?php endif; ?>
40 42
 	</div>
41 43
 	<?php endforeach; ?>
42
-	<?php else :
44
+	<?php else {
45
+	:
43 46
 		if( !empty( $research ) ) : ?>
44
-		<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research ); ?></div>
45
-	<?php else :
46
-			$letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __('ALL', 'wpshop' ); ?>
47
+		<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research );
48
+}
49
+?></div>
50
+	<?php else {
51
+	:
52
+			$letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __('ALL', 'wpshop' );
53
+}
54
+?>
47 55
 			<div class="wps-alert-info"><?php printf( __( 'No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper( $letter_display ) ); ?></div>
48 56
 	<?php endif;
49 57
 		endif; ?>
Please login to merge, or discard this patch.
wps_orders/templates/backend/product-listing/wps_orders_product_listing.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 ?>
3 3
 <div class="wps-boxed">
4
-<span class="wps-h5"><span class="dashicons dashicons-search"></span> <input type="text" placeholder="<?php _e( 'Search products by letter', 'wpshop' ); ?>" id="search_product_by_title_or_barcode" size="50"><a href="#" data-nonce="<?php echo wp_create_nonce( 'refresh_product_list_all' ); ?>" class="wps-bton-second-mini-rounded search_product_by_title_or_barcode"><?php _e('Search', 'wpshop'); ?></a></span>
5
-<?php echo apply_filters( 'wps-filter-free-product-bton-tpl', $post->ID );
6
-foreach( $letters as $letter ) : ?>
7
-<a href="#" data-nonce="<?php echo wp_create_nonce( 'refresh_product_list_'.strtolower($letter) ); ?>" class="wps-bton-second-mini-rounded <?php echo ( strtoupper( $current_letter ) == strtoupper( $letter ) ) ? 'third' : ''; ?> search_product_by_letter" id="<?php echo $letter; ?>"><?php echo ( $letter != 'ALL' ) ? $letter : __('ALL', 'wpshop' ); ?></a>
4
+<span class="wps-h5"><span class="dashicons dashicons-search"></span> <input type="text" placeholder="<?php _e('Search products by letter', 'wpshop'); ?>" id="search_product_by_title_or_barcode" size="50"><a href="#" data-nonce="<?php echo wp_create_nonce('refresh_product_list_all'); ?>" class="wps-bton-second-mini-rounded search_product_by_title_or_barcode"><?php _e('Search', 'wpshop'); ?></a></span>
5
+<?php echo apply_filters('wps-filter-free-product-bton-tpl', $post->ID);
6
+foreach ($letters as $letter) : ?>
7
+<a href="#" data-nonce="<?php echo wp_create_nonce('refresh_product_list_' . strtolower($letter)); ?>" class="wps-bton-second-mini-rounded <?php echo (strtoupper($current_letter) == strtoupper($letter)) ? 'third' : ''; ?> search_product_by_letter" id="<?php echo $letter; ?>"><?php echo ($letter != 'ALL') ? $letter : __('ALL', 'wpshop'); ?></a>
8 8
 <?php endforeach; ?>
9 9
 </div>
10 10
 
11 11
 <div id="wps_orders_product_listing_table">
12
-<?php require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table") ); ?>
12
+<?php require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table")); ?>
13 13
 </div>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 ?>
3 5
 <div class="wps-boxed">
4 6
 <span class="wps-h5"><span class="dashicons dashicons-search"></span> <input type="text" placeholder="<?php _e( 'Search products by letter', 'wpshop' ); ?>" id="search_product_by_title_or_barcode" size="50"><a href="#" data-nonce="<?php echo wp_create_nonce( 'refresh_product_list_all' ); ?>" class="wps-bton-second-mini-rounded search_product_by_title_or_barcode"><?php _e('Search', 'wpshop'); ?></a></span>
Please login to merge, or discard this patch.
includes/modules/wps_orders/controller/wps_orders_in_back_office.php 2 patches
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_orders_in_back_office {
3 3
 
4 4
 	function __construct() {
5 5
 		// Template loading
6 6
 		$this->template_dir = WPS_ORDERS_PATH . WPS_ORDERS_DIR . "/templates/";
7
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes') );
7
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
8 8
 
9 9
 		// Ajax actions
10
-		add_action('wp_ajax_wpshop_add_private_comment_to_order', array( $this, 'wpshop_add_private_comment_to_order' ) );
11
-		add_action('wp_ajax_wps_order_refresh_product_listing', array( $this, 'refresh_product_list' ) );
12
-		add_action('wp_ajax_wps_add_product_to_order_admin', array( $this, 'wps_add_product_to_order_admin' ) );
13
-		add_action('wp_ajax_wps_refresh_cart_order', array( $this, 'refresh_cart_order' ) );
14
-		add_action('wp_ajax_wps_refresh_payments_order', array( $this, 'refresh_payments_order' ) );
15
-		add_action('wp_ajax_wps_update_product_qty_in_admin', array( $this, 'wps_update_product_qty_in_admin' ) );
16
-		add_action('wp_ajax_wps_order_load_product_variations', array( $this, 'wps_order_load_product_variations' ) );
17
-		add_action('wp_ajax_wps-orders-update-cart-informations', array( $this, 'wps_orders_update_cart_informations' ) );
18
-		add_action('wp_ajax_wps_reverify_payment_invoice_ref', array( $this, 'wps_reverify_payment_invoice_ref' ) );
10
+		add_action('wp_ajax_wpshop_add_private_comment_to_order', array($this, 'wpshop_add_private_comment_to_order'));
11
+		add_action('wp_ajax_wps_order_refresh_product_listing', array($this, 'refresh_product_list'));
12
+		add_action('wp_ajax_wps_add_product_to_order_admin', array($this, 'wps_add_product_to_order_admin'));
13
+		add_action('wp_ajax_wps_refresh_cart_order', array($this, 'refresh_cart_order'));
14
+		add_action('wp_ajax_wps_refresh_payments_order', array($this, 'refresh_payments_order'));
15
+		add_action('wp_ajax_wps_update_product_qty_in_admin', array($this, 'wps_update_product_qty_in_admin'));
16
+		add_action('wp_ajax_wps_order_load_product_variations', array($this, 'wps_order_load_product_variations'));
17
+		add_action('wp_ajax_wps-orders-update-cart-informations', array($this, 'wps_orders_update_cart_informations'));
18
+		add_action('wp_ajax_wps_reverify_payment_invoice_ref', array($this, 'wps_reverify_payment_invoice_ref'));
19 19
 
20 20
 		// WP General actions
21
-		add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts') );
22
-		add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts_texts' ), 20 );
23
-		add_action('save_post', array( $this, 'save_order_custom_informations'));
21
+		add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts'));
22
+		add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts_texts'), 20);
23
+		add_action('save_post', array($this, 'save_order_custom_informations'));
24 24
 
25 25
 		// WP Filters
26 26
 		//add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'wps_notif_user_on_order_saving'), 100, 2 );
@@ -31,51 +31,51 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function wps_orders_scripts() {
33 33
 		global $current_screen;
34
-		if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) )
34
+		if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER), true))
35 35
 			return;
36 36
 
37
-		wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL.WPS_ORDERS_DIR.'/assets/backend/js/wps_orders.js' );
37
+		wp_enqueue_script('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js');
38 38
 	}
39 39
 
40 40
 	function wps_orders_scripts_texts() {
41
-		wp_localize_script( 'wps_orders_backend', 'message_confirm_reload', __( 'Are you sure you want to refresh your browser?', 'wpshop' ) );
42
-		wp_localize_script( 'wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __( 'Error detected.', 'wpshop' ) );
41
+		wp_localize_script('wps_orders_backend', 'message_confirm_reload', __('Are you sure you want to refresh your browser?', 'wpshop'));
42
+		wp_localize_script('wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __('Error detected.', 'wpshop'));
43 43
 	}
44 44
 	/**
45 45
 	 * Add meta boxes
46 46
 	 */
47 47
 	function add_meta_boxes() {
48 48
 		global $post;
49
-		$order_meta = get_post_meta( $post->ID, '_order_postmeta', true );
49
+		$order_meta = get_post_meta($post->ID, '_order_postmeta', true);
50 50
 		/** Box  Order Payments **/
51
-		if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) {
52
-			add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> '.__('Order payment', 'wpshop'),array($this, 'display_order_payments_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
51
+		if (!in_array($post->post_status, array('auto-draft'))) {
52
+			add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> ' . __('Order payment', 'wpshop'), array($this, 'display_order_payments_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
53 53
 		}
54 54
 		/**	Box for customer order comment */
55
-		if ( ! empty( $post->post_excerpt ) ) {
56
-			add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> '.__('Order customer comment', 'wpshop'),array( $this, 'order_customer_comment_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
55
+		if (!empty($post->post_excerpt)) {
56
+			add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> ' . __('Order customer comment', 'wpshop'), array($this, 'order_customer_comment_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low');
57 57
 		}
58 58
 		/** Historic sales **/
59
-		add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array( $this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low');
59
+		add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array($this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low');
60 60
 		/**	Box with the complete order content	*/
61 61
 		$payment_started = false;
62
-		if ( ! empty( $order_meta['order_payment'] ) && ! empty( $order_meta['order_payment']['received'] ) ) {
63
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
64
-				if ( empty( $received['received_amount'] ) ) {
62
+		if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received'])) {
63
+			foreach ($order_meta['order_payment']['received'] as $received) {
64
+				if (empty($received['received_amount'])) {
65 65
 					continue;
66 66
 				}
67 67
 				$payment_started = true;
68 68
 				break;
69 69
 			}
70 70
 		}
71
-		if ( ! $payment_started ) {
72
-			add_meta_box( 'wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __( 'Product List', 'wpshop' ), array( $this, 'wps_products_listing_for_quotation' ), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low' );
71
+		if (!$payment_started) {
72
+			add_meta_box('wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __('Product List', 'wpshop'), array($this, 'wps_products_listing_for_quotation'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
73 73
 		}
74 74
 		/**	Box with the complete order content	*/
75
-		add_meta_box( 'wpshop_order_content', '<span class="dashicons dashicons-cart"></span> '.__('Order content', 'wpshop'), array( $this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
75
+		add_meta_box('wpshop_order_content', '<span class="dashicons dashicons-cart"></span> ' . __('Order content', 'wpshop'), array($this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
76 76
 		/** Box Private order comments **/
77
-		if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) {
78
-			add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> '.__('Comments', 'wpshop'), array( $this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
77
+		if (!in_array($post->post_status, array('auto-draft'))) {
78
+			add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> ' . __('Comments', 'wpshop'), array($this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low');
79 79
 		}
80 80
 	}
81 81
 
@@ -83,65 +83,65 @@  discard block
 block discarded – undo
83 83
 	 * METABOX CONTENT - Display Customer comments on order in administration panel
84 84
 	 * @param object $order
85 85
 	 */
86
-	function order_customer_comment_box( $order ) {
87
-		if ( !empty($order) && !empty($order->ID) ) {
88
-			require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box") );
86
+	function order_customer_comment_box($order) {
87
+		if (!empty($order) && !empty($order->ID)) {
88
+			require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box"));
89 89
 		}
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * METABOX CONTENT - Display an order historic of product in administration product panel
94 94
 	 */
95
-	function meta_box_product_sale_informations () {
95
+	function meta_box_product_sale_informations() {
96 96
  		global $post;
97 97
  		$product_id = $post->ID;
98
- 		$variations = wpshop_products::get_variation( $product_id );
99
- 		$order_status = unserialize( WPSHOP_ORDER_STATUS );
100
- 		$color_label = array( 'awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu');
98
+ 		$variations = wpshop_products::get_variation($product_id);
99
+ 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
100
+ 		$color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu');
101 101
  		// Get datas
102 102
  		$sales_informations = array();
103 103
  		/** Query **/
104
- 		$data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";';
105
- 		$query_args = array( 'posts_per_page' => 10, 'paged' => absint( isset( $_GET['paged_sales'] ) ? $_GET['paged_sales'] : 1 ), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) );
106
- 		$orders = new WP_Query( $query_args );
107
- 		if ( !empty($orders) && !empty($orders->posts) ) {
108
- 			foreach( $orders->posts as $order ) {
109
- 				$order_meta = get_post_meta( $order->ID, '_order_postmeta', true );
110
- 				$order_info = get_post_meta( $order->ID, '_order_info', true );
104
+ 		$data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";';
105
+ 		$query_args = array('posts_per_page' => 10, 'paged' => absint(isset($_GET['paged_sales']) ? $_GET['paged_sales'] : 1), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE')));
106
+ 		$orders = new WP_Query($query_args);
107
+ 		if (!empty($orders) && !empty($orders->posts)) {
108
+ 			foreach ($orders->posts as $order) {
109
+ 				$order_meta = get_post_meta($order->ID, '_order_postmeta', true);
110
+ 				$order_info = get_post_meta($order->ID, '_order_info', true);
111 111
  				$sales_informations[] = array(
112
- 						'order_key' => ( !empty($order_meta) && !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '',
113
- 						'order_date' => ( !empty($order_meta) && !empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '',
114
- 						'customer_firstname' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '',
115
- 						'customer_name' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '',
116
- 						'customer_email' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '',
112
+ 						'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '',
113
+ 						'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '',
114
+ 						'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '',
115
+ 						'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '',
116
+ 						'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : '',
117 117
  						'order_id' => $order->ID,
118 118
  						'order_status' => $order_meta['order_status']
119 119
  				);
120 120
  			}
121 121
  		}
122 122
  		// Display results
123
- 		require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic") );
123
+ 		require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic"));
124 124
  	}
125 125
 
126 126
 	/**
127 127
 	 * METABOX CONTENT - Payments Box in Orders panel
128 128
 	 * @param string $order
129 129
 	 */
130
-	function display_order_payments_box( $order ) {
130
+	function display_order_payments_box($order) {
131 131
 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
132 132
 		$order_postmeta = get_post_meta($order->ID, '_order_postmeta', true);
133
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box") );
133
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box"));
134 134
 	}
135 135
 
136 136
 	/**
137 137
 	 * METABOX CONTENT - Display an lsiting of products to make quotation in backend
138 138
 	 */
139 139
 	function wps_products_listing_for_quotation($post) {
140
-		$letters = array( 'ALL', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
141
-		$current_letter = sanitize_title( $letters[1] );
140
+		$letters = array('ALL', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
141
+		$current_letter = sanitize_title($letters[1]);
142 142
 		$wps_product_mdl = new wps_product_mdl();
143
-		$products = $wps_product_mdl->get_products_by_letter( $current_letter );
144
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing") );
143
+		$products = $wps_product_mdl->get_products_by_letter($current_letter);
144
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing"));
145 145
 	}
146 146
 
147 147
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	function meta_box_private_comment() {
151 151
 		global $post;
152
-		require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments") );
152
+		require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments"));
153 153
 	}
154 154
 
155 155
 	/**
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	function meta_box_order_content() {
159 159
 		global $post_id;
160
-		unset( $_SESSION['cart'] );
161
-		echo do_shortcode( '[wps_cart oid="' .$post_id. '" cart_type="admin-panel"]');
160
+		unset($_SESSION['cart']);
161
+		echo do_shortcode('[wps_cart oid="' . $post_id . '" cart_type="admin-panel"]');
162 162
 	}
163 163
 
164 164
 
@@ -168,68 +168,68 @@  discard block
 block discarded – undo
168 168
 	function save_order_custom_informations() {
169 169
 		global $wpdb;
170 170
 
171
-		$post_ID = !empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0;
171
+		$post_ID = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0;
172 172
 		// Check if it is an order save action
173
-		if ( !empty($post_ID) && ( get_post_type($post_ID) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) ) {
173
+		if (!empty($post_ID) && (get_post_type($post_ID) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) {
174 174
 			//Define Customer ID
175
-			$user_id = ( !empty( $_REQUEST['wps_customer_id'] ) ) ? (int) $_REQUEST['wps_customer_id'] : get_current_user_id();
175
+			$user_id = (!empty($_REQUEST['wps_customer_id'])) ? (int)$_REQUEST['wps_customer_id'] : get_current_user_id();
176 176
 
177 177
 			// Order MetaData
178
-			$order_meta = get_post_meta( $post_ID, '_order_postmeta', true);
178
+			$order_meta = get_post_meta($post_ID, '_order_postmeta', true);
179 179
 
180 180
 			// Save General information of order's attached customer
181
-			$wpdb->update( $wpdb->posts, array('post_author' => $user_id, 'post_parent' => $user_id, 'post_status' => 'publish'),  array('ID' => $post_ID) );
182
-			update_post_meta( $post_ID, '_wpshop_order_customer_id', $user_id );
181
+			$wpdb->update($wpdb->posts, array('post_author' => $user_id, 'post_parent' => $user_id, 'post_status' => 'publish'), array('ID' => $post_ID));
182
+			update_post_meta($post_ID, '_wpshop_order_customer_id', $user_id);
183 183
 			$order_meta['customer_id'] = $user_id;
184
-			if ( empty($order_meta['order_key']) ) {
185
-				$order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status']!='awaiting_payment') ? wpshop_orders::get_new_order_reference() : '');
184
+			if (empty($order_meta['order_key'])) {
185
+				$order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status'] != 'awaiting_payment') ? wpshop_orders::get_new_order_reference() : '');
186 186
 				$order_meta['order_temporary_key'] = (isset($order_meta['order_temporary_key']) && ($order_meta['order_temporary_key'] != '')) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference();
187 187
 			}
188 188
 			$order_meta['order_status'] = (isset($order_meta['order_status']) && ($order_meta['order_status'] != '')) ? $order_meta['order_status'] : 'awaiting_payment';
189 189
 			$order_meta['order_date'] = (isset($order_meta['order_date']) && ($order_meta['order_date'] != '')) ? $order_meta['order_date'] : current_time('mysql', 0);
190 190
 			$order_meta['order_currency'] = wpshop_tools::wpshop_get_currency(true);
191 191
 
192
-			$billing_adress_id = ( !empty( $_REQUEST['wps_order_selected_address'] ) && !empty( $_REQUEST['wps_order_selected_address']['billing'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['billing'] : 0;
192
+			$billing_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['billing'])) ? (int)$_REQUEST['wps_order_selected_address']['billing'] : 0;
193 193
 
194 194
 			// Order Attached Addresses save
195
-			if( !empty( $billing_adress_id ) ) {
195
+			if (!empty($billing_adress_id)) {
196 196
 				// Informations
197
-				$order_informations = get_post_meta( $post_ID, '_order_info', true );
198
-				$order_informations = ( !empty($order_informations) ) ? $order_informations : array();
199
-				$billing_address_option = get_option( 'wpshop_billing_address' );
200
-				$billing_address_option = ( !empty($billing_address_option) && !empty( $billing_address_option['choice'] ) ) ? $billing_address_option['choice'] : '';
197
+				$order_informations = get_post_meta($post_ID, '_order_info', true);
198
+				$order_informations = (!empty($order_informations)) ? $order_informations : array();
199
+				$billing_address_option = get_option('wpshop_billing_address');
200
+				$billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : '';
201 201
 
202 202
 				// Billing datas
203
-				$order_informations['billing'] = array( 'id' => $billing_address_option,
203
+				$order_informations['billing'] = array('id' => $billing_address_option,
204 204
 						'address_id' => $billing_adress_id,
205
-						'address' => get_post_meta( $billing_adress_id, '_wpshop_address_metadata', true )
205
+						'address' => get_post_meta($billing_adress_id, '_wpshop_address_metadata', true)
206 206
 				);
207 207
 				// Shipping datas
208
-				$shipping_adress_id = ( !empty( $_REQUEST['wps_order_selected_address'] ) && !empty( $_REQUEST['wps_order_selected_address']['shipping'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['shipping'] : 0;
208
+				$shipping_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['shipping'])) ? (int)$_REQUEST['wps_order_selected_address']['shipping'] : 0;
209 209
 
210
-				if( !empty( $shipping_adress_id ) ) {
211
-					$shipping_address_option = get_option( 'wpshop_shipping_address_choice' );
212
-					$shipping_address_option = ( !empty($shipping_address_option) && !empty($shipping_address_option['choice']) ) ? $shipping_address_option['choice'] : '';
213
-					$order_informations['shipping'] = array( 'id' => $shipping_address_option,
210
+				if (!empty($shipping_adress_id)) {
211
+					$shipping_address_option = get_option('wpshop_shipping_address_choice');
212
+					$shipping_address_option = (!empty($shipping_address_option) && !empty($shipping_address_option['choice'])) ? $shipping_address_option['choice'] : '';
213
+					$order_informations['shipping'] = array('id' => $shipping_address_option,
214 214
 							'address_id' => $shipping_adress_id,
215
-							'address' => get_post_meta( $shipping_adress_id, '_wpshop_address_metadata', true )
215
+							'address' => get_post_meta($shipping_adress_id, '_wpshop_address_metadata', true)
216 216
 					);
217 217
 				}
218
-				update_post_meta( $post_ID, '_order_info', $order_informations );
218
+				update_post_meta($post_ID, '_order_info', $order_informations);
219 219
 			}
220 220
 
221
-			$wpshop_admin_order_payment_received = !empty( $_REQUEST['wpshop_admin_order_payment_received'] ) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array();
222
-			$wpshop_admin_order_payment_received['method'] = !empty( $wpshop_admin_order_payment_received['method'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['method'] ) : '';
223
-			$wpshop_admin_order_payment_received['payment_reference'] = !empty( $wpshop_admin_order_payment_received['payment_reference'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['payment_reference'] ) : '';
224
-			$wpshop_admin_order_payment_received['date'] = !empty( $wpshop_admin_order_payment_received['date'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['date'] ) : '';
225
-			$wpshop_admin_order_payment_received['received_amount'] = !empty( $wpshop_admin_order_payment_received['received_amount'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['received_amount'] ) : '';
226
-			$action_triggered_from = !empty( $_REQUEST['action_triggered_from'] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : '';
227
-			$wshop_admin_order_payment_reference = !empty( $_REQUEST['wpshop_admin_order_payment_reference'] ) ? sanitize_text_field( $_REQUEST['wpshop_admin_order_payment_reference'] ) : '';
221
+			$wpshop_admin_order_payment_received = !empty($_REQUEST['wpshop_admin_order_payment_received']) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array();
222
+			$wpshop_admin_order_payment_received['method'] = !empty($wpshop_admin_order_payment_received['method']) ? sanitize_text_field($wpshop_admin_order_payment_received['method']) : '';
223
+			$wpshop_admin_order_payment_received['payment_reference'] = !empty($wpshop_admin_order_payment_received['payment_reference']) ? sanitize_text_field($wpshop_admin_order_payment_received['payment_reference']) : '';
224
+			$wpshop_admin_order_payment_received['date'] = !empty($wpshop_admin_order_payment_received['date']) ? sanitize_text_field($wpshop_admin_order_payment_received['date']) : '';
225
+			$wpshop_admin_order_payment_received['received_amount'] = !empty($wpshop_admin_order_payment_received['received_amount']) ? sanitize_text_field($wpshop_admin_order_payment_received['received_amount']) : '';
226
+			$action_triggered_from = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : '';
227
+			$wshop_admin_order_payment_reference = !empty($_REQUEST['wpshop_admin_order_payment_reference']) ? sanitize_text_field($_REQUEST['wpshop_admin_order_payment_reference']) : '';
228 228
 
229 229
 			// Add a Payment to Order MetaData
230
-			if ( !empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method'])
230
+			if (!empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method'])
231 231
 					&& !empty($wpshop_admin_order_payment_received['date']) && !empty($wpshop_admin_order_payment_received['received_amount']) &&
232
-					( $action_triggered_from == 'add_payment' || !empty($wshop_admin_order_payment_reference) ) ) {
232
+					($action_triggered_from == 'add_payment' || !empty($wshop_admin_order_payment_reference))) {
233 233
 
234 234
 				$received_payment_amount = $wpshop_admin_order_payment_received['received_amount'];
235 235
 				// Payment Params
@@ -242,36 +242,36 @@  discard block
 block discarded – undo
242 242
 						'date' 				=> current_time('mysql', 0),
243 243
 						'received_amount' 	=> $received_payment_amount
244 244
 				);
245
-				$order_meta = wpshop_payment::check_order_payment_total_amount($post_ID, $params_array, 'completed', $order_meta, false );
245
+				$order_meta = wpshop_payment::check_order_payment_total_amount($post_ID, $params_array, 'completed', $order_meta, false);
246 246
 			}
247 247
 
248 248
 			//Round final amount
249
-			$order_meta['order_grand_total'] = number_format( round($order_meta['order_grand_total'], 2), 2, '.', '');
250
-			$order_meta['order_total_ttc'] = number_format( round($order_meta['order_total_ttc'], 2), 2, '.', '');
251
-			$order_meta['order_amount_to_pay_now'] = number_format( round($order_meta['order_amount_to_pay_now'], 2), 2, '.', '');
249
+			$order_meta['order_grand_total'] = number_format(round($order_meta['order_grand_total'], 2), 2, '.', '');
250
+			$order_meta['order_total_ttc'] = number_format(round($order_meta['order_total_ttc'], 2), 2, '.', '');
251
+			$order_meta['order_amount_to_pay_now'] = number_format(round($order_meta['order_amount_to_pay_now'], 2), 2, '.', '');
252 252
 
253 253
 			// Payment Pre-Fill
254
-			if ( empty( $order_meta['order_payment'] ) ) {
254
+			if (empty($order_meta['order_payment'])) {
255 255
 				$order_meta['order_payment']['customer_choice']['method'] = '';
256
-				$order_meta['order_payment']['received'][] = array('waited_amount' => ( !empty($order_meta) && !empty($order_meta['order_grand_total']) ) ? number_format($order_meta['order_grand_total'],2,'.', '') : 0 );
256
+				$order_meta['order_payment']['received'][] = array('waited_amount' => (!empty($order_meta) && !empty($order_meta['order_grand_total'])) ? number_format($order_meta['order_grand_total'], 2, '.', '') : 0);
257 257
 			}
258 258
 
259
-			$data['post_ID'] = !empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0;
260
-			$data['markascanceled_order_hidden_indicator'] = !empty( $_REQUEST['markascanceled_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['markascanceled_order_hidden_indicator'] ) : '';
261
-			$data['resendordertocustomer_order_hidden_indicator'] = !empty( $_REQUEST['resendordertocustomer_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['resendordertocustomer_order_hidden_indicator'] ) : '';
262
-			$data['action_triggered_from'] = !empty( $_REQUEST['action_triggered_from' ] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : '';
263
-			$data['notif_the_customer'] = !empty( $_REQUEST['notif_the_customer' ] ) ? sanitize_text_field( $_REQUEST['notif_the_customer'] ) : '';
259
+			$data['post_ID'] = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0;
260
+			$data['markascanceled_order_hidden_indicator'] = !empty($_REQUEST['markascanceled_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['markascanceled_order_hidden_indicator']) : '';
261
+			$data['resendordertocustomer_order_hidden_indicator'] = !empty($_REQUEST['resendordertocustomer_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['resendordertocustomer_order_hidden_indicator']) : '';
262
+			$data['action_triggered_from'] = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : '';
263
+			$data['notif_the_customer'] = !empty($_REQUEST['notif_the_customer']) ? sanitize_text_field($_REQUEST['notif_the_customer']) : '';
264 264
 			// Apply a filter to make credit, notificate the customer and generate billing actions
265
-			$order_meta = apply_filters( 'wps_order_saving_admin_extra_action', $order_meta, $data );
265
+			$order_meta = apply_filters('wps_order_saving_admin_extra_action', $order_meta, $data);
266 266
 
267 267
 			// Save Shipping informations & Order status
268
-			if ( isset( $order_meta['order_shipping_date'] ) ) {
269
-				update_post_meta( $post_ID, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']);
268
+			if (isset($order_meta['order_shipping_date'])) {
269
+				update_post_meta($post_ID, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']);
270 270
 			}
271
-			update_post_meta( $post_ID, '_wpshop_order_status', $order_meta['order_status']);
271
+			update_post_meta($post_ID, '_wpshop_order_status', $order_meta['order_status']);
272 272
 
273 273
 			// Save Metadata
274
-			update_post_meta( $post_ID, '_order_postmeta', $order_meta);
274
+			update_post_meta($post_ID, '_order_postmeta', $order_meta);
275 275
 		}
276 276
 	}
277 277
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param array $posted_datas
283 283
 	 * @return array
284 284
 	 */
285
-	function wps_notif_user_on_order_saving( $order_metadata, $posted_datas ) {
286
-		if( !empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer']=='on' ) {
285
+	function wps_notif_user_on_order_saving($order_metadata, $posted_datas) {
286
+		if (!empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer'] == 'on') {
287 287
 			$wps_message = new wps_message_ctr();
288 288
 			/*	Get order current content	*/
289 289
 			$user = get_post_meta($posted_datas['post_ID'], '_order_info', true);
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 			$first_name = $user['billing']['address']['address_first_name'];
293 293
 			$last_name = $user['billing']['address']['address_last_name'];
294 294
 
295
-			$object = array('object_type'=>'order','object_id'=>(int)$_REQUEST['post_ID']);
295
+			$object = array('object_type'=>'order', 'object_id'=>(int)$_REQUEST['post_ID']);
296 296
 			/* Envoie du message de confirmation de commande au client	*/
297
-			if ( empty( $order_metadata['order_key'] ) ) {
297
+			if (empty($order_metadata['order_key'])) {
298 298
 				$wps_message->wpshop_prepared_email($email,
299 299
 						'WPSHOP_QUOTATION_UPDATE_MESSAGE',
300
-						array(  'order_id' => $object['object_id'],
300
+						array('order_id' => $object['object_id'],
301 301
 							    'customer_first_name' => $first_name,
302 302
 								'customer_last_name' => $last_name,
303 303
 								'order_date' => current_time('mysql', 0),
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				$wps_message->wpshop_prepared_email(
313 313
 						$email,
314 314
 						'WPSHOP_ORDER_UPDATE_MESSAGE',
315
-						array(  'customer_first_name' => $first_name,
315
+						array('customer_first_name' => $first_name,
316 316
 								'customer_last_name' => $last_name,
317 317
 								'order_key' => $order_metadata['order_key'],
318 318
 								'order_billing_address' => '',
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 								'order_addresses' => '',
321 321
 								'order_addresses' => '',
322 322
 								'order_billing_address' => '',
323
-								'order_shipping_address' => '' ),
323
+								'order_shipping_address' => ''),
324 324
 						$object);
325 325
 			}
326 326
 		}
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 	 * AJAX - Add a private comment to order
332 332
 	 */
333 333
 	function wpshop_add_private_comment_to_order() {
334
-		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
334
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
335 335
 
336
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) )
336
+		if (!wp_verify_nonce($_wpnonce, 'wpshop_add_private_comment_to_order'))
337 337
 			wp_die();
338 338
 
339 339
 		$status = false; $result = '';
340
-		$order_id = ( !empty($_POST['oid']) ) ? intval($_POST['oid']) : null;
341
-		$comment = ( !empty($_POST['comment']) ) ? wpshop_tools::varSanitizer($_POST['comment']) : null;
342
-		$send_email = ( !empty($_POST['send_email']) ) ? wpshop_tools::varSanitizer($_POST['send_email']) : null;
343
-		$copy_to_administrator = ( !empty($_POST['copy_to_administrator']) ) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null;
340
+		$order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null;
341
+		$comment = (!empty($_POST['comment'])) ? wpshop_tools::varSanitizer($_POST['comment']) : null;
342
+		$send_email = (!empty($_POST['send_email'])) ? wpshop_tools::varSanitizer($_POST['send_email']) : null;
343
+		$copy_to_administrator = (!empty($_POST['copy_to_administrator'])) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null;
344 344
 
345
-		if ( !empty($comment) && !empty($order_id) ) {
345
+		if (!empty($comment) && !empty($order_id)) {
346 346
 			$wps_back_office_orders_mdl = new wps_back_office_orders_mdl();
347
-			$new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator );
348
-			if($new_comment) {
349
-				$order_private_comment = get_post_meta( $order_id, '_order_private_comments', true );
347
+			$new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator);
348
+			if ($new_comment) {
349
+				$order_private_comment = get_post_meta($order_id, '_order_private_comments', true);
350 350
 				$oid = $order_id;
351 351
 				ob_start();
352
-				require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments") );
352
+				require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments"));
353 353
 				$result = ob_get_contents();
354 354
 				ob_end_clean();
355 355
 				$status = true;
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 			$result = __('An error was occured', 'wpshop');
360 360
 		}
361 361
 
362
-		$response = array( 'status' => $status, 'response' => $result );
363
-		echo json_encode( $response );
362
+		$response = array('status' => $status, 'response' => $result);
363
+		echo json_encode($response);
364 364
 		wp_die();
365 365
 	}
366 366
 
@@ -368,34 +368,34 @@  discard block
 block discarded – undo
368 368
 	 * AJAX - Refresh product listing in order back-office
369 369
 	 */
370 370
 	function refresh_product_list() {
371
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
372
-		$letter = ( !empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : '';
373
-		$research = !empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : '';
371
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
372
+		$letter = (!empty($_POST['letter'])) ? sanitize_title($_POST['letter']) : '';
373
+		$research = !empty($_POST['research']) ? sanitize_text_field($_POST['research']) : '';
374 374
 
375
-		if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) )
375
+		if (!wp_verify_nonce($_wpnonce, 'refresh_product_list_' . strtolower($letter)))
376 376
 			wp_die();
377 377
 
378 378
 		$status = false; $response = '';
379
-		$oid = !empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0;
379
+		$oid = !empty($_POST['oid']) ? (int)$_POST['oid'] : 0;
380 380
 
381
-		if( !empty($oid) ) {
382
-			$post = get_post( $oid );
381
+		if (!empty($oid)) {
382
+			$post = get_post($oid);
383 383
 		}
384
-		if( !empty($letter) ) {
384
+		if (!empty($letter)) {
385 385
 			$current_letter = $letter;
386 386
 			$wps_product_mdl = new wps_product_mdl();
387
-			if( !empty( $research ) ) {
388
-				$products = $wps_product_mdl->get_products_by_title_or_barcode( $research, strlen( $research ) >= 8 && ctype_digit( $research ) );
387
+			if (!empty($research)) {
388
+				$products = $wps_product_mdl->get_products_by_title_or_barcode($research, strlen($research) >= 8 && ctype_digit($research));
389 389
 			} else {
390
-				$products = $wps_product_mdl->get_products_by_letter( $letter );
390
+				$products = $wps_product_mdl->get_products_by_letter($letter);
391 391
 			}
392 392
 			ob_start();
393
-			require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table") );
393
+			require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table"));
394 394
 			$response = ob_get_contents();
395 395
 			ob_end_clean();
396 396
 			$status = true;
397 397
 		}
398
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
398
+		echo json_encode(array('status' => $status, 'response' => $response));
399 399
 		wp_die();
400 400
 	}
401 401
 
@@ -403,38 +403,38 @@  discard block
 block discarded – undo
403 403
 	 * AJAX - Add product to order in back-office panel
404 404
 	 */
405 405
 	function wps_add_product_to_order_admin() {
406
-		check_ajax_referer( 'wps_add_product_to_order_admin' );
406
+		check_ajax_referer('wps_add_product_to_order_admin');
407 407
 
408 408
 		$status = false; $response = ''; $product_have_variations = false;
409 409
 		// Sended vars
410
-		$product_id = ( !empty($_POST['pid']) ) ? intval( $_POST['pid']) : null;
411
-		$order_id = ( !empty($_POST['oid']) ) ? intval( $_POST['oid']) : null;
412
-		$product_qty = ( !empty($_POST['qty']) ) ? intval( $_POST['qty']) : 1;
410
+		$product_id = (!empty($_POST['pid'])) ? intval($_POST['pid']) : null;
411
+		$order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null;
412
+		$product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 1;
413 413
 
414
-		if( !empty($order_id) && !empty($product_id) ) {
414
+		if (!empty($order_id) && !empty($product_id)) {
415 415
 			$wps_orders = new wps_orders_ctr();
416 416
 			$product_datas = wpshop_products::get_product_data($product_id, false, '"publish", "free_product"');
417 417
 			// Check if product have variations
418
-			$have_variations_checking = wpshop_products::get_variation( $product_id );
419
-			if( !empty($have_variations_checking) ) {
418
+			$have_variations_checking = wpshop_products::get_variation($product_id);
419
+			if (!empty($have_variations_checking)) {
420 420
 				$product_have_variations = true;
421 421
 			}
422 422
 			else {
423 423
 				// Get Metadatas
424
-				$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
424
+				$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
425 425
 				// Calcul cart informations
426 426
 				$wps_cart = new wps_cart();
427
-				$order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false );
427
+				$order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false);
428 428
 				// Update Metadatas
429
-				update_post_meta( $order_id, '_order_postmeta', $order_metadata );
429
+				update_post_meta($order_id, '_order_postmeta', $order_metadata);
430 430
 				$status = true;
431 431
 			}
432 432
 			$status = true;
433 433
 		}
434 434
 
435
-		$_wpnonce = wp_create_nonce( 'wps_order_load_product_variations' );
435
+		$_wpnonce = wp_create_nonce('wps_order_load_product_variations');
436 436
 
437
-		echo json_encode( array( '_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations ) );
437
+		echo json_encode(array('_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations));
438 438
 		wp_die();
439 439
 	}
440 440
 
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
 	 * AJAX - Refresh cart in administration
443 443
 	 */
444 444
 	function refresh_cart_order() {
445
-		check_ajax_referer( 'wps_reload_cart' );
445
+		check_ajax_referer('wps_reload_cart');
446 446
 
447 447
 		$status = false; $response = '';
448
-		$order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null;
449
-		if( !empty($order_id) ) {
450
-			$response = do_shortcode( '[wps_cart oid="' .$order_id. '" cart_type="admin-panel"]');
448
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
449
+		if (!empty($order_id)) {
450
+			$response = do_shortcode('[wps_cart oid="' . $order_id . '" cart_type="admin-panel"]');
451 451
 			$status = true;
452 452
 		}
453
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
453
+		echo json_encode(array('status' => $status, 'response' => $response));
454 454
 		wp_die();
455 455
 	}
456 456
 
@@ -458,17 +458,17 @@  discard block
 block discarded – undo
458 458
 	 * AJAX - Refresh cart in administration
459 459
 	 */
460 460
 	function refresh_payments_order() {
461
-		check_ajax_referer( 'wps_reload_cart' );
461
+		check_ajax_referer('wps_reload_cart');
462 462
 		$status = false; $response = '';
463
-		$order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null;
464
-		if( !empty($order_id) ) {
463
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
464
+		if (!empty($order_id)) {
465 465
 			ob_start();
466
-			echo $this->display_order_payments_box( get_post( $order_id ) );
466
+			echo $this->display_order_payments_box(get_post($order_id));
467 467
 			$response = ob_get_contents();
468 468
 			ob_end_clean();
469 469
 			$status = true;
470 470
 		}
471
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
471
+		echo json_encode(array('status' => $status, 'response' => $response));
472 472
 		wp_die();
473 473
 	}
474 474
 
@@ -476,25 +476,25 @@  discard block
 block discarded – undo
476 476
 	 * AJAX - Update product Quantity in Back-office Panel
477 477
 	 */
478 478
 	function wps_update_product_qty_in_admin() {
479
-		check_ajax_referer( 'wps_reload_cart' );
479
+		check_ajax_referer('wps_reload_cart');
480 480
 
481 481
 		$status = false; $response = '';
482
-		$product_id = ( !empty($_POST['product_id']) ) ? wpshop_tools::varSanitizer( $_POST['product_id'] ) : null;
483
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
484
-		$product_qty = ( !empty($_POST['qty']) ) ? intval( $_POST['qty'] ) : 0;
482
+		$product_id = (!empty($_POST['product_id'])) ? wpshop_tools::varSanitizer($_POST['product_id']) : null;
483
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
484
+		$product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 0;
485 485
 
486
-		if( !empty($product_id) && !empty($order_id) ) {
486
+		if (!empty($product_id) && !empty($order_id)) {
487 487
 			// Get Metadatas
488
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
488
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
489 489
 			// Calcul cart informations
490 490
 			$wps_cart = new wps_cart();
491
-			$order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false );
491
+			$order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false);
492 492
 			// Update Metadatas
493
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
493
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
494 494
 			$status = true;
495 495
 		}
496 496
 
497
-		echo json_encode( array( 'status' => $status ) );
497
+		echo json_encode(array('status' => $status));
498 498
 		wp_die();
499 499
 	}
500 500
 
@@ -502,15 +502,15 @@  discard block
 block discarded – undo
502 502
 	 * AJAX - Load Product Variations in ThickBox on Add product to order action
503 503
 	 */
504 504
 	function wps_order_load_product_variations() {
505
-		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
505
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
506 506
 
507
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) )
507
+		if (!wp_verify_nonce($_wpnonce, 'wps_order_load_product_variations'))
508 508
 			wp_die();
509 509
 
510
-		$product_id = ( !empty($_GET['pid']) ) ? intval( $_GET['pid']) : null;
511
-		$order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null;
512
-		$qty = ( !empty($_GET['qty']) ) ? intval( $_GET['qty']) : 1;
513
-		echo '<div class="wps-boxed"><span class="wps-h5">'.__( 'Select your variations', 'wpshop' ).'</span>'.wpshop_products::wpshop_variation($product_id, true, $order_id, $qty ).'<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' .__( 'Add to cart', 'wpshop' ). '</a>'.'</div>';
510
+		$product_id = (!empty($_GET['pid'])) ? intval($_GET['pid']) : null;
511
+		$order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null;
512
+		$qty = (!empty($_GET['qty'])) ? intval($_GET['qty']) : 1;
513
+		echo '<div class="wps-boxed"><span class="wps-h5">' . __('Select your variations', 'wpshop') . '</span>' . wpshop_products::wpshop_variation($product_id, true, $order_id, $qty) . '<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' . __('Add to cart', 'wpshop') . '</a>' . '</div>';
514 514
 		wp_die();
515 515
 	}
516 516
 
@@ -518,67 +518,67 @@  discard block
 block discarded – undo
518 518
 	 * AJAX - Update cart informations
519 519
 	 */
520 520
 	function wps_orders_update_cart_informations() {
521
-		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
521
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
522 522
 
523
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) )
523
+		if (!wp_verify_nonce($_wpnonce, 'wps_orders_update_cart_informations'))
524 524
 			wp_die();
525 525
 
526 526
 		$status = false;
527
-		$order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : '';
527
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : '';
528 528
 		$shipping_cost = isset($_POST['shipping_cost']) ? wpshop_tools::varSanitizer($_POST['shipping_cost']) : '';
529 529
 		$discount_value = isset($_POST['discount_amount']) ? wpshop_tools::varSanitizer($_POST['discount_amount']) : '';
530 530
 		$discount_type = isset($_POST['discount_type']) ? wpshop_tools::varSanitizer($_POST['discount_type']) : '';
531 531
 
532 532
 
533
-		if( !empty($order_id) ) {
534
-			$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
533
+		if (!empty($order_id)) {
534
+			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
535 535
 			$order_meta['order_shipping_cost'] = $shipping_cost;
536 536
 
537 537
 			//Add discounts if exists
538
-			if( isset($discount_value) && !empty($discount_type) ) {
538
+			if (isset($discount_value) && !empty($discount_type)) {
539 539
 				$order_meta['order_discount_type'] = $discount_type;
540 540
 				$order_meta['order_discount_value'] = $discount_value;
541 541
 			}
542 542
 			$wps_cart = new wps_cart();
543
-			$order_meta = $wps_cart->calcul_cart_information( array(), '', $order_meta, true );
544
-			update_post_meta( $order_id, '_order_postmeta', $order_meta );
543
+			$order_meta = $wps_cart->calcul_cart_information(array(), '', $order_meta, true);
544
+			update_post_meta($order_id, '_order_postmeta', $order_meta);
545 545
 			$status = true;
546 546
 		}
547 547
 
548
-		echo json_encode( array( 'status' => $status) );
548
+		echo json_encode(array('status' => $status));
549 549
 		wp_die();
550 550
 	}
551 551
 
552 552
 	function wps_reverify_payment_invoice_ref() {
553
-		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
553
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
554 554
 
555
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) )
555
+		if (!wp_verify_nonce($_wpnonce, 'wps_reverify_payment_invoice_ref'))
556 556
 			wp_die();
557 557
 
558 558
 		$status = true;
559
-		$inputs = !empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false;
559
+		$inputs = !empty($_POST['inputs']) ? (array)$_POST['inputs'] : false;
560 560
 
561 561
 		if (!$inputs)
562 562
 			$status = false;
563 563
 
564
-		if( $status ) {
564
+		if ($status) {
565 565
 			$inputs_clone = $inputs;
566 566
 			$inputs = array();
567
-			foreach( $inputs_clone as $var ) {
568
-				if( isset( $var['key'] ) && isset( $var['value'] ) ) {
567
+			foreach ($inputs_clone as $var) {
568
+				if (isset($var['key']) && isset($var['value'])) {
569 569
 					$inputs[$var['key']] = $var['value'];
570 570
 				}
571 571
 			}
572 572
 
573
-			( isset( $inputs['order_id'] ) ) ? $order_id = $inputs['order_id'] : $status = $order_id = false;
574
-			( isset( $inputs['index_payment'] ) ) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false;
573
+			(isset($inputs['order_id'])) ? $order_id = $inputs['order_id'] : $status = $order_id = false;
574
+			(isset($inputs['index_payment'])) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false;
575 575
 		}
576 576
 
577
-		if( $status ) {
578
-			$status = wpshop_payment::reverify_payment_invoice_ref( $order_id, $index_payment );
577
+		if ($status) {
578
+			$status = wpshop_payment::reverify_payment_invoice_ref($order_id, $index_payment);
579 579
 		}
580 580
 
581
-		echo json_encode( array( 'status' => $status ) );
581
+		echo json_encode(array('status' => $status));
582 582
 		wp_die();
583 583
 	}
584 584
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -21 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_orders_in_back_office {
3 5
 
4 6
 	function __construct() {
@@ -31,8 +33,9 @@  discard block
 block discarded – undo
31 33
 	 */
32 34
 	function wps_orders_scripts() {
33 35
 		global $current_screen;
34
-		if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) )
35
-			return;
36
+		if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) {
37
+					return;
38
+		}
36 39
 
37 40
 		wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL.WPS_ORDERS_DIR.'/assets/backend/js/wps_orders.js' );
38 41
 	}
@@ -307,8 +310,7 @@  discard block
 block discarded – undo
307 310
 								'order_shipping_address' => ''
308 311
 								)
309 312
 						);
310
-			}
311
-			else {
313
+			} else {
312 314
 				$wps_message->wpshop_prepared_email(
313 315
 						$email,
314 316
 						'WPSHOP_ORDER_UPDATE_MESSAGE',
@@ -333,8 +335,9 @@  discard block
 block discarded – undo
333 335
 	function wpshop_add_private_comment_to_order() {
334 336
 		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
335 337
 
336
-		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) )
337
-			wp_die();
338
+		if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) {
339
+					wp_die();
340
+		}
338 341
 
339 342
 		$status = false; $result = '';
340 343
 		$order_id = ( !empty($_POST['oid']) ) ? intval($_POST['oid']) : null;
@@ -354,8 +357,7 @@  discard block
 block discarded – undo
354 357
 				ob_end_clean();
355 358
 				$status = true;
356 359
 			}
357
-		}
358
-		else {
360
+		} else {
359 361
 			$result = __('An error was occured', 'wpshop');
360 362
 		}
361 363
 
@@ -372,8 +374,9 @@  discard block
 block discarded – undo
372 374
 		$letter = ( !empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : '';
373 375
 		$research = !empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : '';
374 376
 
375
-		if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) )
376
-			wp_die();
377
+		if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) {
378
+					wp_die();
379
+		}
377 380
 
378 381
 		$status = false; $response = '';
379 382
 		$oid = !empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0;
@@ -418,8 +421,7 @@  discard block
 block discarded – undo
418 421
 			$have_variations_checking = wpshop_products::get_variation( $product_id );
419 422
 			if( !empty($have_variations_checking) ) {
420 423
 				$product_have_variations = true;
421
-			}
422
-			else {
424
+			} else {
423 425
 				// Get Metadatas
424 426
 				$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
425 427
 				// Calcul cart informations
@@ -504,8 +506,9 @@  discard block
 block discarded – undo
504 506
 	function wps_order_load_product_variations() {
505 507
 		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
506 508
 
507
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) )
508
-			wp_die();
509
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) {
510
+					wp_die();
511
+		}
509 512
 
510 513
 		$product_id = ( !empty($_GET['pid']) ) ? intval( $_GET['pid']) : null;
511 514
 		$order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null;
@@ -520,8 +523,9 @@  discard block
 block discarded – undo
520 523
 	function wps_orders_update_cart_informations() {
521 524
 		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
522 525
 
523
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) )
524
-			wp_die();
526
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) {
527
+					wp_die();
528
+		}
525 529
 
526 530
 		$status = false;
527 531
 		$order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : '';
@@ -552,14 +556,16 @@  discard block
 block discarded – undo
552 556
 	function wps_reverify_payment_invoice_ref() {
553 557
 		$_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
554 558
 
555
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) )
556
-			wp_die();
559
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) {
560
+					wp_die();
561
+		}
557 562
 
558 563
 		$status = true;
559 564
 		$inputs = !empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false;
560 565
 
561
-		if (!$inputs)
562
-			$status = false;
566
+		if (!$inputs) {
567
+					$status = false;
568
+		}
563 569
 
564 570
 		if( $status ) {
565 571
 			$inputs_clone = $inputs;
Please login to merge, or discard this patch.
includes/modules/wps-pos-addon/controller/wps-pos-addon.ctr.php 2 patches
Spacing   +137 added lines, -137 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
 /**
4 4
  * Fichier du controlleur principal de l'extension de caisse pour WP-Shop / Main controller file for point of sale management plugin
@@ -20,55 +20,55 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	function __construct() {
22 22
 		/**	Declaration des sessions / Call session utilities on init	*/
23
-		add_action( 'init', array( $this, 'wps_pos_addon_session' ) );
23
+		add_action('init', array($this, 'wps_pos_addon_session'));
24 24
 
25
-		$page = ( !empty( $_GET['page'] ) ) ? sanitize_text_field( $_GET['page'] ) : '';
26
-		$tab = ( !empty( $_GET['tab'] ) ) ? sanitize_text_field( $_GET['tab'] ) : '';
27
-		$action = ( !empty( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
28
-		if ( $action == 'wps_bank_deposit' ) {
25
+		$page = (!empty($_GET['page'])) ? sanitize_text_field($_GET['page']) : '';
26
+		$tab = (!empty($_GET['tab'])) ? sanitize_text_field($_GET['tab']) : '';
27
+		$action = (!empty($_GET['action'])) ? sanitize_text_field($_GET['action']) : '';
28
+		if ($action == 'wps_bank_deposit') {
29 29
 			$tab = 'bank_deposit';
30 30
 		}
31
-		if( /* !empty( $page ) && ( 'wps-pos' == $page ) && */ ( empty( $tab ) || $tab == 'dashboard' ) ) {
31
+		if ( /* !empty( $page ) && ( 'wps-pos' == $page ) && */ (empty($tab) || $tab == 'dashboard') ) {
32 32
 			/** Inclusion des différents composants / Include plugin components */
33
-			require_once( WPSPOS_PATH . 'controller/wps-pos-customer.ctr.php' );
34
-			require_once( WPSPOS_PATH . 'controller/wps-pos-product.ctr.php' );
35
-			require_once( WPSPOS_PATH . 'controller/wps-pos-order.ctr.php' );
33
+			require_once(WPSPOS_PATH . 'controller/wps-pos-customer.ctr.php');
34
+			require_once(WPSPOS_PATH . 'controller/wps-pos-product.ctr.php');
35
+			require_once(WPSPOS_PATH . 'controller/wps-pos-order.ctr.php');
36 36
 
37 37
 			/**	Instanciation des différents composants du logiciel de caisse / Instanciate the different component for POS addon	*/
38 38
 			$this->wps_pos_customer = new wps_pos_addon_customer();
39 39
 			$this->wps_pos_product = new wps_pos_addon_product();
40 40
 			$this->wps_pos_order = new wps_pos_addon_order();
41
-		} elseif( ( $action == 'wps_bank_deposit' ) || ( $tab == 'bank_deposit' ) ) {
41
+		} elseif (($action == 'wps_bank_deposit') || ($tab == 'bank_deposit')) {
42 42
 
43 43
 			/** Inclusion des différents composants / Include plugin components */
44
-			require_once( WPSPOS_PATH . 'controller/wps-pos-bank-deposit.php' );
45
-			require_once( WPSPOS_PATH . 'controller/wps-pos-bank-deposit-histo.php' );
44
+			require_once(WPSPOS_PATH . 'controller/wps-pos-bank-deposit.php');
45
+			require_once(WPSPOS_PATH . 'controller/wps-pos-bank-deposit-histo.php');
46 46
 
47 47
 			$this->wps_pos_addon_bank_deposit = new wps_pos_addon_bank_deposit();
48 48
 			$this->wps_pos_addon_bank_deposit_histo = new wps_pos_addon_bank_deposit_histo();
49 49
 
50 50
 			/** AJAX Bank Deposit **/
51
-			add_action( 'wp_ajax_save_historic_query', array( $this->wps_pos_addon_bank_deposit_histo, 'save_historic_ajax' ) );
51
+			add_action('wp_ajax_save_historic_query', array($this->wps_pos_addon_bank_deposit_histo, 'save_historic_ajax'));
52 52
 		}
53 53
 
54 54
 		/**	Appel des scripts et styles pour le logiciel de caisse / Include styles and scripts for backend	*/
55
-		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_assets' ) );
56
-		add_action( 'admin_print_scripts', array( &$this, 'print_js') );
55
+		add_action('admin_enqueue_scripts', array(&$this, 'admin_assets'));
56
+		add_action('admin_print_scripts', array(&$this, 'print_js'));
57 57
 
58 58
 		/**	Appel du point d'accroche de création de menu dans l'administration et redéfinition de l'ordre des menus / Define the administration menu with some arrangements for displaying the created menu under wpshop menu	*/
59
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
60
-		add_action( 'menu_order', array( $this, 'admin_menu_order' ), 11 );
61
-		add_action( 'custom_menu_order', array( $this, 'admin_custom_menu_order' ) );
59
+		add_action('admin_menu', array($this, 'admin_menu'));
60
+		add_action('menu_order', array($this, 'admin_menu_order'), 11);
61
+		add_action('custom_menu_order', array($this, 'admin_custom_menu_order'));
62 62
 
63 63
 		/**	AJAX Definition	*/
64 64
 		/**	Recharge la liste d'un élément donné ( client ou produit ) pour une lettre donnée / Load element list corresponding to a given letter	*/
65
-		add_action( 'wp_ajax_wpspos_load_element_from_letter', array( $this, 'ajax_load_element_from_letter' ) );
66
-		add_action( 'wp_ajax_wpspos_save_config_barcode_only', array( $this, 'ajax_save_config_barcode_only' ) );
65
+		add_action('wp_ajax_wpspos_load_element_from_letter', array($this, 'ajax_load_element_from_letter'));
66
+		add_action('wp_ajax_wpspos_save_config_barcode_only', array($this, 'ajax_save_config_barcode_only'));
67 67
 		// add_action( 'wap_ajax_wpspos_state_is_quotation', array( $this, 'ajax_wpspos_state_is_quotation' ) );
68 68
 		// add_action( 'wap_ajax_wpspos_state_is_receipt', array( $this, 'ajax_wpspos_state_is_receipt' ) );
69 69
 
70 70
 		/** Bank deposit Page **/
71
-		add_action( 'admin_post_wps_bank_deposit', array( 'wps_pos_addon_bank_deposit', 'wps_pos_bank_deposit_output' ) );
71
+		add_action('admin_post_wps_bank_deposit', array('wps_pos_addon_bank_deposit', 'wps_pos_bank_deposit_output'));
72 72
 	}
73 73
 
74 74
 	/**
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
 	function admin_assets() {
82 82
 		global $wps_pos_addon_menu;
83 83
 		$screen = get_current_screen();
84
-		if ( $screen->id == $wps_pos_addon_menu ) {
85
-			wp_register_style( 'wpspos-common-styles', WPSPOS_URL . 'assets/css/backend.css', '', WPSPOS_VERSION );
86
-			wp_enqueue_style( 'wpspos-common-styles' );
84
+		if ($screen->id == $wps_pos_addon_menu) {
85
+			wp_register_style('wpspos-common-styles', WPSPOS_URL . 'assets/css/backend.css', '', WPSPOS_VERSION);
86
+			wp_enqueue_style('wpspos-common-styles');
87 87
 
88
-			$tab = ( !empty( $_GET['tab'] ) ) ? sanitize_text_field( $_GET['tab'] ) : '';
88
+			$tab = (!empty($_GET['tab'])) ? sanitize_text_field($_GET['tab']) : '';
89 89
 
90
-			if( !empty( $tab ) && $tab == 'bank_deposit' ) {
91
-				wp_enqueue_script('wpspos-backend-bank-deposit-js',  WPSPOS_URL . 'assets/js/backend_bank_deposit.js', array( 'jquery-ui-datepicker' ), WPSPOS_VERSION);
90
+			if (!empty($tab) && $tab == 'bank_deposit') {
91
+				wp_enqueue_script('wpspos-backend-bank-deposit-js', WPSPOS_URL . 'assets/js/backend_bank_deposit.js', array('jquery-ui-datepicker'), WPSPOS_VERSION);
92 92
 			} else {
93
-				wp_enqueue_script('wpspos-backend-js',  WPSPOS_URL . 'assets/js/backend.js', array( 'jquery-form' ), WPSPOS_VERSION);
94
-				wp_enqueue_script('wpshop_jquery_chosen',  WPSHOP_JS_URL . 'jquery-libs/chosen.jquery.min.js', '', WPSHOP_VERSION);
93
+				wp_enqueue_script('wpspos-backend-js', WPSPOS_URL . 'assets/js/backend.js', array('jquery-form'), WPSPOS_VERSION);
94
+				wp_enqueue_script('wpshop_jquery_chosen', WPSHOP_JS_URL . 'jquery-libs/chosen.jquery.min.js', '', WPSHOP_VERSION);
95 95
 			}
96 96
 		}
97 97
 	}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		global $wps_pos_addon_menu;
104 104
 		$screen = get_current_screen();
105 105
 
106
-		if ( $screen->id == $wps_pos_addon_menu ) {
107
-			require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_PATH . 'assets/', 'js', 'header.js' ) );
106
+		if ($screen->id == $wps_pos_addon_menu) {
107
+			require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_PATH . 'assets/', 'js', 'header.js'));
108 108
 		}
109 109
 	}
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	function admin_menu() {
115 115
 		global $wps_pos_addon_menu;
116 116
 
117
-		$wps_pos_addon_menu = add_menu_page( __( 'WP-Shop point of sale interface', 'wps-pos-i18n' ), __( 'WP-Shop POS', 'wps-pos-i18n' ), 'manage_options', 'wps-pos', array( $this, 'display_pos' ), 'dashicons-store' );
117
+		$wps_pos_addon_menu = add_menu_page(__('WP-Shop point of sale interface', 'wps-pos-i18n'), __('WP-Shop POS', 'wps-pos-i18n'), 'manage_options', 'wps-pos', array($this, 'display_pos'), 'dashicons-store');
118 118
 	}
119 119
 
120 120
 	/**
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return array The new admin menu order with the POS addon placed
126 126
 	 */
127
-	function admin_menu_order( $current_menu_order ) {
127
+	function admin_menu_order($current_menu_order) {
128 128
 		/**	Create a new menu order	*/
129 129
 		$wps_pos_menu_ordered = array();
130 130
 
131 131
 		/**	Read the current existing menu order for rearrange it	*/
132
-		foreach ( $current_menu_order as $menu_item ) {
133
-			if ( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER == $menu_item ) {
132
+		foreach ($current_menu_order as $menu_item) {
133
+			if ('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER == $menu_item) {
134 134
 				$wps_pos_menu_ordered[] = 'wps-pos';
135 135
 				$wps_pos_menu_ordered[] = 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER;
136 136
 
137
-				unset( $current_menu_order[ array_search( 'wps-pos', $current_menu_order ) ] );
137
+				unset($current_menu_order[array_search('wps-pos', $current_menu_order)]);
138 138
 			}
139
-			else if ( 'wps-pos' != $menu_item ) {
139
+			else if ('wps-pos' != $menu_item) {
140 140
 				$wps_pos_menu_ordered[] = $menu_item;
141 141
 			}
142 142
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @return boolean A boolean var defining if we apply admin menu reorder for current user
151 151
 	 */
152 152
 	function admin_custom_menu_order() {
153
-		return current_user_can( 'manage_options' );
153
+		return current_user_can('manage_options');
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	function wps_pos_addon_session() {
160 160
 		$session_status = false;
161
-		if ( function_exists( 'session_status' ) ) {
162
-			$session_status = ( session_status() !== PHP_SESSION_NONE ? true : false );
161
+		if (function_exists('session_status')) {
162
+			$session_status = (session_status() !== PHP_SESSION_NONE ? true : false);
163 163
 		}
164
-		else if ( session_id() == '' ) {
164
+		else if (session_id() == '') {
165 165
 			$session_status = true;
166 166
 		}
167
-		if ( false === $session_status ) {
167
+		if (false === $session_status) {
168 168
 			@session_start();
169 169
 		}
170 170
 
171
-		$new_order = ( !empty( $_GET['new_order'] ) ) ? sanitize_text_field( $_GET['new_order'] ) : '';
172
-		$page = ( !empty( $_GET['page'] ) ) ? sanitize_text_field( $_GET['page'] ) : '';
171
+		$new_order = (!empty($_GET['new_order'])) ? sanitize_text_field($_GET['new_order']) : '';
172
+		$page = (!empty($_GET['page'])) ? sanitize_text_field($_GET['page']) : '';
173 173
 
174
-		if ( 'yes' == $new_order ) {
175
-			unset( $_SESSION[ 'cart' ] );
176
-			unset( $_SESSION[ 'wps-pos-addon' ] );
177
-			delete_user_meta( get_current_user_id(), '_wpshop_persistent_cart' );
174
+		if ('yes' == $new_order) {
175
+			unset($_SESSION['cart']);
176
+			unset($_SESSION['wps-pos-addon']);
177
+			delete_user_meta(get_current_user_id(), '_wpshop_persistent_cart');
178 178
 			session_destroy();
179 179
 
180
-			wp_safe_redirect( admin_url( 'admin.php?page=wps-pos' ) );
180
+			wp_safe_redirect(admin_url('admin.php?page=wps-pos'));
181 181
 		}
182 182
 
183
-		if( empty( $page ) || ( 'wps-pos' != $page ) ) {
184
-			unset( $_SESSION[ 'wps-pos-addon' ] );
183
+		if (empty($page) || ('wps-pos' != $page)) {
184
+			unset($_SESSION['wps-pos-addon']);
185 185
 		}
186 186
 
187
-		add_option( 'wps_pos_options',  array(
187
+		add_option('wps_pos_options', array(
188 188
 			'only_barcode' => 'checked',
189
-		) );
189
+		));
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,45 +196,45 @@  discard block
 block discarded – undo
196 196
 		global $wpdb;
197 197
 
198 198
 		/** Activate Barcode attribute **/
199
-		if ( false ) {
200
-			$wpdb->update( WPSHOP_DBT_ATTRIBUTE, array( 'status' => 'valid' ), array( 'code' => 'barcode' ) );
199
+		if (false) {
200
+			$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => 'barcode'));
201 201
 
202 202
 			/** Get the product entity id **/
203
-			$query = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
204
-			$product_entity_id = $wpdb->get_var( $query );
203
+			$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
204
+			$product_entity_id = $wpdb->get_var($query);
205 205
 
206 206
 			/** Check the barcode attribute id **/
207
-			$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', 'barcode');
208
-			$attribute_barcode_id = $wpdb->get_var( $query );
207
+			$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', 'barcode');
208
+			$attribute_barcode_id = $wpdb->get_var($query);
209 209
 
210
-			$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $product_entity_id );
211
-			$products_groups = $wpdb->get_results( $query );
210
+			$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $product_entity_id);
211
+			$products_groups = $wpdb->get_results($query);
212 212
 			/** For each attributes groups used for product configuration **/
213
-			foreach( $products_groups as $products_group ) {
214
-				$query = $wpdb->prepare( 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE attribute_set_id = %d AND code = %s', $products_group->id, 'general');
215
-				$attributes_set_sections = $wpdb->get_results( $query );
216
-				foreach( $attributes_set_sections as $attributes_set_section ) {
217
-					$query = $wpdb->prepare( 'SELECT MAX(position) AS max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $product_entity_id, $products_group->id, $attributes_set_section->id);
218
-					$max_position = $wpdb->get_var( $query );
219
-
220
-					$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $product_entity_id, $products_group->id, $attributes_set_section->id, $attribute_barcode_id);
221
-					$exist_barcode_details_definition = $wpdb->get_results( $query );
213
+			foreach ($products_groups as $products_group) {
214
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d AND code = %s', $products_group->id, 'general');
215
+				$attributes_set_sections = $wpdb->get_results($query);
216
+				foreach ($attributes_set_sections as $attributes_set_section) {
217
+					$query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $product_entity_id, $products_group->id, $attributes_set_section->id);
218
+					$max_position = $wpdb->get_var($query);
219
+
220
+					$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $product_entity_id, $products_group->id, $attributes_set_section->id, $attribute_barcode_id);
221
+					$exist_barcode_details_definition = $wpdb->get_results($query);
222 222
 					/** Insert the barcode attribute details **/
223
-					if ( !empty ($max_position) && empty($exist_barcode_details_definition) ) {
224
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $product_entity_id, 'attribute_set_id' => $products_group->id, 'attribute_group_id' => $attributes_set_section->id, 'attribute_id' => $attribute_barcode_id, 'position' => (int)$max_position +1) );
223
+					if (!empty ($max_position) && empty($exist_barcode_details_definition)) {
224
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $product_entity_id, 'attribute_set_id' => $products_group->id, 'attribute_group_id' => $attributes_set_section->id, 'attribute_id' => $attribute_barcode_id, 'position' => (int)$max_position + 1));
225 225
 					}
226 226
 				}
227 227
 			}
228 228
 		}
229 229
 
230 230
 		/** Activate Barcode for search **/
231
-		$wpdb->update( WPSHOP_DBT_ATTRIBUTE, array('is_used_for_sort_by' => 'yes', 'is_used_in_quick_add_form' => 'yes'), array('code' => 'barcode') );
231
+		$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_for_sort_by' => 'yes', 'is_used_in_quick_add_form' => 'yes'), array('code' => 'barcode'));
232 232
 
233 233
 		/** Activate attribute for the product quick add form **/
234
-		$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
235
-		$code = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? 'price_ht' : 'product_price';
236
-		$wpdb->update( WPSHOP_DBT_ATTRIBUTE, array( 'is_used_in_quick_add_form' => 'yes'), array('code' => $code)  );
237
-		$wpdb->update( WPSHOP_DBT_ATTRIBUTE, array( 'is_used_in_quick_add_form' => 'yes'), array('code' => 'tx_tva' )  );
234
+		$price_piloting_option = get_option('wpshop_shop_price_piloting');
235
+		$code = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? 'price_ht' : 'product_price';
236
+		$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_in_quick_add_form' => 'yes'), array('code' => $code));
237
+		$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_in_quick_add_form' => 'yes'), array('code' => 'tx_tva'));
238 238
 
239 239
 		/** Check If Shop Customer attribute set exist - Deprecated **/
240 240
 		/* $customer_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS );
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 		$exist_attribute_group = 'Nope';
245 245
 
246
-		if ( empty($exist_attribute_group) ) {
246
+		if (empty($exist_attribute_group)) {
247 247
 			/** Create a Attributes Group for POS Customer infos **/
248 248
 			$wpdb->insert(
249 249
 				WPSHOP_DBT_ATTRIBUTE_SET,
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 					'creation_date' => current_time('mysql', 0),
266 266
 					'last_update_date' => current_time('mysql', 0),
267 267
 					'attribute_set_id' => $attribute_set_id,
268
-					'code' => sanitize_title( __('Shop Customer main infos', 'wps-pos-i18n') ),
268
+					'code' => sanitize_title(__('Shop Customer main infos', 'wps-pos-i18n')),
269 269
 					'name' => __('Shop Customer main infos', 'wps-pos-i18n')
270 270
 				)
271 271
 			);
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
 					'creation_date' => current_time('mysql', 0),
278 278
 					'last_update_date' => current_time('mysql', 0),
279 279
 					'attribute_set_id' => $attribute_set_id,
280
-					'code' => sanitize_title( __('Shop Customer address infos', 'wps-pos-i18n') ),
280
+					'code' => sanitize_title(__('Shop Customer address infos', 'wps-pos-i18n')),
281 281
 					'name' => __('Shop Customer address infos', 'wps-pos-i18n')
282 282
 				)
283 283
 			);
284 284
 			$address_set_id = $wpdb->insert_id;
285 285
 			/** Affect Attributes **/
286
-			$attributes = array( 'last_name' => $main_set_id, 'first_name' => $main_set_id, 'address_last_name' => $main_set_id, 'address_first_name' => $main_set_id, 'address_user_email' => $main_set_id, 'address' => $address_set_id, 'postcode' => $address_set_id, 'city' => $address_set_id, 'phone' => $address_set_id);
286
+			$attributes = array('last_name' => $main_set_id, 'first_name' => $main_set_id, 'address_last_name' => $main_set_id, 'address_first_name' => $main_set_id, 'address_user_email' => $main_set_id, 'address' => $address_set_id, 'postcode' => $address_set_id, 'city' => $address_set_id, 'phone' => $address_set_id);
287 287
 			$i = 1;
288
-			foreach( $attributes as $attribute => $group_id) {
289
-				$attribute_def = wpshop_attributes::getElement( $attribute, "'valid'", 'code');
290
-				if ( !empty($attribute_def) ) {
288
+			foreach ($attributes as $attribute => $group_id) {
289
+				$attribute_def = wpshop_attributes::getElement($attribute, "'valid'", 'code');
290
+				if (!empty($attribute_def)) {
291 291
 					$wpdb->insert(
292 292
 						WPSHOP_DBT_ATTRIBUTE_DETAILS,
293 293
 						array(
@@ -307,32 +307,32 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 
309 309
 		$user_name = 'default_customer';
310
-		$user_id = username_exists( $user_name );
311
-		if ( !$user_id ) {
312
-			$random_password = wp_generate_password( $length = 12, $include_standard_special_chars=false );
313
-			$user_id = wp_create_user( $user_name, $random_password, '[email protected]' );
314
-
315
-			if ( !empty($user_id) ) {
316
-				update_user_meta($user_id, 'last_name', __('Default', 'wps-pos-i18n') );
317
-				update_user_meta($user_id, 'first_name', __('Customer', 'wps-pos-i18n') );
310
+		$user_id = username_exists($user_name);
311
+		if (!$user_id) {
312
+			$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
313
+			$user_id = wp_create_user($user_name, $random_password, '[email protected]');
314
+
315
+			if (!empty($user_id)) {
316
+				update_user_meta($user_id, 'last_name', __('Default', 'wps-pos-i18n'));
317
+				update_user_meta($user_id, 'first_name', __('Customer', 'wps-pos-i18n'));
318 318
 				/** Add the default customer id in Option table **/
319 319
 				update_option('wpshop_pos_addon_default_customer_id', $user_id);
320 320
 			}
321 321
 		}
322 322
 
323 323
 		/** Get post of user id */
324
-		$customers_associated_to_user = get_posts( array (
324
+		$customers_associated_to_user = get_posts(array(
325 325
 			'post_status' => 'draft',
326 326
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS,
327 327
 			'author' => $user_id,
328
-		) );
329
-		$customer_id = !empty( $customers_associated_to_user ) && !empty( $customers_associated_to_user[ 0 ] ) && !empty( $customers_associated_to_user[ 0 ]->ID ) ? $customers_associated_to_user[ 0 ]->ID : null;
328
+		));
329
+		$customer_id = !empty($customers_associated_to_user) && !empty($customers_associated_to_user[0]) && !empty($customers_associated_to_user[0]->ID) ? $customers_associated_to_user[0]->ID : null;
330 330
 
331 331
 		$customer_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
332 332
 
333
-		if ( !empty( $customer_id ) ) {
333
+		if (!empty($customer_id)) {
334 334
 			/** Insert attribute data */
335
-			wpshop_attributes::saveAttributeForEntity( array(
335
+			wpshop_attributes::saveAttributeForEntity(array(
336 336
 				'varchar' => array(
337 337
 					'last_name' => __('Default', 'wps-pos-i18n'),
338 338
 					'first_name' => __('Customer', 'wps-pos-i18n'),
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 					'city' => __('Default city'),
346 346
 					'phone' => '0000000042',
347 347
 				),
348
-			),  $customer_entity_id, $customer_id );
348
+			), $customer_entity_id, $customer_id);
349 349
 		}
350 350
 	}
351 351
 
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 		$module_folder = WPSPOS_PATH . 'modules/';
358 358
 
359 359
 		/**	Check if the defined directory exists for reading and including the different modules	*/
360
-		if( is_dir( $module_folder ) ) {
361
-			$parent_folder_content = scandir( $module_folder );
362
-			foreach ( $parent_folder_content as $folder ) {
363
-				if ( $folder && substr( $folder, 0, 1) != '.' && is_dir( $module_folder . $folder ) ) {
364
-					$child_folder_content = scandir( $module_folder . $folder );
365
-					if ( file_exists( $module_folder . $folder . '/' . $folder . '.php') ) {
366
-						$f =  $module_folder . $folder . '/' . $folder . '.php';
367
-						include( $f );
360
+		if (is_dir($module_folder)) {
361
+			$parent_folder_content = scandir($module_folder);
362
+			foreach ($parent_folder_content as $folder) {
363
+				if ($folder && substr($folder, 0, 1) != '.' && is_dir($module_folder . $folder)) {
364
+					$child_folder_content = scandir($module_folder . $folder);
365
+					if (file_exists($module_folder . $folder . '/' . $folder . '.php')) {
366
+						$f = $module_folder . $folder . '/' . $folder . '.php';
367
+						include($f);
368 368
 					}
369 369
 				}
370 370
 			}
@@ -376,25 +376,25 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	function display_pos() {
378 378
 		/**	Define the current step for current order	*/
379
-		$default_customer_id = get_option( 'wpshop_pos_addon_default_customer_id' );
379
+		$default_customer_id = get_option('wpshop_pos_addon_default_customer_id');
380 380
 		$default_user_exists = false;
381
-		if ( !empty( $default_customer_id ) ) {
382
-			$default_user = get_user_by( 'id', $default_customer_id );
383
-			if ( false !== $default_user ) {
381
+		if (!empty($default_customer_id)) {
382
+			$default_user = get_user_by('id', $default_customer_id);
383
+			if (false !== $default_user) {
384 384
 				$default_user_exists = true;
385 385
 			}
386 386
 		}
387 387
 
388
-		if ( !empty( $default_user_exists ) ) {
388
+		if (!empty($default_user_exists)) {
389 389
 			$current_step = 2;
390
-			$_SESSION[ 'cart' ][ 'customer_id' ] = $default_customer_id;
390
+			$_SESSION['cart']['customer_id'] = $default_customer_id;
391 391
 		}
392 392
 		else {
393 393
 			$current_step = 0;
394
-			$_SESSION[ 'cart' ][ 'customer_id' ] = null;
394
+			$_SESSION['cart']['customer_id'] = null;
395 395
 		}
396 396
 
397
-		require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend', 'pos' ) );
397
+		require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend', 'pos'));
398 398
 	}
399 399
 
400 400
 	/**
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 	 */
403 403
 	function ajax_load_element_from_letter() {
404 404
 
405
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
405
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
406 406
 
407
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_load_element_from_letter' ) )
407
+		if (!wp_verify_nonce($_wpnonce, 'ajax_load_element_from_letter'))
408 408
 			wp_die();
409 409
 
410 410
 		$response = array(
@@ -412,37 +412,37 @@  discard block
 block discarded – undo
412 412
 			'output' => __('An error occured', 'wps-pos-i18n'),
413 413
 		);
414 414
 
415
-		$alphabet = unserialize( WPSPOS_ALPHABET_LETTERS );
416
-		$letter = !empty( $_POST['term'] ) && in_array( $_POST['term'], $alphabet )	? sanitize_text_field( $_POST['term'] ) : null;
417
-		$element_type = !empty( $_POST['element_type'] ) ? sanitize_text_field( $_POST['element_type'] ) : 'customer';
418
-		$response[ 'element_type' ] = $element_type;
415
+		$alphabet = unserialize(WPSPOS_ALPHABET_LETTERS);
416
+		$letter = !empty($_POST['term']) && in_array($_POST['term'], $alphabet) ? sanitize_text_field($_POST['term']) : null;
417
+		$element_type = !empty($_POST['element_type']) ? sanitize_text_field($_POST['element_type']) : 'customer';
418
+		$response['element_type'] = $element_type;
419 419
 
420
-		if ( !empty( $letter ) ) {
420
+		if (!empty($letter)) {
421 421
 			$error_message = '';
422
-			switch ( $element_type ) {
422
+			switch ($element_type) {
423 423
 				case 'customer':
424
-					$result = $this->wps_pos_customer->display_customer_list( $letter );
424
+					$result = $this->wps_pos_customer->display_customer_list($letter);
425 425
 					break;
426 426
 				case 'product':
427 427
 					$wps_pos_product = new wps_pos_addon_product();
428
-					$result = $this->wps_pos_product->get_product_table_by_alphabet( $letter );
428
+					$result = $this->wps_pos_product->get_product_table_by_alphabet($letter);
429 429
 					break;
430 430
 			}
431 431
 
432
-			if ( empty( $result ) ) {
433
-				$response[ 'output' ] = sprintf( __( 'Nothing found in %s for letter %s', 'wps-pos-i18n' ), __( $element_type, 'wps-pos-i18n' ), $letter);
432
+			if (empty($result)) {
433
+				$response['output'] = sprintf(__('Nothing found in %s for letter %s', 'wps-pos-i18n'), __($element_type, 'wps-pos-i18n'), $letter);
434 434
 			}
435 435
 			else {
436
-				$response[ 'status' ] = true;
437
-				$response[ 'output' ] = $result;
436
+				$response['status'] = true;
437
+				$response['output'] = $result;
438 438
 			}
439 439
 
440 440
 		}
441 441
 		else {
442
-			$response[ 'output' ] = sprintf( __( 'THe requested term (%s) to search is invalid. Please check your request and try again', 'wps-pos-i18n' ), $letter );
442
+			$response['output'] = sprintf(__('THe requested term (%s) to search is invalid. Please check your request and try again', 'wps-pos-i18n'), $letter);
443 443
 		}
444 444
 
445
-		wp_die( json_encode( $response ) );
445
+		wp_die(json_encode($response));
446 446
 	}
447 447
 
448 448
 	/**
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
 	 */
451 451
 	function ajax_save_config_barcode_only() {
452 452
 
453
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
453
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
454 454
 
455
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_save_config_barcode_only' ) )
455
+		if (!wp_verify_nonce($_wpnonce, 'ajax_save_config_barcode_only'))
456 456
 			wp_die();
457 457
 
458 458
 		$option = 'wps_pos_options';
459
-		$values = get_option( $option );
460
-		if ( !empty( $values['only_barcode'] ) ) {
461
-			$values['only_barcode'] = !empty( $_POST['value_checkbox'] ) ? sanitize_text_field( $_POST['value_checkbox' ] ) : '';
462
-	  	update_option( $option, $values );
459
+		$values = get_option($option);
460
+		if (!empty($values['only_barcode'])) {
461
+			$values['only_barcode'] = !empty($_POST['value_checkbox']) ? sanitize_text_field($_POST['value_checkbox']) : '';
462
+	  	update_option($option, $values);
463 463
 		}
464 464
 		wp_die();
465 465
 	}
Please login to merge, or discard this patch.
Braces   +14 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
 /**
4 6
  * Fichier du controlleur principal de l'extension de caisse pour WP-Shop / Main controller file for point of sale management plugin
@@ -135,8 +137,7 @@  discard block
 block discarded – undo
135 137
 				$wps_pos_menu_ordered[] = 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER;
136 138
 
137 139
 				unset( $current_menu_order[ array_search( 'wps-pos', $current_menu_order ) ] );
138
-			}
139
-			else if ( 'wps-pos' != $menu_item ) {
140
+			} else if ( 'wps-pos' != $menu_item ) {
140 141
 				$wps_pos_menu_ordered[] = $menu_item;
141 142
 			}
142 143
 		}
@@ -160,8 +161,7 @@  discard block
 block discarded – undo
160 161
 		$session_status = false;
161 162
 		if ( function_exists( 'session_status' ) ) {
162 163
 			$session_status = ( session_status() !== PHP_SESSION_NONE ? true : false );
163
-		}
164
-		else if ( session_id() == '' ) {
164
+		} else if ( session_id() == '' ) {
165 165
 			$session_status = true;
166 166
 		}
167 167
 		if ( false === $session_status ) {
@@ -388,8 +388,7 @@  discard block
 block discarded – undo
388 388
 		if ( !empty( $default_user_exists ) ) {
389 389
 			$current_step = 2;
390 390
 			$_SESSION[ 'cart' ][ 'customer_id' ] = $default_customer_id;
391
-		}
392
-		else {
391
+		} else {
393 392
 			$current_step = 0;
394 393
 			$_SESSION[ 'cart' ][ 'customer_id' ] = null;
395 394
 		}
@@ -404,8 +403,9 @@  discard block
 block discarded – undo
404 403
 
405 404
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
406 405
 
407
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_load_element_from_letter' ) )
408
-			wp_die();
406
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_load_element_from_letter' ) ) {
407
+					wp_die();
408
+		}
409 409
 
410 410
 		$response = array(
411 411
 			'status' => false,
@@ -431,14 +431,12 @@  discard block
 block discarded – undo
431 431
 
432 432
 			if ( empty( $result ) ) {
433 433
 				$response[ 'output' ] = sprintf( __( 'Nothing found in %s for letter %s', 'wps-pos-i18n' ), __( $element_type, 'wps-pos-i18n' ), $letter);
434
-			}
435
-			else {
434
+			} else {
436 435
 				$response[ 'status' ] = true;
437 436
 				$response[ 'output' ] = $result;
438 437
 			}
439 438
 
440
-		}
441
-		else {
439
+		} else {
442 440
 			$response[ 'output' ] = sprintf( __( 'THe requested term (%s) to search is invalid. Please check your request and try again', 'wps-pos-i18n' ), $letter );
443 441
 		}
444 442
 
@@ -452,8 +450,9 @@  discard block
 block discarded – undo
452 450
 
453 451
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
454 452
 
455
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_save_config_barcode_only' ) )
456
-			wp_die();
453
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_save_config_barcode_only' ) ) {
454
+					wp_die();
455
+		}
457 456
 
458 457
 		$option = 'wps_pos_options';
459 458
 		$values = get_option( $option );
Please login to merge, or discard this patch.
includes/modules/wps-pos-addon/controller/wps-pos-product.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 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,34 +147,34 @@  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
-		check_ajax_referer( 'ajax_pos_product_variation_selection' );
172
+		check_ajax_referer('ajax_pos_product_variation_selection');
173 173
 
174 174
 		/**	Get the product identifier to display variation chooser	*/
175
-		$product_id = !empty( $_GET ) && !empty( $_GET[ 'product_id' ] ) && is_int( (int)$_GET[ 'product_id' ] ) ? (int)$_GET[ 'product_id' ] : null;
175
+		$product_id = !empty($_GET) && !empty($_GET['product_id']) && is_int((int)$_GET['product_id']) ? (int)$_GET['product_id'] : null;
176 176
 
177
-		require_once( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'modal', 'variation' ) );
177
+		require_once(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'modal', 'variation'));
178 178
 		wp_die();
179 179
 	}
180 180
 
@@ -182,67 +182,67 @@  discard block
 block discarded – undo
182 182
 	 * AJAX - Lance la recherche de produit / Launch product search
183 183
 	 */
184 184
 	function ajax_pos_product_search() {
185
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
185
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
186 186
 
187
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) )
187
+		if (!wp_verify_nonce($_wpnonce, 'ajax_pos_product_search'))
188 188
 			wp_die();
189 189
 
190
-		$term = !empty( $_POST ) && !empty( $_POST[ 'term' ] ) ? sanitize_text_field( $_POST[ 'term' ] ) : null;
190
+		$term = !empty($_POST) && !empty($_POST['term']) ? sanitize_text_field($_POST['term']) : null;
191 191
 		$response = array(
192 192
 			'status' => false,
193 193
 			'action' => '',
194 194
 		);
195
-		if ( !empty( $term ) ) {
196
-			$search_in = !empty( $_POST[ 'search_in' ] ) ? sanitize_text_field( $_POST[ 'search_in' ] ) : '';
195
+		if (!empty($term)) {
196
+			$search_in = !empty($_POST['search_in']) ? sanitize_text_field($_POST['search_in']) : '';
197 197
 
198 198
 			$wps_product_mdl = new wps_product_mdl();
199
-			$results = $wps_product_mdl->get_products_by_title_or_barcode( $term, !empty( $search_in ) && 'only_barcode' == $search_in );
199
+			$results = $wps_product_mdl->get_products_by_title_or_barcode($term, !empty($search_in) && 'only_barcode' == $search_in);
200 200
 
201
-			if ( !empty( $results ) ) {
202
-				if ( 1 < count( $results ) ) {
203
-					foreach ( $results as $product ) {
204
-						$product_post_meta = get_post_meta( $product->ID, '_wpshop_product_metadata', true );
205
-						if ( !empty($product_post_meta) ) {
201
+			if (!empty($results)) {
202
+				if (1 < count($results)) {
203
+					foreach ($results as $product) {
204
+						$product_post_meta = get_post_meta($product->ID, '_wpshop_product_metadata', true);
205
+						if (!empty($product_post_meta)) {
206 206
 							$product_list[] = array(
207 207
 								'ID' => $product->ID,
208 208
 								'product_name' => $product->post_title,
209
-								'product_price' => number_format( (float)$product_post_meta['product_price'], 2, '.', ''),
210
-								'product_barcode' => !empty( $product_post_meta['barcode'] ) ? $product_post_meta['barcode'] : ''
209
+								'product_price' => number_format((float)$product_post_meta['product_price'], 2, '.', ''),
210
+								'product_barcode' => !empty($product_post_meta['barcode']) ? $product_post_meta['barcode'] : ''
211 211
 							);
212 212
 						}
213 213
 					}
214 214
 
215 215
 					ob_start();
216
-					require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products' ) );
216
+					require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products'));
217 217
 					$output = ob_get_contents();
218 218
 					ob_end_clean();
219 219
 				}
220 220
 				else {
221
-					$product_post_meta = get_post_meta( $results[ 0 ]->ID, '_wpshop_variation_defining', true );
222
-					if ( !empty( $product_post_meta ) ) {
223
-						$response[ 'action' ] = 'variation_selection';
221
+					$product_post_meta = get_post_meta($results[0]->ID, '_wpshop_variation_defining', true);
222
+					if (!empty($product_post_meta)) {
223
+						$response['action'] = 'variation_selection';
224 224
 					}
225 225
 					else {
226
-						$response[ 'action' ] = 'direct_to_cart';
226
+						$response['action'] = 'direct_to_cart';
227 227
 					}
228
-					$output = $results[ 0 ]->ID;
228
+					$output = $results[0]->ID;
229 229
 				}
230 230
 
231 231
 				/**	Build response to send	*/
232
-				$response[ 'status' ] = true;
233
-				$response[ 'output' ] = $output;
232
+				$response['status'] = true;
233
+				$response['output'] = $output;
234 234
 			}
235 235
 			else {
236 236
 				ob_start();
237
-				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found' ) );
238
-				$response[ 'output' ] = ob_get_contents();
237
+				require(wpshop_tools::get_template_part(WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found'));
238
+				$response['output'] = ob_get_contents();
239 239
 				ob_end_clean();
240 240
 			}
241 241
 		}
242 242
 
243
-		$response['_wpnonce'] = wp_create_nonce( 'ajax_pos_product_variation_selection' );
243
+		$response['_wpnonce'] = wp_create_nonce('ajax_pos_product_variation_selection');
244 244
 
245
-		wp_die( json_encode( $response ) );
245
+		wp_die(json_encode($response));
246 246
 	}
247 247
 
248 248
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -13 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
 
@@ -184,8 +186,9 @@  discard block
 block discarded – undo
184 186
 	function ajax_pos_product_search() {
185 187
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
186 188
 
187
-		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) )
188
-			wp_die();
189
+		if ( !wp_verify_nonce( $_wpnonce, 'ajax_pos_product_search' ) ) {
190
+					wp_die();
191
+		}
189 192
 
190 193
 		$term = !empty( $_POST ) && !empty( $_POST[ 'term' ] ) ? sanitize_text_field( $_POST[ 'term' ] ) : null;
191 194
 		$response = array(
@@ -216,13 +219,11 @@  discard block
 block discarded – undo
216 219
 					require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'products' ) );
217 220
 					$output = ob_get_contents();
218 221
 					ob_end_clean();
219
-				}
220
-				else {
222
+				} else {
221 223
 					$product_post_meta = get_post_meta( $results[ 0 ]->ID, '_wpshop_variation_defining', true );
222 224
 					if ( !empty( $product_post_meta ) ) {
223 225
 						$response[ 'action' ] = 'variation_selection';
224
-					}
225
-					else {
226
+					} else {
226 227
 						$response[ 'action' ] = 'direct_to_cart';
227 228
 					}
228 229
 					$output = $results[ 0 ]->ID;
@@ -231,8 +232,7 @@  discard block
 block discarded – undo
231 232
 				/**	Build response to send	*/
232 233
 				$response[ 'status' ] = true;
233 234
 				$response[ 'output' ] = $output;
234
-			}
235
-			else {
235
+			} else {
236 236
 				ob_start();
237 237
 				require( wpshop_tools::get_template_part( WPSPOS_DIR, WPSPOS_TEMPLATES_MAIN_DIR, 'backend/products', 'product', 'not_found' ) );
238 238
 				$response[ 'output' ] = ob_get_contents();
Please login to merge, or discard this patch.
includes/modules/wps_help/controller/wps_help_bubble_ctr.php 1 patch
Spacing   +66 added lines, -66 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,45 +19,45 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function __construct() {
21 21
 		/**	Call style & javascript for administration	*/
22
-		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
22
+		add_action('admin_enqueue_scripts', array(&$this, 'admin_scripts'));
23 23
 
24 24
 		/**	Add the scripts into admin footer for future use	*/
25
-		add_action( 'admin_print_footer_scripts', array( &$this, 'wps_dashboard_help') );
25
+		add_action('admin_print_footer_scripts', array(&$this, 'wps_dashboard_help'));
26 26
 
27 27
 		/** Ajax actions **/
28
-		add_action( 'wp_ajax_close_wps_help_window', array( &$this, 'wps_ajax_close_wps_help_window' ) );
28
+		add_action('wp_ajax_close_wps_help_window', array(&$this, 'wps_ajax_close_wps_help_window'));
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * Include stylesheets
33 33
 	 */
34 34
 	function admin_scripts() {
35
-		wp_enqueue_style( 'wp-pointer' );
36
-		wp_enqueue_script( 'wp-pointer' );
35
+		wp_enqueue_style('wp-pointer');
36
+		wp_enqueue_script('wp-pointer');
37 37
 	}
38 38
 
39 39
 	/**
40 40
 	 * AJAX - Save into current user meta the different help that have to be closed next time the user will be logged in
41 41
 	 */
42 42
 	function wps_ajax_close_wps_help_window() {
43
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
43
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
44 44
 
45
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) )
45
+		if (!wp_verify_nonce($_wpnonce, 'wps_ajax_close_wps_help_window'))
46 46
 			wp_die();
47 47
 
48 48
 		$status = false;
49 49
 		$result = '';
50
-		$pointer_id = !empty( $_POST['pointer_id']) ? wpshop_tools::varSanitizer( $_POST['pointer_id'] ) : '';
51
-		if ( !empty($pointer_id) ) {
52
-			$seen_help_windows = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
53
-			$seen_help_windows[ $pointer_id ] = true;
50
+		$pointer_id = !empty($_POST['pointer_id']) ? wpshop_tools::varSanitizer($_POST['pointer_id']) : '';
51
+		if (!empty($pointer_id)) {
52
+			$seen_help_windows = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
53
+			$seen_help_windows[$pointer_id] = true;
54 54
 
55
-			update_user_meta( get_current_user_id(), '_wps_closed_help', $seen_help_windows);
55
+			update_user_meta(get_current_user_id(), '_wps_closed_help', $seen_help_windows);
56 56
 			$status = true;
57 57
 		}
58 58
 
59
-		$response = array( 'status' => $status, 'response' => $result );
60
-		wp_die( json_encode( $response ) );
59
+		$response = array('status' => $status, 'response' => $result);
60
+		wp_die(json_encode($response));
61 61
 	}
62 62
 
63 63
 	/**
@@ -70,118 +70,118 @@  discard block
 block discarded – undo
70 70
 		/**	Get current screen in order to load messages only in required pages	*/
71 71
 		$current_screen = get_current_screen();
72 72
 		$current_screen->id = 'disable';
73
-		switch ( $current_screen->id ) {
73
+		switch ($current_screen->id) {
74 74
 			case 'toplevel_page_wpshop_dashboard':
75
-				$help_cases[ 'download_newsletter_contacts' ]		= array( 'edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts' );
75
+				$help_cases['download_newsletter_contacts'] = array('edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts');
76 76
 			break;
77 77
 
78 78
 			case 'wpshop_product':
79
-				$help_cases[ 'product_page_categories' ] 			= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
80
-				$help_cases[ 'product_datas_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
81
-				$help_cases[ 'product_display_configuration' ] 		= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab' );
82
-				$help_cases[ 'product_variations' ] 				= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button' );
83
-				$help_cases[ 'product_variations_configuration' ] 	= array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button' );
84
-				$help_cases[ 'add_product_automaticly_to_cart' ] 	= array( 'edge' => 'right',  'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options' );
79
+				$help_cases['product_page_categories'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv');
80
+				$help_cases['product_datas_configuration'] = array('edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab');
81
+				$help_cases['product_display_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab');
82
+				$help_cases['product_variations'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button');
83
+				$help_cases['product_variations_configuration'] = array('edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button');
84
+				$help_cases['add_product_automaticly_to_cart'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options');
85 85
 			break;
86 86
 
87 87
 			case 'edit-wpshop_product_category':
88
-				$help_cases[ 'category_filterable_attributes' ] 	= array( 'edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container' );
89
-				$help_cases[ 'category_picture' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload' );
88
+				$help_cases['category_filterable_attributes'] = array('edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container');
89
+				$help_cases['category_picture'] = array('edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload');
90 90
 			break;
91 91
 
92 92
 			case WPSHOP_NEWTYPE_IDENTIFIER_ORDER:
93
-				$help_cases[ 'order_customer_comment' ] 			= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment' );
94
-				$help_cases[ 'order_notification_message' ] 		= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments' );
95
-				$help_cases[ 'order_shipping_box' ] 				= array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping' );
93
+				$help_cases['order_customer_comment'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment');
94
+				$help_cases['order_notification_message'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments');
95
+				$help_cases['order_shipping_box'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping');
96 96
 			break;
97 97
 
98 98
 			case 'wpshop_shop_message':
99
-				$help_cases[ 'message_historic' ] 					= array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo' );
99
+				$help_cases['message_historic'] = array('edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo');
100 100
 			break;
101 101
 
102 102
 			case 'settings_page_wpshop_option':
103
-				$help_cases[ 'options_payment_part' ] 				= array ('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container' );
103
+				$help_cases['options_payment_part'] = array('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container');
104 104
 			break;
105 105
 		}
106 106
 
107
-		if ( !empty( $help_cases ) ) {
107
+		if (!empty($help_cases)) {
108 108
 			/** Get help data seen by user **/
109
-			$closed_help_window = get_user_meta( get_current_user_id(), '_wps_closed_help', true);
109
+			$closed_help_window = get_user_meta(get_current_user_id(), '_wps_closed_help', true);
110 110
 
111 111
 			/**	Read the different help cases	*/
112
-			foreach( $help_cases as $help_id => $help_case ) {
113
-				if ( empty( $closed_help_window ) || ( !empty( $closed_help_window ) && !array_key_exists( $help_id, $closed_help_window ) ) ){
114
-					switch( $help_id ) {
112
+			foreach ($help_cases as $help_id => $help_case) {
113
+				if (empty($closed_help_window) || (!empty($closed_help_window) && !array_key_exists($help_id, $closed_help_window))) {
114
+					switch ($help_id) {
115 115
 						case 'download_newsletter_contacts' :
116
-							$pointer_content  = '<h3>' .__( 'Customers information download', 'wpshop'). '</h3>';
117
-							$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>';
116
+							$pointer_content  = '<h3>' . __('Customers information download', 'wpshop') . '</h3>';
117
+							$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>';
118 118
 							break;
119 119
 
120 120
 						case 'product_page_categories' :
121
-							$pointer_content  = '<h3>' .__( 'WPShop Categories', 'wpshop'). '</h3>';
122
-							$pointer_content .= '<p>' .__( 'You can classify your products by category.', 'wpshop'). '<br/></p>';
123
-							$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>';
121
+							$pointer_content  = '<h3>' . __('WPShop Categories', 'wpshop') . '</h3>';
122
+							$pointer_content .= '<p>' . __('You can classify your products by category.', 'wpshop') . '<br/></p>';
123
+							$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>';
124 124
 							break;
125 125
 
126 126
 						case 'product_datas_configuration' :
127
-							$pointer_content  = '<h3>' .__( 'Product configurations', 'wpshop'). '</h3>';
128
-							$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>';
127
+							$pointer_content  = '<h3>' . __('Product configurations', 'wpshop') . '</h3>';
128
+							$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>';
129 129
 							break;
130 130
 
131 131
 						case 'product_display_configuration' :
132
-							$pointer_content  = '<h3>' .__( 'Product display configurations', 'wpshop'). '</h3>';
133
-							$pointer_content .= '<p>' .__( 'Here, you can manage what elements you want to display on your product page', 'wpshop' ). '</p>';
132
+							$pointer_content  = '<h3>' . __('Product display configurations', 'wpshop') . '</h3>';
133
+							$pointer_content .= '<p>' . __('Here, you can manage what elements you want to display on your product page', 'wpshop') . '</p>';
134 134
 							break;
135 135
 
136 136
 						case 'product_variations' :
137
-							$pointer_content  = '<h3>' .__( 'Product variations', 'wpshop'). '</h3>';
138
-							$pointer_content .= '<p>' .__( 'Here, you can generate your product variations.', 'wpshop'). '</p><br/>';
139
-							$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>';
137
+							$pointer_content  = '<h3>' . __('Product variations', 'wpshop') . '</h3>';
138
+							$pointer_content .= '<p>' . __('Here, you can generate your product variations.', 'wpshop') . '</p><br/>';
139
+							$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>';
140 140
 							break;
141 141
 
142 142
 						case 'product_variations_configuration' :
143
-							$pointer_content  = '<h3>' .__( 'Variations configuration', 'wpshop'). '</h3>';
144
-							$pointer_content .= '<p>' .__( 'Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop'). '</p>';
143
+							$pointer_content  = '<h3>' . __('Variations configuration', 'wpshop') . '</h3>';
144
+							$pointer_content .= '<p>' . __('Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop') . '</p>';
145 145
 							break;
146 146
 
147 147
 						case 'add_product_automaticly_to_cart' :
148
-							$pointer_content  = '<h3>' .__('Add product to cart', 'wpshop'). '</h3>';
149
-							$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>';
148
+							$pointer_content  = '<h3>' . __('Add product to cart', 'wpshop') . '</h3>';
149
+							$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>';
150 150
 							break;
151 151
 
152 152
 						case 'category_filterable_attributes' :
153
-							$pointer_content  = '<h3>' .__('Filterable search', 'wpshop'). '</h3>';
154
-							$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/>';
155
-							$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>';
153
+							$pointer_content  = '<h3>' . __('Filterable search', 'wpshop') . '</h3>';
154
+							$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/>';
155
+							$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>';
156 156
 							break;
157 157
 
158 158
 						case 'category_picture' :
159
-							$pointer_content  = '<h3>' .__('Category image', 'wpshop'). '</h3>';
160
-							$pointer_content .= '<p>' .__( 'You can add a picture to illustrate your category', 'wpshop' ). '</p>';
159
+							$pointer_content  = '<h3>' . __('Category image', 'wpshop') . '</h3>';
160
+							$pointer_content .= '<p>' . __('You can add a picture to illustrate your category', 'wpshop') . '</p>';
161 161
 							break;
162 162
 
163 163
 						case 'order_customer_comment' :
164
-							$pointer_content  = '<h3>' .__('Order customer comment', 'wpshop'). '</h3>';
165
-							$pointer_content .= '<p>' .__( 'Here is displayed the customer comment wrote during the order', 'wpshop' ). '</p>';
164
+							$pointer_content  = '<h3>' . __('Order customer comment', 'wpshop') . '</h3>';
165
+							$pointer_content .= '<p>' . __('Here is displayed the customer comment wrote during the order', 'wpshop') . '</p>';
166 166
 							break;
167 167
 
168 168
 						case 'message_historic' :
169
-							$pointer_content  = '<h3>' .__('Message Historic', 'wpshop'). '</h3>';
170
-							$pointer_content .= '<p>' .__( 'This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop' ). '</p>';
169
+							$pointer_content  = '<h3>' . __('Message Historic', 'wpshop') . '</h3>';
170
+							$pointer_content .= '<p>' . __('This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop') . '</p>';
171 171
 							break;
172 172
 
173 173
 						case 'order_notification_message' :
174
-							$pointer_content  = '<h3>' .__('Order notification', 'wpshop'). '</h3>';
175
-							$pointer_content .= '<p>' .__( 'You can add a private comment to the order or send an comment to customer about this order', 'wpshop' ). '</p>';
174
+							$pointer_content  = '<h3>' . __('Order notification', 'wpshop') . '</h3>';
175
+							$pointer_content .= '<p>' . __('You can add a private comment to the order or send an comment to customer about this order', 'wpshop') . '</p>';
176 176
 							break;
177 177
 
178 178
 						case 'order_shipping_box' :
179
-							$pointer_content  = '<h3>' .__('Shipping actions', 'wpshop'). '</h3>';
180
-							$pointer_content .= '<p>' .__( 'Here, you can manage your shipping actions, download the shipping slip.', 'wpshop' ). '</p>';
179
+							$pointer_content  = '<h3>' . __('Shipping actions', 'wpshop') . '</h3>';
180
+							$pointer_content .= '<p>' . __('Here, you can manage your shipping actions, download the shipping slip.', 'wpshop') . '</p>';
181 181
 							break;
182 182
 
183 183
 						case 'options_payment_part' :
184
-							$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>';
184
+							$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>';
185 185
 							break;
186 186
 
187 187
 						default :
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 							break;
190 190
 					}
191 191
 
192
-					require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container_bubble' ) );
192
+					require(wpshop_tools::get_template_part(WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container_bubble'));
193 193
 				}
194 194
 			}
195 195
 		}
Please login to merge, or discard this patch.
includes/modules/wps_help/controller/wps_help_ctr.php 1 patch
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_NEWTYPE_IDENTIFIER_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.