Completed
Pull Request — master (#2)
by Jimmy
1003:35 queued 970:52
created
includes/librairies/options/options_email.class.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 */
29 29
 	public static function declare_options() {
30
-		add_settings_section('wpshop_emails', '<span class="dashicons dashicons-email"></span>'.__('Email addresses', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_emails');
30
+		add_settings_section('wpshop_emails', '<span class="dashicons dashicons-email"></span>' . __('Email addresses', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_emails');
31 31
 			register_setting('wpshop_options', 'wpshop_emails', array('wpshop_email_options', 'wpshop_options_validate_emails'));
32 32
 			add_settings_field('wpshop_noreply_email', __('Mails answers address email', 'wpshop'), array('wpshop_email_options', 'wpshop_noreply_email_field'), 'wpshop_emails', 'wpshop_emails');
33 33
 			add_settings_field('wpshop_contact_email', __('Contact email', 'wpshop'), array('wpshop_email_options', 'wpshop_contact_email_field'), 'wpshop_emails', 'wpshop_emails');
34 34
 			add_settings_field('wpshop_send_confirmation_order_email', '', array('wpshop_email_options', 'wpshop_send_confirmation_order_message_field'), 'wpshop_emails', 'wpshop_emails');
35 35
 
36 36
 		/** Define the settings section for message	*/
37
-		add_settings_section('wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>'.__('Messages', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_messages' );
37
+		add_settings_section('wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>' . __('Messages', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_messages');
38 38
 
39 39
 		/**	Get default messages defined into xml files 	*/
40
-		$xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' );
41
-		$default_emails = new SimpleXMLElement( $xml_default_emails );
40
+		$xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml');
41
+		$default_emails = new SimpleXMLElement($xml_default_emails);
42 42
 		/**	Read default emails for options creation	*/
43
-		foreach ( $default_emails->xpath( '//emails/email' ) as $email ) {
44
-			if ( ( WPSHOP_DEFINED_SHOP_TYPE == (string)$email->attributes()->shop_type ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) {
45
-				register_setting( 'wpshop_options', (string)$email->attributes()->code, array( 'wpshop_email_options', 'wps_options_validate_emails' ) );
46
-				add_settings_field( (string)$email->attributes()->code, __( (string)$email->description, 'wpshop' ), array( 'wpshop_email_options', 'wps_options_emails_field' ), 'wpshop_messages', 'wpshop_messages', array( 'code' => (string)$email->attributes()->code, ) );
43
+		foreach ($default_emails->xpath('//emails/email') as $email) {
44
+			if ((WPSHOP_DEFINED_SHOP_TYPE == (string)$email->attributes()->shop_type) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) {
45
+				register_setting('wpshop_options', (string)$email->attributes()->code, array('wpshop_email_options', 'wps_options_validate_emails'));
46
+				add_settings_field((string)$email->attributes()->code, __((string)$email->description, 'wpshop'), array('wpshop_email_options', 'wps_options_emails_field'), 'wpshop_messages', 'wpshop_messages', array('code' => (string)$email->attributes()->code,));
47 47
 			}
48 48
 		}
49 49
 	}
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 		$admin_email = get_bloginfo('admin_email');
63 63
 		$emails = get_option('wpshop_emails', null);
64 64
 		$email = empty($emails['noreply_email']) ? $admin_email : $emails['noreply_email'];
65
-		echo '<input name="wpshop_emails[noreply_email]" type="text" value="'.$email.'" />
66
-		<a href="#" title="'.__('This is the no reply email','wpshop').'" class="wpshop_infobulle_marker">?</a>';
65
+		echo '<input name="wpshop_emails[noreply_email]" type="text" value="' . $email . '" />
66
+		<a href="#" title="'.__('This is the no reply email', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
67 67
 	}
68 68
 	public static function wpshop_contact_email_field() {
69 69
 		$admin_email = get_bloginfo('admin_email');
70 70
 		$emails = get_option('wpshop_emails', null);
71 71
 		$email = empty($emails['contact_email']) ? $admin_email : $emails['contact_email'];
72
-		echo '<input name="wpshop_emails[contact_email]" type="text" value="'.$email.'" />
73
-		<a href="#" title="'.__('This is the email on which customers can contact you','wpshop').'" class="wpshop_infobulle_marker">?</a>';
72
+		echo '<input name="wpshop_emails[contact_email]" type="text" value="' . $email . '" />
73
+		<a href="#" title="'.__('This is the email on which customers can contact you', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
74 74
 	}
75
-	public static function wpshop_options_validate_emails($input) {return $input;}
75
+	public static function wpshop_options_validate_emails($input) {return $input; }
76 76
 
77 77
 	public static function wpshop_send_confirmation_order_message_field() {
78
-		$email_option = get_option( 'wpshop_emails' );
79
-		$output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ( ( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ) ? 'checked="checked"' : '') . '/> ';
80
-		$output .= '<label for="wpshop_emails_send_confirmation_order_message">'.__('Send confirmation order message when order is totally paid', 'wpshop').'</label>';
78
+		$email_option = get_option('wpshop_emails');
79
+		$output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ((!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) ? 'checked="checked"' : '') . '/> ';
80
+		$output .= '<label for="wpshop_emails_send_confirmation_order_message">' . __('Send confirmation order message when order is totally paid', 'wpshop') . '</label>';
81 81
 		echo $output;
82 82
 	}
83 83
 
84
-	function wpshop_send_confirmation_order_message_validate( $input ) {
84
+	function wpshop_send_confirmation_order_message_validate($input) {
85 85
 		return $input;
86 86
 	}
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param unknown_type $input
94 94
 	 * @return unknown
95 95
 	 */
96
-	public static function wps_options_validate_emails( $input ) {
96
+	public static function wps_options_validate_emails($input) {
97 97
 		return $input;
98 98
 	}
99 99
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @param unknown_type $args
103 103
 	 */
104
-	public static function wps_options_emails_field( $args ) {
104
+	public static function wps_options_emails_field($args) {
105 105
 		$content = '';
106 106
 
107
-		$current_message_id = get_option( $args['code'], '' );
107
+		$current_message_id = get_option($args['code'], '');
108 108
 		$wps_message = new wps_message_ctr();
109
-		$options = $wps_message->getMessageListOption( $current_message_id );
109
+		$options = $wps_message->getMessageListOption($current_message_id);
110 110
 
111
-		if ( !empty( $options ) ) {
111
+		if (!empty($options)) {
112 112
 			$content .= '<select name="' . $args['code'] . '" class="chosen_select" >';
113 113
 			$content .= $options;
114
-			$content .= '</select> <a id="wps-email-' . $current_message_id . '" title="' . __( 'Edit current selected message', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_message_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>';
114
+			$content .= '</select> <a id="wps-email-' . $current_message_id . '" title="' . __('Edit current selected message', 'wpshop') . '" href="' . admin_url('post.php?post=' . $current_message_id . '&action=edit') . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>';
115 115
 		}
116 116
 
117 117
 		echo $content;
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
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/options/options_general.class.php 3 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -140,8 +142,7 @@  discard block
 block discarded – undo
140 142
 				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
141 143
 				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
142 144
 				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
143
-			}
144
-			elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) {
145
+			} elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) {
145 146
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id']));
146 147
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id']));
147 148
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 class wpshop_advanced_settings{
24 24
 
25 25
 	/**
26
-	*
27
-	*/
26
+	 *
27
+	 */
28 28
 	function declare_options(){
29 29
 		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
30 30
 			register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options'));
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	*
27 27
 	*/
28
-	public static function declare_options(){
29
-		$page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
28
+	public static function declare_options() {
29
+		$page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
30 30
 
31
-		if ( isset($page) && ( substr($page, 0, 13 ) == 'wpshop_option' || $page == 'wps-installer' ) ) {
31
+		if (isset($page) && (substr($page, 0, 13) == 'wpshop_option' || $page == 'wps-installer')) {
32 32
 			wp_enqueue_media();
33 33
 		}
34
-		add_settings_section('wpshop_general_config','<span class="dashicons dashicons-info"></span>'. __('Shop main configuration', 'wpshop'), array('wpshop_general_options', 'plugin_section_text'), 'wpshop_general_config');
34
+		add_settings_section('wpshop_general_config', '<span class="dashicons dashicons-info"></span>' . __('Shop main configuration', 'wpshop'), array('wpshop_general_options', 'plugin_section_text'), 'wpshop_general_config');
35 35
 
36 36
 		register_setting('wpshop_options', 'wpshop_shop_type', array('wpshop_general_options', 'wpshop_options_validate_wpshop_shop_type'));
37 37
 			add_settings_field('wpshop_shop_type', __('Shop type', 'wpshop'), array('wpshop_general_options', 'wpshop_shop_type'), 'wpshop_general_config', 'wpshop_general_config');
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
 	/*	Default currecy for the entire shop	*/
62 62
 	public static function wpshop_shop_default_currency_field() {
63
-		echo wpshop_attributes_unit::wpshop_shop_currency_list_field() . '<a href="#" title="'.__('This is the currency the shop will use','wpshop').'" class="wpshop_infobulle_marker">?</a>';
63
+		echo wpshop_attributes_unit::wpshop_shop_currency_list_field() . '<a href="#" title="' . __('This is the currency the shop will use', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
64 64
 	}
65 65
 
66 66
 	public static function wpshop_default_weight_unity_field() {
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 		$current_weight = get_option('wpshop_shop_default_weight_unity');
71 71
 
72 72
 		$weight_options = '';
73
-		if ( !empty ($weight_group) ) {
74
-			$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE group_id = %d', $weight_group);
73
+		if (!empty ($weight_group)) {
74
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id = %d', $weight_group);
75 75
 			$weight_units = $wpdb->get_results($query);
76
-			foreach ( $weight_units as $weight_unit) {
77
-				$weight_options .= '<option value="'.$weight_unit->id.'"'.( ($weight_unit->id == $current_weight) ? ' selected="selected"' : null).'>'.$weight_unit->name.' ('.$weight_unit->unit.')</option>';
76
+			foreach ($weight_units as $weight_unit) {
77
+				$weight_options .= '<option value="' . $weight_unit->id . '"' . (($weight_unit->id == $current_weight) ? ' selected="selected"' : null) . '>' . $weight_unit->name . ' (' . $weight_unit->unit . ')</option>';
78 78
 			}
79 79
 		}
80 80
 
81
-		echo '<select name="wpshop_shop_default_weight_unity">'.$weight_options.'</select>
82
-		<a href="#" title="'.__('This is the weight unity the shop will use','wpshop').'" class="wpshop_infobulle_marker">?</a>';
81
+		echo '<select name="wpshop_shop_default_weight_unity">' . $weight_options . '</select>
82
+		<a href="#" title="'.__('This is the weight unity the shop will use', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
83 83
 	}
84 84
 
85 85
 	public static function wpshop_options_validate_default_currency($input) {
@@ -94,30 +94,30 @@  discard block
 block discarded – undo
94 94
 		$current_piloting = get_option('wpshop_shop_price_piloting', WPSHOP_PRODUCT_PRICE_PILOT);
95 95
 
96 96
 		$piloting_options = '';
97
-		foreach($wpshop_price_piloting_types as $price_type) {
98
-			$piloting_options .= '<option value="'.$price_type.'"'.(($price_type==$current_piloting) ? ' selected="selected"' : null).'>'.$price_type.'</option>';
97
+		foreach ($wpshop_price_piloting_types as $price_type) {
98
+			$piloting_options .= '<option value="' . $price_type . '"' . (($price_type == $current_piloting) ? ' selected="selected"' : null) . '>' . $price_type . '</option>';
99 99
 		}
100
-		echo '<select name="wpshop_shop_price_piloting">'.$piloting_options.'</select>
101
-		<a href="#" title=\''. __('You can choose if the price you will enter in each product is the "all tax include" price or the "tax free price"','wpshop') .'\' class="wpshop_infobulle_marker">?</a>';
100
+		echo '<select name="wpshop_shop_price_piloting">' . $piloting_options . '</select>
101
+		<a href="#" title=\''. __('You can choose if the price you will enter in each product is the "all tax include" price or the "tax free price"', 'wpshop') . '\' class="wpshop_infobulle_marker">?</a>';
102 102
 	}
103 103
 
104 104
 
105 105
 	public static function wpshop_ga_account_id_field() {
106 106
 		$ga_account_id = get_option('wpshop_ga_account_id');
107
-		echo '<input type="text" name="wpshop_ga_account_id" value="'.$ga_account_id.'" />';
107
+		echo '<input type="text" name="wpshop_ga_account_id" value="' . $ga_account_id . '" />';
108 108
 	}
109 109
 
110
-	public static function wpshop_options_validate_ga_account_id ($input) {
110
+	public static function wpshop_options_validate_ga_account_id($input) {
111 111
 		return $input;
112 112
 	}
113 113
 
114
-	public static function wpshop_options_validate_default_weight_unity ($input) {
114
+	public static function wpshop_options_validate_default_weight_unity($input) {
115 115
 		return $input;
116 116
 	}
117 117
 	public static function wpshop_options_validate_price_piloting($input) {
118 118
 		global $wpdb;
119 119
 
120
-		$price_pilot_attribute_code = constant('WPSHOP_PRODUCT_PRICE_'.$input);
120
+		$price_pilot_attribute_code = constant('WPSHOP_PRODUCT_PRICE_' . $input);
121 121
 
122 122
 		$query = $wpdb->prepare(
123 123
 "SELECT ATTRIBUTE.code, ATTR_SET_SECTION_DETAILS.id, ATTR_SET_SECTION_DETAILS.attribute_group_id, ATTR_SET_SECTION_DETAILS.position
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$new_def = array();
136 136
 		foreach ($attributes_order as $attribute_group_id => $attribute_price_def) :
137
-			if ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_TTC) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) ) {
137
+			if (($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_TTC) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) {
138 138
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id']));
139 139
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id']));
140 140
 
141 141
 				/** Update entries for quick add and variations */
142
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
143
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
144
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
142
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
143
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
144
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
145 145
 			}
146
-			elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) {
146
+			elseif (($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) {
147 147
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id']));
148 148
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id']));
149 149
 
150 150
 				/** Update entries for quick add and variations */
151
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
152
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
153
-				$wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
151
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
152
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
153
+				$wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
154 154
 			}
155 155
 		endforeach;
156 156
 
@@ -161,37 +161,37 @@  discard block
 block discarded – undo
161 161
 	public static function wpshop_shop_type() {
162 162
 		$shop_types = unserialize(WPSHOP_SHOP_TYPES);
163 163
 		$shop_types_options = '';
164
-		foreach($shop_types as $type) {
165
-			$shop_types_options .= '<option value="'.$type.'"'.(($type==WPSHOP_DEFINED_SHOP_TYPE) ? ' selected="selected"' : null).'>'.__($type, 'wpshop').'</option>';
164
+		foreach ($shop_types as $type) {
165
+			$shop_types_options .= '<option value="' . $type . '"' . (($type == WPSHOP_DEFINED_SHOP_TYPE) ? ' selected="selected"' : null) . '>' . __($type, 'wpshop') . '</option>';
166 166
 		}
167
-		echo '<select name="wpshop_shop_type">'.$shop_types_options.'</select><input type="hidden" name="old_wpshop_shop_type" value="'.WPSHOP_DEFINED_SHOP_TYPE.'" />
168
-		<a href="#" title="'.__('Define if you have a shop to sale item or just for item showing','wpshop').'" class="wpshop_infobulle_marker">?</a>';
167
+		echo '<select name="wpshop_shop_type">' . $shop_types_options . '</select><input type="hidden" name="old_wpshop_shop_type" value="' . WPSHOP_DEFINED_SHOP_TYPE . '" />
168
+		<a href="#" title="'.__('Define if you have a shop to sale item or just for item showing', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
169 169
 	}
170 170
 
171
-	public static function wpshop_logo_field () {
171
+	public static function wpshop_logo_field() {
172 172
 		$logo_option = get_option('wpshop_logo');
173 173
 
174
-		$output  = '<a href="#" id="wps-add-logo-picture" class="wps-bton-first-mini-rounded">' .__( 'Upload your logo', 'wpshop' ). '</a><br/>';
175
-		$output .= '<img id="wpshop_logo_thumbnail" src="' .( ( !empty($logo_option) ) ? $logo_option : WPSHOP_DEFAULT_CATEGORY_PICTURE ). '" alt="Logo" style="height : 40px; width : auto; border : 5px solid #E8E8E8; margin-top : 8px;" />';
176
-		$output .= '<input type="hidden" name="wpshop_logo" id="wpshop_logo_field" value="' .$logo_option. '" />';
177
-		$output .= '<br/><a href="#" id="wps-delete-shop-logo" '.( empty($logo_option) ? 'class="wpshopHide"' : '' ) .'>' . __( 'Delete this logo', 'wpshop' ) . '</a>';
174
+		$output  = '<a href="#" id="wps-add-logo-picture" class="wps-bton-first-mini-rounded">' . __('Upload your logo', 'wpshop') . '</a><br/>';
175
+		$output .= '<img id="wpshop_logo_thumbnail" src="' . ((!empty($logo_option)) ? $logo_option : WPSHOP_DEFAULT_CATEGORY_PICTURE) . '" alt="Logo" style="height : 40px; width : auto; border : 5px solid #E8E8E8; margin-top : 8px;" />';
176
+		$output .= '<input type="hidden" name="wpshop_logo" id="wpshop_logo_field" value="' . $logo_option . '" />';
177
+		$output .= '<br/><a href="#" id="wps-delete-shop-logo" ' . (empty($logo_option) ? 'class="wpshopHide"' : '') . '>' . __('Delete this logo', 'wpshop') . '</a>';
178 178
 
179 179
 		echo $output;
180 180
 	}
181 181
 
182
-	public static function wpshop_options_validate_logo ($input) {
182
+	public static function wpshop_options_validate_logo($input) {
183 183
 		return $input;
184 184
 	}
185 185
 
186 186
 	public static function wpshop_options_validate_wpshop_shop_type($input) {
187 187
 		global $current_db_version;
188 188
 
189
-		$current_installation_step = get_option( 'wps-installation-current-step', 1 );
190
-		if ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) ) {
189
+		$current_installation_step = get_option('wps-installation-current-step', 1);
190
+		if (WPSINSTALLER_STEPS_COUNT <= $current_installation_step || (!empty($current_db_version) && !empty($current_db_version['db_version']) && (51 < $current_db_version['db_version']))) {
191 191
 			$current_db_version['installation_state'] = 'completed';
192 192
 			update_option('wpshop_db_options', $current_db_version);
193
-			if ( $input == 'sale' ) {
194
-				wpshop_install::wpshop_insert_default_pages( $input );
193
+			if ($input == 'sale') {
194
+				wpshop_install::wpshop_insert_default_pages($input);
195 195
 			}
196 196
 		}
197 197
 		return $input;
Please login to merge, or discard this patch.
includes/librairies/options/options_advanced.class.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 class wpshop_advanced_settings{
24 24
 
25 25
 	/**
26
-	*
27
-	*/
26
+	 *
27
+	 */
28 28
 	function declare_options(){
29 29
 		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
30 30
 			register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options'));
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 * @package wpshop
21 21
 * @subpackage librairies
22 22
 */
23
-class wpshop_advanced_settings{
23
+class wpshop_advanced_settings {
24 24
 
25 25
 	/**
26 26
 	*
27 27
 	*/
28
-	function declare_options(){
29
-		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
28
+	function declare_options() {
29
+		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>' . __('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
30 30
 			register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options'));
31 31
 			add_settings_field('wpshop_advanced_settings_field', '', array('wpshop_advanced_settings', 'advanced_settings_field'), 'wpshop_extra_options', 'wpshop_extra_options');
32 32
 	}
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 		echo __('This options screen allows you to add functionnalities to the plugin by adding some parameters we defined', 'wpshop');
37 37
 	}
38 38
 
39
-	public static function validate_options($input){
39
+	public static function validate_options($input) {
40 40
 		$new_input = array();
41
-		if ( !empty($input['new']) && !empty($input['new']['key']) && !empty($input['new']['value']) ) {
41
+		if (!empty($input['new']) && !empty($input['new']['key']) && !empty($input['new']['value'])) {
42 42
 			$new_input[$input['new']['key']] = $input['new']['value'];
43 43
 		}
44
-		if ( !empty($input['existing']) ) {
45
-			foreach ( $input['existing'] as $extra_params_to_update ) {
46
-				if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) )
44
+		if (!empty($input['existing'])) {
45
+			foreach ($input['existing'] as $extra_params_to_update) {
46
+				if (!empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']))
47 47
 					$new_input[$extra_params_to_update['key']] = $extra_params_to_update['value'];
48 48
 			}
49 49
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		return $new_input;
52 52
 	}
53 53
 
54
-	public static function advanced_settings_field($input){
54
+	public static function advanced_settings_field($input) {
55 55
 		/*
56 56
 		WPSHOP_DEBUG_MODE_ALLOWED_IP
57 57
 		WPSHOP_DEBUG_MODE
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 	<ul>';
70 70
 		$wpshop_advanced_settings = get_option('wpshop_extra_options', array());
71 71
 
72
-		if ( !empty($wpshop_advanced_settings) ) {
73
-			$i=0;
72
+		if (!empty($wpshop_advanced_settings)) {
73
+			$i = 0;
74 74
 
75
-			foreach($wpshop_advanced_settings as $setting_name => $setting_value){
76
-				$advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>'.__('Extra parameter key', 'wpshop').'</p>' . wpshop_form::form_input('wpshop_extra_options[existing]['.$i.'][key]', 'wpshop_extra_options_new_key', $setting_name, 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>'.__('Extra parameter value', 'wpshop').'</p>' . wpshop_form::form_input('wpshop_extra_options[existing]['.$i.'][value]', 'wpshop_extra_options_new_value', $setting_value, 'text') . '</div><div class="wpshop_cls" ></div></li>';
75
+			foreach ($wpshop_advanced_settings as $setting_name => $setting_value) {
76
+				$advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][key]', 'wpshop_extra_options_new_key', $setting_name, 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][value]', 'wpshop_extra_options_new_value', $setting_value, 'text') . '</div><div class="wpshop_cls" ></div></li>';
77 77
 				$i++;
78 78
 			}
79 79
 		}
80 80
 
81
-		$advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>'.__('New extra parameter key', 'wpshop').'</p>' . wpshop_form::form_input('wpshop_extra_options[new][key]', 'wpshop_extra_options_new_key', '', 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>'.__('New extra parameter value', 'wpshop').'</p>' . wpshop_form::form_input('wpshop_extra_options[new][value]', 'wpshop_extra_options_new_value', '', 'text') . '</div><div class="wpshop_cls" ></div></li>
81
+		$advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][key]', 'wpshop_extra_options_new_key', '', 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][value]', 'wpshop_extra_options_new_value', '', 'text') . '</div><div class="wpshop_cls" ></div></li>
82 82
 	</ul>';
83 83
 
84 84
 		echo $advanced_settings_output;
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -43,8 +45,9 @@  discard block
 block discarded – undo
43 45
 		}
44 46
 		if ( !empty($input['existing']) ) {
45 47
 			foreach ( $input['existing'] as $extra_params_to_update ) {
46
-				if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) )
47
-					$new_input[$extra_params_to_update['key']] = $extra_params_to_update['value'];
48
+				if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) ) {
49
+									$new_input[$extra_params_to_update['key']] = $extra_params_to_update['value'];
50
+				}
48 51
 			}
49 52
 		}
50 53
 
Please login to merge, or discard this patch.
includes/librairies/options/options_pages.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 	 * Declare options
27 27
 	 */
28 28
 	public static function declare_options() {
29
-		add_settings_section('wpshop_pages_option', '<span class="dashicons dashicons-welcome-write-blog"></span>'.__('WPShop pages configuration', 'wpshop'), array('wpshop_page_options', 'plugin_section_text'), 'wpshop_pages_option');
29
+		add_settings_section('wpshop_pages_option', '<span class="dashicons dashicons-welcome-write-blog"></span>' . __('WPShop pages configuration', 'wpshop'), array('wpshop_page_options', 'plugin_section_text'), 'wpshop_pages_option');
30 30
 
31 31
 		/**	Get default messages defined into xml files 	*/
32
-		$default_pages =  new SimpleXMLElement( file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml' ) );
32
+		$default_pages = new SimpleXMLElement(file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml'));
33 33
 		/**	Read default emails for options creation	*/
34
-		foreach ( $default_pages->xpath( '//pages/page' ) as $page ) {
35
-			if ( ( WPSHOP_DEFINED_SHOP_TYPE == (string)$page->attributes()->shop_type ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) {
36
-				register_setting( 'wpshop_options', (string)$page->attributes()->code, array( 'wpshop_page_options', 'wpshop_options_validate_wpshop_shop_pages' ) );
37
-				add_settings_field( (string)$page->attributes()->code, __( (string)$page->description, 'wpshop' ), array( 'wpshop_page_options', 'wps_pages_field' ), 'wpshop_pages_option', 'wpshop_pages_option', array( 'code' => (string)$page->attributes()->code, ) );
34
+		foreach ($default_pages->xpath('//pages/page') as $page) {
35
+			if ((WPSHOP_DEFINED_SHOP_TYPE == (string)$page->attributes()->shop_type) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) {
36
+				register_setting('wpshop_options', (string)$page->attributes()->code, array('wpshop_page_options', 'wpshop_options_validate_wpshop_shop_pages'));
37
+				add_settings_field((string)$page->attributes()->code, __((string)$page->description, 'wpshop'), array('wpshop_page_options', 'wps_pages_field'), 'wpshop_pages_option', 'wpshop_pages_option', array('code' => (string)$page->attributes()->code,));
38 38
 			}
39 39
 		}
40 40
 	}
@@ -43,26 +43,26 @@  discard block
 block discarded – undo
43 43
 	 * Common section description
44 44
 	 */
45 45
 	public static function plugin_section_text() {
46
-		printf( __( 'We define default pages content and layout, however you have possibility to %sedit them%s', 'wpshop' ), '<a href="' . admin_url( 'edit.php?post_type=page' ) . '" target="_wps_content_customisation" >', '</a>');
46
+		printf(__('We define default pages content and layout, however you have possibility to %sedit them%s', 'wpshop'), '<a href="' . admin_url('edit.php?post_type=page') . '" target="_wps_content_customisation" >', '</a>');
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * Shop pages configurations
51 51
 	 */
52
-	public static function wps_pages_field( $args ) {
52
+	public static function wps_pages_field($args) {
53 53
 		$content = '';
54 54
 
55
-		$current_page_id = get_option( $args['code'], '' );
55
+		$current_page_id = get_option($args['code'], '');
56 56
 		$post_list = get_pages();
57 57
 		if (!empty($post_list)) {
58 58
 			$content .= '<select name="' . $args['code'] . '" class="chosen_select shop-content-customisation" ><option value="" >' . __('Choose a page to associate', 'wpshop') . '</option>';
59
-			$p=1;
59
+			$p = 1;
60 60
 			$error = false;
61 61
 			foreach ($post_list as $post) {
62 62
 				$selected = (!empty($current_page_id) && ($current_page_id == $post->ID)) ? ' selected="selected"' : '';
63
-				$content .= '<option'.$selected.' value="' . $post->ID . '" >' . $post->post_title . '</option>';
63
+				$content .= '<option' . $selected . ' value="' . $post->ID . '" >' . $post->post_title . '</option>';
64 64
 			}
65
-			$content .= '</select> <a id="wps-page-' . $current_page_id . '" title="' . __( 'Edit current selected page', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_page_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-page dashicons dashicons-edit"></a>';
65
+			$content .= '</select> <a id="wps-page-' . $current_page_id . '" title="' . __('Edit current selected page', 'wpshop') . '" href="' . admin_url('post.php?post=' . $current_page_id . '&action=edit') . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-page dashicons dashicons-edit"></a>';
66 66
 		}
67 67
 		wp_reset_query();
68 68
 
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
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/wpshop_ajax.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 
402 402
 	/**
403 403
 	 * Delete a variation
404
-	*/
404
+	 */
405 405
 	function ajax_delete_variation() {
406 406
 		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
407 407
 		$result = false;
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 
423 423
 	/**
424 424
 	 * Delete a variation defintion into head product
425
-	*/
425
+	 */
426 426
 	function ajax_wpshop_delete_head_product_variation_def() {
427 427
 		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
428 428
 
Please login to merge, or discard this patch.
Spacing   +796 added lines, -796 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
 * Ajax request management file
4 4
 *
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 */
10 10
 
11 11
 /*	Check if file is include. No direct access possible with file url	*/
12
-if ( !defined( 'WPSHOP_VERSION' ) ) {
13
-	die( __('Access is not allowed by this way', 'wpshop') );
12
+if (!defined('WPSHOP_VERSION')) {
13
+	die(__('Access is not allowed by this way', 'wpshop'));
14 14
 }
15 15
 
16 16
 /*	Products	*/
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * Duplicate a product
19 19
 	 */
20 20
 	function ajax_duplicate_product() {
21
-		check_ajax_referer( 'wpshop_product_duplication', 'wpshop_ajax_nonce' );
21
+		check_ajax_referer('wpshop_product_duplication', 'wpshop_ajax_nonce');
22 22
 
23 23
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
24 24
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 * Delete an attachmant from a product
34 34
 	 */
35 35
 	function ajax_delete_product_thumbnail() {
36
-		check_ajax_referer( 'wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce' );
36
+		check_ajax_referer('wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce');
37 37
 
38 38
 		$bool = false;
39 39
 		$attachement_id = isset($_POST['attachement_id']) ? intval(wpshop_tools::varSanitizer($_POST['attachement_id'])) : null;
40 40
 
41
-		if ( !empty($attachement_id) ) {
41
+		if (!empty($attachement_id)) {
42 42
 			$deletion_result = wp_delete_attachment($attachement_id, false);
43 43
 			$bool = !empty($deletion_result);
44 44
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * Reload attachment container
52 52
 	 */
53 53
 	function ajax_reload_attachment_boxes() {
54
-		check_ajax_referer( 'wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce' );
54
+		check_ajax_referer('wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce');
55 55
 
56 56
 		$bool = false;
57 57
 		$current_post_id = isset($_POST['current_post_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_post_id'])) : null;
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function ajax_product_bulk_edit_save() {
71 71
 		global $wpdb;
72
-		check_ajax_referer( 'product_bulk_edit_save', 'wpshop_ajax_nonce' );
72
+		check_ajax_referer('product_bulk_edit_save', 'wpshop_ajax_nonce');
73 73
 
74
-		$post_ids = ( isset( $_POST[ 'post_ids' ] ) && !empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
75
-		$post_attributes = ( isset( $_POST[ 'attribute' ] ) && !empty( $_POST[ 'attribute' ] ) ) ? $_POST[ 'attribute' ] : array();
74
+		$post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
75
+		$post_attributes = (isset($_POST['attribute']) && !empty($_POST['attribute'])) ? $_POST['attribute'] : array();
76 76
 
77
-		if ( !empty( $post_ids ) && is_array( $post_ids ) && !empty( $post_attributes ) && is_array( $post_attributes ) ) {
77
+		if (!empty($post_ids) && is_array($post_ids) && !empty($post_attributes) && is_array($post_attributes)) {
78 78
 			$attribute_to_save = array();
79
-			foreach ( $post_attributes as $attribute ) {
79
+			foreach ($post_attributes as $attribute) {
80 80
 				$attribute_component = explode('_-val-_', $attribute);
81 81
 				$attribute_definition = explode('[', $attribute_component[0]);
82 82
 				$attribute_data_type = substr($attribute_definition[1], 0, -1);
83 83
 				$attribute_code = substr($attribute_definition[2], 0, -1);
84 84
 
85
-				if ( !empty($attribute_component[1]) ) {
85
+				if (!empty($attribute_component[1])) {
86 86
 					$attribute_to_save[$attribute_data_type][$attribute_code] = $attribute_component[1];
87 87
 				}
88 88
 			}
89 89
 
90
-			foreach ( $post_ids as $post_id ) {
90
+			foreach ($post_ids as $post_id) {
91 91
 				$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = (SELECT language_code FROM " . $wpdb->prefix . "icl_translations WHERE element_id = %d )", $post_id);
92 92
 				$lang_wpml = $wpdb->get_var($query);
93 93
 				$lang = !empty($lang_wpml) ? $lang_wpml : WPSHOP_CURRENT_LOCALE;
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
 
100 100
 				/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
101 101
 				$productMetaDatas = get_post_meta($post_id, '_wpshop_product_metadata', true);
102
-				if ( !empty($productMetaDatas) ) {
102
+				if (!empty($productMetaDatas)) {
103 103
 					$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $post_id);
104
-					if ( !empty($attributes_list)) {
104
+					if (!empty($attributes_list)) {
105 105
 						foreach ($attributes_list as $attribute) {
106
-							$value_key = 'attribute_value_'.$attribute->data_type;
106
+							$value_key = 'attribute_value_' . $attribute->data_type;
107 107
 							$productMetaDatas[$attribute->code] = $attribute->$value_key;
108 108
 						}
109 109
 					}
110 110
 				}
111
-				foreach($attribute_to_save as $attributeType => $attributeValues){
112
-					foreach($attributeValues as $attributeCode => $attributeValue){
113
-						if ( $attributeCode == 'product_attribute_set_id' ) {
111
+				foreach ($attribute_to_save as $attributeType => $attributeValues) {
112
+					foreach ($attributeValues as $attributeCode => $attributeValue) {
113
+						if ($attributeCode == 'product_attribute_set_id') {
114 114
 							/*	Update the attribute set id for the current product	*/
115 115
 							update_post_meta($post_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue);
116 116
 						}
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 
123 123
 
124 124
 				/* If the product have some variations */
125
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
125
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
126 126
 				$product_variations = $wpdb->get_results($query);
127
-				if ( !empty($product_variations) ) {
128
-					foreach( $product_variations as $product_variation ) {
127
+				if (!empty($product_variations)) {
128
+					foreach ($product_variations as $product_variation) {
129 129
 						$variation_post_meta = get_post_meta($product_variation->ID, '_wpshop_product_metadata', true);
130 130
 						$common_attributes = unserialize(WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT);
131
-						if ( !empty($common_attributes) ) {
132
-							if ( !empty($parent_product_metadata) ) {
133
-								foreach( $parent_product_metadata as $key => $value ) {
134
-									if ( in_array($key, $common_attributes) ) {
131
+						if (!empty($common_attributes)) {
132
+							if (!empty($parent_product_metadata)) {
133
+								foreach ($parent_product_metadata as $key => $value) {
134
+									if (in_array($key, $common_attributes)) {
135 135
 										$variation_post_meta[$key] = $value;
136
-										update_post_meta($product_variation->ID, '_'.$key, $value);
136
+										update_post_meta($product_variation->ID, '_' . $key, $value);
137 137
 									}
138 138
 								}
139 139
 								update_post_meta($product_variation->ID, '_wpshop_product_metadata', $variation_post_meta);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 		die();
151 151
 	}
152
-	add_action( 'wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save' );
152
+	add_action('wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save');
153 153
 /*	Products	*/
154 154
 
155 155
 /*	Variations	*/
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * Variation list creation
158 158
 	 */
159 159
 	function ajax_add_new_variation_list() {
160
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
160
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
161 161
 		global $wpdb;
162 162
 
163 163
 		$attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? ($_POST['wpshop_attribute_to_use_for_variation']) : null;
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 		/** Get the list of values of the attribute to affect to a variation	*/
167 167
 		$var = array();
168 168
 
169
-		foreach ( $attributes_for_variation as $attribute_code ) {
169
+		foreach ($attributes_for_variation as $attribute_code) {
170 170
 			$query = $wpdb->prepare("SELECT data_type_to_use FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code);
171
-			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list( $attribute_code, $current_post_id, $wpdb->get_var($query));
171
+			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list($attribute_code, $current_post_id, $wpdb->get_var($query));
172 172
 		}
173 173
 
174
-		$possible_variations = wpshop_tools::search_all_possibilities( $var );
174
+		$possible_variations = wpshop_tools::search_all_possibilities($var);
175 175
 
176
-		wpshop_products::creation_variation_callback( $possible_variations, $current_post_id );
176
+		wpshop_products::creation_variation_callback($possible_variations, $current_post_id);
177 177
 
178
-		$output = wpshop_products::display_variation_admin( $current_post_id );
178
+		$output = wpshop_products::display_variation_admin($current_post_id);
179 179
 
180 180
 		echo $output;
181 181
 		die();
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * Variation uniq item creation
187 187
 	 */
188 188
 	function ajax_new_single_variation_definition() {
189
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
189
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
190 190
 		$output = '';
191 191
 
192 192
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
193 193
 
194 194
 		/*	Get the list of values of the attribute to affect to a variation	*/
195
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id, 'single' );
195
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id, 'single');
196 196
 		$output = $attribute_for_variation[0];
197 197
 
198 198
 		/**	Display specific element for variation	*/
199 199
 		$tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = '';
200 200
 		$tpl_component['VARIATION_IDENTIFIER'] = 'new';
201
-		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']','page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => '') );
201
+		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']', 'page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => ''));
202 202
 		$output .= wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $current_post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $tpl_component['VARIATION_IDENTIFIER']), 'admin');
203 203
 
204 204
 		$tpl_component = array();
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	 * Combined variation list creation
217 217
 	 */
218 218
 	function ajax_new_combined_variation_list_definition() {
219
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
219
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
220 220
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
221 221
 		$output = '';
222 222
 
223
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id );
223
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id);
224 224
 		$output = $attribute_for_variation[0];
225 225
 
226 226
 		echo $output;
@@ -232,43 +232,43 @@  discard block
 block discarded – undo
232 232
 	 * Product variaitons parameters
233 233
 	 */
234 234
 	function wpshop_ajax_admin_variation_parameters() {
235
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
235
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
236 236
 
237 237
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
238 238
 		$output = '';
239 239
 
240 240
 		/*	Display variation options	*/
241 241
 		$options_tpl_component = array();
242
-		$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
243
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single')) ) ? ' checked="checked"' : '';
244
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined')) ) ? ' checked="checked"' : '';
245
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition')) ) ? ' checked="checked"' : '';
246
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement')) ) ? ' checked="checked"' : '';
242
+		$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
243
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single'))) ? ' checked="checked"' : '';
244
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined'))) ? ' checked="checked"' : '';
245
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition'))) ? ' checked="checked"' : '';
246
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement'))) ? ' checked="checked"' : '';
247 247
 
248
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ( ( empty($head_wpshop_variation_definition['options']) ) || ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')) ) ) ? ' checked="checked"' : '';
249
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ( (empty($head_wpshop_variation_definition['options']) ) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')) ) ) ? ' checked="checked"' : '';
248
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')))) ? ' checked="checked"' : '';
249
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')))) ? ' checked="checked"' : '';
250 250
 
251 251
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_PRODUCT_ID'] = $current_post_id;
252 252
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_NOUNCE'] = wp_create_nonce("wpshop_variation_parameters");
253 253
 
254 254
 		$options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] = '';
255 255
 
256
-		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute( $current_post_id );
256
+		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute($current_post_id);
257 257
 
258 258
 		$default_value_for_attributes = $required_attributes = '';
259 259
 
260
-		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => get_post_type($current_post_id)) );
261
-		if ( !empty($attribute_user_defined) ) {
262
-			foreach ( $attribute_user_defined as $attribute_def ) {
260
+		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => get_post_type($current_post_id)));
261
+		if (!empty($attribute_user_defined)) {
262
+			foreach ($attribute_user_defined as $attribute_def) {
263 263
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
264 264
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
265 265
 
266 266
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_def->code;
267 267
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_def->code;
268
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_def->frontend_label, 'wpshop' );
268
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_def->frontend_label, 'wpshop');
269 269
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
270 270
 
271
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
271
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
272 272
 
273 273
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_def->code;
274 274
 
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 			}
277 277
 		}
278 278
 
279
-		if ( !empty($attribute_list_for_variations['available']) ) {
280
-			$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
281
-			foreach ( $attribute_list_for_variations['available'] as $attribute_code => $attribute_definition ) {
279
+		if (!empty($attribute_list_for_variations['available'])) {
280
+			$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
281
+			foreach ($attribute_list_for_variations['available'] as $attribute_code => $attribute_definition) {
282 282
 				/** Default value for attribute	*/
283 283
 				$tpl_component = array();
284 284
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ' variation_attribute_container_default_value_' . $attribute_code;
285 285
 
286 286
 				$attribute_for_default_value = wpshop_attributes::get_attribute_field_definition($attribute_definition['attribute_complete_def'], (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : 'none'), array('from' => 'frontend', 'field_custom_name_prefix' => 'empty'));
287
-				switch ( $attribute_for_default_value['type'] ) {
287
+				switch ($attribute_for_default_value['type']) {
288 288
 					case 'select':
289 289
 					case 'multiple-select':
290 290
 					case 'radio':
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
 						break;
297 297
 				}
298 298
 
299
-				if ( !empty($attribute_for_default_value['possible_value']) ) {
299
+				if (!empty($attribute_for_default_value['possible_value'])) {
300 300
 					$attribute_for_default_value['possible_value']['none'] = __('No default value', 'wpshop');
301
-					foreach( $attribute_for_default_value['possible_value'] as $value_id => $value ){
302
-						if ( !empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values']) ) {
301
+					foreach ($attribute_for_default_value['possible_value'] as $value_id => $value) {
302
+						if (!empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values'])) {
303 303
 							unset($attribute_for_default_value['possible_value'][$value_id]);
304 304
 						}
305 305
 					}
306 306
 					ksort($attribute_for_default_value['possible_value']);
307 307
 
308 308
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = $attribute_for_default_value['id'];
309
-					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf( __('Default value for %s', 'wpshop'), $attribute_for_default_value['label'] );
309
+					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf(__('Default value for %s', 'wpshop'), $attribute_for_default_value['label']);
310 310
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_INPUT'] = wpshop_form::check_input_type($attribute_for_default_value, 'wps_pdt_variations[options][attributes_default_value]');
311 311
 					$default_value_for_attributes .= wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item_for_default', $tpl_component, array(), 'admin');
312 312
 				}
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 
318 318
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_code;
319 319
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code;
320
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_definition['label'], 'wpshop' );
320
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_definition['label'], 'wpshop');
321 321
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
322 322
 
323
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
323
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
324 324
 
325 325
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_code;
326 326
 				$required_attributes .= str_replace('wpshop_attribute_to_use_for_variation', 'wps_pdt_variations[options][required_attributes]', str_replace('variation_attribute_usable', 'variation_attribute_required', wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item', $tpl_component, array(), 'admin')));
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	 * Save product variation paramters
344 344
 	 */
345 345
 	function wpshop_ajax_admin_variation_parameters_save() {
346
-		check_ajax_referer( 'wpshop_variation_parameters', 'wpshop_ajax_nonce' );
346
+		check_ajax_referer('wpshop_variation_parameters', 'wpshop_ajax_nonce');
347 347
 
348 348
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
349 349
 
350
-		if ( !empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options']) ) {
350
+		if (!empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'])) {
351 351
 			$variation_post_meta = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
352 352
 			$variation_post_meta['options'] = $_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'];
353
-			unset( $variation_post_meta['follow_general_config'] );
353
+			unset($variation_post_meta['follow_general_config']);
354 354
 			update_post_meta($current_post_id, '_wpshop_variation_defining', $variation_post_meta);
355 355
 		}
356 356
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * Variation uniq item creation
363 363
 	 */
364 364
 	function ajax_add_new_single_variation() {
365
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
365
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
366 366
 		$output = '';
367 367
 
368 368
 		$attributes_for_variation = isset($_POST['variation_attr']) ? ($_POST['variation_attr']) : null;
@@ -371,28 +371,28 @@  discard block
 block discarded – undo
371 371
 		$current_post_id = isset($_POST['wpshop_head_product_id']) ? wpshop_tools::varSanitizer($_POST['wpshop_head_product_id']) : null;
372 372
 
373 373
 		$attribute_to_use_for_creation = array();
374
-		foreach ( $attributes_for_variation as $attribute_code => $attribute_value) {
375
-			if ( array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox) ) {
374
+		foreach ($attributes_for_variation as $attribute_code => $attribute_value) {
375
+			if (array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox)) {
376 376
 				$attribute_to_use_for_creation[0][$attribute_code] = $attributes_for_variation[$attribute_code];
377 377
 				$attr_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
378 378
 				$variation_specific_definition[$attr_def->data_type][$attribute_code] = $attributes_for_variation[$attribute_code];
379 379
 			}
380 380
 		}
381
-		$new_variation_identifier = wpshop_products::creation_variation_callback( $attribute_to_use_for_creation, $current_post_id );
381
+		$new_variation_identifier = wpshop_products::creation_variation_callback($attribute_to_use_for_creation, $current_post_id);
382 382
 
383 383
 		/*	Save variation specific element	*/
384
-		foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
384
+		foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
385 385
 			$head_product_price_attribute_value = wpshop_attributes::get_attribute_value_content($price_attribute_code, $current_post_id, wpshop_products::currentPageCode);
386 386
 			$price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code');
387
-			if ( !empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
387
+			if (!empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
388 388
 				$variation_specific_definition[$price_attr_def->data_type][$price_attribute_code] = !empty($head_product_price_attribute_value->value) ? $head_product_price_attribute_value->value : 1;
389 389
 			}
390 390
 		}
391 391
 
392 392
 		wpshop_attributes::saveAttributeForEntity($variation_specific_definition, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $new_variation_identifier, WPSHOP_CURRENT_LOCALE);
393
-		wpshop_products::calculate_price( $new_variation_identifier );
393
+		wpshop_products::calculate_price($new_variation_identifier);
394 394
 
395
-		$output = wpshop_products::display_variation_admin( $current_post_id );
395
+		$output = wpshop_products::display_variation_admin($current_post_id);
396 396
 
397 397
 		echo $output;
398 398
 		die();
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
 	 * Delete a variation
404 404
 	*/
405 405
 	function ajax_delete_variation() {
406
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
406
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
407 407
 		$result = false;
408 408
 		$list_to_remove = '';
409 409
 
410 410
 		$current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? $_POST['current_post_id'] : null;
411
-		foreach ( $current_post_id as $variation_id) {
411
+		foreach ($current_post_id as $variation_id) {
412 412
 			$result = wp_delete_post($variation_id, false);
413
-			if ( $result ) {
413
+			if ($result) {
414 414
 				$list_to_remove[] = $variation_id;
415 415
 			}
416 416
 		}
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 * Delete a variation defintion into head product
425 425
 	*/
426 426
 	function ajax_wpshop_delete_head_product_variation_def() {
427
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
427
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
428 428
 
429 429
 		$current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null;
430 430
 		$current_variation_def = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 /*	Orders	*/
439 439
 	/* Validate the payment transaction number */
440 440
 	function wpshop_ajax_validate_payment_method() {
441
-		check_ajax_referer( 'wpshop_validate_payment_method', 'wpshop_ajax_nonce' );
442
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null;
443
-		$payment_method = ( isset( $_POST[ 'payment_method' ] ) && !empty( $_POST[ 'payment_method' ] ) ) ? $_POST[ 'payment_method' ] : null;
444
-		$transaction_id = ( isset( $_POST[ 'transaction_id' ] ) && !empty( $_POST[ 'transaction_id' ] ) ) ? $_POST[ 'transaction_id' ] : null;
441
+		check_ajax_referer('wpshop_validate_payment_method', 'wpshop_ajax_nonce');
442
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null;
443
+		$payment_method = (isset($_POST['payment_method']) && !empty($_POST['payment_method'])) ? $_POST['payment_method'] : null;
444
+		$transaction_id = (isset($_POST['transaction_id']) && !empty($_POST['transaction_id'])) ? $_POST['transaction_id'] : null;
445 445
 
446
-		if ( !empty($order_id) ) {
447
-			if( !empty($payment_method) && !empty($transaction_id) ) {
446
+		if (!empty($order_id)) {
447
+			if (!empty($payment_method) && !empty($transaction_id)) {
448 448
 				/* Update he payment method */
449 449
 				$order = get_post_meta($order_id, '_order_postmeta', true);
450 450
 				$order['payment_method'] = $payment_method;
451 451
 				update_post_meta($order_id, '_order_postmeta', $order);
452 452
 
453 453
 				// Update Transaction identifier regarding the payment method
454
-				if ( !empty($transaction_id) ) {
454
+				if (!empty($transaction_id)) {
455 455
 // 					$transaction_key = '';
456 456
 // 					switch($payment_method) {
457 457
 // 						case 'check':
@@ -461,28 +461,28 @@  discard block
 block discarded – undo
461 461
 // 					if ( !empty($transaction_key) ) update_post_meta($order_id, $transaction_key, $transaction_id);
462 462
 					wpshop_payment::set_payment_transaction_number($order_id, $transaction_id);
463 463
 				}
464
-				$result = json_encode(array(true,''));
464
+				$result = json_encode(array(true, ''));
465 465
 			}
466 466
 			else {
467
-				$result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop')));
467
+				$result = json_encode(array(false, __('Choose a payment method and/or type a transaction number', 'wpshop')));
468 468
 			}
469 469
 		}
470 470
 		else {
471
-			$result = json_encode(array(false,__('Bad order identifier', 'wpshop')));
471
+			$result = json_encode(array(false, __('Bad order identifier', 'wpshop')));
472 472
 		}
473 473
 		echo json_encode($result);
474 474
 		die();
475 475
 	}
476
-	add_action( 'wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method' );
476
+	add_action('wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method');
477 477
 
478 478
 
479 479
 	/* Display a dialog box to inform a shipping tracking number */
480 480
 	function wpshop_ajax_dialog_inform_shipping_number() {
481
-		check_ajax_referer( 'wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce' );
482
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null;
481
+		check_ajax_referer('wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce');
482
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null;
483 483
 
484
-		if ( !empty($order_id) ) {
485
-			$result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />'));
484
+		if (!empty($order_id)) {
485
+			$result = (array(true, '<h1>' . __('Tracking number', 'wpshop') . '</h1><p>' . __('Enter a tracking number, or leave blank:', 'wpshop') . '</p><input type="hidden" value="' . $order_id . '" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>' . __('Enter a tracking link, or leave blank: (http included)', 'wpshop') . '</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="' . __('Send', 'wpshop') . '" /> <input type="button" class="button-secondary closeAlert" value="' . __('Cancel', 'wpshop') . '" />'));
486 486
 
487 487
 		}
488 488
 		else {
@@ -491,23 +491,23 @@  discard block
 block discarded – undo
491 491
 		echo json_encode($result);
492 492
 		die();
493 493
 	}
494
-	add_action( 'wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number' );
494
+	add_action('wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number');
495 495
 
496 496
 	function wpshop_ajax_change_order_state() {
497 497
 		global $order_status;
498
-		check_ajax_referer( 'wpshop_change_order_state', 'wpshop_ajax_nonce' );
498
+		check_ajax_referer('wpshop_change_order_state', 'wpshop_ajax_nonce');
499 499
 
500
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null;
501
-		$order_state = ( isset( $_POST[ 'order_state' ] ) && !empty( $_POST[ 'order_state' ] ) ) ? $_POST[ 'order_state' ] : null;
502
-		$order_shipped_number = ( isset( $_POST[ 'order_shipped_number' ] ) && !empty( $_POST[ 'order_shipped_number' ] ) ) ? $_POST[ 'order_shipped_number' ] : null;
503
-		$order_shipped_link = ( isset( $_POST[ 'order_shipped_link' ] ) && !empty( $_POST[ 'order_shipped_link' ] ) ) ? $_POST[ 'order_shipped_link' ] : null;
500
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null;
501
+		$order_state = (isset($_POST['order_state']) && !empty($_POST['order_state'])) ? $_POST['order_state'] : null;
502
+		$order_shipped_number = (isset($_POST['order_shipped_number']) && !empty($_POST['order_shipped_number'])) ? $_POST['order_shipped_number'] : null;
503
+		$order_shipped_link = (isset($_POST['order_shipped_link']) && !empty($_POST['order_shipped_link'])) ? $_POST['order_shipped_link'] : null;
504 504
 
505
-		if ( !empty($order_id) ) {
505
+		if (!empty($order_id)) {
506 506
 			/* Update the oder state */
507 507
 			$order = get_post_meta($order_id, '_order_postmeta', true);
508 508
 			$order['order_status'] = $order_state;
509 509
 
510
-			if ( $order_state == 'shipped' ) {
510
+			if ($order_state == 'shipped') {
511 511
 				$order['order_shipping_date'] = current_time('mysql', 0);
512 512
 				$order['order_trackingNumber'] = $order_shipped_number;
513 513
 				$order['order_trackingLink'] = $order_shipped_link;
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 				$output_payment_box_class = 'wpshop_order_status_shipped';
519 519
 				$output_payment_box_content = __('Shipped', 'wpshop');
520 520
 
521
-				$output_shipping_box  = '<li><strong>'.__('Order shipping date','wpshop').' :</strong>'.$order['order_shipping_date'].'</li>';
522
-				$output_shipping_box .= '<li><strong>'.__('Tracking number','wpshop').' :</strong> '.$order['order_trackingNumber'].'</li>';
523
-				$output_shipping_box .= '<li><strong>'.__('Tracking link','wpshop').' :</strong> '.$order['order_trackingLink'].'</li>';
521
+				$output_shipping_box  = '<li><strong>' . __('Order shipping date', 'wpshop') . ' :</strong>' . $order['order_shipping_date'] . '</li>';
522
+				$output_shipping_box .= '<li><strong>' . __('Tracking number', 'wpshop') . ' :</strong> ' . $order['order_trackingNumber'] . '</li>';
523
+				$output_shipping_box .= '<li><strong>' . __('Tracking link', 'wpshop') . ' :</strong> ' . $order['order_trackingLink'] . '</li>';
524 524
 
525
-				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
525
+				$result = array(true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content);
526 526
 			}
527 527
 			else {
528 528
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
@@ -539,39 +539,39 @@  discard block
 block discarded – undo
539 539
 		echo json_encode($result);
540 540
 		die();
541 541
 	}
542
-	add_action( 'wp_ajax_change_order_state', 'wpshop_ajax_change_order_state' );
542
+	add_action('wp_ajax_change_order_state', 'wpshop_ajax_change_order_state');
543 543
 
544 544
 
545 545
 	/* Send a confirmation e-mail to the customer */
546
-	function wpshop_send_confirmation_shipping_email($order_id){
546
+	function wpshop_send_confirmation_shipping_email($order_id) {
547 547
 		$wps_message = new wps_message_ctr();
548
-		if ( !empty($order_id) ) {
548
+		if (!empty($order_id)) {
549 549
 			$order_info = get_post_meta($order_id, '_order_info', true);
550 550
 			$order = get_post_meta($order_id, '_order_postmeta', true);
551
-			$email = ( !empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
551
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
552 552
 			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
553
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
553
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
554 554
 
555
-			if( empty($email) && !empty($order['customer_id']) ) {
556
-				$user_data = get_userdata( $order['customer_id'] );
555
+			if (empty($email) && !empty($order['customer_id'])) {
556
+				$user_data = get_userdata($order['customer_id']);
557 557
 				$email = $user_data->user_email;
558 558
 			}
559 559
 
560
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
561
-			$shipping_method = ( !empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order['order_payment']['shipping_method'] : '' );
560
+			$shipping_mode_option = get_option('wps_shipping_mode');
561
+			$shipping_method = (!empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order['order_payment']['shipping_method'] : '');
562 562
 
563 563
 
564
-			$wps_message->wpshop_prepared_email (
564
+			$wps_message->wpshop_prepared_email(
565 565
 				$email,
566 566
 				'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE',
567 567
 				array(
568 568
 					'order_id' => $order_id,
569
-					'order_key' => ( !empty($order['order_key']) ? $order['order_key'] : '' ),
569
+					'order_key' => (!empty($order['order_key']) ? $order['order_key'] : ''),
570 570
 					'customer_first_name' => $first_name,
571 571
 					'customer_last_name' => $last_name,
572
-					'order_date' => ( !empty($order['order_date']) ? $order['order_date'] : '' ),
573
-					'order_trackingNumber' => ( !empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : '' ),
574
-					'order_trackingLink' => ( !empty($order['order_trackingLink']) ? $order['order_trackingLink'] : '' ),
572
+					'order_date' => (!empty($order['order_date']) ? $order['order_date'] : ''),
573
+					'order_trackingNumber' => (!empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : ''),
574
+					'order_trackingLink' => (!empty($order['order_trackingLink']) ? $order['order_trackingLink'] : ''),
575 575
 					'order_addresses' => '',
576 576
 					'order_billing_address' => '',
577 577
 					'order_shipping_address' => '',
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 * @return string The html output for the new value
591 591
 	 */
592 592
 	function ajax_new_option_for_select_callback() {
593
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
593
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
594 594
 		global $wpdb;
595 595
 
596
-		$option_id=$option_default_value=$option_value_id=$options_value='';
596
+		$option_id = $option_default_value = $option_value_id = $options_value = '';
597 597
 		$attribute_identifier = isset($_GET['attribute_identifier']) ? wpshop_tools::varSanitizer($_GET['attribute_identifier']) : '0';
598 598
 		$option_name = (!empty($_REQUEST['attribute_new_label']) ? $_REQUEST['attribute_new_label'] : '');
599 599
 		$options_value = sanitize_title($option_name);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		$existing_values = $wpdb->get_results($query);
604 604
 
605 605
 		/*	If given value does not exist: display result. If value exist alert a error message	*/
606
-		if( empty($existing_values) ) {
606
+		if (empty($existing_values)) {
607 607
 			$tpl_component = array();
608 608
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_ID'] = $option_id;
609 609
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_NAME'] = stripslashes($option_name);
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", stripslashes($options_value));
612 612
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = '';
613 613
 			$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
614
-			if ( current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0) ) :
614
+			if (current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0)) :
615 615
 				$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
616 616
 			endif;
617 617
 			$output = wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * Add a new value to an attribute from select type directly from an entity element edition interface
631 631
 	 */
632 632
 	function ajax_new_option_for_select_from_product_edition_callback() {
633
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
633
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
634 634
 
635 635
 		global $wpdb;
636 636
 		$result = '';
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 		$attribute_options_label = isset($_POST['attribute_new_label']) ? wpshop_tools::varSanitizer($_POST['attribute_new_label']) : null;
648 648
 		$attribute_options_value = sanitize_title($attribute_options_label);
649 649
 
650
-		if ( $type == 'internal' ) {
650
+		if ($type == 'internal') {
651 651
 			/**	Check if the given value does not exist	*/
652 652
 			$query = $wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_status = 'publish'", $attribute_options_label);
653 653
 			$existing_values = $wpdb->get_results($query);
654 654
 
655 655
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
656
-			if ( count($existing_values) <= 0 ) {
656
+			if (count($existing_values) <= 0) {
657 657
 				$result_status = true;
658 658
 				/**	Create the new value as an entity into post database	*/
659 659
 				$new_post = array(
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$existing_values = $wpdb->get_results($query);
677 677
 
678 678
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
679
-			if( count($existing_values) <= 0 ) {
679
+			if (count($existing_values) <= 0) {
680 680
 				$result_status = true;
681 681
 				$position = 1;
682 682
 				/**	Get the last value position for adding the new at the end	*/
@@ -695,15 +695,15 @@  discard block
 block discarded – undo
695 695
 
696 696
 		if ($result_status) {
697 697
 			$tmp_selection_for_output = array();
698
-			foreach ( $attribute_selected_values as $value ) {
698
+			foreach ($attribute_selected_values as $value) {
699 699
 				$tmp_selection_for_output[]['value'] = $value;
700 700
 			}
701 701
 			$tmp_selection_for_output[]['value'] = $new_option_id;
702
-			foreach ( $tmp_selection_for_output as $tmp_value ) {
702
+			foreach ($tmp_selection_for_output as $tmp_value) {
703 703
 				$selection_for_output[] = (object)$tmp_value;
704 704
 			}
705 705
 			$attribute_selected_values[] = $new_option_id;
706
-			$input = wpshop_attributes::get_attribute_field_definition( $attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display) );
706
+			$input = wpshop_attributes::get_attribute_field_definition($attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display));
707 707
 			$result = $input['output'] . $input['options'];
708 708
 		}
709 709
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	 * Delete a value for a select list attribute
717 717
 	 */
718 718
 	function ajax_delete_option_for_select_callback() {
719
-		check_ajax_referer( 'wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce' );
719
+		check_ajax_referer('wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce');
720 720
 
721 721
 		$attribute_value_id = isset($_POST['attribute_value_id']) ? wpshop_tools::varSanitizer($_POST['attribute_value_id']) : '0';
722 722
 
@@ -740,18 +740,18 @@  discard block
 block discarded – undo
740 740
 	 * Display the field for the selected attribute type
741 741
 	 */
742 742
 	function ajax_attribute_output_type_callback() {
743
-		check_ajax_referer( 'wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce' );
743
+		check_ajax_referer('wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce');
744 744
 
745 745
 		$data_type_to_use = isset($_POST['data_type_to_use']) ? str_replace('_data', '', wpshop_tools::varSanitizer($_POST['data_type_to_use'], '')) : 'custom';
746 746
 		$current_type = isset($_POST['current_type']) ? wpshop_tools::varSanitizer($_POST['current_type']) : 'short_text';
747
-		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval( wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
747
+		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval(wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
748 748
 		$the_input = __('An error occured while getting field type', 'wpshop');
749 749
 		$input_def = array();
750 750
 		$input_def['name'] = 'default_value';
751 751
 		$input_def['id'] = 'wpshop_attributes_edition_table_field_id_default_value';
752 752
 		$input_label = __('Default value', 'wpshop');
753 753
 
754
-		switch($current_type){
754
+		switch ($current_type) {
755 755
 			case 'short_text':
756 756
 			case 'float_field':
757 757
 				$input_def['type'] = 'text';
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 			case 'multiple-select':
763 763
 			case 'radio':
764 764
 			case 'checkbox':
765
-				$input_label=__('Options list for attribute', 'wpshop');
765
+				$input_label = __('Options list for attribute', 'wpshop');
766 766
 				$the_input = wpshop_attributes::get_select_options_list($elementIdentifier, $data_type_to_use);
767 767
 				break;
768 768
 			case 'date_field':
769
-				$input_label=__('Date field configuration', 'wpshop');
769
+				$input_label = __('Date field configuration', 'wpshop');
770 770
 
771
-				$the_input = wpshop_attributes::attribute_type_date_config( array() );
771
+				$the_input = wpshop_attributes::attribute_type_date_config(array());
772 772
 				break;
773 773
 			case 'textarea':
774 774
 				$input_def['type'] = 'textarea';
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 	 * Get the attribute set list when creating a new attribute for direct affectation
787 787
 	 */
788 788
 	function ajax_attribute_entity_set_selection_callback() {
789
-		check_ajax_referer( 'wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce' );
789
+		check_ajax_referer('wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce');
790 790
 
791 791
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
792 792
 
793
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
793
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
794 794
 
795 795
 		echo json_encode($the_input);
796 796
 		die();
@@ -800,11 +800,11 @@  discard block
 block discarded – undo
800 800
 	 * Get the attribute set list when creating a new attribute for direct affectation
801 801
 	 */
802 802
 	function ajax_attribute_set_entity_selection_callback() {
803
-		check_ajax_referer( 'wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce' );
803
+		check_ajax_referer('wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce');
804 804
 
805 805
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
806 806
 
807
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
807
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
808 808
 
809 809
 		echo json_encode($the_input);
810 810
 		die();
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	 * Dialog box allowing to change attribute data type from custom to internal
816 816
 	 */
817 817
 	function ajax_attribute_select_data_type_callback() {
818
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce' );
818
+		check_ajax_referer('wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce');
819 819
 		$result = '';
820 820
 
821 821
 		$current_attribute = isset($_POST['current_attribute']) ? intval(wpshop_tools::varSanitizer($_POST['current_attribute'])) : null;
@@ -823,12 +823,12 @@  discard block
 block discarded – undo
823 823
 
824 824
 		$types_toggled = unserialize(WPSHOP_ATTR_SELECT_TYPE_TOGGLED);
825 825
 		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_current_attribute" >' . sprintf(__('Selected attribute %s', 'wpshop'), $attribute->frontend_label) . '</p>';
826
-		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use.'_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
826
+		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use . '_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
827 827
 
828
-		if ( $attribute->data_type_to_use == 'custom' ) {
829
-			$sub_output='';
828
+		if ($attribute->data_type_to_use == 'custom') {
829
+			$sub_output = '';
830 830
 			$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
831
-			unset($input_def);$input_def=array();
831
+			unset($input_def); $input_def = array();
832 832
 			$input_def['label'] = __('Type of data for list', 'wpshop');
833 833
 			$input_def['type'] = 'select';
834 834
 			$input_def['name'] = 'internal_data';
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 			$input_def['possible_value'] = $wp_types;
837 837
 			$input_def['value'] = !empty($attribute_select_options[0]->default_value) ? $attribute_select_options[0]->default_value : null;
838 838
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
839
-			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>';
839
+			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="' . sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')) . '" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">' . $combo_wp_type . '</div>';
840 840
 			$result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />';
841 841
 		}
842 842
 		else {
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 	 */
870 870
 	function ajax_attribute_select_data_type_change_callback() {
871 871
 		global $wpdb;
872
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce' );
872
+		check_ajax_referer('wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce');
873 873
 		$result = '';
874 874
 
875 875
 		$current_attribute = isset($_POST['attribute_id']) ? intval(wpshop_tools::varSanitizer($_POST['attribute_id'])) : null;
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
 		$delete_entity = isset($_POST['delete_entity']) ? wpshop_tools::varSanitizer($_POST['delete_entity']) : false;
880 880
 
881 881
 
882
-		if ( $data_type == 'internal' ) {
882
+		if ($data_type == 'internal') {
883 883
 			$options_list = wpshop_attributes::get_select_option_list_($current_attribute);
884
-			if(!empty($options_list)){
885
-				foreach($options_list as $option){
884
+			if (!empty($options_list)) {
885
+				foreach ($options_list as $option) {
886 886
 					/*	Creat the new entity	*/
887 887
 					$new_post = array(
888 888
 							'post_title' 	=> $option->name,
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 							'post_type' 	=> $internal_data_type
892 892
 					);
893 893
 					$new_option_id = wp_insert_post($new_post);
894
-					if(!empty($new_option_id)){
894
+					if (!empty($new_option_id)) {
895 895
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'deleted'), array('attribute_id'=>$current_attribute));
896 896
 					}
897 897
 				}
@@ -900,19 +900,19 @@  discard block
 block discarded – undo
900 900
 		else {
901 901
 			$post_list = query_posts(array('post_type' => $internal_data_type));
902 902
 			if (!empty($post_list)) {
903
-				$p=1;
903
+				$p = 1;
904 904
 				$error = false;
905 905
 				foreach ($post_list as $post) {
906
-					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
907
-					if(is_int($last_insert) && $delete_items_of_entity){
906
+					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
907
+					if (is_int($last_insert) && $delete_items_of_entity) {
908 908
 						wp_delete_post($post->ID, true);
909 909
 					}
910
-					else{
910
+					else {
911 911
 						$error = true;
912 912
 					}
913 913
 					$p++;
914 914
 				}
915
-				if(!$error && $delete_entity){
915
+				if (!$error && $delete_entity) {
916 916
 					$post = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_name=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, $internal_data_type);
917 917
 					wp_delete_post($wpdb->get_var($post), true);
918 918
 				}
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 	/**
933 933
 	 * Duplicate an existing attribute from an entity to another
934 934
 	 */
935
-	function ajax_wpshop_duplicate_attribute_callback (){
936
-		check_ajax_referer( 'wpshop_duplicate_attribute', 'wpshop_ajax_nonce' );
935
+	function ajax_wpshop_duplicate_attribute_callback() {
936
+		check_ajax_referer('wpshop_duplicate_attribute', 'wpshop_ajax_nonce');
937 937
 		global $wpdb;
938 938
 
939 939
 		$result = '';
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 		/*	Check if the attribute to duplicate does not exist for the selected entity	*/
954 954
 		$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']);
955 955
 		$check_existing_attribute = $wpdb->get_var($query);
956
-		if ( empty($check_existing_attribute) ) {
956
+		if (empty($check_existing_attribute)) {
957 957
 			/*	Save new attribut for the selected entity	*/
958 958
 			$new_attribute = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE, $attribute_def);
959 959
 			$new_attribute_id = $wpdb->insert_id;
960 960
 
961 961
 			if ($new_attribute) {
962
-				if ( in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom') ) {
962
+				if (in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom')) {
963 963
 					$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d", $current_attribute);
964 964
 					$attribute_options_list = $wpdb->get_results($query, ARRAY_A);
965
-					foreach ( $attribute_options_list as $option ) {
965
+					foreach ($attribute_options_list as $option) {
966 966
 						$option['id'] = '';
967 967
 						$option['creation_date'] = current_time('mysql', 0);
968 968
 						$option['attribute_id'] = $new_attribute_id;
@@ -993,27 +993,27 @@  discard block
 block discarded – undo
993 993
 	/**
994 994
 	 * Load comboBox of unit or group of unit
995 995
 	 */
996
-	function wpshop_ajax_load_attribute_unit_list(){
997
-		check_ajax_referer( 'wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce' );
996
+	function wpshop_ajax_load_attribute_unit_list() {
997
+		check_ajax_referer('wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce');
998 998
 		$response = '';
999 999
 
1000
-		$current_group = ( isset( $_POST[ 'current_group' ] ) && !empty( $_POST[ 'current_group' ] ) ) ? $_POST[ 'current_group' ] : null;
1001
-		$selected_list = ( isset( $_POST[ 'selected_list' ] ) && !empty( $_POST[ 'selected_list' ] ) ) ? $_POST[ 'selected_list' ] : null;
1000
+		$current_group = (isset($_POST['current_group']) && !empty($_POST['current_group'])) ? $_POST['current_group'] : null;
1001
+		$selected_list = (isset($_POST['selected_list']) && !empty($_POST['selected_list'])) ? $_POST['selected_list'] : null;
1002 1002
 
1003 1003
 		$group = wpshop_tools::varSanitizer($current_group);
1004 1004
 		$selected_list = wpshop_tools::varSanitizer($selected_list);
1005 1005
 
1006
-		if ( !empty($group) && !empty($selected_list)) {
1006
+		if (!empty($group) && !empty($selected_list)) {
1007 1007
 			/* Test if we want display the group unit list OR the unit list */
1008
-			if ( $selected_list == 'group unit' ) {
1008
+			if ($selected_list == 'group unit') {
1009 1009
 				$list = wpshop_attributes_unit::get_unit_group();
1010 1010
 			}
1011 1011
 			else {
1012 1012
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1013 1013
 			}
1014 1014
 
1015
-			foreach( $list as $unit ) {
1016
-				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1015
+			foreach ($list as $unit) {
1016
+				$response .= '<option value="' . $unit->id . '" ' . (($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '') . '>' . $unit->name . '</option>';
1017 1017
 			}
1018 1018
 			$result = array(true, $response);
1019 1019
 		}
@@ -1043,22 +1043,22 @@  discard block
 block discarded – undo
1043 1043
 </div>
1044 1044
 <div class="tools_db_modif_list_version_details" >
1045 1045
 	<ul>';
1046
-			foreach($plugin_db_modification as $modif_name => $modif_list){
1047
-				switch($modif_name){
1046
+			foreach ($plugin_db_modification as $modif_name => $modif_list) {
1047
+				switch ($modif_name) {
1048 1048
 					case 'FIELD_ADD':{
1049
-						foreach($modif_list as $table_name => $field_list){
1049
+						foreach ($modif_list as $table_name => $field_list) {
1050 1050
 							$sub_modif = '  ';
1051
-							foreach($field_list as $column_name){
1052
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1051
+							foreach ($field_list as $column_name) {
1052
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1053 1053
 								$columns = $wpdb->get_row($query);
1054 1054
 								$sub_modif .= $column_name;
1055
-								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1055
+								if (!empty($columns->Field) && ($columns->Field == $column_name)) {
1056 1056
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1057 1057
 								}
1058
-								else{
1058
+								else {
1059 1059
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1060 1060
 									$error_nb++;
1061
-									if ( !empty($error_list[$plugin_db_version]) ) {
1061
+									if (!empty($error_list[$plugin_db_version])) {
1062 1062
 										$error_list[$plugin_db_version] += 1;
1063 1063
 									}
1064 1064
 									else {
@@ -1067,56 +1067,56 @@  discard block
 block discarded – undo
1067 1067
 								}
1068 1068
 								$sub_modif .= ' / ';
1069 1069
 							}
1070
-							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1070
+							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1071 1071
 						}
1072 1072
 					}break;
1073 1073
 					case 'FIELD_DROP':{
1074
-						foreach($modif_list as $table_name => $field_list){
1074
+						foreach ($modif_list as $table_name => $field_list) {
1075 1075
 							$sub_modif = '  ';
1076
-							foreach($field_list as $column_name){
1077
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1076
+							foreach ($field_list as $column_name) {
1077
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1078 1078
 								$columns = $wpdb->get_row($query);
1079 1079
 								$sub_modif .= $column_name;
1080
-								if(empty($columns) || ($columns->Field != $column_name)){
1080
+								if (empty($columns) || ($columns->Field != $column_name)) {
1081 1081
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />';
1082 1082
 								}
1083
-								else{
1083
+								else {
1084 1084
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1085 1085
 									$error_nb++;
1086 1086
 									$error_list[$plugin_db_version] += 1;
1087 1087
 								}
1088 1088
 								$sub_modif .= ' / ';
1089 1089
 							}
1090
-							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1090
+							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1091 1091
 						}
1092 1092
 					}break;
1093 1093
 					case 'FIELD_CHANGE':{
1094
-						foreach($modif_list as $table_name => $field_list){
1094
+						foreach ($modif_list as $table_name => $field_list) {
1095 1095
 							$sub_modif = '  ';
1096
-							foreach($field_list as $field_infos){
1097
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_infos['field']);
1096
+							foreach ($field_list as $field_infos) {
1097
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_infos['field']);
1098 1098
 								$columns = $wpdb->get_row($query);
1099 1099
 								$what_is_changed = '';
1100
-								if(isset($field_infos['type'])){
1100
+								if (isset($field_infos['type'])) {
1101 1101
 									$what_is_changed = __('field type', 'wpshop');
1102 1102
 									$changed_key = 'type';
1103
-									if($columns->Type == $field_infos['type']){
1103
+									if ($columns->Type == $field_infos['type']) {
1104 1104
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1105 1105
 									}
1106
-									else{
1106
+									else {
1107 1107
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1108 1108
 										$error_nb++;
1109 1109
 										$error_list[$plugin_db_version] += 1;
1110 1110
 									}
1111 1111
 									$sub_modif .= sprintf(__('Change %s for field %s to %s', 'wpshop'), $what_is_changed, $field_infos['field'], $field_infos[$changed_key]);
1112 1112
 								}
1113
-								if(isset($field_infos['original_name'])){
1113
+								if (isset($field_infos['original_name'])) {
1114 1114
 									$what_is_changed = __('field name', 'wpshop');
1115 1115
 									$changed_key = 'original_name';
1116
-									if($columns->Field == $field_infos['field']){
1116
+									if ($columns->Field == $field_infos['field']) {
1117 1117
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1118 1118
 									}
1119
-									else{
1119
+									else {
1120 1120
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1121 1121
 										$error_nb++;
1122 1122
 										$error_list[$plugin_db_version] += 1;
@@ -1131,59 +1131,59 @@  discard block
 block discarded – undo
1131 1131
 					}break;
1132 1132
 
1133 1133
 					case 'DROP_INDEX':{
1134
-						foreach($modif_list as $table_name => $field_list){
1134
+						foreach ($modif_list as $table_name => $field_list) {
1135 1135
 							$sub_modif = '   ';
1136
-							foreach($field_list as $column_name){
1137
-								$query = $wpdb->prepare("SHOW INDEX FROM " .$table_name . " WHERE Column_name = %s", $column_name);
1136
+							foreach ($field_list as $column_name) {
1137
+								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s", $column_name);
1138 1138
 								$columns = $wpdb->get_row($query);
1139 1139
 								$sub_modif .= $column_name;
1140
-								if((empty($columns)) || ($columns->Column_name != $column_name)){
1140
+								if ((empty($columns)) || ($columns->Column_name != $column_name)) {
1141 1141
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />';
1142 1142
 								}
1143
-								else{
1143
+								else {
1144 1144
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />';
1145 1145
 									$error_nb++;
1146 1146
 									$error_list[$plugin_db_version] += 1;
1147 1147
 								}
1148 1148
 								$sub_modif .= ' / ';
1149 1149
 							}
1150
-							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1150
+							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1151 1151
 						}
1152 1152
 					}break;
1153 1153
 					case 'ADD_INDEX':{
1154
-						foreach($modif_list as $table_name => $field_list){
1154
+						foreach ($modif_list as $table_name => $field_list) {
1155 1155
 							$sub_modif = '   ';
1156
-							foreach($field_list as $column_name){
1156
+							foreach ($field_list as $column_name) {
1157 1157
 								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s OR Key_name = %s", $column_name, $column_name);
1158 1158
 								$columns = $wpdb->get_row($query);
1159 1159
 								$sub_modif .= $column_name;
1160
-								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1160
+								if (($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)) {
1161 1161
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />';
1162 1162
 								}
1163
-								else{
1163
+								else {
1164 1164
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />';
1165 1165
 									$error_nb++;
1166 1166
 									$error_list[$plugin_db_version] += 1;
1167 1167
 								}
1168 1168
 								$sub_modif .= ' / ';
1169 1169
 							}
1170
-							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1170
+							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1171 1171
 						}
1172 1172
 					}break;
1173 1173
 
1174 1174
 					case 'ADD_TABLE':{
1175 1175
 						$sub_modif = '  ';
1176
-						foreach($modif_list as $table_name){
1176
+						foreach ($modif_list as $table_name) {
1177 1177
 							$sub_modif .= $table_name;
1178 1178
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table_name);
1179 1179
 							$table_exists = $wpdb->query($query);
1180
-							if($table_exists == 1){
1180
+							if ($table_exists == 1) {
1181 1181
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />';
1182 1182
 							}
1183
-							else{
1183
+							else {
1184 1184
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />';
1185 1185
 								$error_nb++;
1186
-								if ( !empty($error_list[$plugin_db_version]) ) {
1186
+								if (!empty($error_list[$plugin_db_version])) {
1187 1187
 									$error_list[$plugin_db_version] += 1;
1188 1188
 								}
1189 1189
 								else {
@@ -1196,29 +1196,29 @@  discard block
 block discarded – undo
1196 1196
 					}break;
1197 1197
 					case 'TABLE_RENAME':{
1198 1198
 						$sub_modif = '  ';
1199
-						foreach($modif_list as $table){
1199
+						foreach ($modif_list as $table) {
1200 1200
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1201 1201
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1202 1202
 							$table_exists = $wpdb->query($query);
1203 1203
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1204 1204
 							$old_table_exists = $wpdb->query($query);
1205
-							if(($table_exists == 1) && ($old_table_exists == 1)){
1205
+							if (($table_exists == 1) && ($old_table_exists == 1)) {
1206 1206
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Both database table are still present', 'wpshop') . '" title="' . __('Both database table are still present', 'wpshop') . '" class="db_rename_table_check" />';
1207 1207
 								$error_nb++;
1208
-								if ( !empty($error_list[$plugin_db_version]) ) {
1208
+								if (!empty($error_list[$plugin_db_version])) {
1209 1209
 									$error_list[$plugin_db_version] += 1;
1210 1210
 								}
1211 1211
 								else {
1212 1212
 									$error_list[$plugin_db_version] = 1;
1213 1213
 								}
1214 1214
 							}
1215
-							elseif($table_exists == 1){
1215
+							elseif ($table_exists == 1) {
1216 1216
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1217 1217
 							}
1218
-							else{
1218
+							else {
1219 1219
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1220 1220
 								$error_nb++;
1221
-								if ( !empty($error_list[$plugin_db_version]) ) {
1221
+								if (!empty($error_list[$plugin_db_version])) {
1222 1222
 									$error_list[$plugin_db_version] += 1;
1223 1223
 								}
1224 1224
 								else {
@@ -1231,27 +1231,27 @@  discard block
 block discarded – undo
1231 1231
 					}break;
1232 1232
 					case 'TABLE_RENAME_FOR_DELETION':{
1233 1233
 						$sub_modif = '  ';
1234
-						foreach($modif_list as $table){
1234
+						foreach ($modif_list as $table) {
1235 1235
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1236 1236
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1237 1237
 							$table_delete_exists = $wpdb->query($query);
1238 1238
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1239 1239
 							$old_table_exists = $wpdb->query($query);
1240
-							if(($table_delete_exists == 1) || ($old_table_exists == 1)){
1241
-								if($old_table_exists == 1){
1240
+							if (($table_delete_exists == 1) || ($old_table_exists == 1)) {
1241
+								if ($old_table_exists == 1) {
1242 1242
 									$deleted_table_result = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1243 1243
 									$error_nb++;
1244
-									if ( !empty($error_list[$plugin_db_version]) ) {
1244
+									if (!empty($error_list[$plugin_db_version])) {
1245 1245
 										$error_list[$plugin_db_version] += 1;
1246 1246
 									}
1247 1247
 									else {
1248 1248
 										$error_list[$plugin_db_version] = 1;
1249 1249
 									}
1250 1250
 								}
1251
-								else{
1251
+								else {
1252 1252
 									$deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1253 1253
 									$warning_nb++;
1254
-									if ( !empty($warning_list[$plugin_db_version]) ) {
1254
+									if (!empty($warning_list[$plugin_db_version])) {
1255 1255
 										$warning_list[$plugin_db_version] += 1;
1256 1256
 									}
1257 1257
 									else {
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 								}
1261 1261
 								$sub_modif .= $deleted_table_result;
1262 1262
 							}
1263
-							else{
1263
+							else {
1264 1264
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />';
1265 1265
 							}
1266 1266
 							$sub_modif .= ' / ';
@@ -1275,57 +1275,57 @@  discard block
 block discarded – undo
1275 1275
 		}
1276 1276
 
1277 1277
 		$db_table_field_error = '';
1278
-		foreach($wpshop_db_table as $table_name => $table_definition){
1279
-			if(!empty($table_definition)){
1278
+		foreach ($wpshop_db_table as $table_name => $table_definition) {
1279
+			if (!empty($table_definition)) {
1280 1280
 				$table_line = explode("
1281 1281
 ", $table_definition);
1282 1282
 
1283 1283
 				$sub_db_table_field_error = '  ';
1284
-				foreach($table_line as $table_definition_line){
1284
+				foreach ($table_line as $table_definition_line) {
1285 1285
 					$def_line = trim($table_definition_line);
1286
-					if(substr($def_line, 0, 1) == "`"){
1286
+					if (substr($def_line, 0, 1) == "`") {
1287 1287
 						$line_element = explode(" ", $def_line);
1288 1288
 						$field_name = str_replace("`", "", $line_element[0]);
1289
-						$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_name);
1289
+						$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_name);
1290 1290
 						$columns = $wpdb->get_row($query);
1291
-						if ( !empty($columns->Field) && ($columns->Field != $field_name)) {
1291
+						if (!empty($columns->Field) && ($columns->Field != $field_name)) {
1292 1292
 							$sub_db_table_field_error .= $field_name . ', '/*  . ' : <img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />' */;
1293 1293
 							$error_nb++;
1294 1294
 						}
1295 1295
 					}
1296 1296
 				}
1297 1297
 				$sub_db_table_field_error = trim(substr($sub_db_table_field_error, 0, -2));
1298
-				if(!empty($sub_db_table_field_error)){
1298
+				if (!empty($sub_db_table_field_error)) {
1299 1299
 					$db_table_field_error .= sprintf(__('Following fields of %s don\'t exists: %s', 'wpshop'), '<span class="bold" >' . $table_name . '</span>', $sub_db_table_field_error) . '<br/>';
1300 1300
 				}
1301 1301
 			}
1302 1302
 		}
1303
-		if(!empty($db_table_field_error)){
1303
+		if (!empty($db_table_field_error)) {
1304 1304
 			$db_table_field_error = '<hr class="clear" />' . $db_table_field_error . '<hr/>';
1305 1305
 		}
1306 1306
 
1307 1307
 		/*	Start display	*/
1308 1308
 		$plugin_install_error = '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Wpshop install is ok', 'wpshop') . '" title="' . __('Wpshop install is ok', 'wpshop') . '" />&nbsp;' . __('There is no error in your wpshop installation. Please find details below', 'wpshop') . '<hr/>';
1309
-		if($error_nb > 0){
1309
+		if ($error_nb > 0) {
1310 1310
 			$plugin_install_error = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Error in wpshop install', 'wpshop') . '" title="' . __('Error in wpshop install', 'wpshop') . '" />&nbsp;' . __('There are ne or more errors into your wpshop installation. Please find details below', 'wpshop') . '<br/>
1311 1311
 							<ul>';
1312
-			foreach($error_list as $version => $element_nb){
1313
-				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version  . '" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1312
+			foreach ($error_list as $version => $element_nb) {
1313
+				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version . '" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1314 1314
 			}
1315 1315
 			$plugin_install_error .= '
1316 1316
 							</ul>';
1317 1317
 		}
1318
-		if($warning_nb > 0){
1318
+		if ($warning_nb > 0) {
1319 1319
 			$plugin_install_error .= '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Warning in wpshop install', 'wpshop') . '" title="' . __('Warning in wpshop install', 'wpshop') . '" />&nbsp;' . __('Some element need your attention. They have no consequences on wpshop operation. Please find details below', 'wpshop') . '<br/>';
1320
-			foreach($warning_list as $version => $element_nb){
1320
+			foreach ($warning_list as $version => $element_nb) {
1321 1321
 				$plugin_install_error .= '&nbsp;&nbsp;' . sprintf(__('There are %d warning into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - ';
1322 1322
 			}
1323 1323
 			$plugin_install_error = substr($plugin_install_error, 0, -3) . '<hr/>';
1324 1324
 		}
1325 1325
 
1326 1326
 		$max_number = 0;
1327
-		foreach($wpshop_update_way as $number => $operation){
1328
-			if($number > $max_number){
1327
+		foreach ($wpshop_update_way as $number => $operation) {
1328
+			if ($number > $max_number) {
1329 1329
 				$max_number = $number;
1330 1330
 			}
1331 1331
 		}
@@ -1338,25 +1338,25 @@  discard block
 block discarded – undo
1338 1338
 		$output_ok = $output_error = '';
1339 1339
 
1340 1340
 		/**	Get defined default datas type	*/
1341
-		$default_custom_post_type = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES );
1341
+		$default_custom_post_type = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES);
1342 1342
 
1343 1343
 		/**	Read the default data saved to check	*/
1344
-		if ( !empty($default_custom_post_type) ) {
1345
-			foreach ( $default_custom_post_type as $type ) {
1344
+		if (!empty($default_custom_post_type)) {
1345
+			foreach ($default_custom_post_type as $type) {
1346 1346
 				$has_error = false;
1347 1347
 				$file_uri = WPSHOP_TEMPLATES_DIR . 'default_datas/' . $type . '.csv';
1348
-				if ( is_file( $file_uri ) ) {
1348
+				if (is_file($file_uri)) {
1349 1349
 					unset($tpl_component);
1350 1350
 					$tpl_component = array();
1351 1351
 					$tpl_component['CUSTOM_POST_TYPE_NAME'] = 'wpshop_cpt_' . $type;
1352 1352
 
1353 1353
 					/**	Launch check on custom post type	*/
1354
-					$check_cpt = wpshop_entities::check_default_custom_post_type( $type, $tpl_component );
1354
+					$check_cpt = wpshop_entities::check_default_custom_post_type($type, $tpl_component);
1355 1355
 					$has_error = $check_cpt[0];
1356 1356
 					$tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER'] = $check_cpt[1];
1357
-					$tpl_component = array_merge( $tpl_component, $check_cpt[2] );
1357
+					$tpl_component = array_merge($tpl_component, $check_cpt[2]);
1358 1358
 
1359
-					if ( $has_error ) {
1359
+					if ($has_error) {
1360 1360
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1361 1361
 					}
1362 1362
 					else {
@@ -1377,19 +1377,19 @@  discard block
 block discarded – undo
1377 1377
 		$container = '';
1378 1378
 		$result = '';
1379 1379
 
1380
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? $_POST['type'] : null;
1381
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? $_POST['identifier'] : null;
1380
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? $_POST['type'] : null;
1381
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? $_POST['identifier'] : null;
1382 1382
 
1383
-		switch ( $selected_type ) {
1383
+		switch ($selected_type) {
1384 1384
 			case WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES:
1385
-				$result = wpshop_entities::create_cpt_from_csv_file( $identifier );
1385
+				$result = wpshop_entities::create_cpt_from_csv_file($identifier);
1386 1386
 			break;
1387 1387
 			case WPSHOP_DBT_ATTRIBUTE:
1388
-				$result = wpshop_entities::create_cpt_attributes_from_csv_file( $identifier );
1388
+				$result = wpshop_entities::create_cpt_attributes_from_csv_file($identifier);
1389 1389
 			break;
1390 1390
 		}
1391 1391
 
1392
-		echo json_encode( $result );
1392
+		echo json_encode($result);
1393 1393
 		die();
1394 1394
 	}
1395 1395
 	add_action('wp_ajax_wpshop_ajax_repair_default_datas', 'wpshop_ajax_repair_default_datas');
@@ -1398,22 +1398,22 @@  discard block
 block discarded – undo
1398 1398
 		global $wpdb;
1399 1399
 		$result = array('status' => true);
1400 1400
 
1401
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? $_POST['type'] : null;
1402
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? $_POST['identifier'] : null;
1401
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? $_POST['type'] : null;
1402
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? $_POST['identifier'] : null;
1403 1403
 
1404
-		$entity_id = wpshop_entities::get_entity_identifier_from_code( $identifier );
1404
+		$entity_id = wpshop_entities::get_entity_identifier_from_code($identifier);
1405 1405
 		$query = $wpdb->prepare("SELECT id, frontend_label FROM " . $selected_type . " WHERE entity_id = %d", $entity_id);
1406
-		$attribute_list = $wpdb->get_results( $query );
1407
-		if ( !empty($attribute_list) ) {
1408
-			foreach ( $attribute_list as $attribute) {
1409
-				$update_result = $wpdb->update( $selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id) );
1410
-				if ( $update_result === false ) {
1406
+		$attribute_list = $wpdb->get_results($query);
1407
+		if (!empty($attribute_list)) {
1408
+			foreach ($attribute_list as $attribute) {
1409
+				$update_result = $wpdb->update($selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id));
1410
+				if ($update_result === false) {
1411 1411
 					$result['status'] = false;
1412 1412
 				}
1413 1413
 			}
1414 1414
 		}
1415 1415
 
1416
-		echo json_encode( $result );
1416
+		echo json_encode($result);
1417 1417
 		die();
1418 1418
 	}
1419 1419
 	add_action('wp_ajax_wpshop_ajax_translate_default_datas', 'wpshop_ajax_translate_default_datas');
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 	function wpshop_ajax_db_repair_tool() {
1422 1422
 		$version_id = isset($_POST['version_id']) ? wpshop_tools::varSanitizer($_POST['version_id']) : null;
1423 1423
 
1424
-		echo wpshop_install::alter_db_structure_on_update( $version_id );
1424
+		echo wpshop_install::alter_db_structure_on_update($version_id);
1425 1425
 
1426 1426
 		die();
1427 1427
 	}
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
 		$tpl_component = array();
1432 1432
 
1433 1433
 		/**	Copy an attribute content to another	*/
1434
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ), "'valid'", 'entity_id', true);
1434
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), "'valid'", 'entity_id', true);
1435 1435
 		$possible_values = array('' => __('Choose an attribute', 'wpshop'));
1436 1436
 		$possible_values_for_variation = array('' => __('Choose an attribute', 'wpshop'));
1437
-		foreach ( $attribute_list as $attribute ) {
1437
+		foreach ($attribute_list as $attribute) {
1438 1438
 			$possible_values[$attribute->id] = $attribute->frontend_label;
1439
-			if ( $attribute->is_used_for_variation == 'yes' ) {
1439
+			if ($attribute->is_used_for_variation == 'yes') {
1440 1440
 				$possible_values_for_variation[$attribute->id] = $attribute->frontend_label;
1441 1441
 			}
1442 1442
 		}
@@ -1470,14 +1470,14 @@  discard block
 block discarded – undo
1470 1470
 		global $wpdb;
1471 1471
 		$response = array();
1472 1472
 
1473
-		if ( $_POST['wps_update_att_values']['from'] != $_POST['wps_update_att_values']['to'] ) {
1473
+		if ($_POST['wps_update_att_values']['from'] != $_POST['wps_update_att_values']['to']) {
1474 1474
 			$from_attribute = wpshop_attributes::getElement($_POST['wps_update_att_values']['from'], "'valid'");
1475 1475
 			$to_attribute = wpshop_attributes::getElement($_POST['wps_update_att_values']['to'], "'valid'");
1476
-			if ( $from_attribute->data_type == $to_attribute->data_type ) {
1476
+			if ($from_attribute->data_type == $to_attribute->data_type) {
1477 1477
 
1478 1478
 				/**	Manage specific case	*/
1479 1479
 				$query_more_args = array();
1480
-				switch( $to_attribute->code ){
1480
+				switch ($to_attribute->code) {
1481 1481
 					case "barcode":
1482 1482
 							$more_query = "
1483 1483
 						AND VAL.value NOT LIKE %s";
@@ -1493,22 +1493,22 @@  discard block
 block discarded – undo
1493 1493
 					WHERE VAL.attribute_id = %d
1494 1494
 						AND P.post_type = %s
1495 1495
 						AND VAL.value != ''" . $more_query,
1496
-					array_merge( array( $_POST['wps_update_att_values']['from'], $_POST['wps_entity_to_transfert'] ), $query_more_args )
1496
+					array_merge(array($_POST['wps_update_att_values']['from'], $_POST['wps_entity_to_transfert']), $query_more_args)
1497 1497
 				);
1498
-				$element_list_to_update = $wpdb->get_results( $query );
1498
+				$element_list_to_update = $wpdb->get_results($query);
1499 1499
 
1500
-				if ( !empty($element_list_to_update) ) {
1500
+				if (!empty($element_list_to_update)) {
1501 1501
 					$has_error = false;
1502 1502
 					$error_count = 0;
1503
-					foreach ( $element_list_to_update as $element ) {
1503
+					foreach ($element_list_to_update as $element) {
1504 1504
 
1505 1505
 						/**	Historicize the old value of recevier attribute	*/
1506
-						if (  $to_attribute->is_historisable == 'yes' ) {
1506
+						if ($to_attribute->is_historisable == 'yes') {
1507 1507
 							$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $to_attribute->id, $element->ID);
1508
-							$attribute_histos = $wpdb->get_results( $query );
1509
-							if ( !empty( $attribute_histos ) ) {
1510
-								foreach ( $attribute_histos as $attribute_histo ) {
1511
-									if ( !empty( $attribute_histo->value ) ) {
1508
+							$attribute_histos = $wpdb->get_results($query);
1509
+							if (!empty($attribute_histos)) {
1510
+								foreach ($attribute_histos as $attribute_histo) {
1511
+									if (!empty($attribute_histo->value)) {
1512 1512
 										$attribute_histo_content['status'] = 'valid';
1513 1513
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1514 1514
 										$attribute_histo_content['creation_date_value'] = $attribute_histo->creation_date_value;
@@ -1521,12 +1521,12 @@  discard block
 block discarded – undo
1521 1521
 										$attribute_histo_content['value'] = $attribute_histo->value;
1522 1522
 										$attribute_histo_content['value_type'] = WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType;
1523 1523
 										$last_histo = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO, $attribute_histo_content);
1524
-										if ( $last_histo === false ) {
1524
+										if ($last_histo === false) {
1525 1525
 											$has_error = true;
1526 1526
 											$error_count++;
1527 1527
 										}
1528 1528
 										else {
1529
-											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1529
+											$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array('value_id' => $attribute_histo->value_id));
1530 1530
 										}
1531 1531
 									}
1532 1532
 								}
@@ -1535,36 +1535,36 @@  discard block
 block discarded – undo
1535 1535
 
1536 1536
 						/**		*/
1537 1537
 						$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $from_attribute->id, $element->ID);
1538
-						$attribute_to_save = $wpdb->get_row( $query, ARRAY_A );
1538
+						$attribute_to_save = $wpdb->get_row($query, ARRAY_A);
1539 1539
 						unset($attribute_to_save['value_id']);
1540 1540
 						$attribute_to_save['attribute_id'] = $to_attribute->id;
1541 1541
 						$attribute_to_save['creation_date_value'] = current_time('mysql', 0);
1542 1542
 						$attribute_to_save['user_id'] = get_current_user_id();
1543
-						$new_value = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save );
1544
-						if ( $new_value === false ) {
1543
+						$new_value = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save);
1544
+						if ($new_value === false) {
1545 1545
 							$has_error = true;
1546 1546
 							$error_count++;
1547 1547
 						}
1548 1548
 						else {
1549 1549
 							/**	Save new atribute values in product metadata	*/
1550
-							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1550
+							$current_product_metadata = get_post_meta($element->ID, '_wpshop_product_metadata', true);
1551 1551
 							$current_product_metadata[$to_attribute->code] = $element->value;
1552
-							update_post_meta( $element->ID, '_wpshop_product_metadata', $current_product_metadata );
1552
+							update_post_meta($element->ID, '_wpshop_product_metadata', $current_product_metadata);
1553 1553
 
1554 1554
 							/**	Save a single meta for attribute in case it will be used in specific case where meta needs to be alone	*/
1555
-							if ( ( ($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes'))  || ( $to_attribute->is_filterable == 'yes') && !empty($element->value) ) :
1556
-								update_post_meta( $element->ID, '_' . $to_attribute->code, $element->value );
1555
+							if ((($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ($to_attribute->is_filterable == 'yes') && !empty($element->value)) :
1556
+								update_post_meta($element->ID, '_' . $to_attribute->code, $element->value);
1557 1557
 							endif;
1558 1558
 						}
1559 1559
 					}
1560 1560
 
1561
-					if ( !$has_error ) {
1561
+					if (!$has_error) {
1562 1562
 						$response['status'] = true;
1563 1563
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1564 1564
 					}
1565 1565
 					else {
1566 1566
 						$response['status'] = false;
1567
-						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1567
+						$response['error'] = sprinttf(__('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1568 1568
 					}
1569 1569
 				}
1570 1570
 				else {
@@ -1582,17 +1582,17 @@  discard block
 block discarded – undo
1582 1582
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1583 1583
 		}
1584 1584
 
1585
-		echo json_encode( $response );
1585
+		echo json_encode($response);
1586 1586
 		die();
1587 1587
 	}
1588 1588
 	add_action('wp_ajax_wps_mass_action_update_attribute', 'wps_mass_action_update_attribute_value');
1589 1589
 
1590 1590
 	function wps_tools_mass_action_load_possible_options_for_variations_attributes() {
1591 1591
 		$output = '';
1592
-		$attribute = wpshop_attributes::getElement( $_POST['attribute_id'], "'valid'" );
1592
+		$attribute = wpshop_attributes::getElement($_POST['attribute_id'], "'valid'");
1593 1593
 
1594 1594
 		/**	Define new default value	*/
1595
-		$attribute_possible_values_output = wpshop_attributes::get_select_output( $attribute, array() );
1595
+		$attribute_possible_values_output = wpshop_attributes::get_select_output($attribute, array());
1596 1596
 		$attribute_possible_values_output['possible_value']['no_changes'] = __('No changes', 'wpshop');
1597 1597
 		$attribute_possible_values_output['possible_value']['none'] = __('No default value', 'wpshop');
1598 1598
 		ksort($attribute_possible_values_output['possible_value']);
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 		$input_def['valueToPut'] = 'index';
1602 1602
 		$input_def['name'] = 'wps_update_att_for_variation_options_values';
1603 1603
 		$input_def['id'] = 'wps_update_att_for_variation_options_values';
1604
-		$output .= __( 'Default value to affect for this attribute to all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1604
+		$output .= __('Default value to affect for this attribute to all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1605 1605
 
1606 1606
 		/**	Define if attribute is required for adding product to cart	*/
1607 1607
 		$input_def = array();
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 		$input_def['valueToPut'] = 'index';
1611 1611
 		$input_def['name'] = 'wps_update_att_for_variation_required_state';
1612 1612
 		$input_def['id'] = 'wps_update_att_for_variation_required_state';
1613
-		$output .= '<br/>' . __( 'Put this attribute as required for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1613
+		$output .= '<br/>' . __('Put this attribute as required for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1614 1614
 
1615 1615
 
1616 1616
 		$input_def = array();
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 		$input_def['valueToPut'] = 'index';
1620 1620
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][text_from]';
1621 1621
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_text_from';
1622
-		$output .= '<br/>' . __( 'Display "Price from" text before price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1622
+		$output .= '<br/>' . __('Display "Price from" text before price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1623 1623
 
1624 1624
 		$input_def = array();
1625 1625
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'no' => __('No', 'wpshop'), 'yes' => __('Yes', 'wpshop'));
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 		$input_def['valueToPut'] = 'index';
1628 1628
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][lower_price]';
1629 1629
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_lower_price';
1630
-		$output .= '<br/>' . __( 'Display lower price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1630
+		$output .= '<br/>' . __('Display lower price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1631 1631
 
1632 1632
 		$input_def = array();
1633 1633
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'replacement' => __('Replace product price with option price', 'wpshop'), 'addition' => __('Add option price to product price', 'wpshop'));
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 		$input_def['valueToPut'] = 'index';
1636 1636
 		$input_def['name'] = 'wps_update_att_for_variation[price_behaviour]';
1637 1637
 		$input_def['id'] = 'wps_update_att_for_variation_price_behaviour';
1638
-		$output .= '<br/>' . __( 'Price calculation behaviour', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1638
+		$output .= '<br/>' . __('Price calculation behaviour', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1639 1639
 
1640 1640
 		$input_def = array();
1641 1641
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'single' => __('Priority to single options', 'wpshop'), 'combined' => __('Priority to combined options', 'wpshop'));
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
 		$input_def['valueToPut'] = 'index';
1644 1644
 		$input_def['name'] = 'wps_update_att_for_variation[priority]';
1645 1645
 		$input_def['id'] = 'wps_update_att_for_variation_priority';
1646
-		$output .= '<br/>' . __( 'Choose priority combination for calculating options', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1646
+		$output .= '<br/>' . __('Choose priority combination for calculating options', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1647 1647
 
1648 1648
 		echo $output;
1649 1649
 		die();
@@ -1653,58 +1653,58 @@  discard block
 block discarded – undo
1653 1653
 	function wps_mass_action_change_variation_option() {
1654 1654
 		global $wpdb;
1655 1655
 
1656
-		$attribute = wpshop_attributes::getElement( $_POST['attribute_id'], "'valid'" );
1657
-		$query = $wpdb->prepare( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code );
1658
-		$meta_to_update = $wpdb->get_results( $query );
1656
+		$attribute = wpshop_attributes::getElement($_POST['attribute_id'], "'valid'");
1657
+		$query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code);
1658
+		$meta_to_update = $wpdb->get_results($query);
1659 1659
 		$has_error = false;
1660
-		if ( !empty($meta_to_update) ) {
1661
-			foreach ( $meta_to_update as $meta_def ) {
1662
-				$meta_value = unserialize( $meta_def->meta_value );
1663
-				if ( !empty($meta_value) && !empty( $meta_value['attributes'] ) && in_array( $attribute->code, $meta_value['attributes']) ) {
1660
+		if (!empty($meta_to_update)) {
1661
+			foreach ($meta_to_update as $meta_def) {
1662
+				$meta_value = unserialize($meta_def->meta_value);
1663
+				if (!empty($meta_value) && !empty($meta_value['attributes']) && in_array($attribute->code, $meta_value['attributes'])) {
1664 1664
 
1665
-					if ( $_POST['wps_update_att_for_variation_options_values'] != 'no_changes' ) {
1665
+					if ($_POST['wps_update_att_for_variation_options_values'] != 'no_changes') {
1666 1666
 						$meta_value['options']['attributes_default_value'][$attribute->code] = $_POST['wps_update_att_for_variation_options_values'];
1667 1667
 					}
1668 1668
 
1669
-					if ( !empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes') ) {
1670
-						if ( $_POST['wps_update_att_for_variation_required_state'] == 'yes') {
1669
+					if (!empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes')) {
1670
+						if ($_POST['wps_update_att_for_variation_required_state'] == 'yes') {
1671 1671
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1672 1672
 						}
1673
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1673
+						else if (!empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code])) {
1674 1674
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1675 1675
 						}
1676 1676
 					}
1677 1677
 
1678
-					if ( !empty( $_POST['wps_update_att_for_variation'] ) ) {
1679
-						if ( !empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes') ) {
1680
-							if ( $_POST['wps_update_att_for_variation']['text_from'] == 'yes' ) {
1678
+					if (!empty($_POST['wps_update_att_for_variation'])) {
1679
+						if (!empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes')) {
1680
+							if ($_POST['wps_update_att_for_variation']['text_from'] == 'yes') {
1681 1681
 								$meta_value['options']['price_display']['text_from'] = 'on';
1682 1682
 							}
1683
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1683
+							else if (!empty($meta_value['options']['price_display']['text_from'])) {
1684 1684
 								unset($meta_value['options']['price_display']['text_from']);
1685 1685
 							}
1686 1686
 						}
1687 1687
 
1688
-						if ( !empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes') ) {
1689
-							if ( $_POST['wps_update_att_for_variation']['lower_price'] == 'yes' ) {
1688
+						if (!empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes')) {
1689
+							if ($_POST['wps_update_att_for_variation']['lower_price'] == 'yes') {
1690 1690
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1691 1691
 							}
1692
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1692
+							else if (!empty($meta_value['options']['price_display']['lower_price'])) {
1693 1693
 								unset($meta_value['options']['price_display']['lower_price']);
1694 1694
 							}
1695 1695
 						}
1696 1696
 
1697
-						if ( !empty($_POST['wps_update_att_for_variation']['price_behaviour']) && ($_POST['wps_update_att_for_variation']['price_behaviour'] != 'no_changes') ) {
1697
+						if (!empty($_POST['wps_update_att_for_variation']['price_behaviour']) && ($_POST['wps_update_att_for_variation']['price_behaviour'] != 'no_changes')) {
1698 1698
 							$meta_value['options']['price_behaviour'][0] = $_POST['wps_update_att_for_variation']['price_behaviour'];
1699 1699
 						}
1700 1700
 
1701
-						if ( !empty($_POST['wps_update_att_for_variation']['priority']) && ($_POST['wps_update_att_for_variation']['priority'] != 'no_changes') ) {
1701
+						if (!empty($_POST['wps_update_att_for_variation']['priority']) && ($_POST['wps_update_att_for_variation']['priority'] != 'no_changes')) {
1702 1702
 							$meta_value['options']['priority'][0] = $_POST['wps_update_att_for_variation']['priority'];
1703 1703
 						}
1704 1704
 					}
1705 1705
 
1706
-					$meta_save = update_meta( $meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1707
-					if ( $meta_save === false ) {
1706
+					$meta_save = update_meta($meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1707
+					if ($meta_save === false) {
1708 1708
 						$has_error = true;
1709 1709
 					}
1710 1710
 
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 			}
1713 1713
 		}
1714 1714
 
1715
-		echo json_encode( array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))) );
1715
+		echo json_encode(array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))));
1716 1716
 		die();
1717 1717
 	}
1718 1718
 	add_action('wp_ajax_wps_mass_action_change_variation_option', 'wps_mass_action_change_variation_option');
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 	 */
1725 1725
 	function ajax_activate_addons() {
1726 1726
 		global $wpdb;
1727
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1727
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1728 1728
 
1729 1729
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1730 1730
 		$addon_code = isset($_POST['code']) ? wpshop_tools::varSanitizer($_POST['code']) : null;
@@ -1733,56 +1733,56 @@  discard block
 block discarded – undo
1733 1733
 		if (!empty($addon_name) && !empty($addon_code)) {
1734 1734
 			$addons_list = (unserialize(WPSHOP_ADDONS_LIST));
1735 1735
 			if (in_array($addon_name, array_keys($addons_list))) {
1736
-				$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
1736
+				$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
1737 1737
 				$code_part = array();
1738
-				$code_part[] = substr(hash ( "sha256" , $addons_list[$addon_name][0] ),  $addons_list[$addon_name][1], 5);
1739
-				$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
1740
-				$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
1738
+				$code_part[] = substr(hash("sha256", $addons_list[$addon_name][0]), $addons_list[$addon_name][1], 5);
1739
+				$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
1740
+				$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
1741 1741
 				$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
1742 1742
 
1743 1743
 				$current_web_site = site_url('/');
1744 1744
 
1745
-				if ( $addons_list[$addon_name][2] == 'per_site') {
1746
-					$code .= '-' . substr(hash ( "sha256" , $current_web_site ),  $addons_list[$addon_name][1], 5);
1745
+				if ($addons_list[$addon_name][2] == 'per_site') {
1746
+					$code .= '-' . substr(hash("sha256", $current_web_site), $addons_list[$addon_name][1], 5);
1747 1747
 				}
1748 1748
 
1749
-				if ( !empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1750
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1751
-					if ( empty($admin_new_quotation_message) ) {
1752
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1749
+				if (!empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1750
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1751
+					if (empty($admin_new_quotation_message)) {
1752
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1753 1753
 					}
1754
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1755
-					if ( empty($admin_new_quotation_confirm_message) ) {
1756
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1754
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1755
+					if (empty($admin_new_quotation_confirm_message)) {
1756
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1757 1757
 					}
1758 1758
 				}
1759 1759
 
1760 1760
 				if ($code == $addon_code) {
1761
-					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array() );
1761
+					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1762 1762
 					$extra_options[$addon_name]['activate'] = true;
1763 1763
 					$extra_options[$addon_name]['activation_date'] = current_time('mysql', 0);
1764 1764
 					$extra_options[$addon_name]['activation_code'] = $addon_code;
1765
-					if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1766
-						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated','wpshop'));
1767
-						if( !empty($addons_list[$addon_name][3]) ) {
1765
+					if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1766
+						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated', 'wpshop'));
1767
+						if (!empty($addons_list[$addon_name][3])) {
1768 1768
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1769 1769
 						}
1770 1770
 						$state = true;
1771 1771
 					}
1772 1772
 					else {
1773
-						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1773
+						$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1774 1774
 					}
1775 1775
 				}
1776 1776
 				else {
1777
-					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1777
+					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1778 1778
 				}
1779 1779
 			}
1780 1780
 			else {
1781
-				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1781
+				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1782 1782
 			}
1783 1783
 		}
1784 1784
 		else {
1785
-			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1785
+			$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1786 1786
 		}
1787 1787
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
1788 1788
 
@@ -1795,27 +1795,27 @@  discard block
 block discarded – undo
1795 1795
 	 * Addons desactivate
1796 1796
 	 */
1797 1797
 	function ajax_desactivate_wpshop_addons() {
1798
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1798
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1799 1799
 
1800 1800
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1801 1801
 		$state = true;
1802 1802
 
1803
-		if ( !empty($addon_name) ) {
1803
+		if (!empty($addon_name)) {
1804 1804
 			$addons_list = array_keys(unserialize(WPSHOP_ADDONS_LIST));
1805 1805
 			if (in_array($addon_name, $addons_list)) {
1806 1806
 				$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1807 1807
 				$extra_options[$addon_name]['activate'] = false;
1808 1808
 				$extra_options[$addon_name]['deactivation_date'] = current_time('mysql', 0);
1809
-				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1810
-					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1809
+				if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1810
+					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated', 'wpshop'));
1811 1811
 					$state = false;
1812 1812
 				}
1813 1813
 				else {
1814
-					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1814
+					$result = array(false, __('An error occured', 'wpshop'), __('Activated', 'wpshop'));
1815 1815
 				}
1816 1816
 			}
1817 1817
 			else {
1818
-				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1818
+				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated', 'wpshop'));
1819 1819
 			}
1820 1820
 		}
1821 1821
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1829,38 +1829,38 @@  discard block
 block discarded – undo
1829 1829
 	 * Display opttions for including user address into account form
1830 1830
 	 */
1831 1831
 	function ajax_integrate_billing_into_register() {
1832
-		check_ajax_referer( 'wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce' );
1832
+		check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce');
1833 1833
 		global $wpshop_account;
1834 1834
 		$wpshop_billing_address = get_option('wpshop_billing_address');
1835 1835
 		$current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null;
1836 1836
 		$selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null;
1837 1837
 
1838
-		$billing_form_fields = wps_address::get_addresss_form_fields_by_type ( $current_billing_address );
1838
+		$billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address);
1839 1839
 		$possible_values_for_billing = array('' => __('No corresponding field', 'wpshop'));
1840
-		foreach ( $billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1841
-			foreach ( $attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1840
+		foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1841
+			foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1842 1842
 				$possible_values_for_billing[$attribute_build_code] = $attribute_definition['label'];
1843 1843
 			}
1844 1844
 		}
1845
-		$attributes_set = wpshop_attributes_set::getElement( 'yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1845
+		$attributes_set = wpshop_attributes_set::getElement('yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1846 1846
 		/*	Get the attribute set details in order to build the product interface	*/
1847
-		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'");
1848
-		if(!empty($productAttributeSetDetails)){
1849
-			foreach($productAttributeSetDetails as $productAttributeSetDetail){
1850
-				if(count($productAttributeSetDetail['attribut']) >= 1){
1851
-					foreach($productAttributeSetDetail['attribut'] as $attribute) {
1852
-						if(!empty($attribute->id)) {
1853
-							if( !empty($_POST['submitOrderInfos']) ) {
1847
+		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'");
1848
+		if (!empty($productAttributeSetDetails)) {
1849
+			foreach ($productAttributeSetDetails as $productAttributeSetDetail) {
1850
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
1851
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
1852
+						if (!empty($attribute->id)) {
1853
+							if (!empty($_POST['submitOrderInfos'])) {
1854 1854
 								$value = $_POST['attribute'][$attribute->data_type][$attribute->code];
1855 1855
 							}
1856 1856
 							else {
1857 1857
 								$value = '';
1858
-								if ( $attribute->code != 'user_pass') {
1858
+								if ($attribute->code != 'user_pass') {
1859 1859
 									$code = $attribute->code;
1860 1860
 									$value = $user->$code;
1861 1861
 								}
1862 1862
 							}
1863
-							$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute, $value, array() );
1863
+							$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array());
1864 1864
 							$account_form_field[$attribute->code] = $attribute_output_def;
1865 1865
 						}
1866 1866
 					}
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
 
1871 1871
 		$possible_values = array();
1872 1872
 		$matching_field = '';
1873
-		foreach ( $account_form_field as $attribute_code => $attribute_detail) {
1873
+		foreach ($account_form_field as $attribute_code => $attribute_detail) {
1874 1874
 			$possible_values[$attribute_code] = $attribute_detail['label'];
1875 1875
 
1876 1876
 			$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']';
@@ -1902,13 +1902,13 @@  discard block
 block discarded – undo
1902 1902
 	 * Search element in database for shortcode insertion interface
1903 1903
 	 */
1904 1904
 	function ajax_wpshop_element_search() {
1905
-		check_ajax_referer( 'wpshop_element_search', 'wpshop_ajax_nonce' );
1905
+		check_ajax_referer('wpshop_element_search', 'wpshop_ajax_nonce');
1906 1906
 
1907 1907
 		$wpshop_element_searched = isset($_REQUEST['wpshop_element_searched']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_searched']) : null;
1908 1908
 		$wpshop_element_type = isset($_REQUEST['wpshop_element_type']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_type']) : null;
1909 1909
 		$wpshop_format_result = isset($_REQUEST['wpshop_format_result']) ? (bool)wpshop_tools::varSanitizer($_REQUEST['wpshop_format_result']) : true;
1910 1910
 
1911
-		switch ( $wpshop_element_type ) {
1911
+		switch ($wpshop_element_type) {
1912 1912
 			case 'product':
1913 1913
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
1914 1914
 				$data = wpshop_products::product_list($wpshop_format_result, $wpshop_element_searched);
@@ -1918,18 +1918,18 @@  discard block
 block discarded – undo
1918 1918
 				break;
1919 1919
 			case WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS:
1920 1920
 				$wps_provider_ctr = new wps_provider_ctr();
1921
-				$data = $wps_provider_ctr->read( array( 's' => $wpshop_element_searched ) );
1921
+				$data = $wps_provider_ctr->read(array('s' => $wpshop_element_searched));
1922 1922
 				break;
1923 1923
 		}
1924 1924
 
1925
-		if ( $wpshop_format_result ) {
1925
+		if ($wpshop_format_result) {
1926 1926
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1927 1927
 		}
1928 1928
 		else {
1929
-			if ( !empty($data) ) {
1929
+			if (!empty($data)) {
1930 1930
 				$temp_data = $data;
1931
-				unset( $data );
1932
-				foreach ( $temp_data as $post) {
1931
+				unset($data);
1932
+				foreach ($temp_data as $post) {
1933 1933
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1934 1934
 				}
1935 1935
 			}
@@ -1955,27 +1955,27 @@  discard block
 block discarded – undo
1955 1955
 
1956 1956
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
1957 1957
 		$product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1;
1958
-		$cart_option = get_option('wpshop_cart_option', array() );
1958
+		$cart_option = get_option('wpshop_cart_option', array());
1959 1959
 		$wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? $_POST['wps_pdt_variations'] : array();
1960
-		$from_administration =  ( !empty($_POST['from_admin']) ) ? true : false;
1961
-		$order_id =  ( !empty($_POST['wps_orders_order_id']) ) ? wpshop_tools::varSanitizer( $_POST['wps_orders_order_id'] ) : null;
1960
+		$from_administration = (!empty($_POST['from_admin'])) ? true : false;
1961
+		$order_id = (!empty($_POST['wps_orders_order_id'])) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null;
1962 1962
 
1963 1963
 
1964 1964
 		// Check Cart Animation
1965
-		$cart_animation_choice = ( !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
1966
-		if ( !empty($cart_option['total_nb_of_item_allowed']) && ($cart_option['total_nb_of_item_allowed'][0] == 'yes') ) {
1965
+		$cart_animation_choice = (!empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
1966
+		if (!empty($cart_option['total_nb_of_item_allowed']) && ($cart_option['total_nb_of_item_allowed'][0] == 'yes')) {
1967 1967
 			$wpshop_cart->empty_cart();
1968 1968
 		}
1969 1969
 
1970 1970
 		// Prepare Product to be added to cart
1971
-		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected );
1971
+		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected);
1972 1972
 		$product_to_add_to_cart = $formatted_product[0];
1973 1973
 		$new_pid = $formatted_product[1];
1974 1974
 
1975 1975
 		// Check cart Type
1976 1976
 		$cart_type_for_adding = 'normal';
1977
-		if (!empty($_POST['wpshop_cart_type']) ) {
1978
-			switch(wpshop_tools::varSanitizer($_POST['wpshop_cart_type'])){
1977
+		if (!empty($_POST['wpshop_cart_type'])) {
1978
+			switch (wpshop_tools::varSanitizer($_POST['wpshop_cart_type'])) {
1979 1979
 				case 'quotation':
1980 1980
 					$wpshop_cart_type = 'quotation';
1981 1981
 					break;
@@ -1986,43 +1986,43 @@  discard block
 block discarded – undo
1986 1986
 		}
1987 1987
 
1988 1988
 		// Check Product image
1989
-		$product = get_post( $product_id );
1990
-		$product_img = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="no picture" />';
1991
-		if ( !empty($product_id) ) {
1992
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
1993
-				$parent_def = wpshop_products::get_parent_variation( $product_id );
1994
-				$parent_post = ( !empty($parent_def['parent_post']) ) ? $parent_def['parent_post'] : array();
1995
-				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
1996
-				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
1997
-				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
1989
+		$product = get_post($product_id);
1990
+		$product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />';
1991
+		if (!empty($product_id)) {
1992
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
1993
+				$parent_def = wpshop_products::get_parent_variation($product_id);
1994
+				$parent_post = (!empty($parent_def['parent_post'])) ? $parent_def['parent_post'] : array();
1995
+				$product_title = (!empty($parent_post) && !empty($parent_post->post_title)) ? $parent_post->post_title : '';
1996
+				$product_description = (!empty($parent_post) && !empty($parent_post->post_content)) ? $parent_post->post_content : '';
1997
+				$product_img = (!empty($parent_post->ID)) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : '';
1998 1998
 			}
1999 1999
 			else {
2000 2000
 				$product_title = $product->post_title;
2001 2001
 				$product_description = $product->post_content;
2002
-				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
2002
+				$product_img = get_the_post_thumbnail($product_id, 'thumbnail');
2003 2003
 			}
2004 2004
 		}
2005 2005
 
2006 2006
 
2007
-		if ( !empty($_POST['wps_orders_from_admin']) && $_POST['wps_orders_from_admin'] == true) {
2007
+		if (!empty($_POST['wps_orders_from_admin']) && $_POST['wps_orders_from_admin'] == true) {
2008 2008
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2009
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type, array(), true, $order_meta, $order_id );
2009
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type, array(), true, $order_meta, $order_id);
2010 2010
 
2011
-			echo json_encode( array(true) );
2011
+			echo json_encode(array(true));
2012 2012
 			die();
2013 2013
 		}
2014 2014
 		else {
2015
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2015
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type);
2016 2016
 		}
2017 2017
 
2018
-		if ( $return == 'success' ) {
2019
-			$cart_page_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')) );
2018
+		if ($return == 'success') {
2019
+			$cart_page_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')));
2020 2020
 			/** Template parameters	*/
2021 2021
 			$template_part = 'product_added_to_cart_message';
2022 2022
 
2023 2023
 			/** Build template	*/
2024 2024
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2025
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2025
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2026 2026
 				/*	Include the old way template part	*/
2027 2027
 				ob_start();
2028 2028
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2041,14 +2041,14 @@  discard block
 block discarded – undo
2041 2041
 
2042 2042
 			/** Product Price **/
2043 2043
 			$product_price = '';
2044
-			if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart) ) {
2044
+			if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) {
2045 2045
 				$idp = '';
2046 2046
 
2047
-				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2047
+				if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) {
2048 2048
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2049 2049
 				}
2050 2050
 				else {
2051
-					if( strstr( $new_pid, '__') ) {
2051
+					if (strstr($new_pid, '__')) {
2052 2052
 						$idp = $new_pid;
2053 2053
 					}
2054 2054
 					else {
@@ -2056,43 +2056,43 @@  discard block
 block discarded – undo
2056 2056
 					}
2057 2057
 				}
2058 2058
 
2059
-				if( !empty($idp) ) {
2060
-					$default_currency = wpshop_tools::wpshop_get_currency( false );
2061
-					$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
2059
+				if (!empty($idp)) {
2060
+					$default_currency = wpshop_tools::wpshop_get_currency(false);
2061
+					$price_piloting_option = get_option('wpshop_shop_price_piloting');
2062 2062
 
2063 2063
 					$real_price = null;
2064
-					if ( !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid]['item_amount_to_pay_now'] ) ) {
2065
-						$real_price = ( $_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty );
2064
+					if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$new_pid]) && !empty($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'])) {
2065
+						$real_price = ($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty);
2066 2066
 					}
2067 2067
 
2068
-					$pr = empty( $real_price ) ? ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ht']  * $product_qty ) : ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty ) : $real_price;
2069
-					$product_price = wpshop_tools::formate_number( $pr ).$default_currency;
2068
+					$pr = empty($real_price) ? (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty) : ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty) : $real_price;
2069
+					$product_price = wpshop_tools::formate_number($pr) . $default_currency;
2070 2070
 				}
2071 2071
 			}
2072 2072
 			/** Check if there are linked products **/
2073
-			$related_products = get_post_meta( $product_id, '_wpshop_product_related_products', true);
2073
+			$related_products = get_post_meta($product_id, '_wpshop_product_related_products', true);
2074 2074
 			$tpl_component = array();
2075 2075
 			$linked_products = '';
2076
-			if ( !empty($related_products) ) {
2076
+			if (!empty($related_products)) {
2077 2077
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2078
-				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2078
+				$linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>';
2079 2079
 			}
2080 2080
 			else {
2081 2081
 				$linked_products = '';
2082 2082
 			}
2083 2083
 
2084
-			$message_confirmation = sprintf( __('%s has been add to the cart', 'wpshop'), $product->post_title );
2084
+			$message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title);
2085 2085
 
2086
-			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array( 'RELATED_PRODUCTS' => $linked_products , 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description) );
2087
-			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array() );
2086
+			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array('RELATED_PRODUCTS' => $linked_products, 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description));
2087
+			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array());
2088 2088
 
2089
-			$response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content );
2089
+			$response = array(true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content);
2090 2090
 		}
2091 2091
 		else {
2092
-			$response = array( false, $return );
2092
+			$response = array(false, $return);
2093 2093
 		}
2094 2094
 
2095
-		wp_die( json_encode( $response ) );
2095
+		wp_die(json_encode($response));
2096 2096
 	}
2097 2097
  	add_action('wp_ajax_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
2098 2098
 	add_action('wp_ajax_nopriv_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
@@ -2108,37 +2108,37 @@  discard block
 block discarded – undo
2108 2108
 		$product_qty = isset($_POST['product_qty']) ? intval(wpshop_tools::varSanitizer($_POST['product_qty'])) : null;
2109 2109
 
2110 2110
 		$pid = $product_id;
2111
-		if (strpos($product_id,'__') !== false) {
2111
+		if (strpos($product_id, '__') !== false) {
2112 2112
 			//$pid = $_SESSION['cart']['order_items'][$product_id]['item_id'];
2113
-			foreach( $_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation ) {
2113
+			foreach ($_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation) {
2114 2114
 				$pid = $variation['product_id'];
2115 2115
 				break;
2116 2116
 			}
2117 2117
 		}
2118 2118
 
2119
-		if ( !empty($_POST['global_discount']) ) {
2119
+		if (!empty($_POST['global_discount'])) {
2120 2120
 			$_SESSION['cart']['pos_global_discount'] = $_POST['global_discount'];
2121 2121
 		}
2122 2122
 
2123 2123
 		if (!empty($product_id)) {
2124 2124
 			if (isset($product_qty)) {
2125
-				if ( $product_qty == 0 ) {
2126
-					$variation_of_product = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1) );
2127
-					if ( !empty($variation_of_product) ) {
2128
-						foreach ( $variation_of_product as $p_id) {
2125
+				if ($product_qty == 0) {
2126
+					$variation_of_product = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1));
2127
+					if (!empty($variation_of_product)) {
2128
+						foreach ($variation_of_product as $p_id) {
2129 2129
 							$wpshop_cart->set_product_qty($p_id->ID, $product_qty);
2130 2130
 						}
2131 2131
 					}
2132 2132
 				}
2133
-				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2133
+				$return = $wpshop_cart->set_product_qty($product_id, $product_qty, $pid);
2134 2134
 				$response[] = $return;
2135 2135
 			}
2136 2136
 			else {
2137 2137
 				$response[] = false;
2138
-				$response[] = __('Parameters error.','wpshop');
2138
+				$response[] = __('Parameters error.', 'wpshop');
2139 2139
 			}
2140 2140
 		}
2141
-		wp_die( json_encode( $response ) );
2141
+		wp_die(json_encode($response));
2142 2142
 	}
2143 2143
 	add_action('wp_ajax_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
2144 2144
 	add_action('wp_ajax_nopriv_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
@@ -2160,7 +2160,7 @@  discard block
 block discarded – undo
2160 2160
 	/**
2161 2161
 	 * Display mini cart widgte after doing an action on it
2162 2162
 	 */
2163
-	function ajax_wpshop_reload_mini_cart(){
2163
+	function ajax_wpshop_reload_mini_cart() {
2164 2164
 		echo wpshop_cart::mini_cart_content();
2165 2165
 		die();
2166 2166
 	}
@@ -2177,9 +2177,9 @@  discard block
 block discarded – undo
2177 2177
 		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? $_POST['wpshop_current_for_display'] : null;
2178 2178
 		$product_qty = isset($_POST['product_qty']) ? $_POST['product_qty'] : 1;
2179 2179
 
2180
-		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty );
2180
+		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty);
2181 2181
 
2182
-		wp_die( json_encode( $product_variation_summary ) );
2182
+		wp_die(json_encode($product_variation_summary));
2183 2183
 	}
2184 2184
 	add_action('wp_ajax_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
2185 2185
 	add_action('wp_ajax_nopriv_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
@@ -2192,18 +2192,18 @@  discard block
 block discarded – undo
2192 2192
 		$display = '';
2193 2193
 		$attribute_for_detail = isset($_POST['attribute_for_detail']) ? $_POST['attribute_for_detail'] : null;
2194 2194
 
2195
-		if ( !empty( $attribute_for_detail ) ) {
2195
+		if (!empty($attribute_for_detail)) {
2196 2196
 			$selection = array();
2197
-			foreach ( $attribute_for_detail as $selected_variation ) {
2197
+			foreach ($attribute_for_detail as $selected_variation) {
2198 2198
 				$variation_definition = explode('-_variation_val_-', $selected_variation);
2199 2199
 				$attribute_definition = wpshop_attributes::getElement($variation_definition[0], "'valid'", 'code');
2200 2200
 				$post_definition = get_post($variation_definition[1]);
2201 2201
 
2202
-				if ( !empty($post_definition) ) {
2203
-					$post_content = ( !empty($post_definition) && !empty($post_definition->post_content) ) ? $post_definition->post_content : '';
2204
-					if ( empty($post_content) && !empty($post_definition->post_parent) ) {
2202
+				if (!empty($post_definition)) {
2203
+					$post_content = (!empty($post_definition) && !empty($post_definition->post_content)) ? $post_definition->post_content : '';
2204
+					if (empty($post_content) && !empty($post_definition->post_parent)) {
2205 2205
 						$post_parent_definition = get_post($post_definition->post_parent);
2206
-						if ( !empty($post_parent_definition) ) {
2206
+						if (!empty($post_parent_definition)) {
2207 2207
 							$post_content = $post_parent_definition->post_content;
2208 2208
 						}
2209 2209
 					}
@@ -2230,72 +2230,72 @@  discard block
 block discarded – undo
2230 2230
 	 * Save customer account informations
2231 2231
 	 */
2232 2232
 	function wpshop_ajax_save_customer_account() {
2233
-		check_ajax_referer( 'wpshop_customer_register', 'wpshop_ajax_nonce' );
2233
+		check_ajax_referer('wpshop_customer_register', 'wpshop_ajax_nonce');
2234 2234
 		global $wpshop, $wpshop_account, $wpdb;
2235
-		$reponse='';
2235
+		$reponse = '';
2236 2236
 		$status = false;
2237 2237
 		$validate = true;
2238 2238
 
2239 2239
 		$user_id = get_current_user_id();
2240
-		$current_connected_user = !empty( $user_id ) ? $user_id : null;
2240
+		$current_connected_user = !empty($user_id) ? $user_id : null;
2241 2241
 		$wpshop_billing_address = get_option('wpshop_billing_address');
2242
-		if ( !empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($_POST['attribute'][$wpshop_billing_address['choice']]) ) {
2243
-			if ( !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) ) {
2244
-				$address_fields = wps_address::get_addresss_form_fields_by_type ( $wpshop_billing_address['choice'] );
2242
+		if (!empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($_POST['attribute'][$wpshop_billing_address['choice']])) {
2243
+			if (!empty($wpshop_billing_address['integrate_into_register_form_matching_field'])) {
2244
+				$address_fields = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2245 2245
 				$address_field = $address_fields[$wpshop_billing_address['choice']];
2246 2246
 				$temp_aray_for_matching = array_flip($wpshop_billing_address['integrate_into_register_form_matching_field']);
2247
-				foreach ( $address_field as $group_id => $group_detail) {
2248
-					foreach ( $group_detail['content'] as $attribute_build_code => $attribute_def) {
2249
-						if ( in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty( $_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] ) && !empty(  $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]] ) ) {
2247
+				foreach ($address_field as $group_id => $group_detail) {
2248
+					foreach ($group_detail['content'] as $attribute_build_code => $attribute_def) {
2249
+						if (in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']]) && !empty($_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]])) {
2250 2250
 							$_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] = $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]];
2251
-							if ( $attribute_def['_need_verification'] == 'yes' && !empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2']) ) {
2251
+							if ($attribute_def['_need_verification'] == 'yes' && !empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'])) {
2252 2252
 								$_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'] = $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code] . '2'];
2253 2253
 							}
2254 2254
 						}
2255 2255
 					}
2256 2256
 				}
2257
-				$_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty( $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] ) ? $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2257
+				$_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty($_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title']) ? $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2258 2258
 			}
2259 2259
 			$group = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2260 2260
 			$validate = false;
2261
-			foreach ( $group as $attribute_sets ) {
2262
-				foreach ( $attribute_sets as $attribute_set_field ) {
2261
+			foreach ($group as $attribute_sets) {
2262
+				foreach ($attribute_sets as $attribute_set_field) {
2263 2263
 					$validate = $wpshop->validateForm($attribute_set_field['content'], $_POST['attribute'][$wpshop_billing_address['choice']], '');
2264 2264
 				}
2265 2265
 			}
2266 2266
 		}
2267
-		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') )) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2267
+		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2268 2268
 
2269 2269
 
2270
-		$validate_personal_form_infos = ( !empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial' ) ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2271
-		if( $validate && $validate_personal_form_infos ) {
2272
-			$account_creation_result = $wpshop_account->save_account_form($user_id,  ( ( !empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial' ) ? 'partial' : 'complete') );
2270
+		$validate_personal_form_infos = (!empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial') ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2271
+		if ($validate && $validate_personal_form_infos) {
2272
+			$account_creation_result = $wpshop_account->save_account_form($user_id, ((!empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial') ? 'partial' : 'complete'));
2273 2273
 			$status = $account_creation_result[0];
2274 2274
 			$user_id = $account_creation_result[1];
2275
-			$is_partial_account_creation  = $account_creation_result[2];
2276
-			if ( $is_partial_account_creation == 'partial' ) {
2275
+			$is_partial_account_creation = $account_creation_result[2];
2276
+			if ($is_partial_account_creation == 'partial') {
2277 2277
 				$permalink_option = get_option('permalink_structure');
2278
-				if ( !empty($permalink_option) ) {
2279
-					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2278
+				if (!empty($permalink_option)) {
2279
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '?complete_sign_up=ok';
2280 2280
 				}
2281 2281
 				else {
2282
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2282
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '&complete_sign_up=ok';
2283 2283
 				}
2284 2284
 			}
2285 2285
 			else {
2286
-				if ( !empty($_SESSION['cart']) ) {
2287
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2286
+				if (!empty($_SESSION['cart'])) {
2287
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')));
2288 2288
 				}
2289 2289
 				else {
2290
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2290
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2291 2291
 				}
2292 2292
 			}
2293 2293
 			// check if the customer have already register an address
2294
-			$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2294
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2295 2295
 			$exist_address = $wpdb->get_results($query);
2296 2296
 		}
2297 2297
 		// If there is errors
2298
-		if($wpshop->error_count()>0) {
2298
+		if ($wpshop->error_count() > 0) {
2299 2299
 			$reponse = $wpshop->show_messages();
2300 2300
 		}
2301 2301
 
@@ -2312,24 +2312,24 @@  discard block
 block discarded – undo
2312 2312
 	function wpshop_ajax_order_customer_adress_load() {
2313 2313
 		global $wpshop_account;
2314 2314
 		global $wpdb;
2315
-		check_ajax_referer( 'wpshop_order_customer_adress_load', 'wpshop_ajax_nonce' );
2316
-		$current_customer_id = !empty( $_REQUEST['customer_id'] ) ? $_REQUEST['customer_id'] : 0;
2317
-		$order_id = !empty( $_REQUEST['order_id'] ) ? $_REQUEST['order_id'] : 0;
2315
+		check_ajax_referer('wpshop_order_customer_adress_load', 'wpshop_ajax_nonce');
2316
+		$current_customer_id = !empty($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : 0;
2317
+		$order_id = !empty($_REQUEST['order_id']) ? $_REQUEST['order_id'] : 0;
2318 2318
 
2319
-		$order_postmeta = get_post_meta ($order_id, '_order_postmeta', true);
2320
-		$order_infos_postmeta = get_post_meta ($order_id, '_order_info', true);
2319
+		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
2320
+		$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
2321 2321
 
2322
-		if ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded')) ) {
2322
+		if (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded'))) {
2323 2323
 			/** Billing address display **/
2324 2324
 			$tpl_component['ADDRESS_COMBOBOX'] = '';
2325 2325
 			$tpl_component['ADDRESS_BUTTONS'] = '';
2326 2326
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Billing address', 'wpshop');
2327 2327
 			$tpl_component['ADDRESS_TYPE'] = 'billing_address';
2328 2328
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['billing']['id']);
2329
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['billing']['address'] );
2329
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['billing']['address']);
2330 2330
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2331
-			$retour =  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2332
-			unset( $tpl_component );
2331
+			$retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2332
+			unset($tpl_component);
2333 2333
 
2334 2334
 			/** Shipping address display **/
2335 2335
 			$retour .= '<div id="shipping_infos_bloc" class="wpshop_order_customer_container wpshop_order_customer_container_user_information">';
@@ -2338,66 +2338,66 @@  discard block
 block discarded – undo
2338 2338
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Shipping address', 'wpshop');
2339 2339
 			$tpl_component['ADDRESS_TYPE'] = 'shipping_address';
2340 2340
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['shipping']['id']);
2341
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['shipping']['address']);
2341
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['shipping']['address']);
2342 2342
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2343
-			$retour .=  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2344
-			unset( $tpl_component );
2343
+			$retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2344
+			unset($tpl_component);
2345 2345
 			$retour .= '</div>';
2346 2346
 			$retour .= '<div class="wpshop_cls"></div>';
2347
-			$result = json_encode( array(true, $retour) );
2347
+			$result = json_encode(array(true, $retour));
2348 2348
 
2349 2349
 		}
2350 2350
 
2351
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2351
+ 		elseif (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2352 2352
  			$order_info_postmeta = get_post_meta($_REQUEST['order_id'], '_order_info', true);
2353 2353
 
2354 2354
  			$billing_id_attribute_set = get_option('wpshop_billing_address');
2355 2355
  			$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2356 2356
 
2357
- 			$order_billing_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address']) ) ? $order_info_postmeta['billing']['address'] : array();
2358
- 			$order_shipping_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address']) ) ? $order_info_postmeta['shipping']['address'] : array();
2357
+ 			$order_billing_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address'])) ? $order_info_postmeta['billing']['address'] : array();
2358
+ 			$order_shipping_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address'])) ? $order_info_postmeta['shipping']['address'] : array();
2359 2359
 
2360
- 			$billing_form = $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address );
2361
- 			if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2362
- 				$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address );
2360
+ 			$billing_form = $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address);
2361
+ 			if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2362
+ 				$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address);
2363 2363
  			}
2364 2364
 
2365
- 			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2365
+ 			$result = json_encode(array(true, $billing_form, $shipping_form, $current_customer_id));
2366 2366
  		}
2367 2367
 		else {
2368 2368
 				// Check the attribute set id of Billing Address
2369
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2369
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Billing address', 'wpshop') . '"', '');
2370 2370
 				$attribute_set_id = $wpdb->get_var($query);
2371 2371
 				$billing_id_attribute_set = get_option('wpshop_billing_address');
2372 2372
 				//Check the billing address id of the customer
2373
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2373
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2374 2374
 				$post_addresses = $wpdb->get_results($query);
2375 2375
 				$address_id = '';
2376
-				foreach ( $post_addresses as $post_address ) {
2377
-					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2378
-					if ( $address_type == $attribute_set_id ) {
2376
+				foreach ($post_addresses as $post_address) {
2377
+					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2378
+					if ($address_type == $attribute_set_id) {
2379 2379
 						$address_id = $post_address->ID;
2380 2380
 					}
2381 2381
 				}
2382 2382
 				$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2383 2383
 				$shipping_form = '';
2384
-				if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2384
+				if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2385 2385
 					// Check the attribute set id of Shipping Address
2386
-					$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Shipping address', 'wpshop'). '"', '');
2386
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Shipping address', 'wpshop') . '"', '');
2387 2387
 					$attribute_set_id = $wpdb->get_var($query);
2388 2388
 					//Check the billing address id of the customer
2389
-					$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2389
+					$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2390 2390
 					$post_addresses = $wpdb->get_results($query);
2391 2391
 					$shipping_address_id = '';
2392
-					foreach ( $post_addresses as $post_address ) {
2393
-						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2394
-						if ( $address_type == $attribute_set_id ) {
2392
+					foreach ($post_addresses as $post_address) {
2393
+						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2394
+						if ($address_type == $attribute_set_id) {
2395 2395
 							$shipping_address_id = $post_address->ID;
2396 2396
 						}
2397 2397
 					}
2398
-					$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], $shipping_address_id );
2398
+					$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], $shipping_address_id);
2399 2399
 				}
2400
-				$result = json_encode( array(true, $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], $address_id ), $shipping_form, $current_customer_id) );
2400
+				$result = json_encode(array(true, $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], $address_id), $shipping_form, $current_customer_id));
2401 2401
 		}
2402 2402
 		echo $result;
2403 2403
 		die();
@@ -2409,22 +2409,22 @@  discard block
 block discarded – undo
2409 2409
 	 */
2410 2410
 	function ajax_wpshop_add_entity() {
2411 2411
 		global $wpdb;
2412
-		check_ajax_referer( 'wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce' );
2412
+		check_ajax_referer('wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce');
2413 2413
 
2414 2414
 		$attributes = array();
2415 2415
 		/** Get the attribute to create	*/
2416 2416
 		$attribute_to_reload = null;
2417
-		if ( !empty($_POST['attribute']['new_value_creation']) && is_array( $_POST['attribute']['new_value_creation'] ) ) {
2418
-			foreach ( $_POST['attribute']['new_value_creation'] as $attribute_code=>$value) {
2419
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', $attribute_code);
2417
+		if (!empty($_POST['attribute']['new_value_creation']) && is_array($_POST['attribute']['new_value_creation'])) {
2418
+			foreach ($_POST['attribute']['new_value_creation'] as $attribute_code=>$value) {
2419
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $attribute_code);
2420 2420
 				$attribute_def = $wpdb->get_row($query);
2421
-				if ( $value != "" ) {
2422
-					if ( $attribute_def->data_type_to_use == 'internal' ) {
2421
+				if ($value != "") {
2422
+					if ($attribute_def->data_type_to_use == 'internal') {
2423 2423
 						$attribute_default_value = unserialize($attribute_def->default_value);
2424
-						if ( $attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) {
2425
-							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2426
-							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2427
-							$attribute_option_id = $wpdb->get_var( $query );
2424
+						if ($attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
2425
+							$user_id = wp_create_user(sanitize_user($value), wp_generate_password(12, false));
2426
+							$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id);
2427
+							$attribute_option_id = $wpdb->get_var($query);
2428 2428
 						}
2429 2429
 						else {
2430 2430
 							$entity_args = array(
@@ -2437,13 +2437,13 @@  discard block
 block discarded – undo
2437 2437
 						}
2438 2438
 					}
2439 2439
 					else {
2440
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) );
2440
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value));
2441 2441
 						$attribute_option_id = $wpdb->insert_id;
2442 2442
 					}
2443 2443
 
2444
-					foreach ( $_POST['attribute'] as $attribute => $val) {
2444
+					foreach ($_POST['attribute'] as $attribute => $val) {
2445 2445
 						foreach ($val as $k=>$v) {
2446
-							if ( $k == $attribute_code) {
2446
+							if ($k == $attribute_code) {
2447 2447
 								$_POST['attribute'][$attribute][$k] = $attribute_option_id;
2448 2448
 							}
2449 2449
 						}
@@ -2452,10 +2452,10 @@  discard block
 block discarded – undo
2452 2452
 			}
2453 2453
 		}
2454 2454
 		/** Store send attribute into a new array for save purpose	*/
2455
-		if ( is_array( $_POST['attribute'] ) ) {
2456
-			foreach ( $_POST['attribute'] as $attribute_type => $attribute ) {
2457
-				foreach ( $attribute as $attribute_code => $attribute_value ) {
2458
-					if ( !isset( $attributes[$attribute_code] ) ) {
2455
+		if (is_array($_POST['attribute'])) {
2456
+			foreach ($_POST['attribute'] as $attribute_type => $attribute) {
2457
+				foreach ($attribute as $attribute_code => $attribute_value) {
2458
+					if (!isset($attributes[$attribute_code])) {
2459 2459
 						$attributes[$attribute_code] = $attribute_value;
2460 2460
 					}
2461 2461
 				}
@@ -2463,66 +2463,66 @@  discard block
 block discarded – undo
2463 2463
 		}
2464 2464
 
2465 2465
 		/** Save the new entity into database */
2466
-		$result = wpshop_entities::create_new_entity( $_POST['entity_type'], $_POST['wp_fields']['post_title'], '', $attributes, array('attribute_set_id' => $_POST['attribute_set_id']) );
2466
+		$result = wpshop_entities::create_new_entity($_POST['entity_type'], $_POST['wp_fields']['post_title'], '', $attributes, array('attribute_set_id' => $_POST['attribute_set_id']));
2467 2467
 		$new_entity_id = $result[1];
2468 2468
 
2469
-		if ( !empty($new_entity_id) ) {
2469
+		if (!empty($new_entity_id)) {
2470 2470
 			/**	Save address for current entity	*/
2471
-			if ( !empty( $_POST['type_of_form'] ) && !empty( $_POST['attribute'][$_POST['type_of_form']] ) ) {
2471
+			if (!empty($_POST['type_of_form']) && !empty($_POST['attribute'][$_POST['type_of_form']])) {
2472 2472
 				global $wpshop_account;
2473
-				$result = wps_address::wps_address( $_POST['type_of_form'] );
2474
-				update_post_meta ($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2473
+				$result = wps_address::wps_address($_POST['type_of_form']);
2474
+				update_post_meta($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2475 2475
 			}
2476 2476
 
2477 2477
 			/** Make price calculation if entity is a product	*/
2478
-			if ( $_POST['entity_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2478
+			if ($_POST['entity_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2479 2479
 				$wpshop_prices_attribute = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2480 2480
 				$calculate_price = false;
2481
-				foreach( $wpshop_prices_attribute as $attribute_price_code ){
2482
-					if ( array_key_exists($attribute_price_code, $attributes) ) {
2481
+				foreach ($wpshop_prices_attribute as $attribute_price_code) {
2482
+					if (array_key_exists($attribute_price_code, $attributes)) {
2483 2483
 						$calculate_price = true;
2484 2484
 					}
2485 2485
 				}
2486
-				if ( $calculate_price ) {
2486
+				if ($calculate_price) {
2487 2487
 					wpshop_products::calculate_price($new_entity_id);
2488 2488
 				}
2489 2489
 			}
2490 2490
 
2491 2491
 			/** Add picture if a file has been send	*/
2492
-			if ( !empty($_FILES) ) {
2492
+			if (!empty($_FILES)) {
2493 2493
 				$wp_upload_dir = wp_upload_dir();
2494 2494
 				$final_dir = $wp_upload_dir['path'] . '/';
2495
-				if ( !is_dir($final_dir) ) {
2495
+				if (!is_dir($final_dir)) {
2496 2496
 					mkdir($final_dir, 0755, true);
2497 2497
 				}
2498 2498
 
2499
-				foreach ( $_FILES as $file ) {
2499
+				foreach ($_FILES as $file) {
2500 2500
 					$tmp_name = $file['tmp_name']['post_thumbnail'];
2501 2501
 					$name = $file['name']['post_thumbnail'];
2502 2502
 
2503 2503
 					$filename = $final_dir . $name;
2504 2504
 					@move_uploaded_file($tmp_name, $filename);
2505 2505
 
2506
-					$wp_filetype = wp_check_filetype(basename($filename), null );
2506
+					$wp_filetype = wp_check_filetype(basename($filename), null);
2507 2507
 					$attachment = array(
2508
-						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ),
2508
+						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path($filename),
2509 2509
 						'post_mime_type' => $wp_filetype['type'],
2510
-						'post_title' => preg_replace( '/\.[^.]+$/', '', basename($filename) ),
2510
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
2511 2511
 						'post_content' => '',
2512 2512
 						'post_status' => 'inherit'
2513 2513
 					);
2514
-					$attach_id = wp_insert_attachment( $attachment, $filename, $new_entity_id );
2514
+					$attach_id = wp_insert_attachment($attachment, $filename, $new_entity_id);
2515 2515
 					require_once(ABSPATH . 'wp-admin/includes/image.php');
2516
-					$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
2517
-					wp_update_attachment_metadata( $attach_id, $attach_data );
2516
+					$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
2517
+					wp_update_attachment_metadata($attach_id, $attach_data);
2518 2518
 					add_post_meta($new_entity_id, '_thumbnail_id', $attach_id, true);
2519 2519
 				}
2520 2520
 			}
2521 2521
 
2522
-			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2522
+			echo json_encode(array(true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id));
2523 2523
 		}
2524 2524
 		else {
2525
-			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2525
+			echo json_encode(array(false, __('An error occured while adding your element', 'wpshop')));
2526 2526
 		}
2527 2527
 
2528 2528
 		die();
@@ -2532,43 +2532,43 @@  discard block
 block discarded – undo
2532 2532
 
2533 2533
 	function ajax_wpshop_reload_attribute_for_quick_add() {
2534 2534
 		$output = '';
2535
-		if ( !empty($_POST['attribute_to_reload']) ) {
2536
-			foreach ( $_POST['attribute_to_reload'] as $attribute_code ) {
2537
-				$attr_field = wpshop_attributes::display_attribute( $attribute_code, 'frontend' );
2535
+		if (!empty($_POST['attribute_to_reload'])) {
2536
+			foreach ($_POST['attribute_to_reload'] as $attribute_code) {
2537
+				$attr_field = wpshop_attributes::display_attribute($attribute_code, 'frontend');
2538 2538
 				$output[$attribute_code]['result'] = $attr_field['field_definition']['output'] . $attr_field['field_definition']['options'];
2539 2539
 			}
2540 2540
 		}
2541
-		echo json_encode( array($output) );
2541
+		echo json_encode(array($output));
2542 2542
 		die();
2543 2543
 	}
2544 2544
 	add_action('wp_ajax_reload_attribute_for_quick_add', 'ajax_wpshop_reload_attribute_for_quick_add');
2545 2545
 
2546 2546
 	function ajax_wpshop_change_address() {
2547
-		$address_id = ( !empty($_POST['address_id']) ? wpshop_tools::varSanitizer($_POST['address_id']) : null);
2548
-		$address_type = ( !empty($_POST['address_type']) ? wpshop_tools::varSanitizer($_POST['address_type']) : null);
2549
-		$is_allowed_destination  = true;
2550
-		if ( !empty($address_id) && !empty($address_type) ) {
2547
+		$address_id = (!empty($_POST['address_id']) ? wpshop_tools::varSanitizer($_POST['address_id']) : null);
2548
+		$address_type = (!empty($_POST['address_type']) ? wpshop_tools::varSanitizer($_POST['address_type']) : null);
2549
+		$is_allowed_destination = true;
2550
+		if (!empty($address_id) && !empty($address_type)) {
2551 2551
 			//Check if it's an allowed address for shipping
2552 2552
 			$checkout_payment_button = '';
2553
-			$cart_type = (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type']=='quotation') ? 'quotation' : 'cart';
2554
-			$is_allowed_destination = true;//wpshop_shipping_configuration::is_allowed_country ( $address_id );
2555
-			if ( $is_allowed_destination ) {
2553
+			$cart_type = (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') ? 'quotation' : 'cart';
2554
+			$is_allowed_destination = true; //wpshop_shipping_configuration::is_allowed_country ( $address_id );
2555
+			if ($is_allowed_destination) {
2556 2556
 				$available_payement_method = wpshop_payment::display_payment_methods_choice_form(0, $cart_type);
2557 2557
 				//if(!empty($available_payement_method[1]['paypal']) || !empty($available_payement_method[1]['banktransfer']) || !empty($available_payement_method[1]['checks']) || WPSHOP_PAYMENT_METHOD_CIC || !empty($available_payement_method[1]['cic']) || ($cart_type == 'quotation')) {
2558
-				if ( !empty($available_payement_method[0]) ) {
2559
-					if ( $cart_type=='quotation' ) {
2560
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2558
+				if (!empty($available_payement_method[0])) {
2559
+					if ($cart_type == 'quotation') {
2560
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array());
2561 2561
 					}
2562 2562
 					else {
2563
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2563
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array());
2564 2564
 					}
2565 2565
 				}
2566 2566
 			}
2567 2567
 			else {
2568 2568
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2569 2569
 			}
2570
-			if( $address_type == 'billing_address') {
2571
-				$billing_option = get_option( 'wpshop_billing_address' );
2570
+			if ($address_type == 'billing_address') {
2571
+				$billing_option = get_option('wpshop_billing_address');
2572 2572
 				$address_option = $billing_option['choice'];
2573 2573
 			}
2574 2574
 			else {
@@ -2576,16 +2576,16 @@  discard block
 block discarded – undo
2576 2576
 				$address_option = $shipping_address_option['choice'];
2577 2577
 			}
2578 2578
 			$add = wps_address::get_addresss_form_fields_by_type($address_option);
2579
-			$address_infos = get_post_meta($address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
2580
-			$retour = wpshop_account::display_an_address ( $add, $address_infos, $address_id);
2579
+			$address_infos = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
2580
+			$retour = wpshop_account::display_an_address($add, $address_infos, $address_id);
2581 2581
 
2582 2582
 			$_SESSION[$address_type] = $address_id;
2583 2583
 
2584
-			$edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&amp;id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>';
2585
-			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2584
+			$edit_link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?') === false ? '?' : '&') . 'action=editAddress&amp;id=' . $address_id . '" title="' . __('Edit', 'wpshop') . '">' . __('Edit', 'wpshop') . '</a>';
2585
+			$result = json_encode(array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button));
2586 2586
 		}
2587 2587
 		else {
2588
-			$result = json_encode( array(false, 'missing_informations') );
2588
+			$result = json_encode(array(false, 'missing_informations'));
2589 2589
 		}
2590 2590
 		echo $result;
2591 2591
 
@@ -2600,20 +2600,20 @@  discard block
 block discarded – undo
2600 2600
 
2601 2601
 		$tpl_component = array();
2602 2602
 		$tpl_component['LOADING_ICON'] = WPSHOP_LOADING_ICON;
2603
-		if ( !empty($billing_address) ) {
2604
-			echo wpshop_account::get_addresses_by_type( $billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2603
+		if (!empty($billing_address)) {
2604
+			echo wpshop_account::get_addresses_by_type($billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2605 2605
 		}
2606 2606
 		$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] = wpshop_account::display_form_fields($billing_address_option['choice'], '', 'first');
2607 2607
 
2608
-		if ( $shipping_address_option['activate'] ) {
2609
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> '.__('Use as shipping information','wpshop').'</label></p><br/>';
2608
+		if ($shipping_address_option['activate']) {
2609
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> ' . __('Use as shipping information', 'wpshop') . '</label></p><br/>';
2610 2610
 			$display = 'display:none;';
2611
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="'.$display.'">';
2611
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="' . $display . '">';
2612 2612
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= wpshop_account::display_form_fields($shipping_address_option['choice'], '', 'first');
2613 2613
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '</div><br/>';
2614 2614
 		}
2615 2615
 
2616
-		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save','wpshop') . '" /></p>';
2616
+		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save', 'wpshop') . '" /></p>';
2617 2617
 		$output = wpshop_display::display_template_element('wpshop_customer_addresses_form_admin', $tpl_component, array(), 'admin');
2618 2618
 		unset($tpl_component);
2619 2619
 		$result = json_encode(array(true, $output));
@@ -2624,13 +2624,13 @@  discard block
 block discarded – undo
2624 2624
 
2625 2625
 	function ajax_wpshop_create_new_customer() {
2626 2626
 		$result = '';
2627
-		if ( $_POST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'] != null ) {
2627
+		if ($_POST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'] != null) {
2628 2628
 			/** Crerate the new customer user account */
2629 2629
 			$username = $_REQUEST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'];
2630
-			$password = wp_generate_password( $length=12, $include_standard_special_chars=false );
2630
+			$password = wp_generate_password($length = 12, $include_standard_special_chars = false);
2631 2631
 			$email = $_REQUEST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'];
2632
-			if ( !empty($username) && !username_exists($username) && !empty($email) && !email_exists($email) ) {
2633
-				$user_id = wp_create_user( $username, $password, $email );
2632
+			if (!empty($username) && !username_exists($username) && !empty($email) && !email_exists($email)) {
2633
+				$user_id = wp_create_user($username, $password, $email);
2634 2634
 				$_REQUEST['user']['customer_id'] = $user_id;
2635 2635
 				/** Save addresses */
2636 2636
 				$billing_set_infos = get_option('wpshop_billing_address');
@@ -2640,21 +2640,21 @@  discard block
 block discarded – undo
2640 2640
 					wpshop_account::same_billing_and_shipping_address($_REQUEST['billing_address'], $_REQUEST['shipping_address']);
2641 2641
 				}
2642 2642
 
2643
-				if ( !empty($_POST['billing_address']) ) {
2644
-					wps_address::save_address_infos( $_REQUEST['billing_address'] );
2643
+				if (!empty($_POST['billing_address'])) {
2644
+					wps_address::save_address_infos($_REQUEST['billing_address']);
2645 2645
 				}
2646
-				if( !empty($_POST['shipping_address']) ) {
2647
-					wps_address::save_address_infos( $_REQUEST['shipping_address'] );
2646
+				if (!empty($_POST['shipping_address'])) {
2647
+					wps_address::save_address_infos($_REQUEST['shipping_address']);
2648 2648
 				}
2649
-				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2649
+				$result = json_encode(array(true, __('Customer created', 'wpshop'), $user_id));
2650 2650
 			}
2651 2651
 			else {
2652
-				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2652
+				$result = json_encode(array(false, __('A customer account is already created with this email address', 'wpshop')));
2653 2653
 			}
2654 2654
 
2655 2655
 		}
2656 2656
 		else {
2657
-			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2657
+			$result = json_encode(array(false, __('An email address is required', 'wpshop')));
2658 2658
 		}
2659 2659
 		echo $result;
2660 2660
 		die();
@@ -2664,25 +2664,25 @@  discard block
 block discarded – undo
2664 2664
 	/**
2665 2665
 	 * Send a message to customer
2666 2666
 	 */
2667
-	function ajax_wpshop_send_message_by_type () {
2667
+	function ajax_wpshop_send_message_by_type() {
2668 2668
 		global $wpdb;
2669 2669
 		$result = array();
2670
-		$message_type_id = ( !empty( $_POST['message_type_id'])) ? wpshop_tools::varSanitizer($_POST['message_type_id']) : null;
2671
-		$customer_id = ( !empty( $_POST['customer_user_id'])) ? wpshop_tools::varSanitizer($_POST['customer_user_id']) : null;
2672
-		$model_name = ( !empty( $_POST['message_model_name'])) ? wpshop_tools::varSanitizer($_POST['message_model_name']) : null;
2673
-		$order_id = ( !empty( $_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null;
2674
-		if ( !empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2670
+		$message_type_id = (!empty($_POST['message_type_id'])) ? wpshop_tools::varSanitizer($_POST['message_type_id']) : null;
2671
+		$customer_id = (!empty($_POST['customer_user_id'])) ? wpshop_tools::varSanitizer($_POST['customer_user_id']) : null;
2672
+		$model_name = (!empty($_POST['message_model_name'])) ? wpshop_tools::varSanitizer($_POST['message_model_name']) : null;
2673
+		$order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null;
2674
+		if (!empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2675 2675
 			$order_post_meta = get_post_meta($order_id, '_order_postmeta', true);
2676
-			$receiver_infos = get_userdata( $customer_id );
2676
+			$receiver_infos = get_userdata($customer_id);
2677 2677
 			$email = $receiver_infos->user_email;
2678 2678
 			$first_name = get_user_meta($customer_id, 'first_name', true);
2679 2679
 			$last_name = get_user_meta($customer_id, 'last_name', true);
2680 2680
 			$wps_message = new wps_message_ctr();
2681
-			$wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) );
2682
-			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2681
+			$wps_message->wpshop_prepared_email($email, $model_name, array('order_id' => $order_id, 'order_key' => ((!empty($order_post_meta) && !empty($order_post_meta['order_key'])) ? $order_post_meta['order_key'] : ''), 'order_date' => ((!empty($order_post_meta) && !empty($order_post_meta['order_date'])) ? $order_post_meta['order_date'] : ''), 'customer_first_name' => $first_name, 'customer_last_name' => $last_name));
2682
+			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id));
2683 2683
 		}
2684 2684
 		else {
2685
-			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2685
+			$result = array('status' => false, 'response' => __('An error occured', 'wpshop'));
2686 2686
 		}
2687 2687
 		echo json_encode($result);
2688 2688
 		die();
@@ -2692,18 +2692,18 @@  discard block
 block discarded – undo
2692 2692
 
2693 2693
 	function ajax_wpshop_upload_downloadable_file_action() {
2694 2694
 		$result = '';
2695
-		if ( !empty( $_FILES['wpshop_file'] ) && !empty($_POST['element_identifer']) ) {
2696
-			if(!is_dir(WPSHOP_UPLOAD_DIR)){
2695
+		if (!empty($_FILES['wpshop_file']) && !empty($_POST['element_identifer'])) {
2696
+			if (!is_dir(WPSHOP_UPLOAD_DIR)) {
2697 2697
 				mkdir(WPSHOP_UPLOAD_DIR, 0755, true);
2698 2698
 			}
2699 2699
 			$file = $_FILES['wpshop_file'];
2700 2700
 			$tmp_name = $file['tmp_name'];
2701
-			$name = sanitize_file_name( current_time( 'mysql', 0 ).'__'.$file["name"] );
2702
-			@move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR.$name);
2701
+			$name = sanitize_file_name(current_time('mysql', 0) . '__' . $file["name"]);
2702
+			@move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR . $name);
2703 2703
 
2704
-			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2705
-			update_post_meta( $_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n));
2706
-			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2704
+			$n = WPSHOP_UPLOAD_URL . '/' . $name;
2705
+			update_post_meta($_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n));
2706
+			$result = '<a href="' . $n . '" target="_blank" download>' . $name . '</a>';
2707 2707
 		}
2708 2708
 		else {
2709 2709
 			$result = '';
@@ -2714,20 +2714,20 @@  discard block
 block discarded – undo
2714 2714
 	add_action('wp_ajax_upload_downloadable_file_action', 'ajax_wpshop_upload_downloadable_file_action');
2715 2715
 
2716 2716
 	function ajax_wpshop_fill_the_downloadable_dialog() {
2717
-		$output  = '<form method="post" action="' .admin_url('admin-ajax.php') .'" name="" id="upload_downloadable_file" enctype="multipart/form-data" >';
2718
-		$output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>';
2717
+		$output  = '<form method="post" action="' . admin_url('admin-ajax.php') . '" name="" id="upload_downloadable_file" enctype="multipart/form-data" >';
2718
+		$output .= '<p class="formField"><label for="wpshop_file">' . __('Choose your file to send', 'wpshop') . '</label><input type="file" name="wpshop_file" /></p>';
2719 2719
 		$output .= '<input type="hidden" name="action" value="upload_downloadable_file_action" />';
2720
-		$output .= '<input type="hidden" name="element_identifer" id="element_identifer" value="' .$_POST['product_identifer']. '" />';
2721
-		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' .__('Send your file', 'wpshop'). '</a></p>';
2720
+		$output .= '<input type="hidden" name="element_identifer" id="element_identifer" value="' . $_POST['product_identifer'] . '" />';
2721
+		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' . __('Send your file', 'wpshop') . '</a></p>';
2722 2722
 		$output .= '</form>';
2723
-		$output .='<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2723
+		$output .= '<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2724 2724
 		beforeSubmit : function() { },success: function(response) {
2725 2725
 		jQuery("#send_downloadable_file_dialog").dialog("close");
2726 2726
 		jQuery(".statut").html( response );
2727 2727
 		}});</script>';
2728 2728
 
2729
-		$response = array( 'status' => true, 'response' => $output);
2730
-		echo json_encode( $response );
2729
+		$response = array('status' => true, 'response' => $output);
2730
+		echo json_encode($response);
2731 2731
 		die();
2732 2732
 	}
2733 2733
 	add_action('wp_ajax_fill_the_downloadable_dialog', 'ajax_wpshop_fill_the_downloadable_dialog');
@@ -2735,55 +2735,55 @@  discard block
 block discarded – undo
2735 2735
 	function ajax_wpshop_show_downloadable_interface_in_admin() {
2736 2736
 		global $wpdb;
2737 2737
 		$status = false;
2738
-		$selected_value = ( !empty($_POST['selected_value']) ) ? wpshop_tools::varSanitizer( $_POST['selected_value'] ) : '';
2739
-		$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $selected_value);
2740
-		$value = $wpdb->get_var( $query );
2738
+		$selected_value = (!empty($_POST['selected_value'])) ? wpshop_tools::varSanitizer($_POST['selected_value']) : '';
2739
+		$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $selected_value);
2740
+		$value = $wpdb->get_var($query);
2741 2741
 
2742
-		if ( !empty($value) && __( $value, 'wpshop') == __('Yes', 'wpshop') ) {
2742
+		if (!empty($value) && __($value, 'wpshop') == __('Yes', 'wpshop')) {
2743 2743
 			$status = true;
2744 2744
 		}
2745
-		$response = array( 'status' => $status );
2746
-		echo json_encode( $response );
2745
+		$response = array('status' => $status);
2746
+		echo json_encode($response);
2747 2747
 		die();
2748 2748
 	}
2749
-	add_action( 'wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2749
+	add_action('wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2750 2750
 
2751 2751
 	function ajax_wpshop_restart_the_order() {
2752 2752
 		global $wpshop_cart, $wpdb;
2753 2753
 		$status = $add_to_cart_checking = $manage_stock_checking_bool = false;
2754 2754
 		$add_to_cart_checking_message = '';
2755 2755
 		$result = __('Error, you cannot restart this order', 'wpshop');
2756
-		$order_id = ( !empty($_POST['order_id']) ) ? wpshop_tools::varSanitizer($_POST['order_id']) : null;
2757
-		$is_make_order_again = ( !empty($_POST['make_order_again']) ) ? wpshop_tools::varSanitizer( $_POST['make_order_again'] ) : null;
2758
-		if( !empty( $order_id ) ) {
2756
+		$order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null;
2757
+		$is_make_order_again = (!empty($_POST['make_order_again'])) ? wpshop_tools::varSanitizer($_POST['make_order_again']) : null;
2758
+		if (!empty($order_id)) {
2759 2759
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2760 2760
 			$_SESSION['cart'] = array();
2761 2761
 			$_SESSION['cart']['order_items'] = array();
2762 2762
 			$wpshop_cart_type = $order_meta['cart_type'];
2763 2763
 
2764
-			if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
2764
+			if (!empty($order_meta) && !empty($order_meta['order_items'])) {
2765 2765
 				$wpshop_cart_type = $order_meta['cart_type'];
2766
-				foreach( $order_meta['order_items'] as $item_key => $item ) {
2767
-					$item_meta = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true );
2768
-					$stock =  $item_meta['product_stock'];
2766
+				foreach ($order_meta['order_items'] as $item_key => $item) {
2767
+					$item_meta = get_post_meta($item['item_id'], '_wpshop_product_metadata', true);
2768
+					$stock = $item_meta['product_stock'];
2769 2769
 					$qty = $item['item_qty'];
2770
-					$item_option = get_post_meta( $item['item_id'], '_wpshop_product_options', true );
2771
-					if( !empty($item_meta['manage_stock']) ) {
2772
-						$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $item_meta['manage_stock']);
2773
-						$manage_stock_checking = $wpdb->get_var( $query );
2774
-						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2770
+					$item_option = get_post_meta($item['item_id'], '_wpshop_product_options', true);
2771
+					if (!empty($item_meta['manage_stock'])) {
2772
+						$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $item_meta['manage_stock']);
2773
+						$manage_stock_checking = $wpdb->get_var($query);
2774
+						if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2775 2775
 							$manage_stock_checking_bool = true;
2776 2776
 						}
2777 2777
 					}
2778 2778
 					else {
2779
-						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2780
-							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2781
-							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
2779
+						if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2780
+							$parent_product = wpshop_products::get_parent_variation($item['item_id']);
2781
+							if (!empty($parent_product) && !empty($parent_product['parent_post_meta'])) {
2782 2782
 								$parent_metadata = $parent_product['parent_post_meta'];
2783
-								if( !empty($parent_product['parent_post_meta']['manage_stock']) ) {
2784
-									$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2785
-									$manage_stock_checking = $wpdb->get_var( $query );
2786
-									if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2783
+								if (!empty($parent_product['parent_post_meta']['manage_stock'])) {
2784
+									$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2785
+									$manage_stock_checking = $wpdb->get_var($query);
2786
+									if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2787 2787
 										$manage_stock_checking_bool = true;
2788 2788
 										$stock = $parent_product['parent_post_meta']['product_stock'];
2789 2789
 									}
@@ -2796,8 +2796,8 @@  discard block
 block discarded – undo
2796 2796
 
2797 2797
 
2798 2798
 					/** Checking stock **/
2799
-					if ( empty($item_meta['manage_stock']) || ( !empty($item_meta['manage_stock']) && !$manage_stock_checking_bool )|| ( !empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty ) ) {
2800
-						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2799
+					if (empty($item_meta['manage_stock']) || (!empty($item_meta['manage_stock']) && !$manage_stock_checking_bool) || (!empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty)) {
2800
+						$_SESSION['cart']['order_items'][$item_key] = $item;
2801 2801
 					}
2802 2802
 					else {
2803 2803
 						$add_to_cart_checking = true;
@@ -2806,38 +2806,38 @@  discard block
 block discarded – undo
2806 2806
 				}
2807 2807
 
2808 2808
 				$wps_cart_ctr = new wps_cart();
2809
-				$order = $wps_cart_ctr->calcul_cart_information( array() );
2809
+				$order = $wps_cart_ctr->calcul_cart_information(array());
2810 2810
 				$order['cart_type'] = $wpshop_cart_type;
2811
-				$wps_cart_ctr->store_cart_in_session( $order );
2811
+				$wps_cart_ctr->store_cart_in_session($order);
2812 2812
 			}
2813 2813
 
2814
-			if ( empty($is_make_order_again) ) {
2814
+			if (empty($is_make_order_again)) {
2815 2815
 				$_SESSION['order_id'] = $order_id;
2816 2816
 			}
2817 2817
 			$status = true;
2818 2818
 
2819
-			$result = get_permalink( get_option('wpshop_cart_page_id') );
2819
+			$result = get_permalink(get_option('wpshop_cart_page_id'));
2820 2820
 		}
2821 2821
 
2822
-		$response = array( 'status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2823
-		echo json_encode( $response );
2822
+		$response = array('status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2823
+		echo json_encode($response);
2824 2824
 		die();
2825 2825
 	}
2826
-	add_action( 'wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2826
+	add_action('wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2827 2827
 
2828 2828
 
2829 2829
 
2830 2830
 	function wps_hide_notice_messages() {
2831 2831
 		$status = false;
2832
-		$indicator = !empty($_POST['indicator'] ) ? wpshop_tools::varSanitizer($_POST['indicator']) : null;
2833
-		if ( !empty($indicator) ) {
2832
+		$indicator = !empty($_POST['indicator']) ? wpshop_tools::varSanitizer($_POST['indicator']) : null;
2833
+		if (!empty($indicator)) {
2834 2834
 			$user_id = get_current_user_id();
2835
-			$hide_notice_meta = get_user_meta( $user_id, '_wps_hide_notice_messages_indicator', true);
2835
+			$hide_notice_meta = get_user_meta($user_id, '_wps_hide_notice_messages_indicator', true);
2836 2836
 			$hide_notice_meta = !empty($hide_notice_meta) ? $hide_notice_meta : array();
2837 2837
 			$indicators = explode(',', $indicator);
2838
-			if ( !empty($indicators) && is_array($indicators) ) {
2839
-				foreach( $indicators as $i ) {
2840
-					if ( !empty($i) ) {
2838
+			if (!empty($indicators) && is_array($indicators)) {
2839
+				foreach ($indicators as $i) {
2840
+					if (!empty($i)) {
2841 2841
 						$hide_notice_meta[$i] = true;
2842 2842
 					}
2843 2843
 				}
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
 			$status = true;
2847 2847
 		}
2848 2848
 		$response = array('status' => $status);
2849
-		echo json_encode( $response );
2849
+		echo json_encode($response);
2850 2850
 		die();
2851 2851
 	}
2852 2852
 	add_action('wp_ajax_wps_hide_notice_messages', 'wps_hide_notice_messages');
@@ -2855,99 +2855,99 @@  discard block
 block discarded – undo
2855 2855
 
2856 2856
 	function wps_update_products_prices() {
2857 2857
 		$action = wpshop_prices::mass_update_prices();
2858
-		$response = array( 'status' => $action[0], 'response' => $action[1] );
2859
-		echo json_encode( $response );
2858
+		$response = array('status' => $action[0], 'response' => $action[1]);
2859
+		echo json_encode($response);
2860 2860
 		die();
2861 2861
 	}
2862
-	add_action( 'wp_ajax_update_products_prices', 'wps_update_products_prices' );
2862
+	add_action('wp_ajax_update_products_prices', 'wps_update_products_prices');
2863 2863
 
2864 2864
 	/** Quotation is payable by customer **/
2865 2865
 	function wps_quotation_is_payable_by_customer() {
2866 2866
 		global $wpdb;
2867 2867
 		$status = false; $response = '';
2868
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
2869
-		if( !empty($_POST['order_id']) ) {
2870
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2871
-			if( isset( $order_metadata['pay_quotation'] ) ) {
2872
-				unset( $order_metadata['pay_quotation'] );
2868
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
2869
+		if (!empty($_POST['order_id'])) {
2870
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2871
+			if (isset($order_metadata['pay_quotation'])) {
2872
+				unset($order_metadata['pay_quotation']);
2873 2873
 			} else {
2874 2874
 				$order_metadata['pay_quotation'] = 'on';
2875 2875
 			}
2876
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
2876
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
2877 2877
 
2878
-			$response = wpshop_orders::display_customer_pay_quotation( isset( $order_metadata['pay_quotation'] ), $order_id );
2878
+			$response = wpshop_orders::display_customer_pay_quotation(isset($order_metadata['pay_quotation']), $order_id);
2879 2879
 			$status = true;
2880 2880
 		} else {
2881
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2881
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
2882 2882
 		}
2883
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
2883
+		echo json_encode(array('status' => $status, 'response' => $response));
2884 2884
 		die();
2885 2885
 	}
2886
-	add_action( 'wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer' );
2886
+	add_action('wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer');
2887 2887
 
2888 2888
 	/** Send a direct payment Link **/
2889 2889
 	function wps_send_direct_payment_link() {
2890 2890
 		global $wpdb;
2891 2891
 		$status = false; $response = '';
2892
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
2893
-		if( !empty($_POST['order_id']) ) {
2892
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
2893
+		if (!empty($_POST['order_id'])) {
2894 2894
 			/** Get the customer **/
2895
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2896
-			if( !empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) {
2897
-				$user_infos = get_userdata( $order_metadata['customer_id'] );
2895
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2896
+			if (!empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') {
2897
+				$user_infos = get_userdata($order_metadata['customer_id']);
2898 2898
 
2899
-				$first_name =  get_user_meta($user_infos->ID, 'first_name', true);
2900
-				$last_name =  get_user_meta($user_infos->ID, 'last_name', true);
2899
+				$first_name = get_user_meta($user_infos->ID, 'first_name', true);
2900
+				$last_name = get_user_meta($user_infos->ID, 'last_name', true);
2901 2901
 
2902 2902
 
2903 2903
 				/** Create an activation key **/
2904 2904
 				$token = wp_generate_password(20, false);
2905
-				$wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login) );
2905
+				$wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login));
2906 2906
 
2907
-				$permalink_option = get_option( 'permalink_structure' );
2908
-				$link = '<a href="' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ).( (!empty($permalink_option)) ? '?' : '&').'action=direct_payment_link&token=' .$token. '&login=' .rawurlencode( $user_infos->user_login). '&order_id=' .$order_id. '">' .__( 'Click here to pay your order', 'wpshop' ). '</a>';
2907
+				$permalink_option = get_option('permalink_structure');
2908
+				$link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . ((!empty($permalink_option)) ? '?' : '&') . 'action=direct_payment_link&token=' . $token . '&login=' . rawurlencode($user_infos->user_login) . '&order_id=' . $order_id . '">' . __('Click here to pay your order', 'wpshop') . '</a>';
2909 2909
 
2910 2910
 				/** Send message **/
2911 2911
 				$wps_message = new wps_message_ctr();
2912 2912
 				$wps_message->wpshop_prepared_email($user_infos->user_email,
2913 2913
 				'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE',
2914
-				array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '' )
2914
+				array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '')
2915 2915
 				);
2916 2916
 
2917
-				$response = __( 'Direct payment link has been send', 'wpshop' );
2917
+				$response = __('Direct payment link has been send', 'wpshop');
2918 2918
 				$status = true;
2919 2919
 			}
2920 2920
 			else {
2921
-				$response = __( 'An error was occured', 'wpshop' );
2921
+				$response = __('An error was occured', 'wpshop');
2922 2922
 			}
2923 2923
 		}
2924 2924
 		else {
2925
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2925
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
2926 2926
 		}
2927
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
2927
+		echo json_encode(array('status' => $status, 'response' => $response));
2928 2928
 		die();
2929 2929
 	}
2930
-	add_action( 'wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link' );
2930
+	add_action('wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link');
2931 2931
 
2932 2932
 	function wps_mass_action_product() {
2933 2933
 		$mass_actions_tools_page = '';
2934
-		$default_attributes = array( 'product_stock', 'barcode', 'product_price', 'special_price', );
2934
+		$default_attributes = array('product_stock', 'barcode', 'product_price', 'special_price',);
2935 2935
 
2936 2936
 		/**	Copy an attribute content to another	*/
2937
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_PRODUCT ), "'valid'", 'entity_id', true);
2938
-		if ( !empty( $attribute_list ) ) {
2937
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_PRODUCT), "'valid'", 'entity_id', true);
2938
+		if (!empty($attribute_list)) {
2939 2939
 			$mass_actions_tools_page .= '
2940
-			<form action="' . admin_url( "admin-ajax.php" ) . '" method="POST" id="wps_mass_action_on_entity_form" >
2940
+			<form action="' . admin_url("admin-ajax.php") . '" method="POST" id="wps_mass_action_on_entity_form" >
2941 2941
 				<input type="hidden" value="wps_mass_action_on_entity_launch" name="action" />
2942
-				<!--<div>' . __( 'Choose attribute to display into list', 'wpshop' ) . '
2942
+				<!--<div>' . __('Choose attribute to display into list', 'wpshop') . '
2943 2943
 					<ul>';
2944
-			foreach ( $attribute_list as $attribute ) {
2944
+			foreach ($attribute_list as $attribute) {
2945 2945
 				$mass_actions_tools_page .= '
2946
-						<li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked( in_array( $attribute->code, $default_attributes ), true, false ) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __( $attribute->frontend_label, 'wpshop' ) . '</li>';
2946
+						<li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked(in_array($attribute->code, $default_attributes), true, false) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __($attribute->frontend_label, 'wpshop') . '</li>';
2947 2947
 			}
2948 2948
 			$mass_actions_tools_page .= '
2949 2949
 					</ul>
2950
-					<button>' . __( 'Voir la liste des produits', 'wpshop' ) . '</button> -->
2950
+					<button>' . __('Voir la liste des produits', 'wpshop') . '</button> -->
2951 2951
 				</div>
2952 2952
 			</form>
2953 2953
 			<div id="wps_entity_list" >' . wps_mass_action_on_entity_launch() . '</div>
@@ -2960,29 +2960,29 @@  discard block
 block discarded – undo
2960 2960
 			</script>';
2961 2961
 		}
2962 2962
 
2963
-		wp_die( $mass_actions_tools_page );
2963
+		wp_die($mass_actions_tools_page);
2964 2964
 	}
2965
-	add_action( 'wp_ajax_wps_mass_action_product', 'wps_mass_action_product' );
2965
+	add_action('wp_ajax_wps_mass_action_product', 'wps_mass_action_product');
2966 2966
 
2967 2967
 	function wps_put_history_back() {
2968 2968
 		global $wpdb;
2969 2969
 		$upload_dir = wp_upload_dir();
2970
-		$log_dir = $upload_dir[ 'basedir' ] . '/wps_repair/';
2971
-		wp_mkdir_p( $log_dir );
2972
-		foreach ( $_POST[ 'value_to_take' ] as $product_id => $product_element ) {
2973
-			foreach( $product_element as $attribute_id => $attribute_value_to_take ){
2974
-				$query = $wpdb->prepare( "SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take );
2975
-				$the_new_value = $wpdb->get_row( $query );
2976
-				if ( 6 == $attribute_id ) {
2977
-					$query = $wpdb->prepare( "SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id );
2978
-					$the_tax = $wpdb->get_row( $query );
2979
-					$pttc = number_format( $the_new_value->value, 5, ".", " " );
2980
-					$ht = number_format( $pttc / ( 1 + ( $the_tax->value / 100 ) ), 5, ".", " " );
2981
-					$tax_amount = number_format( $pttc - $ht, 5, ".", " " );
2982
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 6 ) );
2983
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 28 ) );
2984
-					$wpdb->delete( 'wp_wpshop__attribute_value_integer', array( "entity_id" => $product_id, "attribute_id" => 29 ) );
2985
-					$wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 30 ) );
2970
+		$log_dir = $upload_dir['basedir'] . '/wps_repair/';
2971
+		wp_mkdir_p($log_dir);
2972
+		foreach ($_POST['value_to_take'] as $product_id => $product_element) {
2973
+			foreach ($product_element as $attribute_id => $attribute_value_to_take) {
2974
+				$query = $wpdb->prepare("SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take);
2975
+				$the_new_value = $wpdb->get_row($query);
2976
+				if (6 == $attribute_id) {
2977
+					$query = $wpdb->prepare("SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id);
2978
+					$the_tax = $wpdb->get_row($query);
2979
+					$pttc = number_format($the_new_value->value, 5, ".", " ");
2980
+					$ht = number_format($pttc / (1 + ($the_tax->value / 100)), 5, ".", " ");
2981
+					$tax_amount = number_format($pttc - $ht, 5, ".", " ");
2982
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 6));
2983
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 28));
2984
+					$wpdb->delete('wp_wpshop__attribute_value_integer', array("entity_id" => $product_id, "attribute_id" => 29));
2985
+					$wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 30));
2986 2986
 
2987 2987
 					$common_datas = array(
2988 2988
 						'value_id' => null,
@@ -2990,20 +2990,20 @@  discard block
 block discarded – undo
2990 2990
 						'entity_id' => $product_id,
2991 2991
 						'unit_id' => null,
2992 2992
 						'user_id' => 1,
2993
-						'creation_date_value' => current_time( "mysql", 0 ),
2993
+						'creation_date_value' => current_time("mysql", 0),
2994 2994
 						'language' => 'fr_FR',
2995 2995
 					);
2996 2996
 
2997
-					$content_to_write =  "
2998
-" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'ttc' => $pttc,  'ht' => $ht,  'tax_rate_id' => $the_tax->rate_id,  'tax_amount' => $tax_amount,  ) ). '';
2999
-					$fp = fopen( $log_dir . 'correction_prix.txt', 'a' );
3000
-					fwrite( $fp, $content_to_write );
3001
-					fclose( $fp );
2997
+					$content_to_write = "
2998
+" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('ttc' => $pttc, 'ht' => $ht, 'tax_rate_id' => $the_tax->rate_id, 'tax_amount' => $tax_amount,)) . '';
2999
+					$fp = fopen($log_dir . 'correction_prix.txt', 'a');
3000
+					fwrite($fp, $content_to_write);
3001
+					fclose($fp);
3002 3002
 
3003
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 6, 'value' => $pttc ) ) );
3004
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3005
-					$wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3006
-					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3003
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 6, 'value' => $pttc)));
3004
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 28, 'value' => $ht)));
3005
+					$wpdb->insert('wp_wpshop__attribute_value_integer', array_merge($common_datas, array('attribute_id' => 29, 'value' => $the_tax->rate_id)));
3006
+					$wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 30, 'value' => $tax_amount)));
3007 3007
 				}
3008 3008
 				else {
3009 3009
 					$common_datas = array(
@@ -3012,33 +3012,33 @@  discard block
 block discarded – undo
3012 3012
 						'entity_id' => $product_id,
3013 3013
 						'unit_id' => null,
3014 3014
 						'user_id' => 1,
3015
-						'creation_date_value' => current_time( "mysql", 0 ),
3015
+						'creation_date_value' => current_time("mysql", 0),
3016 3016
 						'language' => 'fr_FR',
3017 3017
 					);
3018
-					$wpdb->delete( $the_new_value->value_type, array( "entity_id" => $product_id, "attribute_id" => $attribute_id ) );
3019
-					$wpdb->insert( $the_new_value->value_type, array_merge( $common_datas, array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ) ) ) );
3020
-
3021
-					$content_to_write =  "
3022
-" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ),  ) ). '';
3023
-					$fp = fopen( $log_dir . 'correction_attribut.txt', 'a' );
3024
-					fwrite( $fp, $content_to_write );
3025
-					fclose( $fp );
3018
+					$wpdb->delete($the_new_value->value_type, array("entity_id" => $product_id, "attribute_id" => $attribute_id));
3019
+					$wpdb->insert($the_new_value->value_type, array_merge($common_datas, array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value))));
3020
+
3021
+					$content_to_write = "
3022
+" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value),)) . '';
3023
+					$fp = fopen($log_dir . 'correction_attribut.txt', 'a');
3024
+					fwrite($fp, $content_to_write);
3025
+					fclose($fp);
3026 3026
 				}
3027 3027
 			}
3028 3028
 		}
3029 3029
 		wp_die();
3030 3030
 	}
3031
-	add_action( 'wp_ajax_wps_put_history_back', 'wps_put_history_back' );
3031
+	add_action('wp_ajax_wps_put_history_back', 'wps_put_history_back');
3032 3032
 
3033 3033
 	function wps_mass_action_on_entity_launch() {
3034 3034
 		global $wpdb;
3035 3035
 		$response = '';
3036 3036
 		$element_to_output = array();
3037 3037
 
3038
-		$attributes_to_test = array( 'decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118' );
3038
+		$attributes_to_test = array('decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118');
3039 3039
 
3040 3040
 		$decimal_attribute = $attributes_to_test['decimal']; //,30,28
3041
-		$query = $wpdb->prepare( "
3041
+		$query = $wpdb->prepare("
3042 3042
 				SELECT P.ID, P.post_title,
3043 3043
 					D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3044 3044
 				FROM {$wpdb->posts} AS P
@@ -3052,21 +3052,21 @@  discard block
 block discarded – undo
3052 3052
 					AND H.value_type = 'wp_wpshop__attribute_value_decimal'
3053 3053
 
3054 3054
 				ORDER BY H.entity_id ASC, H.value_id DESC",
3055
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3055
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3056 3056
 		);
3057
-		 $list_of_element = $wpdb->get_results( $query );
3058
-		 if ( !empty( $list_of_element ) ) {
3059
-			foreach ( $list_of_element as $element ) {
3060
-				$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3061
-				$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3062
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3063
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3064
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3057
+		 $list_of_element = $wpdb->get_results($query);
3058
+		 if (!empty($list_of_element)) {
3059
+			foreach ($list_of_element as $element) {
3060
+				$element_to_output[$element->ID]['title'] = $element->post_title;
3061
+				$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3062
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3063
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3064
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3065 3065
 			}
3066 3066
 		}
3067 3067
 
3068 3068
 		$attribute_list = $attributes_to_test['varchar'];
3069
-		$query = $wpdb->prepare( "
3069
+		$query = $wpdb->prepare("
3070 3070
 			SELECT P.ID, P.post_title,
3071 3071
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3072 3072
 			FROM {$wpdb->posts} AS P
@@ -3079,22 +3079,22 @@  discard block
 block discarded – undo
3079 3079
 				AND H.value != ''
3080 3080
 				AND H.value_type = 'wp_wpshop__attribute_value_varchar'
3081 3081
 			ORDER BY H.creation_date",
3082
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3082
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3083 3083
 		);
3084
-		$list_of_element = $wpdb->get_results( $query );
3085
-		if ( !empty( $list_of_element ) ) {
3086
-			foreach ( $list_of_element as $element ) {
3087
-			 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3088
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3089
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3090
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3091
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3084
+		$list_of_element = $wpdb->get_results($query);
3085
+		if (!empty($list_of_element)) {
3086
+			foreach ($list_of_element as $element) {
3087
+			 	$element_to_output[$element->ID]['title'] = $element->post_title;
3088
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3089
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3090
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3091
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3092 3092
 			}
3093 3093
 		}
3094 3094
 
3095 3095
 
3096 3096
 		$attribute_list = $attributes_to_test['text'];
3097
-		$query = $wpdb->prepare( "
3097
+		$query = $wpdb->prepare("
3098 3098
 				SELECT P.ID, P.post_title,
3099 3099
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3100 3100
 				FROM {$wpdb->posts} AS P
@@ -3107,21 +3107,21 @@  discard block
 block discarded – undo
3107 3107
 				AND H.value != ''
3108 3108
 				AND H.value_type = 'wp_wpshop__attribute_value_text'
3109 3109
 			ORDER BY H.creation_date",
3110
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3110
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3111 3111
 		);
3112
-		$list_of_element = $wpdb->get_results( $query );
3113
-		if ( !empty( $list_of_element ) ) {
3114
-		foreach ( $list_of_element as $element ) {
3115
-		 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3116
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3117
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3118
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3119
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3112
+		$list_of_element = $wpdb->get_results($query);
3113
+		if (!empty($list_of_element)) {
3114
+		foreach ($list_of_element as $element) {
3115
+		 	$element_to_output[$element->ID]['title'] = $element->post_title;
3116
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3117
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3118
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3119
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3120 3120
 		 	}
3121 3121
 		}
3122 3122
 
3123 3123
 		$attribute_list = $attributes_to_test['integer'];
3124
-		$query = $wpdb->prepare( "
3124
+		$query = $wpdb->prepare("
3125 3125
 				SELECT P.ID, P.post_title,
3126 3126
 				D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value
3127 3127
 				FROM {$wpdb->posts} AS P
@@ -3134,21 +3134,21 @@  discard block
 block discarded – undo
3134 3134
 				AND H.value != ''
3135 3135
 				AND H.value_type = 'wp_wpshop__attribute_value_integer'
3136 3136
 			ORDER BY H.creation_date",
3137
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", )
3137
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",)
3138 3138
 		);
3139
-							$list_of_element = $wpdb->get_results( $query );
3140
-							if ( !empty( $list_of_element ) ) {
3141
-							foreach ( $list_of_element as $element ) {
3142
-					 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3143
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3144
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3145
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3146
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3139
+							$list_of_element = $wpdb->get_results($query);
3140
+							if (!empty($list_of_element)) {
3141
+							foreach ($list_of_element as $element) {
3142
+					 	$element_to_output[$element->ID]['title'] = $element->post_title;
3143
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3144
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3145
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3146
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3147 3147
 					 	}
3148 3148
 							}
3149 3149
 
3150 3150
 		$array_done = array();
3151
-		if ( !empty( $element_to_output ) ) {
3151
+		if (!empty($element_to_output)) {
3152 3152
 			$lines = '';
3153 3153
 			$done_header = array();
3154 3154
 
@@ -3156,23 +3156,23 @@  discard block
 block discarded – undo
3156 3156
 			/** Formate informations **/
3157 3157
 			$formatted_datas = array();
3158 3158
 			$controller_rows_array = array();
3159
-			foreach( $attributes_to_test as $attribute_to_test ) {
3160
-				$atts = explode( ',', $attribute_to_test );
3161
-				foreach( $atts as $att ) {
3162
-					$controller_rows_array[ $att ] = false;
3159
+			foreach ($attributes_to_test as $attribute_to_test) {
3160
+				$atts = explode(',', $attribute_to_test);
3161
+				foreach ($atts as $att) {
3162
+					$controller_rows_array[$att] = false;
3163 3163
 				}
3164 3164
 			}
3165 3165
 
3166
-			foreach(  $element_to_output as $element_id => $element_definition ) {
3166
+			foreach ($element_to_output as $element_id => $element_definition) {
3167 3167
 				$formatted_datas[$element_id]['title'] = $element_definition['title'];
3168 3168
 				$formatted_datas[$element_id]['content'] = array();
3169 3169
 
3170
-				foreach( $attributes_to_test as $attribute_to_test ) {
3171
-					$atts = explode( ',', $attribute_to_test );
3172
-					foreach( $atts as $att ) {
3173
-						if( !empty($element_definition['content'][$att]) ) {
3170
+				foreach ($attributes_to_test as $attribute_to_test) {
3171
+					$atts = explode(',', $attribute_to_test);
3172
+					foreach ($atts as $att) {
3173
+						if (!empty($element_definition['content'][$att])) {
3174 3174
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3175
-							$controller_rows_array[ $att ] = true;
3175
+							$controller_rows_array[$att] = true;
3176 3176
 						}
3177 3177
 						else {
3178 3178
 							$formatted_datas[$element_id]['content'][$att] = array();
@@ -3181,39 +3181,39 @@  discard block
 block discarded – undo
3181 3181
 				}
3182 3182
 			}
3183 3183
 
3184
-			foreach ( $formatted_datas as $element_id => $element_definition ) {
3185
-				if ( !in_array( $element_id, $array_done ) ) {
3186
-					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition[ 'title' ] . '</td>';
3187
-					ksort( $element_definition[ 'content' ] );
3188
-					foreach ( $element_definition[ 'content' ] as $atribute_id => $value_on_date ) {
3189
-						if( $controller_rows_array[$atribute_id] ) {
3190
-							$current_attribute = wpshop_attributes::getElement( $atribute_id );
3191
-							if ( !in_array( $atribute_id, $done_header ) ) {
3192
-								$more_header .= '<td style="border:1px solid black;" >' . __( $current_attribute->frontend_label, 'wpshop' ) . '</td>';
3184
+			foreach ($formatted_datas as $element_id => $element_definition) {
3185
+				if (!in_array($element_id, $array_done)) {
3186
+					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition['title'] . '</td>';
3187
+					ksort($element_definition['content']);
3188
+					foreach ($element_definition['content'] as $atribute_id => $value_on_date) {
3189
+						if ($controller_rows_array[$atribute_id]) {
3190
+							$current_attribute = wpshop_attributes::getElement($atribute_id);
3191
+							if (!in_array($atribute_id, $done_header)) {
3192
+								$more_header .= '<td style="border:1px solid black;" >' . __($current_attribute->frontend_label, 'wpshop') . '</td>';
3193 3193
 								$done_header[] = $atribute_id;
3194 3194
 							}
3195 3195
 							$last_value = 'XXXXX';
3196 3196
 							$counter_for_line = 0;
3197 3197
 							$content_line = '';
3198
-							foreach ( $value_on_date as $date => $value ) {
3199
-								if ( $value[ 'histo' ][ 'value' ] != $last_value ) {
3200
-									$current_val = $value[ 'current' ];
3201
-									$old_val = $value[ 'histo' ][ 'value' ];
3198
+							foreach ($value_on_date as $date => $value) {
3199
+								if ($value['histo']['value'] != $last_value) {
3200
+									$current_val = $value['current'];
3201
+									$old_val = $value['histo']['value'];
3202 3202
 									// Test if attribute data Type is integer
3203
-									if ( $current_attribute->data_type == 'integer' ) {
3204
-										if( $current_attribute->data_type_to_use == 'internal' ) {
3203
+									if ($current_attribute->data_type == 'integer') {
3204
+										if ($current_attribute->data_type_to_use == 'internal') {
3205 3205
 											$current_val = get_the_title($current_val);
3206 3206
 											$old_val = get_the_title($old_val);
3207 3207
 										}
3208 3208
 										else {
3209
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3210
-											$old_val = $wpdb->get_var( $query );
3211
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
3212
-											$current_val = $wpdb->get_var( $query );
3209
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $old_val);
3210
+											$old_val = $wpdb->get_var($query);
3211
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $current_val);
3212
+											$current_val = $wpdb->get_var($query);
3213 3213
 										}
3214 3214
 									}
3215
-									$content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value[ 'histo' ][ 'value_id' ] . '"' . checked( ( 0 == $counter_for_line ? true : false), true, false ) . '/>' . __( 'Current value', 'wpshop' ) . ' : ' .$current_val. ' / ' . __( 'Last value', 'wpshop' ) . ' : ' .$old_val. '</label><br/>';
3216
-									$last_value = $value[ 'histo' ][ 'value' ];
3215
+									$content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value['histo']['value_id'] . '"' . checked((0 == $counter_for_line ? true : false), true, false) . '/>' . __('Current value', 'wpshop') . ' : ' . $current_val . ' / ' . __('Last value', 'wpshop') . ' : ' . $old_val . '</label><br/>';
3216
+									$last_value = $value['histo']['value'];
3217 3217
 									$counter_for_line++;
3218 3218
 								}
3219 3219
 							}
@@ -3223,15 +3223,15 @@  discard block
 block discarded – undo
3223 3223
 						}
3224 3224
 					}
3225 3225
 					$lines .= '</tr>';
3226
-					$array_done[ $element_id ];
3226
+					$array_done[$element_id];
3227 3227
 				}
3228 3228
 			}
3229 3229
 
3230 3230
 			$response = '
3231
-				<form action="' . admin_url( 'admin-ajax.php' ) . '" method="POST" id="wps_put_histo_back" >
3231
+				<form action="' . admin_url('admin-ajax.php') . '" method="POST" id="wps_put_histo_back" >
3232 3232
 					<input type="text" name="action" value="wps_put_history_back" />
3233 3233
 					<table style="border-collapse: collapse;border:1px solid black;" cellpadding="0" cellspacing="0" >
3234
-						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __( 'Product', 'wpshop' ) . '</td>'.$more_header.'</tr>
3234
+						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __('Product', 'wpshop') . '</td>' . $more_header . '</tr>
3235 3235
 						' . $lines . '
3236 3236
 					</table>
3237 3237
 				</form><script type="text/javascript" >
@@ -3249,26 +3249,26 @@  discard block
 block discarded – undo
3249 3249
 
3250 3250
 	function wps_delete_picture_category() {
3251 3251
 		$status = false; $response = '';
3252
-		$cat_id = ( !empty($_POST['cat_id']) ) ? intval( $_POST['cat_id'] ) : null;
3253
-		if( !empty($cat_id) ) {
3252
+		$cat_id = (!empty($_POST['cat_id'])) ? intval($_POST['cat_id']) : null;
3253
+		if (!empty($cat_id)) {
3254 3254
 			// Get Category option
3255
-			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id );
3256
-			if( !empty($category_option) && !empty($category_option['wpshop_category_picture']) ) {
3257
-				unset( $category_option['wpshop_category_picture'] );
3258
-				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3259
-				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3255
+			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id);
3256
+			if (!empty($category_option) && !empty($category_option['wpshop_category_picture'])) {
3257
+				unset($category_option['wpshop_category_picture']);
3258
+				update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option);
3259
+				$response = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview"/>';
3260 3260
 				$status = true;
3261 3261
 			}
3262 3262
 			else {
3263
-				$response = __( 'Category options are not defined', 'wpshop');
3263
+				$response = __('Category options are not defined', 'wpshop');
3264 3264
 			}
3265 3265
 		}
3266 3266
 		else {
3267
-			$response = __( 'Category ID is not defined', 'wpshop');
3267
+			$response = __('Category ID is not defined', 'wpshop');
3268 3268
 		}
3269
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3269
+		echo json_encode(array('status' => $status, 'response' => $response));
3270 3270
 		wp_die();
3271 3271
 	}
3272
-	add_action( 'wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category' );
3272
+	add_action('wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category');
3273 3273
 
3274 3274
 ?>
3275 3275
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +88 added lines, -172 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
 * Ajax request management file
4 6
 *
@@ -462,12 +464,10 @@  discard block
 block discarded – undo
462 464
 					wpshop_payment::set_payment_transaction_number($order_id, $transaction_id);
463 465
 				}
464 466
 				$result = json_encode(array(true,''));
465
-			}
466
-			else {
467
+			} else {
467 468
 				$result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop')));
468 469
 			}
469
-		}
470
-		else {
470
+		} else {
471 471
 			$result = json_encode(array(false,__('Bad order identifier', 'wpshop')));
472 472
 		}
473 473
 		echo json_encode($result);
@@ -484,8 +484,7 @@  discard block
 block discarded – undo
484 484
 		if ( !empty($order_id) ) {
485 485
 			$result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />'));
486 486
 
487
-		}
488
-		else {
487
+		} else {
489 488
 			$result = json_encode(array(false, __('Order reference error', 'wpshop')));
490 489
 		}
491 490
 		echo json_encode($result);
@@ -523,16 +522,14 @@  discard block
 block discarded – undo
523 522
 				$output_shipping_box .= '<li><strong>'.__('Tracking link','wpshop').' :</strong> '.$order['order_trackingLink'].'</li>';
524 523
 
525 524
 				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
526
-			}
527
-			else {
525
+			} else {
528 526
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
529 527
 
530 528
 				$result = array(true, $order_state, __($order_status[$order_state], 'wpshop'));
531 529
 			}
532 530
 			update_post_meta($order_id, '_order_postmeta', $order);
533 531
 			update_post_meta($order_id, '_wpshop_order_status', $order_state);
534
-		}
535
-		else {
532
+		} else {
536 533
 			$result = array(false, __('Incorrect order request', 'wpshop'));
537 534
 		}
538 535
 
@@ -618,8 +615,7 @@  discard block
 block discarded – undo
618 615
 			unset($tpl_component);
619 616
 
620 617
 			echo json_encode(array(true, str_replace('optionsUpdate', 'options', $output)));
621
-		}
622
-		else {
618
+		} else {
623 619
 			echo json_encode(array(false, __('The value you entered already exist', 'wpshop')));
624 620
 		}
625 621
 		die();
@@ -664,13 +660,11 @@  discard block
 block discarded – undo
664 660
 				);
665 661
 				$new_option_id = wp_insert_post($new_post);
666 662
 				$input_def['valueToPut'] = 'index';
667
-			}
668
-			else {
663
+			} else {
669 664
 				$result_status = false;
670 665
 				$result = __('This value already exist for this attribute', 'wpshop');
671 666
 			}
672
-		}
673
-		else {
667
+		} else {
674 668
 			/**	Check if the given value does not exist	*/
675 669
 			$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE (label = %s OR value = %s) AND attribute_id = %d AND status = 'valid'", str_replace(",", ".", $attribute_options_label), $attribute_options_value, $attribute->id);
676 670
 			$existing_values = $wpdb->get_results($query);
@@ -686,8 +680,7 @@  discard block
 block discarded – undo
686 680
 				/**	Add the new value into database	*/
687 681
 				$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $attribute->id, 'position' => $position, 'label' => str_replace(",", ".", stripslashes($attribute_options_label)), 'value' => stripslashes($attribute_options_value)));
688 682
 				$new_option_id = $wpdb->insert_id;
689
-			}
690
-			else {
683
+			} else {
691 684
 				$result_status = false;
692 685
 				$result = __('This value already exist for this attribute', 'wpshop');
693 686
 			}
@@ -838,8 +831,7 @@  discard block
 block discarded – undo
838 831
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
839 832
 			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>';
840 833
 			$result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />';
841
-		}
842
-		else {
834
+		} else {
843 835
 			$result .= '<input type="hidden" value="' . $attribute->default_value . '" name="internal_data" id="internal_data" />';
844 836
 
845 837
 			unset($input_def);
@@ -896,8 +888,7 @@  discard block
 block discarded – undo
896 888
 					}
897 889
 				}
898 890
 			}
899
-		}
900
-		else {
891
+		} else {
901 892
 			$post_list = query_posts(array('post_type' => $internal_data_type));
902 893
 			if (!empty($post_list)) {
903 894
 				$p=1;
@@ -906,8 +897,7 @@  discard block
 block discarded – undo
906 897
 					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
907 898
 					if(is_int($last_insert) && $delete_items_of_entity){
908 899
 						wp_delete_post($post->ID, true);
909
-					}
910
-					else{
900
+					} else{
911 901
 						$error = true;
912 902
 					}
913 903
 					$p++;
@@ -971,13 +961,11 @@  discard block
 block discarded – undo
971 961
 				}
972 962
 				$result = true;
973 963
 				$result_output = '<p class="wpshop_duplicate_attribute_result" ><a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&action=edit&id=' . $new_attribute_id) . '" >' . __('Edit the new attribute', 'wpshop') . '</a></p>';
974
-			}
975
-			else {
964
+			} else {
976 965
 				$result = false;
977 966
 				$result_output = __('An error occured while duplicating attribute', 'wpshop');
978 967
 			}
979
-		}
980
-		else {
968
+		} else {
981 969
 			$result = false;
982 970
 			$result_output = __('This attribute has already been duplicate to this entity', 'wpshop');
983 971
 		}
@@ -1007,8 +995,7 @@  discard block
 block discarded – undo
1007 995
 			/* Test if we want display the group unit list OR the unit list */
1008 996
 			if ( $selected_list == 'group unit' ) {
1009 997
 				$list = wpshop_attributes_unit::get_unit_group();
1010
-			}
1011
-			else {
998
+			} else {
1012 999
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1013 1000
 			}
1014 1001
 
@@ -1016,8 +1003,7 @@  discard block
 block discarded – undo
1016 1003
 				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1017 1004
 			}
1018 1005
 			$result = array(true, $response);
1019
-		}
1020
-		else {
1006
+		} else {
1021 1007
 			$result = array(false, __('Incorrect order request', 'wpshop'));
1022 1008
 		}
1023 1009
 
@@ -1054,14 +1040,12 @@  discard block
 block discarded – undo
1054 1040
 								$sub_modif .= $column_name;
1055 1041
 								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1056 1042
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1057
-								}
1058
-								else{
1043
+								} else{
1059 1044
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1060 1045
 									$error_nb++;
1061 1046
 									if ( !empty($error_list[$plugin_db_version]) ) {
1062 1047
 										$error_list[$plugin_db_version] += 1;
1063
-									}
1064
-									else {
1048
+									} else {
1065 1049
 										$error_list[$plugin_db_version] = 1;
1066 1050
 									}
1067 1051
 								}
@@ -1079,8 +1063,7 @@  discard block
 block discarded – undo
1079 1063
 								$sub_modif .= $column_name;
1080 1064
 								if(empty($columns) || ($columns->Field != $column_name)){
1081 1065
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />';
1082
-								}
1083
-								else{
1066
+								} else{
1084 1067
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1085 1068
 									$error_nb++;
1086 1069
 									$error_list[$plugin_db_version] += 1;
@@ -1102,8 +1085,7 @@  discard block
 block discarded – undo
1102 1085
 									$changed_key = 'type';
1103 1086
 									if($columns->Type == $field_infos['type']){
1104 1087
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1105
-									}
1106
-									else{
1088
+									} else{
1107 1089
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1108 1090
 										$error_nb++;
1109 1091
 										$error_list[$plugin_db_version] += 1;
@@ -1115,8 +1097,7 @@  discard block
 block discarded – undo
1115 1097
 									$changed_key = 'original_name';
1116 1098
 									if($columns->Field == $field_infos['field']){
1117 1099
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1118
-									}
1119
-									else{
1100
+									} else{
1120 1101
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1121 1102
 										$error_nb++;
1122 1103
 										$error_list[$plugin_db_version] += 1;
@@ -1139,8 +1120,7 @@  discard block
 block discarded – undo
1139 1120
 								$sub_modif .= $column_name;
1140 1121
 								if((empty($columns)) || ($columns->Column_name != $column_name)){
1141 1122
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />';
1142
-								}
1143
-								else{
1123
+								} else{
1144 1124
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />';
1145 1125
 									$error_nb++;
1146 1126
 									$error_list[$plugin_db_version] += 1;
@@ -1159,8 +1139,7 @@  discard block
 block discarded – undo
1159 1139
 								$sub_modif .= $column_name;
1160 1140
 								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1161 1141
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />';
1162
-								}
1163
-								else{
1142
+								} else{
1164 1143
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />';
1165 1144
 									$error_nb++;
1166 1145
 									$error_list[$plugin_db_version] += 1;
@@ -1179,14 +1158,12 @@  discard block
 block discarded – undo
1179 1158
 							$table_exists = $wpdb->query($query);
1180 1159
 							if($table_exists == 1){
1181 1160
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />';
1182
-							}
1183
-							else{
1161
+							} else{
1184 1162
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />';
1185 1163
 								$error_nb++;
1186 1164
 								if ( !empty($error_list[$plugin_db_version]) ) {
1187 1165
 									$error_list[$plugin_db_version] += 1;
1188
-								}
1189
-								else {
1166
+								} else {
1190 1167
 									$error_list[$plugin_db_version] = 1;
1191 1168
 								}
1192 1169
 							}
@@ -1207,21 +1184,17 @@  discard block
 block discarded – undo
1207 1184
 								$error_nb++;
1208 1185
 								if ( !empty($error_list[$plugin_db_version]) ) {
1209 1186
 									$error_list[$plugin_db_version] += 1;
1210
-								}
1211
-								else {
1187
+								} else {
1212 1188
 									$error_list[$plugin_db_version] = 1;
1213 1189
 								}
1214
-							}
1215
-							elseif($table_exists == 1){
1190
+							} elseif($table_exists == 1){
1216 1191
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1217
-							}
1218
-							else{
1192
+							} else{
1219 1193
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1220 1194
 								$error_nb++;
1221 1195
 								if ( !empty($error_list[$plugin_db_version]) ) {
1222 1196
 									$error_list[$plugin_db_version] += 1;
1223
-								}
1224
-								else {
1197
+								} else {
1225 1198
 									$error_list[$plugin_db_version] = 1;
1226 1199
 								}
1227 1200
 							}
@@ -1243,24 +1216,20 @@  discard block
 block discarded – undo
1243 1216
 									$error_nb++;
1244 1217
 									if ( !empty($error_list[$plugin_db_version]) ) {
1245 1218
 										$error_list[$plugin_db_version] += 1;
1246
-									}
1247
-									else {
1219
+									} else {
1248 1220
 										$error_list[$plugin_db_version] = 1;
1249 1221
 									}
1250
-								}
1251
-								else{
1222
+								} else{
1252 1223
 									$deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1253 1224
 									$warning_nb++;
1254 1225
 									if ( !empty($warning_list[$plugin_db_version]) ) {
1255 1226
 										$warning_list[$plugin_db_version] += 1;
1256
-									}
1257
-									else {
1227
+									} else {
1258 1228
 										$warning_list[$plugin_db_version] = 1;
1259 1229
 									}
1260 1230
 								}
1261 1231
 								$sub_modif .= $deleted_table_result;
1262
-							}
1263
-							else{
1232
+							} else{
1264 1233
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />';
1265 1234
 							}
1266 1235
 							$sub_modif .= ' / ';
@@ -1358,8 +1327,7 @@  discard block
 block discarded – undo
1358 1327
 
1359 1328
 					if ( $has_error ) {
1360 1329
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1361
-					}
1362
-					else {
1330
+					} else {
1363 1331
 						$output_ok .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1364 1332
 					}
1365 1333
 				}
@@ -1524,8 +1492,7 @@  discard block
 block discarded – undo
1524 1492
 										if ( $last_histo === false ) {
1525 1493
 											$has_error = true;
1526 1494
 											$error_count++;
1527
-										}
1528
-										else {
1495
+										} else {
1529 1496
 											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1530 1497
 										}
1531 1498
 									}
@@ -1544,8 +1511,7 @@  discard block
 block discarded – undo
1544 1511
 						if ( $new_value === false ) {
1545 1512
 							$has_error = true;
1546 1513
 							$error_count++;
1547
-						}
1548
-						else {
1514
+						} else {
1549 1515
 							/**	Save new atribute values in product metadata	*/
1550 1516
 							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1551 1517
 							$current_product_metadata[$to_attribute->code] = $element->value;
@@ -1561,23 +1527,19 @@  discard block
 block discarded – undo
1561 1527
 					if ( !$has_error ) {
1562 1528
 						$response['status'] = true;
1563 1529
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1564
-					}
1565
-					else {
1530
+					} else {
1566 1531
 						$response['status'] = false;
1567 1532
 						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1568 1533
 					}
1569
-				}
1570
-				else {
1534
+				} else {
1571 1535
 					$response['status'] = false;
1572 1536
 					$response['error'] = __('There are no element corresponding to attribute choosen to copy from', 'wpshop');
1573 1537
 				}
1574
-			}
1575
-			else {
1538
+			} else {
1576 1539
 				$response['status'] = false;
1577 1540
 				$response['error'] = __('Both attribute must have same data type to be updated', 'wpshop');
1578 1541
 			}
1579
-		}
1580
-		else {
1542
+		} else {
1581 1543
 			$response['status'] = false;
1582 1544
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1583 1545
 		}
@@ -1669,8 +1631,7 @@  discard block
 block discarded – undo
1669 1631
 					if ( !empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes') ) {
1670 1632
 						if ( $_POST['wps_update_att_for_variation_required_state'] == 'yes') {
1671 1633
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1672
-						}
1673
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1634
+						} else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1674 1635
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1675 1636
 						}
1676 1637
 					}
@@ -1679,8 +1640,7 @@  discard block
 block discarded – undo
1679 1640
 						if ( !empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes') ) {
1680 1641
 							if ( $_POST['wps_update_att_for_variation']['text_from'] == 'yes' ) {
1681 1642
 								$meta_value['options']['price_display']['text_from'] = 'on';
1682
-							}
1683
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1643
+							} else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1684 1644
 								unset($meta_value['options']['price_display']['text_from']);
1685 1645
 							}
1686 1646
 						}
@@ -1688,8 +1648,7 @@  discard block
 block discarded – undo
1688 1648
 						if ( !empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes') ) {
1689 1649
 							if ( $_POST['wps_update_att_for_variation']['lower_price'] == 'yes' ) {
1690 1650
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1691
-							}
1692
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1651
+							} else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1693 1652
 								unset($meta_value['options']['price_display']['lower_price']);
1694 1653
 							}
1695 1654
 						}
@@ -1768,20 +1727,16 @@  discard block
 block discarded – undo
1768 1727
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1769 1728
 						}
1770 1729
 						$state = true;
1771
-					}
1772
-					else {
1730
+					} else {
1773 1731
 						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1774 1732
 					}
1775
-				}
1776
-				else {
1733
+				} else {
1777 1734
 					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1778 1735
 				}
1779
-			}
1780
-			else {
1736
+			} else {
1781 1737
 				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1782 1738
 			}
1783
-		}
1784
-		else {
1739
+		} else {
1785 1740
 			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1786 1741
 		}
1787 1742
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1809,12 +1764,10 @@  discard block
 block discarded – undo
1809 1764
 				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1810 1765
 					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1811 1766
 					$state = false;
1812
-				}
1813
-				else {
1767
+				} else {
1814 1768
 					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1815 1769
 				}
1816
-			}
1817
-			else {
1770
+			} else {
1818 1771
 				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1819 1772
 			}
1820 1773
 		}
@@ -1852,8 +1805,7 @@  discard block
 block discarded – undo
1852 1805
 						if(!empty($attribute->id)) {
1853 1806
 							if( !empty($_POST['submitOrderInfos']) ) {
1854 1807
 								$value = $_POST['attribute'][$attribute->data_type][$attribute->code];
1855
-							}
1856
-							else {
1808
+							} else {
1857 1809
 								$value = '';
1858 1810
 								if ( $attribute->code != 'user_pass') {
1859 1811
 									$code = $attribute->code;
@@ -1924,16 +1876,14 @@  discard block
 block discarded – undo
1924 1876
 
1925 1877
 		if ( $wpshop_format_result ) {
1926 1878
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1927
-		}
1928
-		else {
1879
+		} else {
1929 1880
 			if ( !empty($data) ) {
1930 1881
 				$temp_data = $data;
1931 1882
 				unset( $data );
1932 1883
 				foreach ( $temp_data as $post) {
1933 1884
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1934 1885
 				}
1935
-			}
1936
-			else {
1886
+			} else {
1937 1887
 				$data = array();
1938 1888
 			}
1939 1889
 		}
@@ -1995,8 +1945,7 @@  discard block
 block discarded – undo
1995 1945
 				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
1996 1946
 				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
1997 1947
 				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
1998
-			}
1999
-			else {
1948
+			} else {
2000 1949
 				$product_title = $product->post_title;
2001 1950
 				$product_description = $product->post_content;
2002 1951
 				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
@@ -2010,8 +1959,7 @@  discard block
 block discarded – undo
2010 1959
 
2011 1960
 			echo json_encode( array(true) );
2012 1961
 			die();
2013
-		}
2014
-		else {
1962
+		} else {
2015 1963
 			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2016 1964
 		}
2017 1965
 
@@ -2028,8 +1976,7 @@  discard block
 block discarded – undo
2028 1976
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
2029 1977
 				$succes_message_box = ob_get_contents();
2030 1978
 				ob_end_clean();
2031
-			}
2032
-			else {
1979
+			} else {
2033 1980
 				$succes_message_box = wpshop_display::display_template_element($template_part, array('PRODUCT_ID' => $product_id));
2034 1981
 			}
2035 1982
 			unset($tpl_component);
@@ -2046,12 +1993,10 @@  discard block
 block discarded – undo
2046 1993
 
2047 1994
 				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2048 1995
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2049
-				}
2050
-				else {
1996
+				} else {
2051 1997
 					if( strstr( $new_pid, '__') ) {
2052 1998
 						$idp = $new_pid;
2053
-					}
2054
-					else {
1999
+					} else {
2055 2000
 						$idp = $product_to_add_to_cart[$new_pid]['id'];
2056 2001
 					}
2057 2002
 				}
@@ -2076,8 +2021,7 @@  discard block
 block discarded – undo
2076 2021
 			if ( !empty($related_products) ) {
2077 2022
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2078 2023
 				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2079
-			}
2080
-			else {
2024
+			} else {
2081 2025
 				$linked_products = '';
2082 2026
 			}
2083 2027
 
@@ -2087,8 +2031,7 @@  discard block
 block discarded – undo
2087 2031
 			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array() );
2088 2032
 
2089 2033
 			$response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content );
2090
-		}
2091
-		else {
2034
+		} else {
2092 2035
 			$response = array( false, $return );
2093 2036
 		}
2094 2037
 
@@ -2132,8 +2075,7 @@  discard block
 block discarded – undo
2132 2075
 				}
2133 2076
 				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2134 2077
 				$response[] = $return;
2135
-			}
2136
-			else {
2078
+			} else {
2137 2079
 				$response[] = false;
2138 2080
 				$response[] = __('Parameters error.','wpshop');
2139 2081
 			}
@@ -2277,16 +2219,13 @@  discard block
 block discarded – undo
2277 2219
 				$permalink_option = get_option('permalink_structure');
2278 2220
 				if ( !empty($permalink_option) ) {
2279 2221
 					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2280
-				}
2281
-				else {
2222
+				} else {
2282 2223
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2283 2224
 				}
2284
-			}
2285
-			else {
2225
+			} else {
2286 2226
 				if ( !empty($_SESSION['cart']) ) {
2287 2227
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2288
-				}
2289
-				else {
2228
+				} else {
2290 2229
 					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2291 2230
 				}
2292 2231
 			}
@@ -2346,9 +2285,7 @@  discard block
 block discarded – undo
2346 2285
 			$retour .= '<div class="wpshop_cls"></div>';
2347 2286
 			$result = json_encode( array(true, $retour) );
2348 2287
 
2349
-		}
2350
-
2351
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2288
+		} elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2352 2289
  			$order_info_postmeta = get_post_meta($_REQUEST['order_id'], '_order_info', true);
2353 2290
 
2354 2291
  			$billing_id_attribute_set = get_option('wpshop_billing_address');
@@ -2363,8 +2300,7 @@  discard block
 block discarded – undo
2363 2300
  			}
2364 2301
 
2365 2302
  			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2366
- 		}
2367
-		else {
2303
+ 		} else {
2368 2304
 				// Check the attribute set id of Billing Address
2369 2305
 				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2370 2306
 				$attribute_set_id = $wpdb->get_var($query);
@@ -2425,8 +2361,7 @@  discard block
 block discarded – undo
2425 2361
 							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2426 2362
 							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2427 2363
 							$attribute_option_id = $wpdb->get_var( $query );
2428
-						}
2429
-						else {
2364
+						} else {
2430 2365
 							$entity_args = array(
2431 2366
 								'post_type' 	 => $attribute_default_value['default_value'],
2432 2367
 								'post_title'  	 => $value,
@@ -2435,8 +2370,7 @@  discard block
 block discarded – undo
2435 2370
 							);
2436 2371
 							$attribute_option_id = wp_insert_post($entity_args);
2437 2372
 						}
2438
-					}
2439
-					else {
2373
+					} else {
2440 2374
 						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) );
2441 2375
 						$attribute_option_id = $wpdb->insert_id;
2442 2376
 					}
@@ -2520,8 +2454,7 @@  discard block
 block discarded – undo
2520 2454
 			}
2521 2455
 
2522 2456
 			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2523
-		}
2524
-		else {
2457
+		} else {
2525 2458
 			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2526 2459
 		}
2527 2460
 
@@ -2558,20 +2491,17 @@  discard block
 block discarded – undo
2558 2491
 				if ( !empty($available_payement_method[0]) ) {
2559 2492
 					if ( $cart_type=='quotation' ) {
2560 2493
 						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2561
-					}
2562
-					else {
2494
+					} else {
2563 2495
 						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2564 2496
 					}
2565 2497
 				}
2566
-			}
2567
-			else {
2498
+			} else {
2568 2499
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2569 2500
 			}
2570 2501
 			if( $address_type == 'billing_address') {
2571 2502
 				$billing_option = get_option( 'wpshop_billing_address' );
2572 2503
 				$address_option = $billing_option['choice'];
2573
-			}
2574
-			else {
2504
+			} else {
2575 2505
 				$shipping_address_option = get_option('wpshop_shipping_address_choice');
2576 2506
 				$address_option = $shipping_address_option['choice'];
2577 2507
 			}
@@ -2583,8 +2513,7 @@  discard block
 block discarded – undo
2583 2513
 
2584 2514
 			$edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&amp;id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>';
2585 2515
 			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2586
-		}
2587
-		else {
2516
+		} else {
2588 2517
 			$result = json_encode( array(false, 'missing_informations') );
2589 2518
 		}
2590 2519
 		echo $result;
@@ -2647,13 +2576,11 @@  discard block
 block discarded – undo
2647 2576
 					wps_address::save_address_infos( $_REQUEST['shipping_address'] );
2648 2577
 				}
2649 2578
 				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2650
-			}
2651
-			else {
2579
+			} else {
2652 2580
 				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2653 2581
 			}
2654 2582
 
2655
-		}
2656
-		else {
2583
+		} else {
2657 2584
 			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2658 2585
 		}
2659 2586
 		echo $result;
@@ -2680,8 +2607,7 @@  discard block
 block discarded – undo
2680 2607
 			$wps_message = new wps_message_ctr();
2681 2608
 			$wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) );
2682 2609
 			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2683
-		}
2684
-		else {
2610
+		} else {
2685 2611
 			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2686 2612
 		}
2687 2613
 		echo json_encode($result);
@@ -2704,8 +2630,7 @@  discard block
 block discarded – undo
2704 2630
 			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2705 2631
 			update_post_meta( $_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n));
2706 2632
 			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2707
-		}
2708
-		else {
2633
+		} else {
2709 2634
 			$result = '';
2710 2635
 		}
2711 2636
 		echo $result;
@@ -2774,8 +2699,7 @@  discard block
 block discarded – undo
2774 2699
 						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2775 2700
 							$manage_stock_checking_bool = true;
2776 2701
 						}
2777
-					}
2778
-					else {
2702
+					} else {
2779 2703
 						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2780 2704
 							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2781 2705
 							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
@@ -2798,8 +2722,7 @@  discard block
 block discarded – undo
2798 2722
 					/** Checking stock **/
2799 2723
 					if ( empty($item_meta['manage_stock']) || ( !empty($item_meta['manage_stock']) && !$manage_stock_checking_bool )|| ( !empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty ) ) {
2800 2724
 						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2801
-					}
2802
-					else {
2725
+					} else {
2803 2726
 						$add_to_cart_checking = true;
2804 2727
 						$add_to_cart_checking_message = __('Some products cannot be added to cart because they are out of stock', 'wpshop');
2805 2728
 					}
@@ -2916,12 +2839,10 @@  discard block
 block discarded – undo
2916 2839
 
2917 2840
 				$response = __( 'Direct payment link has been send', 'wpshop' );
2918 2841
 				$status = true;
2919
-			}
2920
-			else {
2842
+			} else {
2921 2843
 				$response = __( 'An error was occured', 'wpshop' );
2922 2844
 			}
2923
-		}
2924
-		else {
2845
+		} else {
2925 2846
 			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2926 2847
 		}
2927 2848
 		echo json_encode( array( 'status' => $status, 'response' => $response) );
@@ -3004,8 +2925,7 @@  discard block
 block discarded – undo
3004 2925
 					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3005 2926
 					$wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3006 2927
 					$wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3007
-				}
3008
-				else {
2928
+				} else {
3009 2929
 					$common_datas = array(
3010 2930
 						'value_id' => null,
3011 2931
 						'entity_type_id' => 5,
@@ -3173,8 +3093,7 @@  discard block
 block discarded – undo
3173 3093
 						if( !empty($element_definition['content'][$att]) ) {
3174 3094
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3175 3095
 							$controller_rows_array[ $att ] = true;
3176
-						}
3177
-						else {
3096
+						} else {
3178 3097
 							$formatted_datas[$element_id]['content'][$att] = array();
3179 3098
 						}
3180 3099
 					}
@@ -3204,8 +3123,7 @@  discard block
 block discarded – undo
3204 3123
 										if( $current_attribute->data_type_to_use == 'internal' ) {
3205 3124
 											$current_val = get_the_title($current_val);
3206 3125
 											$old_val = get_the_title($old_val);
3207
-										}
3208
-										else {
3126
+										} else {
3209 3127
 											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3210 3128
 											$old_val = $wpdb->get_var( $query );
3211 3129
 											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
@@ -3258,12 +3176,10 @@  discard block
 block discarded – undo
3258 3176
 				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3259 3177
 				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3260 3178
 				$status = true;
3261
-			}
3262
-			else {
3179
+			} else {
3263 3180
 				$response = __( 'Category options are not defined', 'wpshop');
3264 3181
 			}
3265
-		}
3266
-		else {
3182
+		} else {
3267 3183
 			$response = __( 'Category ID is not defined', 'wpshop');
3268 3184
 		}
3269 3185
 		echo json_encode( array( 'status' => $status, 'response' => $response) );
Please login to merge, or discard this patch.
includes/include.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /*************************** LOAD THE BASE CLASS *******************************
19 19
  *******************************************************************************/
20 20
 
21
-include_once( WPSHOP_DIR . '/core/module_management/module_management.php');
21
+include_once(WPSHOP_DIR . '/core/module_management/module_management.php');
22 22
 
23 23
 include_once(WPSHOP_INCLUDES_DIR . 'wpshop_ajax.php');
24 24
 
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/payment.class.php');
45 45
 include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/paypal.class.php');
46 46
 // If the CIC payment method is active
47
-$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
48
-if ( WPSHOP_PAYMENT_METHOD_CIC && !empty($wpshop_paymentMethod) && !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) ) {
47
+$wpshop_paymentMethod = get_option('wps_payment_mode');
48
+if (WPSHOP_PAYMENT_METHOD_CIC && !empty($wpshop_paymentMethod) && !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) {
49 49
 	include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/cic.class.php');
50 50
 }
51 51
 
52 52
 /* Display management */
53
-if ( !class_exists('WP_List_Table') ) {
54
-	require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
53
+if (!class_exists('WP_List_Table')) {
54
+	require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
55 55
 }
56 56
 include_once(WPSHOP_LIBRAIRIES_DIR . 'display/display.class.php');
57 57
 
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
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/ajax.php 2 patches
Spacing   +71 added lines, -71 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
 * Plugin ajax request management.
4 4
 *
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 /**
25 25
 *	Include the different config for the plugin
26 26
 */
27
-require_once(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php' );
27
+require_once(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php');
28 28
 /**
29 29
 *	Include the file which includes the different files used by all the plugin
30 30
 */
31
-require_once(WPSHOP_INCLUDES_DIR.'include.php');
31
+require_once(WPSHOP_INCLUDES_DIR . 'include.php');
32 32
 
33 33
 /*	Get the different resquest vars to sanitize them before using	*/
34 34
 $method = isset($_REQUEST['post']) ? wpshop_tools::varSanitizer($_REQUEST['post'], '') : null;
@@ -43,54 +43,54 @@  discard block
 block discarded – undo
43 43
 
44 44
 
45 45
 /*	Look at the element type we have to work on	*/
46
-switch ( $elementCode ) {
46
+switch ($elementCode) {
47 47
 
48 48
 	case 'ajax_refresh_order':{
49 49
 		/*	Get order current content	*/
50 50
 		$order_meta = get_post_meta($elementIdentifier, '_order_postmeta', true);
51 51
 
52
-		switch($action){
52
+		switch ($action) {
53 53
 			case 'order_product_content':{
54 54
 				/*	Check if there are product to delete from order	*/
55 55
 				$listing_to_delete = array();
56
-				if(isset($_REQUEST['product_to_delete']) && ($_REQUEST['product_to_delete'] != '')){
56
+				if (isset($_REQUEST['product_to_delete']) && ($_REQUEST['product_to_delete'] != '')) {
57 57
 					$listing_to_delete = explode(',', $_REQUEST['product_to_delete']);
58 58
 				}
59 59
 
60 60
 				/*	Check product quantity to update	*/
61 61
 				$listing_to_update = array();
62
-				if(isset($_REQUEST['product_to_update_qty']) && ($_REQUEST['product_to_update_qty'] != '') && (is_array($_REQUEST['product_to_update_qty']))){
62
+				if (isset($_REQUEST['product_to_update_qty']) && ($_REQUEST['product_to_update_qty'] != '') && (is_array($_REQUEST['product_to_update_qty']))) {
63 63
 					$temp_listing_to_update = $_REQUEST['product_to_update_qty'];
64
-					foreach($temp_listing_to_update as $pdt_id_qty){
64
+					foreach ($temp_listing_to_update as $pdt_id_qty) {
65 65
 						$pdt_infos = explode('_x_', $pdt_id_qty);
66 66
 						$listing_to_update[$pdt_infos[0]] = $pdt_infos[1];
67 67
 					}
68 68
 				}
69 69
 
70 70
 				$order_items = array();
71
-				if(!empty($order_meta['order_items']) && is_array($order_meta['order_items']) && count($order_meta['order_items']) > 0){
72
-					foreach($order_meta['order_items'] as $order_item_key => $order_item){
71
+				if (!empty($order_meta['order_items']) && is_array($order_meta['order_items']) && count($order_meta['order_items']) > 0) {
72
+					foreach ($order_meta['order_items'] as $order_item_key => $order_item) {
73 73
 						$order_items[$order_item['item_id']]['product_id'] = $order_item['item_id'];
74 74
 						$order_items[$order_item['item_id']]['product_qty'] = $order_item['item_qty'];
75 75
 
76 76
 						/*	If current product exists into product list to delete	*/
77
-						if(in_array($order_item['item_id'], $listing_to_delete)){
77
+						if (in_array($order_item['item_id'], $listing_to_delete)) {
78 78
 							unset($order_items[$order_item['item_id']]);
79 79
 						}
80 80
 
81 81
 						/*	Check product quantity for update	*/
82
-						if(array_key_exists($order_item['item_id'], $listing_to_update)){
82
+						if (array_key_exists($order_item['item_id'], $listing_to_update)) {
83 83
 							$order_items[$order_item['item_id']]['product_qty'] = $listing_to_update[$order_item['item_id']];
84 84
 						}
85 85
 					}
86 86
 				}
87 87
 
88 88
 				$order_custom_infos = '';
89
-				if(isset($_REQUEST['order_shipping_cost']) && ($_REQUEST['order_shipping_cost']>=0)){
89
+				if (isset($_REQUEST['order_shipping_cost']) && ($_REQUEST['order_shipping_cost'] >= 0)) {
90 90
 					$order_custom_infos['custom_shipping_cost'] = $_REQUEST['order_shipping_cost'];
91 91
 				}
92 92
 				$wps_cart = new $wps_cart();
93
-				$order_meta = array_merge($order_meta, $wps_cart->calcul_cart_information(array(), $order_custom_infos, $order_meta, $elementIdentifier, $order_items) );
93
+				$order_meta = array_merge($order_meta, $wps_cart->calcul_cart_information(array(), $order_custom_infos, $order_meta, $elementIdentifier, $order_items));
94 94
 
95 95
 			}break;
96 96
 			// Set the shipping price to zero
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 		/*	Update order content	*/
113 113
 		update_post_meta($elementIdentifier, '_order_postmeta', $order_meta);
114
-		echo wpshop_orders::order_content(get_post($elementIdentifier) );
114
+		echo wpshop_orders::order_content(get_post($elementIdentifier));
115 115
 	}break;
116 116
 
117 117
 	//	Load product list
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$current_order_id = (isset($_POST['order_id']) && ($_POST['order_id'] > 0)) ? $_POST['order_id'] : 0;
121 121
 		$current_page = (isset($_POST['page']) && ($_POST['page'] > 0)) ? $_POST['page'] : 1;
122 122
 
123
-		if($current_order_id > 0){
123
+		if ($current_order_id > 0) {
124 124
 
125 125
 
126 126
 			$product_list_for_selection_pagination = '<div class="dialog_listing_pagination_container alignright" >' . paginate_links(array(
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 });
182 182
 </script>';
183 183
 		}
184
-		else{
184
+		else {
185 185
 			$product_association_box = __('We are unable to satisfy your request because of the order you asked was not found in your database', 'wpshop');
186 186
 		}
187 187
 
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 		$order_meta = get_post_meta($current_order_id, '_order_postmeta', true);
201 201
 
202 202
 		$order_items = array();
203
-		foreach($_GET['wp_list_product'] as $pid){
203
+		foreach ($_GET['wp_list_product'] as $pid) {
204 204
 			$order_items[$pid]['product_id'] = $pid;
205 205
 			$order_items[$pid]['product_qty'] = $_GET['wpshop_pdt_qty'][$pid];
206 206
 		}
207
-		if(isset($order_meta['order_items']) && is_array($order_meta['order_items'])){
208
-			foreach($order_meta['order_items'] as $product_in_order){
209
-				if(!isset($order_items[$product_in_order['item_id']])){
207
+		if (isset($order_meta['order_items']) && is_array($order_meta['order_items'])) {
208
+			foreach ($order_meta['order_items'] as $product_in_order) {
209
+				if (!isset($order_items[$product_in_order['item_id']])) {
210 210
 					$order_items[$product_in_order['item_id']]['product_id'] = $product_in_order['item_id'];
211 211
 					$order_items[$product_in_order['item_id']]['product_qty'] = $product_in_order['item_qty'];
212 212
 				}
213
-				else{
213
+				else {
214 214
 					$order_items[$product_in_order['item_id']]['product_qty'] += $product_in_order['item_qty'];
215 215
 				}
216 216
 			}
217 217
 		}
218 218
 
219
-		$wps_cart  = new $wps_cart();
219
+		$wps_cart = new $wps_cart();
220 220
 		$order_meta = $wps_cart->calcul_cart_information($order_items);
221 221
 
222 222
 		/*	Update order content	*/
@@ -242,30 +242,30 @@  discard block
 block discarded – undo
242 242
 	}break;
243 243
 
244 244
 	case 'attribute_set':
245
-		switch ( $elementType ) {
245
+		switch ($elementType) {
246 246
 			case 'attributeSetSection':
247
-				switch ( $action ) {
247
+				switch ($action) {
248 248
 					case 'saveNewAttributeSetSection':
249 249
 						$attributeSetSectionName = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionName']);
250 250
 						$attributeSetInfos = array();
251 251
 						$attributeSetInfos['id'] = '';
252 252
 						$attributeSetInfos['status'] = 'valid';
253 253
 						$attributeSetInfos['attribute_set_id'] = $elementIdentifier;
254
-						$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM ". WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
254
+						$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
255 255
 						$attributeSetInfos['position'] = $wpdb->get_var($query);
256 256
 						$attributeSetInfos['creation_date'] = date('Y-m-d H:i:s');
257 257
 						$attributeSetInfos['code'] = wpshop_tools::slugify($attributeSetSectionName, array('noAccent', 'noSpaces', 'lowerCase'));
258 258
 						$attributeSetInfos['name'] = $attributeSetSectionName;
259 259
 
260
-						$more_script='';
260
+						$more_script = '';
261 261
 						$attributeSetSectionCreation = wpshop_database::save($attributeSetInfos, WPSHOP_DBT_ATTRIBUTE_GROUP);
262
-						if ( $attributeSetSectionCreation == 'done' ) {
262
+						if ($attributeSetSectionCreation == 'done') {
263 263
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
264
-							$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
264
+							$more_script = 'wpshop_go_to("#attribute_group_' . $wpdb->insert_id . '")';
265 265
 						}
266 266
 						else
267 267
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
268
-						echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
268
+						echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
269 269
 					break;
270 270
 
271 271
 					case 'editAttributeSetSection':
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 						$attributeSetSectionDefault = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDefault']);
275 275
 						$backend_display_type = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDisplayType']);
276 276
 						$display_on_frontend = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDisplayinFrontEnd']);
277
-						$backend_display_type = in_array($backend_display_type, array('movable-tab','fixed-tab')) ? $backend_display_type : 'fixed-tab';
277
+						$backend_display_type = in_array($backend_display_type, array('movable-tab', 'fixed-tab')) ? $backend_display_type : 'fixed-tab';
278 278
 
279
-						if($attributeSetSectionDefault == 'yes'){
279
+						if ($attributeSetSectionDefault == 'yes') {
280 280
 							$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, array('last_update_date' => current_time('mysql', 0), 'default_group' => 'no'), array('attribute_set_id' => $elementIdentifier));
281 281
 						}
282 282
 						$attributeSetInfos = array();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 						$attributeSetInfos['backend_display_type'] = $backend_display_type;
287 287
 						$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
288 288
 						$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
289
-						if ( $attributeSetSectionCreation == 'done' )
289
+						if ($attributeSetSectionCreation == 'done')
290 290
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
291 291
 						else
292 292
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 						$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
306 306
 
307 307
 						$more_script = '';
308
-						if ( $attributeSetSectionCreation == 'done' ) {
308
+						if ($attributeSetSectionCreation == 'done') {
309 309
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
310
-							$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
310
+							$more_script .= 'jQuery("#attribute_group_' . $attributeSetSectionId . '").remove();';
311 311
 						}
312 312
 						else
313 313
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
314
-						echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
314
+						echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
315 315
 					break;
316 316
 				}
317 317
 			break;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	break;
320 320
 
321 321
 	case 'attribute_unit_management':
322
-		switch ( $action ) {
322
+		switch ($action) {
323 323
 			case 'load_unit_interface':
324 324
 				echo '
325 325
 					<div id="wpshop_unit_main_listing_interface">
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			case 'add_attribute_unit':
348 348
 			case 'edit_attribute_unit':
349 349
 				$atribute_unit = '';
350
-				if ( $action == 'edit_attribute_unit' ) {
350
+				if ($action == 'edit_attribute_unit') {
351 351
 					$atribute_unit = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']);
352 352
 				}
353 353
 				echo wpshop_attributes_unit::elementEdition($atribute_unit);
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 				$attribute_unit_informations['group_id'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['group_id']);
364 364
 
365 365
 				$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT);
366
-				if($save_unit_result == 'done'){
366
+				if ($save_unit_result == 'done') {
367 367
 					$save_output = wpshop_attributes_unit::elementList();
368 368
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
369 369
 				}
370
-				else{
370
+				else {
371 371
 					$save_output = wpshop_attributes_unit::elementEdition();
372 372
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
373 373
 				}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				$attribute_unit_informations['change_rate'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['change_rate']);
388 388
 				$attribute_unit_informations['code_iso'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
389 389
 
390
-				if ( $attribute_unit_informations['is_default_of_group'] == 'yes' ) {
390
+				if ($attribute_unit_informations['is_default_of_group'] == 'yes') {
391 391
 					$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array(
392 392
 						'is_default_of_group' => 'no'
393 393
 					), array(
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 					));
396 396
 				}
397 397
 
398
-				$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
399
-				if ( $save_unit_result == 'done' ) {
398
+				$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
399
+				if ($save_unit_result == 'done') {
400 400
 					$save_output = wpshop_attributes_unit::elementList();
401 401
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
402 402
 				}
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 				$attribute_unit_informations['status'] = 'deleted';
415 415
 				$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
416 416
 				$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
417
-				if ( $save_unit_result == 'done' ) {
417
+				if ($save_unit_result == 'done') {
418 418
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
419 419
 				}
420 420
 				else {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			case 'add_attribute_unit_group':
433 433
 			case 'edit_attribute_unit_group':
434 434
 				$atribute_unit_group = '';
435
-				if($action == 'edit_attribute_unit_group'){
435
+				if ($action == 'edit_attribute_unit_group') {
436 436
 					$atribute_unit_group = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']);
437 437
 				}
438 438
 				echo wpshop_attributes_unit::unit_group_edition($atribute_unit_group);
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 				$attribute_unit_informations['name'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
449 449
 
450 450
 				$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
451
-				if($save_unit_result == 'done'){
451
+				if ($save_unit_result == 'done') {
452 452
 					$save_output = wpshop_attributes_unit::unit_group_list();
453 453
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
454 454
 				}
455
-				else{
455
+				else {
456 456
 					$save_output = wpshop_attributes_unit::unit_group_edition();
457 457
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
458 458
 				}
@@ -469,12 +469,12 @@  discard block
 block discarded – undo
469 469
 				$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
470 470
 				$attribute_unit_informations['name'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
471 471
 
472
-				$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
473
-				if($save_unit_result == 'done'){
472
+				$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
473
+				if ($save_unit_result == 'done') {
474 474
 					$save_output = wpshop_attributes_unit::unit_group_list();
475 475
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
476 476
 				}
477
-				else{
477
+				else {
478 478
 					$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
479 479
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
480 480
 				}
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 				$attribute_unit_informations['status'] = 'deleted';
491 491
 				$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
492 492
 				$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
493
-				if($save_unit_result == 'done'){
493
+				if ($save_unit_result == 'done') {
494 494
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
495 495
 				}
496
-				else{
496
+				else {
497 497
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
498 498
 				}
499 499
 
@@ -505,23 +505,23 @@  discard block
 block discarded – undo
505 505
 
506 506
 	case 'products_by_criteria':
507 507
 		// If a filter by attribute is found, recalcul the products that matching it
508
-		if(!empty($_REQUEST['attr'])) {
509
-			$att = explode(':',$_REQUEST['attr']);
510
-			$products_id = wpshop_products::get_products_matching_attribute($att[0],$att[1]);
508
+		if (!empty($_REQUEST['attr'])) {
509
+			$att = explode(':', $_REQUEST['attr']);
510
+			$products_id = wpshop_products::get_products_matching_attribute($att[0], $att[1]);
511 511
 		}
512 512
 		$products_id = !empty($products_id) ? $products_id : $_REQUEST['pid'];
513 513
 		$page_number = $_REQUEST['page_number'];
514 514
 
515 515
 
516
-		if ( !empty($_GET['page_product']) ) {
516
+		if (!empty($_GET['page_product'])) {
517 517
 			$page_number = wpshop_tools::varSanitizer($_GET['page_product']);
518 518
 		}
519 519
 		$data = wpshop_products::wpshop_get_product_by_criteria(
520 520
 			$_REQUEST['criteria'], $_REQUEST['cid'], $products_id, $_REQUEST['display_type'], $_REQUEST['order'], $page_number, $_REQUEST['products_per_page']
521 521
 		);
522
-		if($data[0]) {
522
+		if ($data[0]) {
523 523
 			echo json_encode(array(true, do_shortcode($data[1])));
524
-		} else echo json_encode(array(false,__('No product found','wpshop')));
524
+		} else echo json_encode(array(false, __('No product found', 'wpshop')));
525 525
 	break;
526 526
 
527 527
 	case 'ajax_sendMessage':
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 			$user_info = get_userdata($_REQUEST['recipient']);
532 532
 			$first_name = $user_info->user_firstname;
533 533
 			$last_name = $user_info->user_lastname;
534
-			$data = array('customer_first_name'=>$first_name,'customer_last_name'=>$last_name);
534
+			$data = array('customer_first_name'=>$first_name, 'customer_last_name'=>$last_name);
535 535
 
536 536
 			$wps_message_ctr = new wps_message_ctr();
537 537
 
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 			$message = $wps_message_ctr->customMessage($_REQUEST['message'], $data);
541 541
 
542 542
 			if (!empty($user_info->user_email)) {
543
-				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$_REQUEST['postid'], $object=array());
543
+				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save = true, $model_id = $_REQUEST['postid'], $object = array());
544 544
 				$array = array('result' => true, 'message' => '');
545 545
 			}
546
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
546
+			else $array = array('result' => true, 'message' => __('An error occured', 'wpshop'));
547 547
 		}
548 548
 		else {
549
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
549
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
550 550
 		}
551 551
 
552 552
 		echo json_encode($array);
@@ -557,29 +557,29 @@  discard block
 block discarded – undo
557 557
 
558 558
 		if (!empty($_REQUEST['messageid'])) {
559 559
 
560
-			$ids = explode('-',$_REQUEST['messageid']);
560
+			$ids = explode('-', $_REQUEST['messageid']);
561 561
 			$postid = $ids[0];
562
-			$date = $ids[1].'-'.$ids[2];
562
+			$date = $ids[1] . '-' . $ids[2];
563 563
 			$arraykey = $ids[3];
564 564
 
565
-			$historic = get_post_meta($postid, 'wpshop_messages_histo_'.$date, true);
565
+			$historic = get_post_meta($postid, 'wpshop_messages_histo_' . $date, true);
566 566
 
567 567
 			if (isset($historic[$arraykey])) {
568 568
 				$historic[$arraykey]['mess_dispatch_date'][] = current_time('mysql', 0);
569
-				update_post_meta($postid, 'wpshop_messages_histo_'.$date, $historic);
569
+				update_post_meta($postid, 'wpshop_messages_histo_' . $date, $historic);
570 570
 
571 571
 				$data = $historic[$arraykey];
572 572
 				$wps_message_ctr = new wps_message_ctr();
573
-				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
573
+				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save = false, $object = array());
574 574
 
575 575
 				$array = array('result' => true, 'message' => '');
576 576
 			}
577 577
 			else {
578
-				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
578
+				$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
579 579
 			}
580 580
 		}
581 581
 		else {
582
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
582
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
583 583
 		}
584 584
 
585 585
 		echo json_encode($array);
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
 	case 'related_products':
590 590
 		$data = wpshop_products::product_list(false, $_REQUEST['search']);
591
-		$array=array();
591
+		$array = array();
592 592
 		foreach ($data as $d) {
593 593
 			$array[] = array('id' => $d->ID, 'name' => $d->post_title);
594 594
 		}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			case 'applyCoupon':
602 602
 				$wps_coupon_ctr = new wps_coupon_ctr();
603 603
 				$result = $wps_coupon_ctr->applyCoupon($_REQUEST['coupon_code']);
604
-				if ($result['status']===true) {
604
+				if ($result['status'] === true) {
605 605
 					$wps_cart_ctr = new wps_cart();
606 606
 					$order = $wps_cart_ctr->calcul_cart_information(array());
607 607
 					$wps_cart_ctr->store_cart_in_session($order);
Please login to merge, or discard this patch.
Braces   +31 added lines, -34 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
 * Plugin ajax request management.
4 6
 *
@@ -180,8 +182,7 @@  discard block
 block discarded – undo
180 182
 });
181 183
 });
182 184
 </script>';
183
-		}
184
-		else{
185
+		} else{
185 186
 			$product_association_box = __('We are unable to satisfy your request because of the order you asked was not found in your database', 'wpshop');
186 187
 		}
187 188
 
@@ -209,8 +210,7 @@  discard block
 block discarded – undo
209 210
 				if(!isset($order_items[$product_in_order['item_id']])){
210 211
 					$order_items[$product_in_order['item_id']]['product_id'] = $product_in_order['item_id'];
211 212
 					$order_items[$product_in_order['item_id']]['product_qty'] = $product_in_order['item_qty'];
212
-				}
213
-				else{
213
+				} else{
214 214
 					$order_items[$product_in_order['item_id']]['product_qty'] += $product_in_order['item_qty'];
215 215
 				}
216 216
 			}
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 						if ( $attributeSetSectionCreation == 'done' ) {
263 263
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
264 264
 							$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
265
+						} else {
266
+													$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
265 267
 						}
266
-						else
267
-							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
268 268
 						echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
269 269
 					break;
270 270
 
@@ -286,10 +286,11 @@  discard block
 block discarded – undo
286 286
 						$attributeSetInfos['backend_display_type'] = $backend_display_type;
287 287
 						$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
288 288
 						$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
289
-						if ( $attributeSetSectionCreation == 'done' )
290
-							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
291
-						else
292
-							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
289
+						if ( $attributeSetSectionCreation == 'done' ) {
290
+													$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
291
+						} else {
292
+													$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
293
+						}
293 294
 
294 295
 						echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>';
295 296
 
@@ -308,9 +309,9 @@  discard block
 block discarded – undo
308 309
 						if ( $attributeSetSectionCreation == 'done' ) {
309 310
 							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
310 311
 							$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
312
+						} else {
313
+													$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
311 314
 						}
312
-						else
313
-							$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
314 315
 						echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
315 316
 					break;
316 317
 				}
@@ -366,8 +367,7 @@  discard block
 block discarded – undo
366 367
 				if($save_unit_result == 'done'){
367 368
 					$save_output = wpshop_attributes_unit::elementList();
368 369
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
369
-				}
370
-				else{
370
+				} else{
371 371
 					$save_output = wpshop_attributes_unit::elementEdition();
372 372
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
373 373
 				}
@@ -399,8 +399,7 @@  discard block
 block discarded – undo
399 399
 				if ( $save_unit_result == 'done' ) {
400 400
 					$save_output = wpshop_attributes_unit::elementList();
401 401
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
402
-				}
403
-				else {
402
+				} else {
404 403
 					$save_output = wpshop_attributes_unit::elementEdition($attributeUnitId);
405 404
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit saving', 'wpshop');
406 405
 				}
@@ -416,8 +415,7 @@  discard block
 block discarded – undo
416 415
 				$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
417 416
 				if ( $save_unit_result == 'done' ) {
418 417
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
419
-				}
420
-				else {
418
+				} else {
421 419
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit deletion', 'wpshop');
422 420
 				}
423 421
 
@@ -451,8 +449,7 @@  discard block
 block discarded – undo
451 449
 				if($save_unit_result == 'done'){
452 450
 					$save_output = wpshop_attributes_unit::unit_group_list();
453 451
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
454
-				}
455
-				else{
452
+				} else{
456 453
 					$save_output = wpshop_attributes_unit::unit_group_edition();
457 454
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
458 455
 				}
@@ -473,8 +470,7 @@  discard block
 block discarded – undo
473 470
 				if($save_unit_result == 'done'){
474 471
 					$save_output = wpshop_attributes_unit::unit_group_list();
475 472
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
476
-				}
477
-				else{
473
+				} else{
478 474
 					$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
479 475
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
480 476
 				}
@@ -492,8 +488,7 @@  discard block
 block discarded – undo
492 488
 				$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
493 489
 				if($save_unit_result == 'done'){
494 490
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
495
-				}
496
-				else{
491
+				} else{
497 492
 					$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
498 493
 				}
499 494
 
@@ -521,7 +516,9 @@  discard block
 block discarded – undo
521 516
 		);
522 517
 		if($data[0]) {
523 518
 			echo json_encode(array(true, do_shortcode($data[1])));
524
-		} else echo json_encode(array(false,__('No product found','wpshop')));
519
+		} else {
520
+			echo json_encode(array(false,__('No product found','wpshop')));
521
+		}
525 522
 	break;
526 523
 
527 524
 	case 'ajax_sendMessage':
@@ -542,10 +539,10 @@  discard block
 block discarded – undo
542 539
 			if (!empty($user_info->user_email)) {
543 540
 				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$_REQUEST['postid'], $object=array());
544 541
 				$array = array('result' => true, 'message' => '');
542
+			} else {
543
+				$array = array('result' => true, 'message' => __('An error occured','wpshop'));
545 544
 			}
546
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
547
-		}
548
-		else {
545
+		} else {
549 546
 			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
550 547
 		}
551 548
 
@@ -573,12 +570,10 @@  discard block
 block discarded – undo
573 570
 				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
574 571
 
575 572
 				$array = array('result' => true, 'message' => '');
576
-			}
577
-			else {
573
+			} else {
578 574
 				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
579 575
 			}
580
-		}
581
-		else {
576
+		} else {
582 577
 			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
583 578
 		}
584 579
 
@@ -606,7 +601,9 @@  discard block
 block discarded – undo
606 601
 					$order = $wps_cart_ctr->calcul_cart_information(array());
607 602
 					$wps_cart_ctr->store_cart_in_session($order);
608 603
 					echo json_encode(array(true, ''));
609
-				} else echo json_encode(array(false, $result['message']));
604
+				} else {
605
+					echo json_encode(array(false, $result['message']));
606
+				}
610 607
 			break;
611 608
 		}
612 609
 	break;
Please login to merge, or discard this patch.
includes/modules/wps_statistics/wps_statistics.php 2 patches
Spacing   +10 added lines, -10 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
  * WPShop Statistics bootstrap file
4 4
  * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]>
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
  * @subpackage modules
8 8
  *
9 9
  */
10
-if ( !defined( 'WPSHOP_VERSION' ) ) {
11
-	die( __("You are not allowed to use this service.", 'wpshop') );
10
+if (!defined('WPSHOP_VERSION')) {
11
+	die(__("You are not allowed to use this service.", 'wpshop'));
12 12
 }
13 13
 
14 14
 /** */
15
-DEFINE( 'WPS_STATISTICS_VERSION', '1.0.1' );
16
-DEFINE( 'WPS_STATISTICS_DIR', basename(dirname(__FILE__)));
17
-DEFINE( 'WPS_STATISTICS_PATH', dirname( __FILE__ ) );
18
-DEFINE( 'WPS_STATISTICS_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', str_replace( "\\", "/", WPS_STATISTICS_PATH ) ) );
15
+DEFINE('WPS_STATISTICS_VERSION', '1.0.1');
16
+DEFINE('WPS_STATISTICS_DIR', basename(dirname(__FILE__)));
17
+DEFINE('WPS_STATISTICS_PATH', dirname(__FILE__));
18
+DEFINE('WPS_STATISTICS_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', str_replace("\\", "/", WPS_STATISTICS_PATH)));
19 19
 
20 20
 /**	Define the templates directories	*/
21
-DEFINE( 'WPS_STATISTICS_TEMPLATES_MAIN_DIR', WPS_STATISTICS_PATH . '/templates/');
21
+DEFINE('WPS_STATISTICS_TEMPLATES_MAIN_DIR', WPS_STATISTICS_PATH . '/templates/');
22 22
 
23
-include( plugin_dir_path( __FILE__ ).'/controller/wps_statistics_ctr.php' );
24
-include( plugin_dir_path( __FILE__ ).'/model/wps_statisticsmdl.php' );
23
+include(plugin_dir_path(__FILE__) . '/controller/wps_statistics_ctr.php');
24
+include(plugin_dir_path(__FILE__) . '/model/wps_statisticsmdl.php');
25 25
 
26 26
 $wps_statistics_ctr = new wps_statistics_ctr();
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
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
modules/wps_statistics/templates/backend/wps_statistics_orders_status.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- if( !empty($orders_status) ) : ?>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ if (!empty($orders_status)) : ?>
3 3
 <canvas id="wps_orders_status" width="" height=""></canvas>
4 4
 <script type="text/javascript">
5 5
 	jQuery( document ).ready( function() {
6 6
 		var pieData2 = [
7
-<?php foreach( $orders_status as $status => $count ) : ?>
7
+<?php foreach ($orders_status as $status => $count) : ?>
8 8
 						{value: <?php echo $count; ?>, color:"<?php echo $colors[strtolower($status)]; ?>"},
9 9
 <?php endforeach; ?>	
10 10
 						];	
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	});
13 13
 </script>
14 14
 <ul class="wps_statistics_legend">
15
-	<?php foreach( $orders_status as $status => $count ) : ?>
16
-		<li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[ strtolower($status) ], 'wpshop' ); ?> (<?php echo $count; ?>)</span></li>
15
+	<?php foreach ($orders_status as $status => $count) : ?>
16
+		<li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[strtolower($status)], 'wpshop'); ?> (<?php echo $count; ?>)</span></li>
17 17
 	<?php endforeach; ?>	
18 18
 </ul>
19 19
 <?php else : ?>
20
-<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' ); ?></div>
20
+<div class="wps-alert-info"><?php _e('No order have been created', 'wpshop'); ?></div>
21 21
 <?php endif; ?>
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
  if( !empty($orders_status) ) : ?>
3 5
 <canvas id="wps_orders_status" width="" height=""></canvas>
4 6
 <script type="text/javascript">
@@ -16,6 +18,9 @@  discard block
 block discarded – undo
16 18
 		<li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[ strtolower($status) ], 'wpshop' ); ?> (<?php echo $count; ?>)</span></li>
17 19
 	<?php endforeach; ?>	
18 20
 </ul>
19
-<?php else : ?>
20
-<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' ); ?></div>
21
+<?php else {
22
+	: ?>
23
+<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' );
24
+}
25
+?></div>
21 26
 <?php endif; ?>
Please login to merge, or discard this patch.