Completed
Push — master ( f161aa...d0d50d )
by
unknown
15:24
created
wpshop.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -18,55 +18,55 @@  discard block
 block discarded – undo
18 18
  * @package wpshop
19 19
  */
20 20
 
21
-ini_set( 'memory_limit', '512M' );
21
+ini_set('memory_limit', '512M');
22 22
 
23 23
 /**    Check if file is include. No direct access possible with file url    */
24
-if ( ! defined( 'ABSPATH' ) ) {
25
-	die( 'Access is not allowed by this way' );
24
+if (!defined('ABSPATH')) {
25
+	die('Access is not allowed by this way');
26 26
 }
27 27
 
28 28
 /**    Allows to refresh css and js file in final user browser    */
29
-DEFINE( 'WPSHOP_VERSION', '1.4.4.3' );
29
+DEFINE('WPSHOP_VERSION', '1.4.4.3');
30 30
 
31 31
 /**    Allows to avoid problem with theme not supporting thumbnail for post    */
32
-add_theme_support( 'post-thumbnails' );
33
-add_image_size( 'wpshop-product-galery', 270, 270, true );
34
-add_image_size( 'wps-categorie-mini-display', 80, 80, true );
35
-add_image_size( 'wps-categorie-display', 480, 340, true );
32
+add_theme_support('post-thumbnails');
33
+add_image_size('wpshop-product-galery', 270, 270, true);
34
+add_image_size('wps-categorie-mini-display', 80, 80, true);
35
+add_image_size('wps-categorie-display', 480, 340, true);
36 36
 
37 37
 /**    First thing we define the main directory for our plugin in a super global var    */
38
-DEFINE( 'WPSHOP_PLUGIN_DIR', basename( dirname( __FILE__ ) ) );
39
-DEFINE( 'WPSHOP_PLUGIN_NAME', plugin_basename( __FILE__ ) );
38
+DEFINE('WPSHOP_PLUGIN_DIR', basename(dirname(__FILE__)));
39
+DEFINE('WPSHOP_PLUGIN_NAME', plugin_basename(__FILE__));
40 40
 
41 41
 /**    Get the current language to translate the different text in plugin    */
42 42
 $locale = get_locale();
43 43
 global $wpdb;
44
-if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
45
-	$query = $wpdb->prepare( 'SELECT locale FROM ' . $wpdb->prefix . 'icl_locale_map WHERE code = %s', ICL_LANGUAGE_CODE );
46
-	$local = $wpdb->get_var( $query );
47
-	$locale = ! empty( $local ) ? $local : $locale;
44
+if (defined('ICL_LANGUAGE_CODE')) {
45
+	$query = $wpdb->prepare('SELECT locale FROM ' . $wpdb->prefix . 'icl_locale_map WHERE code = %s', ICL_LANGUAGE_CODE);
46
+	$local = $wpdb->get_var($query);
47
+	$locale = !empty($local) ? $local : $locale;
48 48
 }
49
-DEFINE( 'WPSHOP_CURRENT_LOCALE', $locale );
49
+DEFINE('WPSHOP_CURRENT_LOCALE', $locale);
50 50
 /**    Load plugin translation    */
51
-load_plugin_textdomain( 'wpshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
51
+load_plugin_textdomain('wpshop', false, dirname(plugin_basename(__FILE__)) . '/languages/');
52 52
 
53 53
 /**    Include the config file    */
54 54
 require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php';
55 55
 
56 56
 /** Allow to get errors back when debug mode is set to true    */
57
-if ( WPSHOP_DEBUG_MODE && (in_array( long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) )) ) {
58
-	ini_set( 'display_errors', true );
59
-	error_reporting( E_ALL );
57
+if (WPSHOP_DEBUG_MODE && (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP)))) {
58
+	ini_set('display_errors', true);
59
+	error_reporting(E_ALL);
60 60
 }
61 61
 
62 62
 include_once WPSHOP_LIBRAIRIES_DIR . 'init.class.php';
63
-$current_installation_step = get_option( 'wps-installation-current-step', 1 );
63
+$current_installation_step = get_option('wps-installation-current-step', 1);
64 64
 
65 65
 /**    Get current plugin version    */
66
-$current_db_version = get_option( 'wpshop_db_options', 0 );
66
+$current_db_version = get_option('wpshop_db_options', 0);
67 67
 
68 68
 /**    Call main initialisation function    */
69
-add_action( 'init', array( 'wpshop_init', 'load' ) );
69
+add_action('init', array('wpshop_init', 'load'));
70 70
 
71 71
 /**    Include the main including file    */
72 72
 require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/include.php';
@@ -78,32 +78,32 @@  discard block
 block discarded – undo
78 78
 
79 79
 /**    Call function to create the main left menu    */
80 80
 // if ( ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $_GET ) && !empty( $_GET[ 'installation_state' ] ) && ( "ignored" == $_GET[ 'installation_state' ] ) ) ) {
81
-add_action( 'admin_menu', array( 'wpshop_init', 'admin_menu' ) );
82
-add_action( 'menu_order', array( 'wpshop_init', 'admin_menu_order' ) );
83
-add_action( 'custom_menu_order', array( 'wpshop_init', 'admin_custom_menu_order' ) );
81
+add_action('admin_menu', array('wpshop_init', 'admin_menu'));
82
+add_action('menu_order', array('wpshop_init', 'admin_menu_order'));
83
+add_action('custom_menu_order', array('wpshop_init', 'admin_custom_menu_order'));
84 84
 
85 85
 /*    Call function for new WordPress element creating [term (product_category) / post (product)]    */
86
-add_action( 'init', array( 'wpshop_init', 'add_new_wp_type' ) );
86
+add_action('init', array('wpshop_init', 'add_new_wp_type'));
87 87
 
88 88
 /*    Call function allowing to change element front output    */
89
-add_action( 'the_content', array( 'wpshop_display', 'products_page' ), 1 );
89
+add_action('the_content', array('wpshop_display', 'products_page'), 1);
90 90
 // add_action('archive_template', array('wpshop_categories', 'category_template_switcher'));
91 91
 // }
92 92
 /**    On plugin activation create the default parameters to use the ecommerce    */
93
-register_activation_hook( __FILE__, array( 'wpshop_install', 'install_on_activation' ) );
93
+register_activation_hook(__FILE__, array('wpshop_install', 'install_on_activation'));
94 94
 
95 95
 /**    Get current plugin version    */
96
-$current_db_version = get_option( 'wpshop_db_options', 0 );
96
+$current_db_version = get_option('wpshop_db_options', 0);
97 97
 
98 98
 /**    Add the database content    */
99
-add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop' ) );
100
-if ( (defined( 'WPSINSTALLER_STEPS_COUNT' ) && (WPSINSTALLER_STEPS_COUNT <= $current_installation_step)) || ( ! empty( $current_db_version ) && ! empty( $current_db_version['db_version'] ) && (51 < $current_db_version['db_version'])) || ( ! empty( $current_db_version ) && ! empty( $current_db_version['installation_state'] ) && ('ignore' == $current_db_version['installation_state'])) ) {
101
-	if ( in_array( long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) ) ) {
102
-		add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop_dev' ) );
99
+add_action('admin_init', array('wpshop_install', 'update_wpshop'));
100
+if ((defined('WPSINSTALLER_STEPS_COUNT') && (WPSINSTALLER_STEPS_COUNT <= $current_installation_step)) || (!empty($current_db_version) && !empty($current_db_version['db_version']) && (51 < $current_db_version['db_version'])) || (!empty($current_db_version) && !empty($current_db_version['installation_state']) && ('ignore' == $current_db_version['installation_state']))) {
101
+	if (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) {
102
+		add_action('admin_init', array('wpshop_install', 'update_wpshop_dev'));
103 103
 	}
104 104
 }
105 105
 // Start session
106
-if ( session_id() == '' ) {
106
+if (session_id() == '') {
107 107
 	 session_start();
108 108
 }
109 109
 
@@ -113,52 +113,52 @@  discard block
 block discarded – undo
113 113
 	$wpshop = new wpshop_form_management();
114 114
 	$wpshop_payment = new wpshop_payment();
115 115
 }
116
-add_action( 'init', 'classes_init' );
116
+add_action('init', 'classes_init');
117 117
 
118 118
 /** Shortcode management */
119
-add_shortcode( 'wpshop_att_val', array( 'wpshop_attributes', 'wpshop_att_val_func' ) ); // Attributes
120
-add_shortcode( 'wpshop_products', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list
121
-add_shortcode( 'wpshop_product', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list
122
-add_shortcode( 'wpshop_product_variation_summary', array( 'wpshop_products', 'wpshop_product_variations_summary' ) ); // Variation summary
123
-add_shortcode( 'wpshop_product_variation_value_detail', array( 'wpshop_products', 'wpshop_product_variation_value_detail' ) ); // Variation value detail
124
-add_shortcode( 'wpshop_related_products', array( 'wpshop_products', 'wpshop_related_products_func' ) ); // Products list
125
-add_shortcode( 'wpshop_category', array( 'wpshop_categories', 'wpshop_category_func' ) ); // Category
126
-add_shortcode( 'wpshop_att_group', array( 'wpshop_attributes_set', 'wpshop_att_group_func' ) ); // Attributes groups
127
-add_shortcode( 'wpshop_cart', 'wpshop_display_cart' ); // Cart
119
+add_shortcode('wpshop_att_val', array('wpshop_attributes', 'wpshop_att_val_func')); // Attributes
120
+add_shortcode('wpshop_products', array('wpshop_products', 'wpshop_products_func')); // Products list
121
+add_shortcode('wpshop_product', array('wpshop_products', 'wpshop_products_func')); // Products list
122
+add_shortcode('wpshop_product_variation_summary', array('wpshop_products', 'wpshop_product_variations_summary')); // Variation summary
123
+add_shortcode('wpshop_product_variation_value_detail', array('wpshop_products', 'wpshop_product_variation_value_detail')); // Variation value detail
124
+add_shortcode('wpshop_related_products', array('wpshop_products', 'wpshop_related_products_func')); // Products list
125
+add_shortcode('wpshop_category', array('wpshop_categories', 'wpshop_category_func')); // Category
126
+add_shortcode('wpshop_att_group', array('wpshop_attributes_set', 'wpshop_att_group_func')); // Attributes groups
127
+add_shortcode('wpshop_cart', 'wpshop_display_cart'); // Cart
128 128
 // add_shortcode('wpshop_mini_cart', 'wpshop_display_mini_cart'); // Mini cart
129 129
 // add_shortcode('wpshop_signup', 'wpshop_signup_init'); // Signup
130 130
 // add_shortcode('wpshop_myaccount', 'wpshop_account_display_form' );
131
-add_shortcode( 'wpshop_payment_result', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result
132
-add_shortcode( 'wpshop_payment_result_unsuccessfull', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result
131
+add_shortcode('wpshop_payment_result', array('wpshop_payment', 'wpshop_payment_result')); // Payment result
132
+add_shortcode('wpshop_payment_result_unsuccessfull', array('wpshop_payment', 'wpshop_payment_result')); // Payment result
133 133
 
134
-add_shortcode( 'wpshop_variations', array( 'wpshop_products', 'wpshop_variation' ) );
135
-add_shortcode( 'wpshop_entities', array( 'wpshop_entities', 'wpshop_entities_shortcode' ) );
136
-add_shortcode( 'wpshop_attributes', array( 'wpshop_attributes', 'wpshop_attributes_shortcode' ) );
134
+add_shortcode('wpshop_variations', array('wpshop_products', 'wpshop_variation'));
135
+add_shortcode('wpshop_entities', array('wpshop_entities', 'wpshop_entities_shortcode'));
136
+add_shortcode('wpshop_attributes', array('wpshop_attributes', 'wpshop_attributes_shortcode'));
137 137
 
138 138
 /** Add specific messages for wpshop elements management    */
139 139
 // add_filter('post_updated_messages', array('wpshop_messages', 'update_wp_message_list'));
140
-$file = basename( __FILE__ );
141
-$folder = basename( dirname( __FILE__ ) );
140
+$file = basename(__FILE__);
141
+$folder = basename(dirname(__FILE__));
142 142
 $hook = "in_plugin_update_message-{$folder}/{$file}";
143
-add_action( $hook, 'wps_update_message', 10, 2 ); // 10:priority, 2:arguments #
144
-function wps_update_message( $currentPluginMetadata, $newPluginMetadata ) {
143
+add_action($hook, 'wps_update_message', 10, 2); // 10:priority, 2:arguments #
144
+function wps_update_message($currentPluginMetadata, $newPluginMetadata) {
145 145
 	$message = '';
146 146
 
147
-	if ( '1.4.1.6' == $currentPluginMetadata['Version'] ) {
148
-		$message = sprintf( __( 'For security reason %1$splease read this post%2$s', 'wpshop' ), '<a href="" >', '</a>' );
147
+	if ('1.4.1.6' == $currentPluginMetadata['Version']) {
148
+		$message = sprintf(__('For security reason %1$splease read this post%2$s', 'wpshop'), '<a href="" >', '</a>');
149 149
 	}
150 150
 
151 151
 	// check "upgrade_notice"
152
-	if ( isset( $newPluginMetadata->upgrade_notice ) && strlen( trim( $newPluginMetadata->upgrade_notice ) ) > 0 ) {
153
-		$message = esc_html( $newPluginMetadata->upgrade_notice );
152
+	if (isset($newPluginMetadata->upgrade_notice) && strlen(trim($newPluginMetadata->upgrade_notice)) > 0) {
153
+		$message = esc_html($newPluginMetadata->upgrade_notice);
154 154
 	}
155 155
 
156
-	if ( ! empty( $message ) ) {
157
-		echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __( 'Important upgrade notice', 'wpshop' ) . ': </strong>' . $message . '</p>';
156
+	if (!empty($message)) {
157
+		echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __('Important upgrade notice', 'wpshop') . ': </strong>' . $message . '</p>';
158 158
 	}
159 159
 }
160 160
 
161 161
 require_once 'core/external/wpeo_util/singleton.util.php';
162 162
 require_once 'core/external/wpeo_util/init.util.php';
163 163
 require_once 'core/external/wpeo_log/class/log.class.php';
164
-\eoxia\Init_util::g()->exec( realpath( plugin_dir_path( __FILE__ ) ) . '/', basename( __FILE__, '.php' ) );
164
+\eoxia\Init_util::g()->exec(realpath(plugin_dir_path(__FILE__)) . '/', basename(__FILE__, '.php'));
Please login to merge, or discard this patch.
includes/librairies/catalog/products.class.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
 	public static function admin_menu() {
180 180
 		global $submenu;
181 181
 		$attributeEntitySetList = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode));
182
-		$entities_to_unset = array( 'free_product', 'default' );
182
+		$entities_to_unset = array('free_product', 'default');
183 183
 		$submenu_before = $submenu['edit.php?post_type=wpshop_product'];
184 184
 		foreach ($attributeEntitySetList as $key_attribute_set => $attribute_set) {
185
-			if ( !( in_array( $attribute_set->slug, $entities_to_unset ) || in_array( $attribute_set->name, $entities_to_unset ) ) ) {
186
-				add_submenu_page( 'edit.php?post_type=wpshop_product', sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product');
185
+			if (!(in_array($attribute_set->slug, $entities_to_unset) || in_array($attribute_set->name, $entities_to_unset))) {
186
+				add_submenu_page('edit.php?post_type=wpshop_product', sprintf(__('Add %s', 'wpshop'), $attribute_set->name), sprintf(__('Add %s', 'wpshop'), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product');
187 187
 			}
188 188
 		}
189
-		$submenu_new_elements = array_diff_key ( $submenu['edit.php?post_type=wpshop_product'], $submenu_before );
189
+		$submenu_new_elements = array_diff_key($submenu['edit.php?post_type=wpshop_product'], $submenu_before);
190 190
 		$submenu_reorder = array();
191
-		foreach( $submenu_before as $key => $element ) {
192
-			if( empty( $submenu_reorder[$key] ) ) {
191
+		foreach ($submenu_before as $key => $element) {
192
+			if (empty($submenu_reorder[$key])) {
193 193
 				$submenu_reorder[$key] = $element;
194
-				if( in_array( 'post-new.php?post_type=wpshop_product', $element ) ) {
195
-					$submenu_reorder = array_merge( $submenu_reorder, array_values( $submenu_new_elements ) );
194
+				if (in_array('post-new.php?post_type=wpshop_product', $element)) {
195
+					$submenu_reorder = array_merge($submenu_reorder, array_values($submenu_new_elements));
196 196
 				}
197 197
 			} else {
198 198
 				$submenu_reorder[] = $element;
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 
541 541
         $products = array();
542 542
         $query = "SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code=%s";
543
-        $data = (array) $wpdb->get_row($wpdb->prepare($query, $attr_name));
543
+        $data = (array)$wpdb->get_row($wpdb->prepare($query, $attr_name));
544 544
 
545 545
         if (!empty($data)) {
546 546
             if ($data['data_type_to_use'] == 'custom') {
547 547
                 // Find which table to take
548
-                if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME;} elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL;} elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER;} elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;} elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT;} elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR;}
548
+                if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; } elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; } elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; } elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; } elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; } elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
549 549
 
550 550
                 if (isset($table_name)) {
551 551
                     // If the value is an id of a select, radio or checkbox
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
         if (!empty($atts['product_type'])) {
696 696
             switch ($atts['product_type']) {
697 697
                 case 'related':
698
-                    $product_id = !empty($atts['pid']) ? (int) $atts['pid'] : get_the_ID();
698
+                    $product_id = !empty($atts['pid']) ? (int)$atts['pid'] : get_the_ID();
699 699
                     $type = !empty($atts['display_mode']) && in_array($atts['display_mode'], array('list', 'grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE;
700 700
                     $grid_element_nb_per_line = !empty($atts['grid_element_nb_per_line']) ? $atts['grid_element_nb_per_line'] : WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE;
701 701
 
702
-                    $pids = get_post_meta((int) $product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
702
+                    $pids = get_post_meta((int)$product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
703 703
                     if (!empty($pids) && !empty($pids[0])) {
704 704
                         $pid = implode(',', $pids);
705 705
                     }
@@ -768,8 +768,8 @@  discard block
 block discarded – undo
768 768
                     $sub_tpl_component = array();
769 769
                     $criteria = '';
770 770
                     foreach ($sorting_criteria as $c):
771
-											$selected = isset( $atts['order'] ) ? $atts['order'] : null;
772
-                      $criteria .= '<option value="' . $c['code'] . '" ' . selected( $selected, $c['code'], false ) . '>' . __($c['frontend_label'], 'wpshop') . '</option>';
771
+											$selected = isset($atts['order']) ? $atts['order'] : null;
772
+                      $criteria .= '<option value="' . $c['code'] . '" ' . selected($selected, $c['code'], false) . '>' . __($c['frontend_label'], 'wpshop') . '</option>';
773 773
                     endforeach;
774 774
                     $sub_tpl_component['SORTING_CRITERIA_LIST'] = $criteria;
775 775
                     $tpl_component['SORTING_CRITERIA'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component);
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             // --------------------- //
939 939
             // Pagination management //
940 940
             // --------------------- //
941
-            if ( $display_pagination ) {
941
+            if ($display_pagination) {
942 942
                 if ($nb_of_product_limit == 0) {
943 943
 
944 944
                     $paginate = paginate_links(array(
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
 		$newQty = $product['product_stock'] - $qty;
1014 1014
 		$value_id = 0;
1015 1015
 		if ($newQty >= 0) {
1016
-			$query = $wpdb->prepare( "
1016
+			$query = $wpdb->prepare("
1017 1017
 				SELECT ATTDEC.value_id
1018 1018
 				FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . " AS ATTDEC
1019 1019
 				LEFT JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATT ON ATTDEC.attribute_id = ATT.id
1020 1020
 				WHERE ATTDEC.entity_id = %d AND ATT.code = %s
1021
-				LIMIT 1", $product_id, 'product_stock' );
1021
+				LIMIT 1", $product_id, 'product_stock');
1022 1022
 				$value_id = $wpdb->get_var($query);
1023
-				$update = $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => wpshop_tools::wpshop_clean($newQty)), array('value_id' => $value_id));
1023
+				$update = $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => wpshop_tools::wpshop_clean($newQty)), array('value_id' => $value_id));
1024 1024
 			}
1025 1025
 			// Historic
1026 1026
 			$attribute_histo_content = array();
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
     {
1218 1218
         global $wpdb;
1219 1219
 
1220
-        $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array) $_REQUEST;
1220
+        $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array)$_REQUEST;
1221 1221
         // Apply a filter to extra actions
1222 1222
         $data_to_save = apply_filters('wps_save_product_extra_filter', $data_to_save);
1223 1223
 
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
                             $attributeValue = str_replace(',', '.', $attributeValue);
1274 1274
                         }
1275 1275
                         if (($attributeType == 'integer') && !is_array($attributeValue)) {
1276
-                            $attributeValue = (int) $attributeValue;
1276
+                            $attributeValue = (int)$attributeValue;
1277 1277
                         }
1278 1278
                         $productMetaDatas[$attributeCode] = $attributeValue;
1279 1279
                     }
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
                                     $attributeValue = str_replace(',', '.', $attribute->$value_key);
1324 1324
                                 }
1325 1325
                                 if (($attribute->data_type == 'integer') && !is_array($attributeValue)) {
1326
-                                    $attributeValue = (int) $attribute->$value_key;
1326
+                                    $attributeValue = (int)$attribute->$value_key;
1327 1327
                                 }
1328 1328
                                 $variation_metadata[$attribute->code] = $attribute->$value_key;
1329 1329
                             }
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
                                 $attributeValue = str_replace(',', '.', $attributeValue);
1337 1337
                             }
1338 1338
                             if (($attributeType == 'integer') && !is_array($attributeValue)) {
1339
-                                $attributeValue = (int) $attributeValue;
1339
+                                $attributeValue = (int)$attributeValue;
1340 1340
                             }
1341 1341
                             $variation_metadata[$attributeCode] = $attributeValue;
1342 1342
                         }
@@ -1672,13 +1672,13 @@  discard block
 block discarded – undo
1672 1672
             if (!empty($product_price_infos)) {
1673 1673
                 $tpl_component_price = array();
1674 1674
                 /** Price piloting **/
1675
-				$price_display_option = get_option( 'wpshop_catalog_product_option' );
1676
-				$tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) ? 'on' : '';
1675
+				$price_display_option = get_option('wpshop_catalog_product_option');
1676
+				$tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) ? 'on' : '';
1677 1677
                 $price_ploting = get_option('wpshop_shop_price_piloting');
1678 1678
                 $tpl_component_price['CROSSED_OUT_PRICE'] = (!empty($product_price_infos['CROSSED_OUT_PRICE'])) ? ((!empty($product_price_infos['PRICE_FROM'])) ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $product_price_infos['CROSSED_OUT_PRICE'])) : '';
1679 1679
                 $variations = wpshop_products::get_variation($product_id);
1680 1680
 				$tpl_component_price['PRODUCT_PRICE'] = $product_price_infos['PRODUCT_PRICE'];
1681
-				if(empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty( $tpl_component['PRICE_FROM'] ) ))) {
1681
+				if (empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty($tpl_component['PRICE_FROM'])))) {
1682 1682
 					$tpl_component_price['PRODUCT_PRICE'] = __('Price from', 'wpshop') . ' ' . $tpl_component_price['PRODUCT_PRICE'];
1683 1683
 				}
1684 1684
                 $tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY'];
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
             }
2122 2122
 
2123 2123
             $template_part = ($variations_list && ($output_type == 'mini')) ? 'configure_product_button' : (!empty($productStock) ? 'add_to_cart_button' : 'unavailable_product_button');
2124
-						$template_part = apply_filters( 'wps_custom_add_to_cart_button', $template_part, $product_id );
2124
+						$template_part = apply_filters('wps_custom_add_to_cart_button', $template_part, $product_id);
2125 2125
 
2126 2126
             $tpl_component = array();
2127 2127
             $tpl_component['PRODUCT_ID'] = $product_id;
@@ -2983,7 +2983,7 @@  discard block
 block discarded – undo
2983 2983
                 $single_variations = array();
2984 2984
                 foreach ($selected_variation as $attribute_code => $attribute_value) {
2985 2985
                     if (isset($attribute_value) && $attribute_code != 'free') {
2986
-                        $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int) $attribute_value)) . "'", $product_id);
2986
+                        $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int)$attribute_value)) . "'", $product_id);
2987 2987
                         $single_variation_id = $wpdb->get_var($query);
2988 2988
                         if (!empty($single_variation_id)) {
2989 2989
                             $single_variations[] = $single_variation_id;
@@ -3085,7 +3085,7 @@  discard block
 block discarded – undo
3085 3085
              * Since 1.4.3.7
3086 3086
              * L'option du produit remplace le prix du produit de tête.
3087 3087
              */
3088
-			if( true ) {
3088
+			if (true) {
3089 3089
                 //Replace the product price
3090 3090
                 if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) {
3091 3091
                     $product_into_cart['price_ttc_before_discount'] = $variations_total_price['price_ati'];
@@ -3452,16 +3452,16 @@  discard block
 block discarded – undo
3452 3452
 		$variation_post_meta = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
3453 3453
         $variation_post_meta['options'] = $options;
3454 3454
 		$variation_post_meta['follow_general_config'] = true;
3455
-		if( $variation_post_meta['follow_general_config'] ) {
3455
+		if ($variation_post_meta['follow_general_config']) {
3456 3456
 			$shop_option = get_option('wpshop_catalog_product_option', array());
3457
-			if( isset( $shop_option ) ) {
3457
+			if (isset($shop_option)) {
3458 3458
 				$variation_post_meta['options']['price_display'] = $shop_option['price_display'];
3459 3459
 			}
3460 3460
 		}
3461 3461
 		$variations = wpshop_attributes::get_variation_available_attribute($current_post_id);
3462
-		if( !empty( $variations['available'] ) ) {
3463
-			foreach( $variations['available'] as $key => $value ) {
3464
-				if( !in_array( $value['attribute_complete_def']->code, $variation_post_meta['attributes'] ) ) {
3462
+		if (!empty($variations['available'])) {
3463
+			foreach ($variations['available'] as $key => $value) {
3464
+				if (!in_array($value['attribute_complete_def']->code, $variation_post_meta['attributes'])) {
3465 3465
 					$variation_post_meta['attributes'][] = $value['attribute_complete_def']->code;
3466 3466
 				}
3467 3467
 			}
Please login to merge, or discard this patch.
modules/wps_customer/controller/wps-customer-metaboxes.controller.01.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package WPShop
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 	 * Instanciation de la gestion des metaboxes / Insctanciate metaboxes management
24 24
 	 */
25 25
 	function __construct() {
26
-		add_action( 'add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array( $this, 'add_meta_box_customer' ) );
27
-		add_action( 'add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, array( $this, 'add_meta_box_order' ) );
26
+		add_action('add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array($this, 'add_meta_box_customer'));
27
+		add_action('add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, array($this, 'add_meta_box_order'));
28 28
 	}
29 29
 
30 30
 	/**
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param WP_Post $customer Le client actuel / The current customer.
34 34
 	 */
35
-	function add_meta_box_customer( $customer ) {
36
-		add_meta_box( 'wps_customer_informations', __( 'Customer\'s account informations', 'wpshop' ), array( $this, 'wps_customer_account_informations' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high' );
37
-		if ( 'auto-draft' !== $customer->post_status ) {
38
-			add_meta_box( 'wps_customer_orders', __( 'Customer\'s orders', 'wpshop' ) . '<a class="page-title-action" href="' . admin_url( 'post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) . '&customer_id=' . $customer->ID . '">' . __( 'Add quotation', 'wpshop' ) . '</a>', array( $this, 'wps_customer_orders_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' );
39
-			add_meta_box( 'wps_customer_messages_list', __( 'Customer\'s send messages', 'wpshop' ), array( $this, 'wps_customer_messages_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' );
40
-			add_meta_box( 'wps_customer_coupons_list', __( 'Customer\'s coupons list', 'wpshop' ), array( $this, 'wps_customer_coupons_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' );
41
-			add_meta_box( 'wps_customer_addresses_list', __( 'Customer\'s addresses', 'wpshop' ), array( $this, 'wps_customer_addresses_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' );
35
+	function add_meta_box_customer($customer) {
36
+		add_meta_box('wps_customer_informations', __('Customer\'s account informations', 'wpshop'), array($this, 'wps_customer_account_informations'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high');
37
+		if ('auto-draft' !== $customer->post_status) {
38
+			add_meta_box('wps_customer_orders', __('Customer\'s orders', 'wpshop') . '<a class="page-title-action" href="' . admin_url('post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER) . '&customer_id=' . $customer->ID . '">' . __('Add quotation', 'wpshop') . '</a>', array($this, 'wps_customer_orders_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low');
39
+			add_meta_box('wps_customer_messages_list', __('Customer\'s send messages', 'wpshop'), array($this, 'wps_customer_messages_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low');
40
+			add_meta_box('wps_customer_coupons_list', __('Customer\'s coupons list', 'wpshop'), array($this, 'wps_customer_coupons_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low');
41
+			add_meta_box('wps_customer_addresses_list', __('Customer\'s addresses', 'wpshop'), array($this, 'wps_customer_addresses_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low');
42 42
 		}
43 43
 	}
44 44
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param WP_Post $order La commande sur laquelle on se trouve / Currently edited order.
49 49
 	 */
50
-	function add_meta_box_order( $order ) {
50
+	function add_meta_box_order($order) {
51 51
 		/**	Box with order customer information	*/
52 52
 		$metabox_title_button = '';
53
-		$order_metadata = get_post_meta( $order->ID, '_order_postmeta', true );
54
-		if ( empty( $order_metadata ) || ( ! empty( $order_metadata['order_status'] ) && ( 'awaiting_payment' === $order_metadata['order_status'] ) ) ) {
55
-			$metabox_title_button = '<a href="' . wp_nonce_url( admin_url( 'admin-ajax.php?action=wps_load_customer_creation_form_in_admin&width=730&height=690' ), 'wps_load_customer_creation_form_in_admin', '_wpnonce' ) . '" title="' . __( 'Create a customer', 'wpshop' ) . '" class="page-title-action thickbox" >' . __( 'Create a customer', 'wpshop' ) . '</a>';
53
+		$order_metadata = get_post_meta($order->ID, '_order_postmeta', true);
54
+		if (empty($order_metadata) || (!empty($order_metadata['order_status']) && ('awaiting_payment' === $order_metadata['order_status']))) {
55
+			$metabox_title_button = '<a href="' . wp_nonce_url(admin_url('admin-ajax.php?action=wps_load_customer_creation_form_in_admin&width=730&height=690'), 'wps_load_customer_creation_form_in_admin', '_wpnonce') . '" title="' . __('Create a customer', 'wpshop') . '" class="page-title-action thickbox" >' . __('Create a customer', 'wpshop') . '</a>';
56 56
 		}
57
-		add_meta_box( 'wpshop_order_customer_information_box', '<span class="dashicons dashicons-businessman"></span> ' . __( 'Customer information', 'wpshop' ) . $metabox_title_button, array( $this, 'display_order_customer_informations_in_administration' ), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'high' );
57
+		add_meta_box('wpshop_order_customer_information_box', '<span class="dashicons dashicons-businessman"></span> ' . __('Customer information', 'wpshop') . $metabox_title_button, array($this, 'display_order_customer_informations_in_administration'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'high');
58 58
 	}
59 59
 
60 60
 	/**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @param WP_Post $post Current post (customer) we are editing.
64 64
 	 */
65
-	function wps_customer_orders_list( $post ) {
65
+	function wps_customer_orders_list($post) {
66 66
 		$output = '';
67 67
 		$wps_orders = new wps_orders_ctr();
68
-		$output .= $wps_orders->display_orders_in_account( $post->ID );
68
+		$output .= $wps_orders->display_orders_in_account($post->ID);
69 69
 
70 70
 		echo $output; // WPCS: XSS ok.
71 71
 	}
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param WP_Post $post Current post (customer) we are editing.
77 77
 	 */
78
-	function wps_customer_addresses_list( $post ) {
78
+	function wps_customer_addresses_list($post) {
79 79
 		$wps_addresses = new wps_address();
80
-		$output = $wps_addresses->display_addresses_interface( $post->ID, true );
81
-		echo '<input type="hidden" name="wps_customer_id" id="wps_orders_selected_customer" value="' . esc_attr( $post->ID ) . '">';
82
-		echo '<input type="hidden" name="wps_customer_addresses_nonce" id="wps_customer_addresses_nonce" value="' . esc_attr( wp_create_nonce( 'reload_addresses_for_customer' ) ) . '">';
80
+		$output = $wps_addresses->display_addresses_interface($post->ID, true);
81
+		echo '<input type="hidden" name="wps_customer_id" id="wps_orders_selected_customer" value="' . esc_attr($post->ID) . '">';
82
+		echo '<input type="hidden" name="wps_customer_addresses_nonce" id="wps_customer_addresses_nonce" value="' . esc_attr(wp_create_nonce('reload_addresses_for_customer')) . '">';
83 83
 		echo '<div id="wps_customer_addresses" class="wps-gridwrapper2-padded">' . $output . '</div>'; // WPCS: XSS ok.
84 84
 	}
85 85
 
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param WP_Post $post Current post (customer) we are editing.
90 90
 	 */
91
-	function wps_customer_messages_list( $post ) {
91
+	function wps_customer_messages_list($post) {
92 92
 		$wps_messages = new wps_message_ctr();
93
-		$output = $wps_messages->display_message_histo_per_customer( array(), $post->ID );
93
+		$output = $wps_messages->display_message_histo_per_customer(array(), $post->ID);
94 94
 
95 95
 		echo $output; // WPCS: XSS ok.
96 96
 	}
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param WP_Post $post Current post (customer) we are editing.
102 102
 	 */
103
-	function wps_customer_coupons_list( $post ) {
103
+	function wps_customer_coupons_list($post) {
104 104
 		$wps_vouncher = new wps_coupon_ctr();
105
-		$output = $wps_vouncher->display_coupons( $post->post_author );
105
+		$output = $wps_vouncher->display_coupons($post->post_author);
106 106
 
107 107
 		echo $output; // WPCS: XSS ok.
108 108
 	}
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param WP_Post $post Current post (customer) we are editing.
114 114
 	 */
115
-	function wps_customer_account_informations( $post ) {
115
+	function wps_customer_account_informations($post) {
116 116
 		$wps_account = new wps_account_ctr();
117
-		$output = $wps_account->display_account_informations( $post->ID );
117
+		$output = $wps_account->display_account_informations($post->ID);
118 118
 
119 119
 		echo $output; // WPCS: XSS ok.
120 120
 	}
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param WP_Post $post L'objet WP_Post correspond à la commande / The WP_Post object corresponding to the order.
126 126
 	 */
127
-	function display_order_customer_informations_in_administration( $post ) {
127
+	function display_order_customer_informations_in_administration($post) {
128 128
 		// N'afficher la metabox uniquement dans les commandes / Only display metabox in orders.
129
-		if ( ! empty( $post ) && ( WPSHOP_NEWTYPE_IDENTIFIER_ORDER === $post->post_type ) ) {
129
+		if (!empty($post) && (WPSHOP_NEWTYPE_IDENTIFIER_ORDER === $post->post_type)) {
130 130
 			$post_id = $post->ID;
131 131
 
132
-			wps_customer_admin::display_customer_informations_in_order( $post_id, ( ! empty( $_REQUEST['customer_id'] ) ? (int) $_REQUEST['customer_id'] : $post->post_parent ) );
132
+			wps_customer_admin::display_customer_informations_in_order($post_id, (!empty($_REQUEST['customer_id']) ? (int)$_REQUEST['customer_id'] : $post->post_parent));
133 133
 		} else {
134
-			esc_html_e( 'The requested order has not been found', 'wpshop' );
134
+			esc_html_e('The requested order has not been found', 'wpshop');
135 135
 		}
136 136
 	}
137 137
 
Please login to merge, or discard this patch.
includes/modules/wps_message/model/wps_message_mdl.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_message_mdl {
3 3
 
4 4
 	function __construct() { }
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 	 * @param integer $customer_id
10 10
 	 * @return array
11 11
 	 */
12
-	function get_messages_histo( $message_id = '', $customer_id = '' ) {
12
+	function get_messages_histo($message_id = '', $customer_id = '') {
13 13
 		global $wpdb;
14 14
 		$messages_data = array();
15
-		if( empty($customer_id) ) {
16
-			$query = $wpdb->prepare( 'SELECT meta_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_' . $message_id . '%' );
15
+		if (empty($customer_id)) {
16
+			$query = $wpdb->prepare('SELECT meta_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_' . $message_id . '%');
17 17
 		} else {
18
-			$query = $wpdb->prepare( 'SELECT meta_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND post_id = %d', '_wpshop_messages_histo_' . $message_id . '%', $customer_id );
18
+			$query = $wpdb->prepare('SELECT meta_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND post_id = %d', '_wpshop_messages_histo_' . $message_id . '%', $customer_id);
19 19
 		}
20 20
 
21
-		$messages = $wpdb->get_results( $query );
21
+		$messages = $wpdb->get_results($query);
22 22
 
23
-		if( !empty($messages) ) {
24
-			foreach( $messages as $message ) {
25
-				$messages_data[$message->meta_id] = maybe_unserialize( $message->meta_value );
23
+		if (!empty($messages)) {
24
+			foreach ($messages as $message) {
25
+				$messages_data[$message->meta_id] = maybe_unserialize($message->meta_value);
26 26
 			}
27 27
 		}
28 28
 		return $messages_data;
Please login to merge, or discard this patch.
includes/modules/wps_message/controller/wps_message_ctr.php 1 patch
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) { exit;
1
+<?php if (!defined('ABSPATH')) { exit;
2 2
 }
3 3
 class wps_message_ctr {
4 4
 
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 	function __construct() {
19 19
 
20 20
 		/** Js */
21
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
21
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
22 22
 		// End if().
23 23
 		$this->template_dir = WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/';
24 24
 		// WP General actions
25
-		add_action( 'admin_init', array( $this, 'wps_messages_init_actions' ) );
26
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
27
-		add_action( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column',  array( $this, 'messages_custom_columns' ) );
28
-		add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array( $this, 'messages_edit_columns' ) );
25
+		add_action('admin_init', array($this, 'wps_messages_init_actions'));
26
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
27
+		add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column', array($this, 'messages_custom_columns'));
28
+		add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array($this, 'messages_edit_columns'));
29 29
 		// Shortcodes
30
-		add_shortcode( 'wps_message_histo', array( $this, 'display_message_histo_per_customer' ) );
31
-		add_shortcode( 'order_customer_personnal_informations', array( $this, 'order_personnal_informations' ) );
30
+		add_shortcode('wps_message_histo', array($this, 'display_message_histo_per_customer'));
31
+		add_shortcode('order_customer_personnal_informations', array($this, 'order_personnal_informations'));
32 32
 		/** Ajax */
33
-		add_action( 'wp_ajax_get_content_message', array( $this, 'get_content_message' ) );
33
+		add_action('wp_ajax_get_content_message', array($this, 'get_content_message'));
34 34
 	}
35 35
 
36 36
 	/**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
 		/** Css */
42 42
 		add_thickbox();
43
-		wp_register_style( 'wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION );
44
-		wp_enqueue_style( 'wpeo-message-css' );
43
+		wp_register_style('wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION);
44
+		wp_enqueue_style('wpeo-message-css');
45 45
 		/** My js */
46
-		wp_enqueue_script( 'wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array( 'jquery', 'thickbox' ), WPS_MESSAGE_VERSION );
46
+		wp_enqueue_script('wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array('jquery', 'thickbox'), WPS_MESSAGE_VERSION);
47 47
 	}
48 48
 
49 49
 	/**
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	function create_message_type() {
61 61
 
62
-		register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array(
62
+		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array(
63 63
 			'labels' => array(
64
-				'name' => __( 'Message', 'wpshop' ),
65
-				'singular_name' => __( 'message', 'wpshop' ),
66
-				'add_new' => __( 'Add message', 'wpshop' ),
67
-				'add_new_item' => __( 'Add New message', 'wpshop' ),
68
-				'edit' => __( 'Edit', 'wpshop' ),
69
-				'edit_item' => __( 'Edit message', 'wpshop' ),
70
-				'new_item' => __( 'New message', 'wpshop' ),
71
-				'view' => __( 'View message', 'wpshop' ),
72
-				'view_item' => __( 'View message', 'wpshop' ),
73
-				'search_items' => __( 'Search messages', 'wpshop' ),
74
-				'not_found' => __( 'No message found', 'wpshop' ),
75
-				'not_found_in_trash' => __( 'No message found in trash', 'wpshop' ),
64
+				'name' => __('Message', 'wpshop'),
65
+				'singular_name' => __('message', 'wpshop'),
66
+				'add_new' => __('Add message', 'wpshop'),
67
+				'add_new_item' => __('Add New message', 'wpshop'),
68
+				'edit' => __('Edit', 'wpshop'),
69
+				'edit_item' => __('Edit message', 'wpshop'),
70
+				'new_item' => __('New message', 'wpshop'),
71
+				'view' => __('View message', 'wpshop'),
72
+				'view_item' => __('View message', 'wpshop'),
73
+				'search_items' => __('Search messages', 'wpshop'),
74
+				'not_found' => __('No message found', 'wpshop'),
75
+				'not_found_in_trash' => __('No message found in trash', 'wpshop'),
76 76
 				'parent-item-colon' => '',
77 77
 			),
78
-			'description' => __( 'This is where store messages are stored.', 'wpshop' ),
78
+			'description' => __('This is where store messages are stored.', 'wpshop'),
79 79
 			'public' => true,
80 80
 			'show_ui' => true,
81 81
 			'capability_type' => 'post',
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 			'show_in_nav_menus' => false,
87 87
 			'rewrite' => false,
88 88
 			'query_var' => true,
89
-			'supports' => array( 'title', 'editor' ),
89
+			'supports' => array('title', 'editor'),
90 90
 			'has_archive' => false,
91
-		) );
91
+		));
92 92
 	}
93 93
 
94 94
 	/**
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	function add_meta_boxes() {
98 98
 
99 99
 		// Add message sending historic meta box
100
-		add_meta_box( 'wpshop_message_histo',
101
-			__( 'Message historic', 'wpshop' ),
102
-			array( $this, 'message_histo_box' ),
103
-		WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high' );
100
+		add_meta_box('wpshop_message_histo',
101
+			__('Message historic', 'wpshop'),
102
+			array($this, 'message_histo_box'),
103
+		WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high');
104 104
 	}
105 105
 
106 106
 	/**
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	 * @param unknown_type $post
110 110
 	 * @param unknown_type $params
111 111
 	 */
112
-	function message_histo_box( $post, $params ) {
112
+	function message_histo_box($post, $params) {
113 113
 
114 114
 		$output  = '<div id="message_histo_container">';
115
-		$output .= $this->get_historic_message_by_type( $post->ID );
115
+		$output .= $this->get_historic_message_by_type($post->ID);
116 116
 		$output .= '</div>';
117 117
 		echo $output;
118 118
 	}
@@ -123,39 +123,39 @@  discard block
 block discarded – undo
123 123
 	 * @param  integer $message_type_id : Message type ID
124 124
 	 * @return string
125 125
 	 */
126
-	function get_historic_message_by_type( $message_type_id ) {
126
+	function get_historic_message_by_type($message_type_id) {
127 127
 
128 128
 		global $wpdb;
129 129
 		$output = '';
130
-		if ( ! empty( $message_type_id ) ) {
130
+		if (!empty($message_type_id)) {
131 131
 			// Recover all sended messages
132 132
 			$wps_message_mdl = new wps_message_mdl();
133
-			$messages = $wps_message_mdl->get_messages_histo( $message_type_id );
133
+			$messages = $wps_message_mdl->get_messages_histo($message_type_id);
134 134
 			ob_start();
135
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic' ) );
135
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic'));
136 136
 			$output .= ob_get_contents();
137 137
 			ob_end_clean();
138 138
 		}
139 139
 		return $output;
140 140
 	}
141 141
 
142
-	public static function get_xml_messages( $code = null ) {
143
-		if ( is_null( self::$xml_messages ) ) {
144
-			$xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' );
145
-			$default_emails = new SimpleXMLElement( $xml_default_emails );
142
+	public static function get_xml_messages($code = null) {
143
+		if (is_null(self::$xml_messages)) {
144
+			$xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml');
145
+			$default_emails = new SimpleXMLElement($xml_default_emails);
146 146
 			self::$xml_messages = array();
147
-			foreach ( $default_emails->xpath( '//emails/email' ) as $email ) {
148
-				self::$xml_messages[ (string) $email->attributes()->code ] = array(
149
-					'shop_type' => (string) $email->attributes()->shop_type,
150
-					'object' => (string) $email->subject,
151
-					'message' => (string) $email->content,
147
+			foreach ($default_emails->xpath('//emails/email') as $email) {
148
+				self::$xml_messages[(string)$email->attributes()->code] = array(
149
+					'shop_type' => (string)$email->attributes()->shop_type,
150
+					'object' => (string)$email->subject,
151
+					'message' => (string)$email->content,
152 152
 				);
153 153
 			}
154 154
 		}
155
-		if ( is_null( $code ) ) {
155
+		if (is_null($code)) {
156 156
 			return self::$xml_messages;
157
-		} elseif ( isset( self::$xml_messages[ $code ] ) ) {
158
-			return self::$xml_messages[ $code ];
157
+		} elseif (isset(self::$xml_messages[$code])) {
158
+			return self::$xml_messages[$code];
159 159
 		} else {
160 160
 			return false;
161 161
 		}
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public static function create_default_message() {
167 167
 		// Read default emails for options creation
168
-		foreach ( self::get_xml_messages() as $code => $email ) {
169
-			if ( ( WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type'] ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) {
170
-				self::createMessage( $code, $email['object'], $email['message'] );
168
+		foreach (self::get_xml_messages() as $code => $email) {
169
+			if ((WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type']) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) {
170
+				self::createMessage($code, $email['object'], $email['message']);
171 171
 			}
172 172
 		}
173 173
 	}
@@ -180,25 +180,25 @@  discard block
 block discarded – undo
180 180
 	 * @param string $message : Message content
181 181
 	 * @return integer message ID
182 182
 	 */
183
-	public static function createMessage( $code, $object = '', $message = '' ) {
183
+	public static function createMessage($code, $object = '', $message = '') {
184 184
 		$id = 0;
185
-		$xml_message = self::get_xml_messages( $code );
186
-		$object = empty( $object ) ? $xml_message['object'] : $object;
187
-		$message = empty( $message ) ? $xml_message['message'] : $message;
188
-		$message_option = get_option( $code, null );
189
-		if ( empty( $message_option ) || false === get_post_status( $message_option ) ) {
190
-			$id = post_exists( __( $object , 'wpshop' ), self::customize_message( __( $message, 'wpshop' ) ) );
191
-			if( $id == 0 ) {
185
+		$xml_message = self::get_xml_messages($code);
186
+		$object = empty($object) ? $xml_message['object'] : $object;
187
+		$message = empty($message) ? $xml_message['message'] : $message;
188
+		$message_option = get_option($code, null);
189
+		if (empty($message_option) || false === get_post_status($message_option)) {
190
+			$id = post_exists(__($object, 'wpshop'), self::customize_message(__($message, 'wpshop')));
191
+			if ($id == 0) {
192 192
 				$new_message = array(
193
-					'post_title' => __( $object , 'wpshop' ),
194
-					'post_content' => self::customize_message( __( $message, 'wpshop' ) ),
193
+					'post_title' => __($object, 'wpshop'),
194
+					'post_content' => self::customize_message(__($message, 'wpshop')),
195 195
 					'post_status' => 'publish',
196 196
 					'post_author' => 1,
197 197
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE,
198 198
 				);
199
-				$id = wp_insert_post( $new_message );
199
+				$id = wp_insert_post($new_message);
200 200
 			}
201
-			update_option( $code, $id );
201
+			update_option($code, $id);
202 202
 		} else {
203 203
 			$id = $message_option;
204 204
 		}
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return array
213 213
 	 */
214
-	function messages_custom_columns( $column ) {
214
+	function messages_custom_columns($column) {
215 215
 
216 216
 		global $post;
217 217
 		$metadata = get_post_custom();
218
-		switch ( $column ) {
218
+		switch ($column) {
219 219
 			case 'extract':
220
-				echo wp_trim_words( $post->post_content, 55 );
220
+				echo wp_trim_words($post->post_content, 55);
221 221
 		break;
222 222
 			case 'last_dispatch_date':
223
-				if ( ! empty( $metadata['wpshop_message_last_dispatch_date'][0] ) ) {
224
-					echo mysql2date( 'd F Y, H:i:s',$metadata['wpshop_message_last_dispatch_date'][0], true );
223
+				if (!empty($metadata['wpshop_message_last_dispatch_date'][0])) {
224
+					echo mysql2date('d F Y, H:i:s', $metadata['wpshop_message_last_dispatch_date'][0], true);
225 225
 				} else { echo '-';
226 226
 				}
227 227
 		break;
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return array
235 235
 	 */
236
-	function messages_edit_columns( $columns ) {
236
+	function messages_edit_columns($columns) {
237 237
 
238 238
 		$columns = array(
239 239
 			'cb' => '<input type="checkbox" />',
240
-			'title' => __( 'Name', 'wpshop' ),
241
-			'extract' => __( 'Extract from the message','wpshop' ),
242
-			'date' => __( 'Creation date','wpshop' ),
243
-			'last_dispatch_date' => __( 'Last dispatch date','wpshop' ),
240
+			'title' => __('Name', 'wpshop'),
241
+			'extract' => __('Extract from the message', 'wpshop'),
242
+			'date' => __('Creation date', 'wpshop'),
243
+			'last_dispatch_date' => __('Last dispatch date', 'wpshop'),
244 244
 		);
245 245
 		return $columns;
246 246
 	}
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
 	 * @param integer $current
252 252
 	 * @return string
253 253
 	 */
254
-	function getMessageListOption( $current = 0 ) {
254
+	function getMessageListOption($current = 0) {
255 255
 
256
-		$posts = query_posts( array(
256
+		$posts = query_posts(array(
257 257
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE,
258 258
 			'posts_per_page' => '-1',
259
-		) );
259
+		));
260 260
 		$options = '';
261
-		if ( ! empty( $posts ) ) {
262
-			$options = '<option value="0">' . __( 'Select values from list', 'wpshop' ) . '</option>';
263
-			foreach ( $posts as $p ) {
264
-				$selected = $p->ID == $current ? ' selected="selected"': '';
261
+		if (!empty($posts)) {
262
+			$options = '<option value="0">' . __('Select values from list', 'wpshop') . '</option>';
263
+			foreach ($posts as $p) {
264
+				$selected = $p->ID == $current ? ' selected="selected"' : '';
265 265
 				$options .= '<option value="' . $p->ID . '"' . $selected . '>' . $p->post_title . '</option>';
266 266
 			}
267 267
 		}
@@ -276,33 +276,33 @@  discard block
 block discarded – undo
276 276
 	 * @param integer $customer_id : ID to identifiate the customer
277 277
 	 * @return string
278 278
 	 */
279
-	function display_message_histo_per_customer( $args, $customer_id = '' ) {
280
-		$customer_id = ( ! empty( $customer_id ) ) ? $customer_id : ( isset( $args['cid'] ) && ! empty( $args['cid'] ) ? $args['cid'] : get_current_user_id() );
281
-		$message_id = ( ! empty( $args ) && ! empty( $args['message_id'] ) ) ? $args['message_id'] : '';
279
+	function display_message_histo_per_customer($args, $customer_id = '') {
280
+		$customer_id = (!empty($customer_id)) ? $customer_id : (isset($args['cid']) && !empty($args['cid']) ? $args['cid'] : get_current_user_id());
281
+		$message_id = (!empty($args) && !empty($args['message_id'])) ? $args['message_id'] : '';
282 282
 		$message_elements = '';
283 283
 		$wps_message_mdl = new wps_message_mdl();
284
-		$messages_data = $wps_message_mdl->get_messages_histo( $message_id, $customer_id );
284
+		$messages_data = $wps_message_mdl->get_messages_histo($message_id, $customer_id);
285 285
 
286 286
 		$messages_histo = array();
287
- 		foreach ( $messages_data as $meta_id => $messages ) :
287
+ 		foreach ($messages_data as $meta_id => $messages) :
288 288
  			$i = 0;
289
- 			foreach ( $messages as $message ) :
290
-				if ( $current_user->user_email === $message['mess_user_email'] ) :
291
-	 				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['title'] = $message['mess_title'];
292
-	 				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['message'] = $message['mess_message'];
293
-	 				$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['dates'] = $message['mess_dispatch_date'];
294
-	 				if ( ! empty( $message['mess_object_id'] ) ) {
295
-	 					$messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['object'] = $message['mess_object_id'];
289
+ 			foreach ($messages as $message) :
290
+				if ($current_user->user_email === $message['mess_user_email']) :
291
+	 				$messages_histo[$message['mess_dispatch_date'][0]][$i]['title'] = $message['mess_title'];
292
+	 				$messages_histo[$message['mess_dispatch_date'][0]][$i]['message'] = $message['mess_message'];
293
+	 				$messages_histo[$message['mess_dispatch_date'][0]][$i]['dates'] = $message['mess_dispatch_date'];
294
+	 				if (!empty($message['mess_object_id'])) {
295
+	 					$messages_histo[$message['mess_dispatch_date'][0]][$i]['object'] = $message['mess_object_id'];
296 296
 	 				}
297 297
 	 				$i++;
298 298
 				endif;
299 299
  			endforeach;
300 300
  		endforeach;
301 301
 
302
-		ksort( $messages_histo );
303
-		$messages_histo = array_reverse( $messages_histo );
302
+		ksort($messages_histo);
303
+		$messages_histo = array_reverse($messages_histo);
304 304
 		ob_start();
305
-		require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages' ) );
305
+		require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages'));
306 306
 		$output = ob_get_contents();
307 307
 		ob_end_clean();
308 308
 
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	 * @param string $message : message content
316 316
 	 * @return string
317 317
 	 */
318
-	public static function customize_message( $message ) {
318
+	public static function customize_message($message) {
319 319
 
320
-		if ( ! empty( $message ) ) {
320
+		if (!empty($message)) {
321 321
 			ob_start();
322
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure' ) );
322
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure'));
323 323
 			$message = ob_get_contents();
324 324
 			ob_end_clean();
325 325
 		}
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return boolean
332 332
 	 */
333
-	function add_message( $recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null ) {
333
+	function add_message($recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null) {
334 334
 
335
-		$date = empty( $date ) ? current_time( 'mysql', 0 ) : $date;
335
+		$date = empty($date) ? current_time('mysql', 0) : $date;
336 336
 		$object_empty = array(
337 337
 			'object_type' => '',
338 338
 			'object_id' => 0,
339 339
 		);
340
-		$object = array_merge( $object_empty, $object );
341
-		$historic = get_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), true );
340
+		$object = array_merge($object_empty, $object);
341
+		$historic = get_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), true);
342 342
 		$data_to_insert = array(
343 343
 			'mess_user_id' => $recipient_id,
344 344
 			'mess_user_email' => $email,
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 			'mess_object_id' => $object['object_id'],
347 347
 			'mess_title' => $title,
348 348
 			'mess_message' => $message,
349
-			'mess_dispatch_date' => array( $date ),
349
+			'mess_dispatch_date' => array($date),
350 350
 		);
351 351
 		$historic[] = $data_to_insert;
352
-		update_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), $historic );
352
+		update_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), $historic);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,49 +361,49 @@  discard block
 block discarded – undo
361 361
 	 * @param boolean $duplicate_message : Duplicate a light message for historic storage
362 362
 	 * @return string
363 363
 	 */
364
-	function customMessage( $string, $data, $model_name = '', $duplicate_message = false ) {
364
+	function customMessage($string, $data, $model_name = '', $duplicate_message = false) {
365 365
 
366 366
 		$avant = array();
367 367
 		$apres = array();
368
-		$logo_option = get_option( 'wpshop_logo' );
368
+		$logo_option = get_option('wpshop_logo');
369 369
 
370
-		$data['your_shop_logo'] = ( ! empty( $logo_option ) ) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo( 'name' ) . '" />' : '';
370
+		$data['your_shop_logo'] = (!empty($logo_option)) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo('name') . '" />' : '';
371 371
 
372
-		foreach ( $data as $key => $value ) {
372
+		foreach ($data as $key => $value) {
373 373
 			$avant[] = '[' . $key . ']';
374
-			switch ( $key ) {
374
+			switch ($key) {
375 375
 				case 'order_content' :
376
-					$apres[] = ( $duplicate_message ) ? '[order_content]' : $this->order_content_template_for_mail( $data['order_id'] );
376
+					$apres[] = ($duplicate_message) ? '[order_content]' : $this->order_content_template_for_mail($data['order_id']);
377 377
 					break;
378 378
 				case 'order_addresses' :
379
-					$apres[] = ( $duplicate_message ) ? '[order_addresses]' : $this->order_addresses_template_for_mail( $data['order_id'] );
379
+					$apres[] = ($duplicate_message) ? '[order_addresses]' : $this->order_addresses_template_for_mail($data['order_id']);
380 380
 					break;
381 381
 
382 382
 				case 'order_billing_address' :
383
-					$apres[] = ( $duplicate_message ) ? '[order_billing_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'billing' );
383
+					$apres[] = ($duplicate_message) ? '[order_billing_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'billing');
384 384
 					break;
385 385
 
386 386
 				case 'order_shipping_address' :
387
-					$apres[] = ( $duplicate_message ) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'shipping' );
387
+					$apres[] = ($duplicate_message) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'shipping');
388 388
 					break;
389 389
 
390 390
 				case 'order_customer_comments' :
391
-					$apres[] = ( $duplicate_message ) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail( $data['order_id'] );
391
+					$apres[] = ($duplicate_message) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail($data['order_id']);
392 392
 					break;
393 393
 				case 'order_personnal_informations' :
394
-					$apres[] = ( $duplicate_message ) ? '[order_personnal_informations]' : $this->order_personnal_informations();
394
+					$apres[] = ($duplicate_message) ? '[order_personnal_informations]' : $this->order_personnal_informations();
395 395
 					break;
396 396
 				default :
397 397
 					$apres[] = $value;
398 398
 					break;
399 399
 			}
400 400
 		}
401
-		$string = str_replace( $avant, $apres, $string );
401
+		$string = str_replace($avant, $apres, $string);
402 402
 
403
-		$string = apply_filters( 'wps_more_customized_message', $string, $data, $duplicate_message );
403
+		$string = apply_filters('wps_more_customized_message', $string, $data, $duplicate_message);
404 404
 
405
-		if ( ($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE') ) {
406
-			$string = preg_replace( '/\[(.*)\]/Usi', '', $string );
405
+		if (($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE')) {
406
+			$string = preg_replace('/\[(.*)\]/Usi', '', $string);
407 407
 		}
408 408
 
409 409
 		return $string;
@@ -418,22 +418,22 @@  discard block
 block discarded – undo
418 418
 	 * @param string $object : message object
419 419
 	 * @param file   $attached_file : File to attached to e-mail
420 420
 	 */
421
-	function wpshop_prepared_email( $email, $model_name, $data = array(), $object = array(), $attached_file = '' ) {
421
+	function wpshop_prepared_email($email, $model_name, $data = array(), $object = array(), $attached_file = '') {
422 422
 		global $wpdb;
423
-		$data = apply_filters( 'wps_extra_data_to_send_in_email', $data );
424
-		$model_id = get_option( $model_name, 0 );
425
-		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id );
426
-		$post_message = $wpdb->get_row( $query );
423
+		$data = apply_filters('wps_extra_data_to_send_in_email', $data);
424
+		$model_id = get_option($model_name, 0);
425
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id);
426
+		$post_message = $wpdb->get_row($query);
427 427
 		$duplicate_message = '';
428
-		if ( ! empty( $post_message ) ) {
429
-			$title = $this->customMessage( $post_message->post_title, $data, $model_name );
430
-			$message = $this->customMessage( $post_message->post_content, $data, $model_name );
428
+		if (!empty($post_message)) {
429
+			$title = $this->customMessage($post_message->post_title, $data, $model_name);
430
+			$message = $this->customMessage($post_message->post_content, $data, $model_name);
431 431
 			// End if().
432
-			if ( array_key_exists( 'order_content', $data ) || array_key_exists( 'order_addresses', $data ) || array_key_exists( 'order_customer_comments', $data ) ) {
433
-				$duplicate_message = $this->customMessage( $post_message->post_content, $data, $model_name, true );
432
+			if (array_key_exists('order_content', $data) || array_key_exists('order_addresses', $data) || array_key_exists('order_customer_comments', $data)) {
433
+				$duplicate_message = $this->customMessage($post_message->post_content, $data, $model_name, true);
434 434
 			}
435
-			if ( ! empty( $email ) ) {
436
-				$this->wpshop_email( $email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message );
435
+			if (!empty($email)) {
436
+				$this->wpshop_email($email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message);
437 437
 			}
438 438
 		}
439 439
 	}
@@ -450,37 +450,37 @@  discard block
 block discarded – undo
450 450
 	 * @param file    $attachments : File to attached to e-mail
451 451
 	 * @param string  $duplicate_message : lighter message to store
452 452
 	 */
453
-	function wpshop_email( $email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '' ) {
453
+	function wpshop_email($email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '') {
454 454
 		global $wpdb;
455 455
 		// Sauvegarde
456
-		if ( $save ) {
457
-			$user = $wpdb->get_row( 'SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";' );
456
+		if ($save) {
457
+			$user = $wpdb->get_row('SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";');
458 458
 			$user_id = $user ? $user->ID : get_current_user_id();
459
-			$query = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
460
-			$user_post_id = $wpdb->get_var( $query );
459
+			$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
460
+			$user_post_id = $wpdb->get_var($query);
461 461
 
462
-			if ( ! empty( $duplicate_message ) ) {
463
-				$this->add_message( $user_post_id, $email, $title, $duplicate_message, $model_id, $object );
462
+			if (!empty($duplicate_message)) {
463
+				$this->add_message($user_post_id, $email, $title, $duplicate_message, $model_id, $object);
464 464
 			} else {
465
-				$this->add_message( $user_post_id, $email, $title, $message, $model_id, $object );
465
+				$this->add_message($user_post_id, $email, $title, $message, $model_id, $object);
466 466
 			}
467 467
 		}
468 468
 
469
-		$emails = get_option( 'wpshop_emails', array() );
469
+		$emails = get_option('wpshop_emails', array());
470 470
 		$noreply_email = $emails['noreply_email'];
471 471
 		// Split the email to get the name
472
-		$vers_nom = substr( $email, 0, strpos( $email,'@' ) );
472
+		$vers_nom = substr($email, 0, strpos($email, '@'));
473 473
 
474 474
 		// Headers du mail
475 475
 		$headers = "MIME-Version: 1.0\r\n";
476 476
 		$headers .= "Content-type: text/html; charset=UTF-8\r\n";
477
-		$headers .= 'From: ' . get_bloginfo( 'name' ) . ' <' . $noreply_email . '>' . "\r\n";
477
+		$headers .= 'From: ' . get_bloginfo('name') . ' <' . $noreply_email . '>' . "\r\n";
478 478
 
479 479
 		// Mail en HTML
480
-		@wp_mail( $email, $title, $message, $headers, $attachments );
480
+		@wp_mail($email, $title, $message, $headers, $attachments);
481 481
 
482
-		if ( ! empty( $attachments ) ) {
483
-			unlink( $attachments );
482
+		if (!empty($attachments)) {
483
+			unlink($attachments);
484 484
 		}
485 485
 	}
486 486
 
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
 	 * @param integer $order_id : Order ID
491 491
 	 * @return string
492 492
 	 */
493
-	function order_content_template_for_mail( $order_id ) {
493
+	function order_content_template_for_mail($order_id) {
494 494
 		$message = '';
495
-		if ( ! empty( $order_id ) ) {
496
-			$currency_code = wpshop_tools::wpshop_get_currency( false );
497
-			$orders_infos = get_post_meta( $order_id, '_order_postmeta', true );
495
+		if (!empty($order_id)) {
496
+			$currency_code = wpshop_tools::wpshop_get_currency(false);
497
+			$orders_infos = get_post_meta($order_id, '_order_postmeta', true);
498 498
 			ob_start();
499
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template' ) );
499
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template'));
500 500
 			$message .= ob_get_contents();
501 501
 			ob_end_clean();
502 502
 		}
@@ -510,44 +510,44 @@  discard block
 block discarded – undo
510 510
 	 * @param integer $address_type : Address type ID
511 511
 	 * @return string
512 512
 	 */
513
-	function order_addresses_template_for_mail( $order_id, $address_type = '' ) {
513
+	function order_addresses_template_for_mail($order_id, $address_type = '') {
514 514
 		global $wpdb;
515
-		$shipping_option = get_option( 'wpshop_shipping_address_choice' );
516
-		$display_shipping = ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) ? true : false;
515
+		$shipping_option = get_option('wpshop_shipping_address_choice');
516
+		$display_shipping = (!empty($shipping_option) && !empty($shipping_option['activate'])) ? true : false;
517 517
 		$message = '';
518
-		if ( ! empty( $order_id ) ) {
519
-			$order_addresses = get_post_meta( $order_id, '_order_info', true );
520
-			if ( ! empty( $order_addresses ) ) {
521
-				foreach ( $order_addresses as $key => $order_address ) {
522
-					if ( ! empty( $order_address ) && ( empty( $address_type ) || $address_type == $key ) ) {
523
-
524
-						if ( $key != 'shipping' || ($key == 'shipping' && $display_shipping) ) {
525
-							$address_type_title = ( ! empty( $key ) && $key == 'billing' ) ? __( 'Billing address', 'wpshop' ) : __( 'Shipping address', 'wpshop' );
518
+		if (!empty($order_id)) {
519
+			$order_addresses = get_post_meta($order_id, '_order_info', true);
520
+			if (!empty($order_addresses)) {
521
+				foreach ($order_addresses as $key => $order_address) {
522
+					if (!empty($order_address) && (empty($address_type) || $address_type == $key)) {
523
+
524
+						if ($key != 'shipping' || ($key == 'shipping' && $display_shipping)) {
525
+							$address_type_title = (!empty($key) && $key == 'billing') ? __('Billing address', 'wpshop') : __('Shipping address', 'wpshop');
526 526
 							$civility = '';
527
-							if ( ! empty( $order_address['address']['civility'] ) ) {
528
-								$query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility'] );
529
-								$civility = $wpdb->get_var( $query );
527
+							if (!empty($order_address['address']['civility'])) {
528
+								$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility']);
529
+								$civility = $wpdb->get_var($query);
530 530
 							}
531 531
 
532 532
 							// Address informations
533
-							$customer_last_name = ( ! empty( $order_address['address']['address_last_name'] ) ) ? $order_address['address']['address_last_name'] : '';
534
-							$customer_firtsname = ( ! empty( $order_address['address']['address_first_name'] ) ) ? $order_address['address']['address_first_name'] : '';
535
-							$customer_company = ( ! empty( $order_address['address']['company'] ) ) ? $order_address['address']['company'] : '';
536
-							$customer_address = ( ! empty( $order_address['address']['address'] ) ) ? $order_address['address']['address'] : '';
537
-							$customer_zip_code = ( ! empty( $order_address['address']['postcode'] ) ) ? $order_address['address']['postcode'] : '';
538
-							$customer_city = ( ! empty( $order_address['address']['city'] ) ) ? $order_address['address']['city'] : '';
539
-							$customer_state = ( ! empty( $order_address['address']['state'] ) ) ? $order_address['address']['state'] : '';
540
-							$customer_phone = ( ! empty( $order_address['address']['phone'] ) ) ? ' Tel. : ' . $order_address['address']['phone'] : '';
533
+							$customer_last_name = (!empty($order_address['address']['address_last_name'])) ? $order_address['address']['address_last_name'] : '';
534
+							$customer_firtsname = (!empty($order_address['address']['address_first_name'])) ? $order_address['address']['address_first_name'] : '';
535
+							$customer_company = (!empty($order_address['address']['company'])) ? $order_address['address']['company'] : '';
536
+							$customer_address = (!empty($order_address['address']['address'])) ? $order_address['address']['address'] : '';
537
+							$customer_zip_code = (!empty($order_address['address']['postcode'])) ? $order_address['address']['postcode'] : '';
538
+							$customer_city = (!empty($order_address['address']['city'])) ? $order_address['address']['city'] : '';
539
+							$customer_state = (!empty($order_address['address']['state'])) ? $order_address['address']['state'] : '';
540
+							$customer_phone = (!empty($order_address['address']['phone'])) ? ' Tel. : ' . $order_address['address']['phone'] : '';
541 541
 							$country = '';
542
-							foreach ( unserialize( WPSHOP_COUNTRY_LIST ) as $key => $value ) {
543
-								if ( ! empty( $order_address['address']['country'] ) && $key == $order_address['address']['country'] ) {
542
+							foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key => $value) {
543
+								if (!empty($order_address['address']['country']) && $key == $order_address['address']['country']) {
544 544
 									$country = $value;
545 545
 								}
546 546
 							}
547 547
 							$customer_country = $country;
548 548
 
549 549
 							ob_start();
550
-							require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail' ) );
550
+							require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail'));
551 551
 							$message .= ob_get_contents();
552 552
 							ob_end_clean();
553 553
 						}
@@ -564,20 +564,20 @@  discard block
 block discarded – undo
564 564
 	 * @param integer $order_id : Order ID
565 565
 	 * @return string
566 566
 	 */
567
-	function order_customer_comment_template_for_mail( $order_id ) {
567
+	function order_customer_comment_template_for_mail($order_id) {
568 568
 		global $wpdb;
569 569
 		$message = '';
570
-		if ( ! empty( $order_id ) ) {
571
-			$query = $wpdb->prepare( 'SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id );
572
-			$comment = $wpdb->get_var( $query );
573
-			$order_infos = get_post_meta( $order_id, '_order_postmeta', true );
574
-			if ( ! empty( $order_infos['order_key'] ) ) {
575
-				$comment_title = __( 'Comments about the order', 'wpshop' );
570
+		if (!empty($order_id)) {
571
+			$query = $wpdb->prepare('SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id);
572
+			$comment = $wpdb->get_var($query);
573
+			$order_infos = get_post_meta($order_id, '_order_postmeta', true);
574
+			if (!empty($order_infos['order_key'])) {
575
+				$comment_title = __('Comments about the order', 'wpshop');
576 576
 			} else {
577
-				$comment_title = __( 'Comments about the quotation', 'wpshop' );
577
+				$comment_title = __('Comments about the quotation', 'wpshop');
578 578
 			}
579 579
 			ob_start();
580
-			require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments' ) );
580
+			require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments'));
581 581
 			$message .= ob_get_contents();
582 582
 			ob_end_clean();
583 583
 		}
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 		global $wpdb;
594 594
 		$user_id = get_current_user_id();
595 595
 		$message = '';
596
-		$customer_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
597
-		if ( ! empty( $customer_entity ) ) {
596
+		$customer_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
597
+		if (!empty($customer_entity)) {
598 598
 
599
-			$query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid' );
600
-			$attributes_sets = $wpdb->get_results( $query );
599
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid');
600
+			$attributes_sets = $wpdb->get_results($query);
601 601
 
602
-			if ( ! empty( $attributes_sets ) ) {
602
+			if (!empty($attributes_sets)) {
603 603
 				ob_start();
604
-				require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail' ) );
604
+				require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail'));
605 605
 				$message .= ob_get_contents();
606 606
 				ob_end_clean();
607 607
 			}
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	function wpshop_messages_historic_correction() {
616 616
 		global $wpdb;
617
-		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%' );
618
-		$messages_histo = $wpdb->get_results( $query );
617
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%');
618
+		$messages_histo = $wpdb->get_results($query);
619 619
 
620
-		foreach ( $messages_histo as $message ) {
621
-			$query_user = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s',  $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
622
-			$user_post_id = $wpdb->get_var( $query_user );
623
-			$wpdb->update( $wpdb->postmeta, array(
620
+		foreach ($messages_histo as $message) {
621
+			$query_user = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
622
+			$user_post_id = $wpdb->get_var($query_user);
623
+			$wpdb->update($wpdb->postmeta, array(
624 624
 				'post_id' => $user_post_id,
625 625
 				), array(
626 626
 				'meta_id' => $message->meta_id,
627
-			) );
627
+			));
628 628
 		}
629 629
 	}
630 630
 
@@ -633,20 +633,20 @@  discard block
 block discarded – undo
633 633
 	 * Récupères le contenu du message
634 634
 	 */
635 635
 	public function get_content_message() {
636
-		$_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
636
+		$_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
637 637
 
638
-		if ( ! wp_verify_nonce( $_wpnonce, 'get_content_message' ) ) {
638
+		if (!wp_verify_nonce($_wpnonce, 'get_content_message')) {
639 639
 			wp_die();
640 640
 		}
641 641
 
642 642
 		global $wpdb;
643
-		$meta_id = (int) $_GET['meta_id'];
643
+		$meta_id = (int)$_GET['meta_id'];
644 644
 
645
-		$result = $wpdb->get_results( $wpdb->prepare( 'SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array( ($meta_id) ) ) );
646
-		$result = unserialize( $result[0]->meta_value );
645
+		$result = $wpdb->get_results($wpdb->prepare('SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array(($meta_id))));
646
+		$result = unserialize($result[0]->meta_value);
647 647
 		$result = $result[0]['mess_message'];
648 648
 
649
-		wp_die( $result );
649
+		wp_die($result);
650 650
 	}
651 651
 
652 652
 }
Please login to merge, or discard this patch.
includes/wpshop_ajax.php 1 patch
Spacing   +980 added lines, -980 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
 * Ajax request management file
4 4
 *
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 */
10 10
 
11 11
 /*	Check if file is include. No direct access possible with file url	*/
12
-if ( !defined( 'WPSHOP_VERSION' ) ) {
13
-	die( __('Access is not allowed by this way', 'wpshop') );
12
+if (!defined('WPSHOP_VERSION')) {
13
+	die(__('Access is not allowed by this way', 'wpshop'));
14 14
 }
15 15
 
16 16
 /*	Products	*/
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	function ajax_duplicate_product() {
21 21
 
22
-		check_ajax_referer( 'wpshop_product_duplication', 'wpshop_ajax_nonce' );
22
+		check_ajax_referer('wpshop_product_duplication', 'wpshop_ajax_nonce');
23 23
 
24 24
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
25 25
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	 * Delete an attachmant from a product
35 35
 	 */
36 36
 	function ajax_delete_product_thumbnail() {
37
-		check_ajax_referer( 'wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce' );
37
+		check_ajax_referer('wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce');
38 38
 
39 39
 		$bool = false;
40
-		$attachement_id = isset($_POST['attachement_id']) ? (int) $_POST['attachement_id'] : null;
40
+		$attachement_id = isset($_POST['attachement_id']) ? (int)$_POST['attachement_id'] : null;
41 41
 
42
-		if ( !empty($attachement_id) ) {
42
+		if (!empty($attachement_id)) {
43 43
 			$deletion_result = wp_delete_attachment($attachement_id, false);
44 44
 			$bool = !empty($deletion_result);
45 45
 		}
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 * Reload attachment container
53 53
 	 */
54 54
 	function ajax_reload_attachment_boxes() {
55
-		check_ajax_referer( 'wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce' );
55
+		check_ajax_referer('wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce');
56 56
 
57 57
 		$bool = false;
58
-		$current_post_id = isset($_POST['current_post_id']) ? (int) $_POST['current_post_id'] : null;
58
+		$current_post_id = isset($_POST['current_post_id']) ? (int)$_POST['current_post_id'] : null;
59 59
 		$attachement_type_list = array('reload_box_document' => 'application/pdf', 'reload_box_picture' => 'image/');
60
-		$part_to_reload = isset($_POST['part_to_reload']) ? sanitize_text_field( $_POST['part_to_reload']) : null;
60
+		$part_to_reload = isset($_POST['part_to_reload']) ? sanitize_text_field($_POST['part_to_reload']) : null;
61 61
 		$attachement_type = $attachement_type_list[$part_to_reload];
62 62
 
63 63
 		echo json_encode(array(wpshop_products::product_attachement_by_type($current_post_id, $attachement_type, 'media-upload.php?post_id=' . $current_post_id . '&amp;tab=library&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=566'), $part_to_reload));
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	function ajax_product_bulk_edit_save() {
72 72
 		global $wpdb;
73
-		check_ajax_referer( 'product_bulk_edit_save', 'wpshop_ajax_nonce' );
73
+		check_ajax_referer('product_bulk_edit_save', 'wpshop_ajax_nonce');
74 74
 
75
-		$post_ids = ( isset( $_POST[ 'post_ids' ] ) && !empty( $_POST[ 'post_ids' ] ) ) ? (array) $_POST[ 'post_ids' ] : array();
76
-		$post_attributes = ( isset( $_POST[ 'attribute' ] ) && !empty( $_POST[ 'attribute' ] ) ) ? (array) $_POST[ 'attribute' ] : array();
75
+		$post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? (array)$_POST['post_ids'] : array();
76
+		$post_attributes = (isset($_POST['attribute']) && !empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array();
77 77
 
78
-		if ( !empty( $post_ids ) && is_array( $post_ids ) && !empty( $post_attributes ) && is_array( $post_attributes ) ) {
78
+		if (!empty($post_ids) && is_array($post_ids) && !empty($post_attributes) && is_array($post_attributes)) {
79 79
 			$attribute_to_save = array();
80
-			foreach ( $post_attributes as $attribute ) {
80
+			foreach ($post_attributes as $attribute) {
81 81
 				$attribute_component = explode('_-val-_', $attribute);
82 82
 				$attribute_definition = explode('[', $attribute_component[0]);
83 83
 				$attribute_data_type = substr($attribute_definition[1], 0, -1);
84 84
 				$attribute_code = substr($attribute_definition[2], 0, -1);
85 85
 
86
-				if ( !empty($attribute_component[1]) ) {
86
+				if (!empty($attribute_component[1])) {
87 87
 					$attribute_to_save[$attribute_data_type][$attribute_code] = $attribute_component[1];
88 88
 				}
89 89
 			}
90 90
 
91
-			foreach ( $post_ids as $post_id ) {
91
+			foreach ($post_ids as $post_id) {
92 92
 				$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = (SELECT language_code FROM " . $wpdb->prefix . "icl_translations WHERE element_id = %d )", $post_id);
93 93
 				$lang_wpml = $wpdb->get_var($query);
94 94
 				$lang = !empty($lang_wpml) ? $lang_wpml : WPSHOP_CURRENT_LOCALE;
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
 
101 101
 				/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
102 102
 				$productMetaDatas = get_post_meta($post_id, '_wpshop_product_metadata', true);
103
-				if ( !empty($productMetaDatas) ) {
103
+				if (!empty($productMetaDatas)) {
104 104
 					$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $post_id);
105
-					if ( !empty($attributes_list)) {
105
+					if (!empty($attributes_list)) {
106 106
 						foreach ($attributes_list as $attribute) {
107
-							$value_key = 'attribute_value_'.$attribute->data_type;
107
+							$value_key = 'attribute_value_' . $attribute->data_type;
108 108
 							$productMetaDatas[$attribute->code] = $attribute->$value_key;
109 109
 						}
110 110
 					}
111 111
 				}
112
-				foreach($attribute_to_save as $attributeType => $attributeValues){
113
-					foreach($attributeValues as $attributeCode => $attributeValue){
114
-						if ( $attributeCode == 'product_attribute_set_id' ) {
112
+				foreach ($attribute_to_save as $attributeType => $attributeValues) {
113
+					foreach ($attributeValues as $attributeCode => $attributeValue) {
114
+						if ($attributeCode == 'product_attribute_set_id') {
115 115
 							/*	Update the attribute set id for the current product	*/
116 116
 							update_post_meta($post_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue);
117 117
 						}
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 
124 124
 
125 125
 				/* If the product have some variations */
126
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
126
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION);
127 127
 				$product_variations = $wpdb->get_results($query);
128
-				if ( !empty($product_variations) ) {
129
-					foreach( $product_variations as $product_variation ) {
128
+				if (!empty($product_variations)) {
129
+					foreach ($product_variations as $product_variation) {
130 130
 						$variation_post_meta = get_post_meta($product_variation->ID, '_wpshop_product_metadata', true);
131 131
 						$common_attributes = unserialize(WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT);
132
-						if ( !empty($common_attributes) ) {
133
-							if ( !empty($parent_product_metadata) ) {
134
-								foreach( $parent_product_metadata as $key => $value ) {
135
-									if ( in_array($key, $common_attributes) ) {
132
+						if (!empty($common_attributes)) {
133
+							if (!empty($parent_product_metadata)) {
134
+								foreach ($parent_product_metadata as $key => $value) {
135
+									if (in_array($key, $common_attributes)) {
136 136
 										$variation_post_meta[$key] = $value;
137
-										update_post_meta($product_variation->ID, '_'.$key, $value);
137
+										update_post_meta($product_variation->ID, '_' . $key, $value);
138 138
 									}
139 139
 								}
140 140
 								update_post_meta($product_variation->ID, '_wpshop_product_metadata', $variation_post_meta);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 		die();
152 152
 	}
153
-	add_action( 'wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save' );
153
+	add_action('wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save');
154 154
 /*	Products	*/
155 155
 
156 156
 /*	Variations	*/
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
 	 * Variation list creation
159 159
 	 */
160 160
 	function ajax_add_new_variation_list() {
161
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
161
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
162 162
 		global $wpdb;
163 163
 
164
-		$attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? (array) $_POST['wpshop_attribute_to_use_for_variation'] : null;
164
+		$attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? (array)$_POST['wpshop_attribute_to_use_for_variation'] : null;
165 165
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
166 166
 
167 167
 		/** Get the list of values of the attribute to affect to a variation	*/
168 168
 		$var = array();
169 169
 
170
-		foreach ( $attributes_for_variation as $attribute_code ) {
170
+		foreach ($attributes_for_variation as $attribute_code) {
171 171
 			$query = $wpdb->prepare("SELECT data_type_to_use FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code);
172
-			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list( $attribute_code, $current_post_id, $wpdb->get_var($query));
172
+			$var[$attribute_code] = wpshop_attributes::get_affected_value_for_list($attribute_code, $current_post_id, $wpdb->get_var($query));
173 173
 		}
174 174
 
175
-		$possible_variations = wpshop_tools::search_all_possibilities( $var );
175
+		$possible_variations = wpshop_tools::search_all_possibilities($var);
176 176
 
177
-		wpshop_products::creation_variation_callback( $possible_variations, $current_post_id );
177
+		wpshop_products::creation_variation_callback($possible_variations, $current_post_id);
178 178
 
179
-		$output = wpshop_products::display_variation_admin( $current_post_id );
179
+		$output = wpshop_products::display_variation_admin($current_post_id);
180 180
 
181 181
 		echo $output;
182 182
 		die();
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 * Variation uniq item creation
188 188
 	 */
189 189
 	function ajax_new_single_variation_definition() {
190
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
190
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
191 191
 		$output = '';
192 192
 
193 193
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
194 194
 
195 195
 		/*	Get the list of values of the attribute to affect to a variation	*/
196
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id, 'single' );
196
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id, 'single');
197 197
 		$output = $attribute_for_variation[0];
198 198
 
199 199
 		/**	Display specific element for variation	*/
200 200
 		$tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = '';
201 201
 		$tpl_component['VARIATION_IDENTIFIER'] = 'new';
202
-		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']','page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => '') );
202
+		$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']', 'page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => ''));
203 203
 		$output .= wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $current_post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $tpl_component['VARIATION_IDENTIFIER']), 'admin');
204 204
 
205 205
 		$tpl_component = array();
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	 * Combined variation list creation
218 218
 	 */
219 219
 	function ajax_new_combined_variation_list_definition() {
220
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
220
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
221 221
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
222 222
 		$output = '';
223 223
 
224
-		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id );
224
+		$attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id);
225 225
 		$output = $attribute_for_variation[0];
226 226
 
227 227
 		echo $output;
@@ -233,43 +233,43 @@  discard block
 block discarded – undo
233 233
 	 * Product variaitons parameters
234 234
 	 */
235 235
 	function wpshop_ajax_admin_variation_parameters() {
236
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
236
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
237 237
 
238 238
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
239 239
 		$output = '';
240 240
 
241 241
 		/*	Display variation options	*/
242 242
 		$options_tpl_component = array();
243
-		$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
244
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single')) ) ? ' checked="checked"' : '';
245
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined')) ) ? ' checked="checked"' : '';
246
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition')) ) ? ' checked="checked"' : '';
247
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = ( empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement')) ) ? ' checked="checked"' : '';
243
+		$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
244
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'single'))) ? ' checked="checked"' : '';
245
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && ($head_wpshop_variation_definition['options']['priority'][0] == 'combined'))) ? ' checked="checked"' : '';
246
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition'))) ? ' checked="checked"' : '';
247
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = (empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && ($head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement'))) ? ' checked="checked"' : '';
248 248
 
249
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ( ( empty($head_wpshop_variation_definition['options']) ) || ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')) ) ) ? ' checked="checked"' : '';
250
-		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ( (empty($head_wpshop_variation_definition['options']) ) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')) ) ) ? ' checked="checked"' : '';
249
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && ($head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on')))) ? ' checked="checked"' : '';
250
+		$options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = ((empty($head_wpshop_variation_definition['options'])) || ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && ($head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on')))) ? ' checked="checked"' : '';
251 251
 
252 252
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_PRODUCT_ID'] = $current_post_id;
253 253
 		$options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_NOUNCE'] = wp_create_nonce("wpshop_variation_parameters");
254 254
 
255 255
 		$options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] = '';
256 256
 
257
-		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute( $current_post_id );
257
+		$attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute($current_post_id);
258 258
 
259 259
 		$default_value_for_attributes = $required_attributes = '';
260 260
 
261
-		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => get_post_type($current_post_id)) );
262
-		if ( !empty($attribute_user_defined) ) {
263
-			foreach ( $attribute_user_defined as $attribute_def ) {
261
+		$attribute_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => get_post_type($current_post_id)));
262
+		if (!empty($attribute_user_defined)) {
263
+			foreach ($attribute_user_defined as $attribute_def) {
264 264
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
265 265
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
266 266
 
267 267
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_def->code;
268 268
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_def->code;
269
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_def->frontend_label, 'wpshop' );
269
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_def->frontend_label, 'wpshop');
270 270
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
271 271
 
272
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
272
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
273 273
 
274 274
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_def->code;
275 275
 
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 		}
279 279
 
280
-		if ( !empty($attribute_list_for_variations['available']) ) {
281
-			$head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true );
282
-			foreach ( $attribute_list_for_variations['available'] as $attribute_code => $attribute_definition ) {
280
+		if (!empty($attribute_list_for_variations['available'])) {
281
+			$head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true);
282
+			foreach ($attribute_list_for_variations['available'] as $attribute_code => $attribute_definition) {
283 283
 				/** Default value for attribute	*/
284 284
 				$tpl_component = array();
285 285
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ' variation_attribute_container_default_value_' . $attribute_code;
286 286
 
287 287
 				$attribute_for_default_value = wpshop_attributes::get_attribute_field_definition($attribute_definition['attribute_complete_def'], (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : 'none'), array('from' => 'frontend', 'field_custom_name_prefix' => 'empty'));
288
-				switch ( $attribute_for_default_value['type'] ) {
288
+				switch ($attribute_for_default_value['type']) {
289 289
 					case 'select':
290 290
 					case 'multiple-select':
291 291
 					case 'radio':
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 						break;
298 298
 				}
299 299
 
300
-				if ( !empty($attribute_for_default_value['possible_value']) ) {
300
+				if (!empty($attribute_for_default_value['possible_value'])) {
301 301
 					$attribute_for_default_value['possible_value']['none'] = __('No default value', 'wpshop');
302
-					foreach( $attribute_for_default_value['possible_value'] as $value_id => $value ){
303
-						if ( !empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values']) ) {
302
+					foreach ($attribute_for_default_value['possible_value'] as $value_id => $value) {
303
+						if (!empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values'])) {
304 304
 							unset($attribute_for_default_value['possible_value'][$value_id]);
305 305
 						}
306 306
 					}
307 307
 					ksort($attribute_for_default_value['possible_value']);
308 308
 
309 309
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = $attribute_for_default_value['id'];
310
-					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf( __('Default value for %s', 'wpshop'), $attribute_for_default_value['label'] );
310
+					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf(__('Default value for %s', 'wpshop'), $attribute_for_default_value['label']);
311 311
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_INPUT'] = wpshop_form::check_input_type($attribute_for_default_value, 'wps_pdt_variations[options][attributes_default_value]');
312 312
 					$default_value_for_attributes .= wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item_for_default', $tpl_component, array(), 'admin');
313 313
 				}
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 
319 319
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_code;
320 320
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code;
321
-				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_definition['label'], 'wpshop' );
321
+				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_definition['label'], 'wpshop');
322 322
 				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = '';
323 323
 
324
-				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? ' checked="checked"' : '';
324
+				$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? ' checked="checked"' : '';
325 325
 
326 326
 				$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_code;
327 327
 				$required_attributes .= str_replace('wpshop_attribute_to_use_for_variation', 'wps_pdt_variations[options][required_attributes]', str_replace('variation_attribute_usable', 'variation_attribute_required', wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item', $tpl_component, array(), 'admin')));
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 * Save product variation paramters
345 345
 	 */
346 346
 	function wpshop_ajax_admin_variation_parameters_save() {
347
-		check_ajax_referer( 'wpshop_variation_parameters', 'wpshop_ajax_nonce' );
347
+		check_ajax_referer('wpshop_variation_parameters', 'wpshop_ajax_nonce');
348 348
 
349 349
 		$current_post_id = isset($_POST['current_post_id']) ? sanitize_key($_POST['current_post_id']) : null;
350
-		$options = !empty( $_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] ) ? (array)$_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] : array();
350
+		$options = !empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options']) ? (array)$_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'] : array();
351 351
 
352
-		if ( !empty($options) ) {
353
-			wpshop_products::variation_parameters_save( $post_id, $options );
352
+		if (!empty($options)) {
353
+			wpshop_products::variation_parameters_save($post_id, $options);
354 354
 		}
355 355
 
356 356
 		die();
@@ -361,41 +361,41 @@  discard block
 block discarded – undo
361 361
 	 * Variation uniq item creation
362 362
 	 */
363 363
 	function ajax_add_new_single_variation() {
364
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
364
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
365 365
 		$output = '';
366 366
 
367
-		$attributes_for_variation = isset($_POST['variation_attr']) ? (array) $_POST['variation_attr'] : null;
368
-		$wpshop_admin_use_attribute_for_single_variation_checkbox = isset($_POST['wpshop_admin_use_attribute_for_single_variation_checkbox']) ? (array) $_POST['wpshop_admin_use_attribute_for_single_variation_checkbox'] : null;
369
-		$variation_specific_definition = isset($_POST['wps_pdt_variations']['new']['attribute']) ? (array) $_POST['wps_pdt_variations']['new']['attribute'] : null;
367
+		$attributes_for_variation = isset($_POST['variation_attr']) ? (array)$_POST['variation_attr'] : null;
368
+		$wpshop_admin_use_attribute_for_single_variation_checkbox = isset($_POST['wpshop_admin_use_attribute_for_single_variation_checkbox']) ? (array)$_POST['wpshop_admin_use_attribute_for_single_variation_checkbox'] : null;
369
+		$variation_specific_definition = isset($_POST['wps_pdt_variations']['new']['attribute']) ? (array)$_POST['wps_pdt_variations']['new']['attribute'] : null;
370 370
 		$current_post_id = isset($_POST['wpshop_head_product_id']) ? sanitize_key($_POST['wpshop_head_product_id']) : null;
371
-		$display = isset( $_POST['data'] ) ? (bool) $_POST['data'] : false;
371
+		$display = isset($_POST['data']) ? (bool)$_POST['data'] : false;
372 372
 
373 373
 		$attribute_to_use_for_creation = array();
374
-		foreach ( $attributes_for_variation as $attribute_code => $attribute_value) {
375
-			if ( array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox) ) {
374
+		foreach ($attributes_for_variation as $attribute_code => $attribute_value) {
375
+			if (array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox)) {
376 376
 				$attribute_to_use_for_creation[0][$attribute_code] = $attributes_for_variation[$attribute_code];
377 377
 				$attr_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
378 378
 				$variation_specific_definition[$attr_def->data_type][$attribute_code] = $attributes_for_variation[$attribute_code];
379 379
 			}
380 380
 		}
381
-		$new_variation_identifier = wpshop_products::creation_variation_callback( $attribute_to_use_for_creation, $current_post_id );
381
+		$new_variation_identifier = wpshop_products::creation_variation_callback($attribute_to_use_for_creation, $current_post_id);
382 382
 
383 383
 		/*	Save variation specific element	*/
384
-		foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
384
+		foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
385 385
 			$head_product_price_attribute_value = wpshop_attributes::get_attribute_value_content($price_attribute_code, $current_post_id, wpshop_products::currentPageCode);
386 386
 			$price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code');
387
-			if ( !empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
387
+			if (!empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) {
388 388
 				$variation_specific_definition[$price_attr_def->data_type][$price_attribute_code] = !empty($head_product_price_attribute_value->value) ? $head_product_price_attribute_value->value : 1;
389 389
 			}
390 390
 		}
391 391
 
392 392
 		wpshop_attributes::saveAttributeForEntity($variation_specific_definition, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $new_variation_identifier, WPSHOP_CURRENT_LOCALE);
393
-		wpshop_products::calculate_price( $new_variation_identifier );
393
+		wpshop_products::calculate_price($new_variation_identifier);
394 394
 
395
-		if( $display ) {
396
-			$output = json_encode( array( 'ID' => $new_variation_identifier ) );
395
+		if ($display) {
396
+			$output = json_encode(array('ID' => $new_variation_identifier));
397 397
 		} else {
398
-			$output = wpshop_products::display_variation_admin( $current_post_id );
398
+			$output = wpshop_products::display_variation_admin($current_post_id);
399 399
 		}
400 400
 
401 401
 		echo $output;
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 	 * Delete a variation
408 408
 	*/
409 409
 	function ajax_delete_variation() {
410
-		check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' );
410
+		check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce');
411 411
 		$result = false;
412 412
 		$list_to_remove = '';
413 413
 
414
-		$current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? (array) $_POST['current_post_id'] : null;
415
-		foreach ( $current_post_id as $variation_id) {
414
+		$current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? (array)$_POST['current_post_id'] : null;
415
+		foreach ($current_post_id as $variation_id) {
416 416
 			$result = wp_delete_post($variation_id, false);
417
-			if ( $result ) {
417
+			if ($result) {
418 418
 				$list_to_remove[] = $variation_id;
419 419
 			}
420 420
 		}
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 /*	Orders	*/
443 443
 	/* Validate the payment transaction number */
444 444
 	function wpshop_ajax_validate_payment_method() {
445
-		check_ajax_referer( 'wpshop_validate_payment_method', 'wpshop_ajax_nonce' );
446
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int) $_POST[ 'order_id' ] : null;
447
-		$payment_method = ( isset( $_POST[ 'payment_method' ] ) && !empty( $_POST[ 'payment_method' ] ) ) ? sanitize_text_field( $_POST[ 'payment_method' ] ) : null;
448
-		$transaction_id = ( isset( $_POST[ 'transaction_id' ] ) && !empty( $_POST[ 'transaction_id' ] ) ) ? (int) $_POST[ 'transaction_id' ] : null;
445
+		check_ajax_referer('wpshop_validate_payment_method', 'wpshop_ajax_nonce');
446
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
447
+		$payment_method = (isset($_POST['payment_method']) && !empty($_POST['payment_method'])) ? sanitize_text_field($_POST['payment_method']) : null;
448
+		$transaction_id = (isset($_POST['transaction_id']) && !empty($_POST['transaction_id'])) ? (int)$_POST['transaction_id'] : null;
449 449
 
450
-		if ( !empty($order_id) ) {
451
-			if( !empty($payment_method) && !empty($transaction_id) ) {
450
+		if (!empty($order_id)) {
451
+			if (!empty($payment_method) && !empty($transaction_id)) {
452 452
 				/* Update he payment method */
453 453
 				$order = get_post_meta($order_id, '_order_postmeta', true);
454 454
 				$order['payment_method'] = $payment_method;
455 455
 				update_post_meta($order_id, '_order_postmeta', $order);
456 456
 
457 457
 				// Update Transaction identifier regarding the payment method
458
-				if ( !empty($transaction_id) ) {
458
+				if (!empty($transaction_id)) {
459 459
 // 					$transaction_key = '';
460 460
 // 					switch($payment_method) {
461 461
 // 						case 'check':
@@ -465,28 +465,28 @@  discard block
 block discarded – undo
465 465
 // 					if ( !empty($transaction_key) ) update_post_meta($order_id, $transaction_key, $transaction_id);
466 466
 					wpshop_payment::set_payment_transaction_number($order_id, $transaction_id);
467 467
 				}
468
-				$result = json_encode(array(true,''));
468
+				$result = json_encode(array(true, ''));
469 469
 			}
470 470
 			else {
471
-				$result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop')));
471
+				$result = json_encode(array(false, __('Choose a payment method and/or type a transaction number', 'wpshop')));
472 472
 			}
473 473
 		}
474 474
 		else {
475
-			$result = json_encode(array(false,__('Bad order identifier', 'wpshop')));
475
+			$result = json_encode(array(false, __('Bad order identifier', 'wpshop')));
476 476
 		}
477 477
 		echo json_encode($result);
478 478
 		die();
479 479
 	}
480
-	add_action( 'wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method' );
480
+	add_action('wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method');
481 481
 
482 482
 
483 483
 	/* Display a dialog box to inform a shipping tracking number */
484 484
 	function wpshop_ajax_dialog_inform_shipping_number() {
485
-		check_ajax_referer( 'wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce' );
486
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int)$_POST[ 'order_id' ] : null;
485
+		check_ajax_referer('wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce');
486
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
487 487
 
488
-		if ( !empty($order_id) ) {
489
-			$result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" data-nonce="' . esc_attr( wp_create_nonce( 'wpshop_change_order_state' ) ) . '" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />'));
488
+		if (!empty($order_id)) {
489
+			$result = (array(true, '<h1>' . __('Tracking number', 'wpshop') . '</h1><p>' . __('Enter a tracking number, or leave blank:', 'wpshop') . '</p><input type="hidden" value="' . $order_id . '" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>' . __('Enter a tracking link, or leave blank: (http included)', 'wpshop') . '</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" data-nonce="' . esc_attr(wp_create_nonce('wpshop_change_order_state')) . '" class="button-primary sendTrackingNumber" value="' . __('Send', 'wpshop') . '" /> <input type="button" class="button-secondary closeAlert" value="' . __('Cancel', 'wpshop') . '" />'));
490 490
 
491 491
 		}
492 492
 		else {
@@ -495,23 +495,23 @@  discard block
 block discarded – undo
495 495
 		echo json_encode($result);
496 496
 		die();
497 497
 	}
498
-	add_action( 'wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number' );
498
+	add_action('wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number');
499 499
 
500 500
 	function wpshop_ajax_change_order_state() {
501 501
 		global $order_status, $wps_shipping_mode_ctr;
502
-		check_ajax_referer( 'wpshop_change_order_state', 'wpshop_ajax_nonce' );
502
+		check_ajax_referer('wpshop_change_order_state', 'wpshop_ajax_nonce');
503 503
 
504
-		$order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? (int)$_POST[ 'order_id' ] : null;
505
-		$order_state = ( isset( $_POST[ 'order_state' ] ) && !empty( $_POST[ 'order_state' ] ) ) ? sanitize_text_field( $_POST[ 'order_state' ] ) : null;
506
-		$order_shipped_number = ( isset( $_POST[ 'order_shipped_number' ] ) && !empty( $_POST[ 'order_shipped_number' ] ) ) ? sanitize_text_field( $_POST[ 'order_shipped_number' ] ) : null;
507
-		$order_shipped_link = ( isset( $_POST[ 'order_shipped_link' ] ) && !empty( $_POST[ 'order_shipped_link' ] ) ) ? sanitize_text_field( $_POST[ 'order_shipped_link' ] ) : null;
504
+		$order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
505
+		$order_state = (isset($_POST['order_state']) && !empty($_POST['order_state'])) ? sanitize_text_field($_POST['order_state']) : null;
506
+		$order_shipped_number = (isset($_POST['order_shipped_number']) && !empty($_POST['order_shipped_number'])) ? sanitize_text_field($_POST['order_shipped_number']) : null;
507
+		$order_shipped_link = (isset($_POST['order_shipped_link']) && !empty($_POST['order_shipped_link'])) ? sanitize_text_field($_POST['order_shipped_link']) : null;
508 508
 
509
-		if ( !empty($order_id) ) {
509
+		if (!empty($order_id)) {
510 510
 			/* Update the oder state */
511 511
 			$order = get_post_meta($order_id, '_order_postmeta', true);
512 512
 			$order['order_status'] = $order_state;
513 513
 
514
-			if ( $order_state == 'shipped' ) {
514
+			if ($order_state == 'shipped') {
515 515
 				$order['order_shipping_date'] = current_time('mysql', 0);
516 516
 				$order['order_trackingNumber'] = $order_shipped_number;
517 517
 				$order['order_trackingLink'] = $order_shipped_link;
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 
525 525
 				$order_postmeta = $order;
526 526
 				ob_start();
527
-				require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $wps_shipping_mode_ctr->template_dir, 'backend', 'order-shipping-informations' ) );
527
+				require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $wps_shipping_mode_ctr->template_dir, 'backend', 'order-shipping-informations'));
528 528
 				$output_shipping_box = ob_get_clean();
529 529
 
530
-				$result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content );
530
+				$result = array(true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content);
531 531
 			}
532 532
 			else {
533 533
 				wpshop_payment::setOrderPaymentStatus($order_id, $order_state);
@@ -544,39 +544,39 @@  discard block
 block discarded – undo
544 544
 		echo json_encode($result);
545 545
 		die();
546 546
 	}
547
-	add_action( 'wp_ajax_change_order_state', 'wpshop_ajax_change_order_state' );
547
+	add_action('wp_ajax_change_order_state', 'wpshop_ajax_change_order_state');
548 548
 
549 549
 
550 550
 	/* Send a confirmation e-mail to the customer */
551
-	function wpshop_send_confirmation_shipping_email($order_id){
551
+	function wpshop_send_confirmation_shipping_email($order_id) {
552 552
 		$wps_message = new wps_message_ctr();
553
-		if ( !empty($order_id) ) {
553
+		if (!empty($order_id)) {
554 554
 			$order_info = get_post_meta($order_id, '_order_info', true);
555 555
 			$order = get_post_meta($order_id, '_order_postmeta', true);
556
-			$email = ( !empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
556
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
557 557
 			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
558
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
558
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
559 559
 
560
-			if( empty($email) && !empty($order['customer_id']) ) {
561
-				$user_data = get_userdata( $order['customer_id'] );
560
+			if (empty($email) && !empty($order['customer_id'])) {
561
+				$user_data = get_userdata($order['customer_id']);
562 562
 				$email = $user_data->user_email;
563 563
 			}
564 564
 
565
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
566
-			$shipping_method = ( !empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order['order_payment']['shipping_method'] : '' );
565
+			$shipping_mode_option = get_option('wps_shipping_mode');
566
+			$shipping_method = (!empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order['order_payment']['shipping_method'] : '');
567 567
 
568 568
 
569
-			$wps_message->wpshop_prepared_email (
569
+			$wps_message->wpshop_prepared_email(
570 570
 				$email,
571 571
 				'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE',
572 572
 				array(
573 573
 					'order_id' => $order_id,
574
-					'order_key' => ( !empty($order['order_key']) ? $order['order_key'] : '' ),
574
+					'order_key' => (!empty($order['order_key']) ? $order['order_key'] : ''),
575 575
 					'customer_first_name' => $first_name,
576 576
 					'customer_last_name' => $last_name,
577
-					'order_date' => ( !empty($order['order_date']) ? $order['order_date'] : '' ),
578
-					'order_trackingNumber' => ( !empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : '' ),
579
-					'order_trackingLink' => ( !empty($order['order_trackingLink']) ? $order['order_trackingLink'] : '' ),
577
+					'order_date' => (!empty($order['order_date']) ? $order['order_date'] : ''),
578
+					'order_trackingNumber' => (!empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : ''),
579
+					'order_trackingLink' => (!empty($order['order_trackingLink']) ? $order['order_trackingLink'] : ''),
580 580
 					'order_addresses' => '',
581 581
 					'order_billing_address' => '',
582 582
 					'order_shipping_address' => '',
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @return string The html output for the new value
596 596
 	 */
597 597
 	function ajax_new_option_for_select_callback() {
598
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
598
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
599 599
 		global $wpdb;
600 600
 
601
-		$option_id=$option_default_value=$option_value_id=$options_value='';
602
-		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int) $_GET['attribute_identifier'] : '0';
603
-		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field( $_REQUEST['attribute_new_label'] ) : '');
601
+		$option_id = $option_default_value = $option_value_id = $options_value = '';
602
+		$attribute_identifier = isset($_GET['attribute_identifier']) ? (int)$_GET['attribute_identifier'] : '0';
603
+		$option_name = (!empty($_REQUEST['attribute_new_label']) ? sanitize_text_field($_REQUEST['attribute_new_label']) : '');
604 604
 		$options_value = sanitize_title($option_name);
605 605
 
606 606
 		/*	Check if given value does not exist before continuing	*/
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		$existing_values = $wpdb->get_results($query);
609 609
 
610 610
 		/*	If given value does not exist: display result. If value exist alert a error message	*/
611
-		if( empty($existing_values) ) {
611
+		if (empty($existing_values)) {
612 612
 			$tpl_component = array();
613 613
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_ID'] = $option_id;
614 614
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_NAME'] = stripslashes($option_name);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", stripslashes($options_value));
617 617
 			$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = '';
618 618
 			$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
619
-			if ( current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0) ) :
619
+			if (current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0)) :
620 620
 				$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
621 621
 			endif;
622 622
 			$output = wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin');
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * Add a new value to an attribute from select type directly from an entity element edition interface
636 636
 	 */
637 637
 	function ajax_new_option_for_select_from_product_edition_callback() {
638
-		check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' );
638
+		check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce');
639 639
 
640 640
 		global $wpdb;
641 641
 		$result = '';
@@ -652,13 +652,13 @@  discard block
 block discarded – undo
652 652
 		$attribute_options_label = isset($_POST['attribute_new_label']) ? wpshop_tools::varSanitizer($_POST['attribute_new_label']) : null;
653 653
 		$attribute_options_value = sanitize_title($attribute_options_label);
654 654
 
655
-		if ( $type == 'internal' ) {
655
+		if ($type == 'internal') {
656 656
 			/**	Check if the given value does not exist	*/
657 657
 			$query = $wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_status = 'publish'", $attribute_options_label);
658 658
 			$existing_values = $wpdb->get_results($query);
659 659
 
660 660
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
661
-			if ( count($existing_values) <= 0 ) {
661
+			if (count($existing_values) <= 0) {
662 662
 				$result_status = true;
663 663
 				/**	Create the new value as an entity into post database	*/
664 664
 				$new_post = array(
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 			$existing_values = $wpdb->get_results($query);
682 682
 
683 683
 			/**	If the value does not exist, we create it and output, in case it exists alert an error message	*/
684
-			if( count($existing_values) <= 0 ) {
684
+			if (count($existing_values) <= 0) {
685 685
 				$result_status = true;
686 686
 				$position = 1;
687 687
 				/**	Get the last value position for adding the new at the end	*/
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
 
701 701
 		if ($result_status) {
702 702
 			$tmp_selection_for_output = array();
703
-			foreach ( $attribute_selected_values as $value ) {
703
+			foreach ($attribute_selected_values as $value) {
704 704
 				$tmp_selection_for_output[]['value'] = $value;
705 705
 			}
706 706
 			$tmp_selection_for_output[]['value'] = $new_option_id;
707
-			foreach ( $tmp_selection_for_output as $tmp_value ) {
707
+			foreach ($tmp_selection_for_output as $tmp_value) {
708 708
 				$selection_for_output[] = (object)$tmp_value;
709 709
 			}
710 710
 			$attribute_selected_values[] = $new_option_id;
711
-			$input = wpshop_attributes::get_attribute_field_definition( $attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display) );
711
+			$input = wpshop_attributes::get_attribute_field_definition($attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display));
712 712
 			$result = $input['output'] . $input['options'];
713 713
 		}
714 714
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 * Delete a value for a select list attribute
722 722
 	 */
723 723
 	function ajax_delete_option_for_select_callback() {
724
-		check_ajax_referer( 'wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce' );
724
+		check_ajax_referer('wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce');
725 725
 
726 726
 		$attribute_value_id = isset($_POST['attribute_value_id']) ? wpshop_tools::varSanitizer($_POST['attribute_value_id']) : '0';
727 727
 
@@ -745,18 +745,18 @@  discard block
 block discarded – undo
745 745
 	 * Display the field for the selected attribute type
746 746
 	 */
747 747
 	function ajax_attribute_output_type_callback() {
748
-		check_ajax_referer( 'wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce' );
748
+		check_ajax_referer('wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce');
749 749
 
750 750
 		$data_type_to_use = isset($_POST['data_type_to_use']) ? str_replace('_data', '', wpshop_tools::varSanitizer($_POST['data_type_to_use'], '')) : 'custom';
751 751
 		$current_type = isset($_POST['current_type']) ? wpshop_tools::varSanitizer($_POST['current_type']) : 'short_text';
752
-		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval( wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
752
+		$elementIdentifier = isset($_POST['elementIdentifier']) ? intval(wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null;
753 753
 		$the_input = __('An error occured while getting field type', 'wpshop');
754 754
 		$input_def = array();
755 755
 		$input_def['name'] = 'default_value';
756 756
 		$input_def['id'] = 'wpshop_attributes_edition_table_field_id_default_value';
757 757
 		$input_label = __('Default value', 'wpshop');
758 758
 
759
-		switch($current_type){
759
+		switch ($current_type) {
760 760
 			case 'short_text':
761 761
 			case 'float_field':
762 762
 				$input_def['type'] = 'text';
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 			case 'multiple-select':
768 768
 			case 'radio':
769 769
 			case 'checkbox':
770
-				$input_label=__('Options list for attribute', 'wpshop');
770
+				$input_label = __('Options list for attribute', 'wpshop');
771 771
 				$the_input = wpshop_attributes::get_select_options_list($elementIdentifier, $data_type_to_use);
772 772
 				break;
773 773
 			case 'date_field':
774
-				$input_label=__('Date field configuration', 'wpshop');
774
+				$input_label = __('Date field configuration', 'wpshop');
775 775
 
776
-				$the_input = wpshop_attributes::attribute_type_date_config( array() );
776
+				$the_input = wpshop_attributes::attribute_type_date_config(array());
777 777
 				break;
778 778
 			case 'textarea':
779 779
 				$input_def['type'] = 'textarea';
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	 * Get the attribute set list when creating a new attribute for direct affectation
792 792
 	 */
793 793
 	function ajax_attribute_entity_set_selection_callback() {
794
-		check_ajax_referer( 'wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce' );
794
+		check_ajax_referer('wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce');
795 795
 
796 796
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
797 797
 
798
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
798
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode);
799 799
 
800 800
 		echo json_encode($the_input);
801 801
 		die();
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	 * Get the attribute set list when creating a new attribute for direct affectation
806 806
 	 */
807 807
 	function ajax_attribute_set_entity_selection_callback() {
808
-		check_ajax_referer( 'wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce' );
808
+		check_ajax_referer('wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce');
809 809
 
810 810
 		$current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null;
811 811
 
812
-		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
812
+		$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false);
813 813
 
814 814
 		echo json_encode($the_input);
815 815
 		die();
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	 * Dialog box allowing to change attribute data type from custom to internal
821 821
 	 */
822 822
 	function ajax_attribute_select_data_type_callback() {
823
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce' );
823
+		check_ajax_referer('wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce');
824 824
 		$result = '';
825 825
 
826 826
 		$current_attribute = isset($_POST['current_attribute']) ? intval(wpshop_tools::varSanitizer($_POST['current_attribute'])) : null;
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
 
829 829
 		$types_toggled = unserialize(WPSHOP_ATTR_SELECT_TYPE_TOGGLED);
830 830
 		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_current_attribute" >' . sprintf(__('Selected attribute %s', 'wpshop'), $attribute->frontend_label) . '</p>';
831
-		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use.'_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
831
+		$result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use . '_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>';
832 832
 
833
-		if ( $attribute->data_type_to_use == 'custom' ) {
834
-			$sub_output='';
833
+		if ($attribute->data_type_to_use == 'custom') {
834
+			$sub_output = '';
835 835
 			$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
836
-			unset($input_def);$input_def=array();
836
+			unset($input_def); $input_def = array();
837 837
 			$input_def['label'] = __('Type of data for list', 'wpshop');
838 838
 			$input_def['type'] = 'select';
839 839
 			$input_def['name'] = 'internal_data';
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 			$input_def['possible_value'] = $wp_types;
842 842
 			$input_def['value'] = !empty($attribute_select_options[0]->default_value) ? $attribute_select_options[0]->default_value : null;
843 843
 			$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
844
-			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>';
844
+			$result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="' . sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')) . '" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">' . $combo_wp_type . '</div>';
845 845
 			$result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />';
846 846
 		}
847 847
 		else {
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 	 */
875 875
 	function ajax_attribute_select_data_type_change_callback() {
876 876
 		global $wpdb;
877
-		check_ajax_referer( 'wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce' );
877
+		check_ajax_referer('wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce');
878 878
 		$result = '';
879 879
 
880 880
 		$current_attribute = isset($_POST['attribute_id']) ? intval(wpshop_tools::varSanitizer($_POST['attribute_id'])) : null;
@@ -884,10 +884,10 @@  discard block
 block discarded – undo
884 884
 		$delete_entity = isset($_POST['delete_entity']) ? wpshop_tools::varSanitizer($_POST['delete_entity']) : false;
885 885
 
886 886
 
887
-		if ( $data_type == 'internal' ) {
887
+		if ($data_type == 'internal') {
888 888
 			$options_list = wpshop_attributes::get_select_option_list_($current_attribute);
889
-			if(!empty($options_list)){
890
-				foreach($options_list as $option){
889
+			if (!empty($options_list)) {
890
+				foreach ($options_list as $option) {
891 891
 					/*	Creat the new entity	*/
892 892
 					$new_post = array(
893 893
 							'post_title' 	=> $option->name,
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 							'post_type' 	=> $internal_data_type
897 897
 					);
898 898
 					$new_option_id = wp_insert_post($new_post);
899
-					if(!empty($new_option_id)){
899
+					if (!empty($new_option_id)) {
900 900
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'deleted'), array('attribute_id'=>$current_attribute));
901 901
 					}
902 902
 				}
@@ -905,19 +905,19 @@  discard block
 block discarded – undo
905 905
 		else {
906 906
 			$post_list = query_posts(array('post_type' => $internal_data_type));
907 907
 			if (!empty($post_list)) {
908
-				$p=1;
908
+				$p = 1;
909 909
 				$error = false;
910 910
 				foreach ($post_list as $post) {
911
-					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
912
-					if(is_int($last_insert) && $delete_items_of_entity){
911
+					$last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title));
912
+					if (is_int($last_insert) && $delete_items_of_entity) {
913 913
 						wp_delete_post($post->ID, true);
914 914
 					}
915
-					else{
915
+					else {
916 916
 						$error = true;
917 917
 					}
918 918
 					$p++;
919 919
 				}
920
-				if(!$error && $delete_entity){
920
+				if (!$error && $delete_entity) {
921 921
 					$post = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_name=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, $internal_data_type);
922 922
 					wp_delete_post($wpdb->get_var($post), true);
923 923
 				}
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 	/**
938 938
 	 * Duplicate an existing attribute from an entity to another
939 939
 	 */
940
-	function ajax_wpshop_duplicate_attribute_callback (){
941
-		check_ajax_referer( 'wpshop_duplicate_attribute', 'wpshop_ajax_nonce' );
940
+	function ajax_wpshop_duplicate_attribute_callback() {
941
+		check_ajax_referer('wpshop_duplicate_attribute', 'wpshop_ajax_nonce');
942 942
 		global $wpdb;
943 943
 
944 944
 		$result = '';
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
 		/*	Check if the attribute to duplicate does not exist for the selected entity	*/
959 959
 		$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']);
960 960
 		$check_existing_attribute = $wpdb->get_var($query);
961
-		if ( empty($check_existing_attribute) ) {
961
+		if (empty($check_existing_attribute)) {
962 962
 			/*	Save new attribut for the selected entity	*/
963 963
 			$new_attribute = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE, $attribute_def);
964 964
 			$new_attribute_id = $wpdb->insert_id;
965 965
 
966 966
 			if ($new_attribute) {
967
-				if ( in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom') ) {
967
+				if (in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom')) {
968 968
 					$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d", $current_attribute);
969 969
 					$attribute_options_list = $wpdb->get_results($query, ARRAY_A);
970
-					foreach ( $attribute_options_list as $option ) {
970
+					foreach ($attribute_options_list as $option) {
971 971
 						$option['id'] = '';
972 972
 						$option['creation_date'] = current_time('mysql', 0);
973 973
 						$option['attribute_id'] = $new_attribute_id;
@@ -998,27 +998,27 @@  discard block
 block discarded – undo
998 998
 	/**
999 999
 	 * Load comboBox of unit or group of unit
1000 1000
 	 */
1001
-	function wpshop_ajax_load_attribute_unit_list(){
1002
-		check_ajax_referer( 'wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce' );
1001
+	function wpshop_ajax_load_attribute_unit_list() {
1002
+		check_ajax_referer('wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce');
1003 1003
 		$response = '';
1004 1004
 
1005
-		$current_group = ( isset( $_POST[ 'current_group' ] ) && !empty( $_POST[ 'current_group' ] ) ) ? sanitize_text_field( $_POST[ 'current_group' ] ) : null;
1006
-		$selected_list = ( isset( $_POST[ 'selected_list' ] ) && !empty( $_POST[ 'selected_list' ] ) ) ? sanitize_text_field( $_POST[ 'selected_list' ] ) : null;
1005
+		$current_group = (isset($_POST['current_group']) && !empty($_POST['current_group'])) ? sanitize_text_field($_POST['current_group']) : null;
1006
+		$selected_list = (isset($_POST['selected_list']) && !empty($_POST['selected_list'])) ? sanitize_text_field($_POST['selected_list']) : null;
1007 1007
 
1008 1008
 		$group = wpshop_tools::varSanitizer($current_group);
1009 1009
 		$selected_list = wpshop_tools::varSanitizer($selected_list);
1010 1010
 
1011
-		if ( !empty($group) && !empty($selected_list)) {
1011
+		if (!empty($group) && !empty($selected_list)) {
1012 1012
 			/* Test if we want display the group unit list OR the unit list */
1013
-			if ( $selected_list == 'group unit' ) {
1013
+			if ($selected_list == 'group unit') {
1014 1014
 				$list = wpshop_attributes_unit::get_unit_group();
1015 1015
 			}
1016 1016
 			else {
1017 1017
 				$list = wpshop_attributes_unit::get_unit_list_for_group($group);
1018 1018
 			}
1019 1019
 
1020
-			foreach( $list as $unit ) {
1021
-				$response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>';
1020
+			foreach ($list as $unit) {
1021
+				$response .= '<option value="' . $unit->id . '" ' . (($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '') . '>' . $unit->name . '</option>';
1022 1022
 			}
1023 1023
 			$result = array(true, $response);
1024 1024
 		}
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 /**	Tools page	*/
1036 1036
 	function wpshop_ajax_db_check_tool() {
1037
-		check_ajax_referer( 'wpshop_ajax_db_check_tool', '_wpnonce' );
1037
+		check_ajax_referer('wpshop_ajax_db_check_tool', '_wpnonce');
1038 1038
 
1039 1039
 		global $wpdb, $wpshop_db_table_operation_list, $wpshop_db_table, $wpshop_update_way;
1040 1040
 		$current_db_version = get_option('wpshop_db_options', 0);
@@ -1050,22 +1050,22 @@  discard block
 block discarded – undo
1050 1050
 </div>
1051 1051
 <div class="tools_db_modif_list_version_details" >
1052 1052
 	<ul>';
1053
-			foreach($plugin_db_modification as $modif_name => $modif_list){
1054
-				switch($modif_name){
1053
+			foreach ($plugin_db_modification as $modif_name => $modif_list) {
1054
+				switch ($modif_name) {
1055 1055
 					case 'FIELD_ADD':{
1056
-						foreach($modif_list as $table_name => $field_list){
1056
+						foreach ($modif_list as $table_name => $field_list) {
1057 1057
 							$sub_modif = '  ';
1058
-							foreach($field_list as $column_name){
1059
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1058
+							foreach ($field_list as $column_name) {
1059
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1060 1060
 								$columns = $wpdb->get_row($query);
1061 1061
 								$sub_modif .= $column_name;
1062
-								if( !empty($columns->Field) && ($columns->Field == $column_name) ){
1062
+								if (!empty($columns->Field) && ($columns->Field == $column_name)) {
1063 1063
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1064 1064
 								}
1065
-								else{
1065
+								else {
1066 1066
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1067 1067
 									$error_nb++;
1068
-									if ( !empty($error_list[$plugin_db_version]) ) {
1068
+									if (!empty($error_list[$plugin_db_version])) {
1069 1069
 										$error_list[$plugin_db_version] += 1;
1070 1070
 									}
1071 1071
 									else {
@@ -1074,56 +1074,56 @@  discard block
 block discarded – undo
1074 1074
 								}
1075 1075
 								$sub_modif .= ' / ';
1076 1076
 							}
1077
-							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1077
+							$plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1078 1078
 						}
1079 1079
 					}break;
1080 1080
 					case 'FIELD_DROP':{
1081
-						foreach($modif_list as $table_name => $field_list){
1081
+						foreach ($modif_list as $table_name => $field_list) {
1082 1082
 							$sub_modif = '  ';
1083
-							foreach($field_list as $column_name){
1084
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name);
1083
+							foreach ($field_list as $column_name) {
1084
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name);
1085 1085
 								$columns = $wpdb->get_row($query);
1086 1086
 								$sub_modif .= $column_name;
1087
-								if(empty($columns) || ($columns->Field != $column_name)){
1087
+								if (empty($columns) || ($columns->Field != $column_name)) {
1088 1088
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />';
1089 1089
 								}
1090
-								else{
1090
+								else {
1091 1091
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />';
1092 1092
 									$error_nb++;
1093 1093
 									$error_list[$plugin_db_version] += 1;
1094 1094
 								}
1095 1095
 								$sub_modif .= ' / ';
1096 1096
 							}
1097
-							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -2) . '</li>';
1097
+							$plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -2) . '</li>';
1098 1098
 						}
1099 1099
 					}break;
1100 1100
 					case 'FIELD_CHANGE':{
1101
-						foreach($modif_list as $table_name => $field_list){
1101
+						foreach ($modif_list as $table_name => $field_list) {
1102 1102
 							$sub_modif = '  ';
1103
-							foreach($field_list as $field_infos){
1104
-								$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_infos['field']);
1103
+							foreach ($field_list as $field_infos) {
1104
+								$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_infos['field']);
1105 1105
 								$columns = $wpdb->get_row($query);
1106 1106
 								$what_is_changed = '';
1107
-								if(isset($field_infos['type'])){
1107
+								if (isset($field_infos['type'])) {
1108 1108
 									$what_is_changed = __('field type', 'wpshop');
1109 1109
 									$changed_key = 'type';
1110
-									if($columns->Type == $field_infos['type']){
1110
+									if ($columns->Type == $field_infos['type']) {
1111 1111
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1112 1112
 									}
1113
-									else{
1113
+									else {
1114 1114
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1115 1115
 										$error_nb++;
1116 1116
 										$error_list[$plugin_db_version] += 1;
1117 1117
 									}
1118 1118
 									$sub_modif .= sprintf(__('Change %s for field %s to %s', 'wpshop'), $what_is_changed, $field_infos['field'], $field_infos[$changed_key]);
1119 1119
 								}
1120
-								if(isset($field_infos['original_name'])){
1120
+								if (isset($field_infos['original_name'])) {
1121 1121
 									$what_is_changed = __('field name', 'wpshop');
1122 1122
 									$changed_key = 'original_name';
1123
-									if($columns->Field == $field_infos['field']){
1123
+									if ($columns->Field == $field_infos['field']) {
1124 1124
 										$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />';
1125 1125
 									}
1126
-									else{
1126
+									else {
1127 1127
 										$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />';
1128 1128
 										$error_nb++;
1129 1129
 										$error_list[$plugin_db_version] += 1;
@@ -1138,59 +1138,59 @@  discard block
 block discarded – undo
1138 1138
 					}break;
1139 1139
 
1140 1140
 					case 'DROP_INDEX':{
1141
-						foreach($modif_list as $table_name => $field_list){
1141
+						foreach ($modif_list as $table_name => $field_list) {
1142 1142
 							$sub_modif = '   ';
1143
-							foreach($field_list as $column_name){
1144
-								$query = $wpdb->prepare("SHOW INDEX FROM " .$table_name . " WHERE Column_name = %s", $column_name);
1143
+							foreach ($field_list as $column_name) {
1144
+								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s", $column_name);
1145 1145
 								$columns = $wpdb->get_row($query);
1146 1146
 								$sub_modif .= $column_name;
1147
-								if((empty($columns)) || ($columns->Column_name != $column_name)){
1147
+								if ((empty($columns)) || ($columns->Column_name != $column_name)) {
1148 1148
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />';
1149 1149
 								}
1150
-								else{
1150
+								else {
1151 1151
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />';
1152 1152
 									$error_nb++;
1153 1153
 									$error_list[$plugin_db_version] += 1;
1154 1154
 								}
1155 1155
 								$sub_modif .= ' / ';
1156 1156
 							}
1157
-							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1157
+							$plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1158 1158
 						}
1159 1159
 					}break;
1160 1160
 					case 'ADD_INDEX':{
1161
-						foreach($modif_list as $table_name => $field_list){
1161
+						foreach ($modif_list as $table_name => $field_list) {
1162 1162
 							$sub_modif = '   ';
1163
-							foreach($field_list as $column_name){
1163
+							foreach ($field_list as $column_name) {
1164 1164
 								$query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s OR Key_name = %s", $column_name, $column_name);
1165 1165
 								$columns = $wpdb->get_row($query);
1166 1166
 								$sub_modif .= $column_name;
1167
-								if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){
1167
+								if (($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)) {
1168 1168
 									$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />';
1169 1169
 								}
1170
-								else{
1170
+								else {
1171 1171
 									$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />';
1172 1172
 									$error_nb++;
1173 1173
 									$error_list[$plugin_db_version] += 1;
1174 1174
 								}
1175 1175
 								$sub_modif .= ' / ';
1176 1176
 							}
1177
-							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' .  substr($sub_modif, 0, -3) . '</li>';
1177
+							$plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . '&nbsp;:&nbsp;' . substr($sub_modif, 0, -3) . '</li>';
1178 1178
 						}
1179 1179
 					}break;
1180 1180
 
1181 1181
 					case 'ADD_TABLE':{
1182 1182
 						$sub_modif = '  ';
1183
-						foreach($modif_list as $table_name){
1183
+						foreach ($modif_list as $table_name) {
1184 1184
 							$sub_modif .= $table_name;
1185 1185
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table_name);
1186 1186
 							$table_exists = $wpdb->query($query);
1187
-							if($table_exists == 1){
1187
+							if ($table_exists == 1) {
1188 1188
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />';
1189 1189
 							}
1190
-							else{
1190
+							else {
1191 1191
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />';
1192 1192
 								$error_nb++;
1193
-								if ( !empty($error_list[$plugin_db_version]) ) {
1193
+								if (!empty($error_list[$plugin_db_version])) {
1194 1194
 									$error_list[$plugin_db_version] += 1;
1195 1195
 								}
1196 1196
 								else {
@@ -1203,29 +1203,29 @@  discard block
 block discarded – undo
1203 1203
 					}break;
1204 1204
 					case 'TABLE_RENAME':{
1205 1205
 						$sub_modif = '  ';
1206
-						foreach($modif_list as $table){
1206
+						foreach ($modif_list as $table) {
1207 1207
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1208 1208
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1209 1209
 							$table_exists = $wpdb->query($query);
1210 1210
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1211 1211
 							$old_table_exists = $wpdb->query($query);
1212
-							if(($table_exists == 1) && ($old_table_exists == 1)){
1212
+							if (($table_exists == 1) && ($old_table_exists == 1)) {
1213 1213
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Both database table are still present', 'wpshop') . '" title="' . __('Both database table are still present', 'wpshop') . '" class="db_rename_table_check" />';
1214 1214
 								$error_nb++;
1215
-								if ( !empty($error_list[$plugin_db_version]) ) {
1215
+								if (!empty($error_list[$plugin_db_version])) {
1216 1216
 									$error_list[$plugin_db_version] += 1;
1217 1217
 								}
1218 1218
 								else {
1219 1219
 									$error_list[$plugin_db_version] = 1;
1220 1220
 								}
1221 1221
 							}
1222
-							elseif($table_exists == 1){
1222
+							elseif ($table_exists == 1) {
1223 1223
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1224 1224
 							}
1225
-							else{
1225
+							else {
1226 1226
 								$sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />';
1227 1227
 								$error_nb++;
1228
-								if ( !empty($error_list[$plugin_db_version]) ) {
1228
+								if (!empty($error_list[$plugin_db_version])) {
1229 1229
 									$error_list[$plugin_db_version] += 1;
1230 1230
 								}
1231 1231
 								else {
@@ -1238,27 +1238,27 @@  discard block
 block discarded – undo
1238 1238
 					}break;
1239 1239
 					case 'TABLE_RENAME_FOR_DELETION':{
1240 1240
 						$sub_modif = '  ';
1241
-						foreach($modif_list as $table){
1241
+						foreach ($modif_list as $table) {
1242 1242
 							$sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']);
1243 1243
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']);
1244 1244
 							$table_delete_exists = $wpdb->query($query);
1245 1245
 							$query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']);
1246 1246
 							$old_table_exists = $wpdb->query($query);
1247
-							if(($table_delete_exists == 1) || ($old_table_exists == 1)){
1248
-								if($old_table_exists == 1){
1247
+							if (($table_delete_exists == 1) || ($old_table_exists == 1)) {
1248
+								if ($old_table_exists == 1) {
1249 1249
 									$deleted_table_result = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1250 1250
 									$error_nb++;
1251
-									if ( !empty($error_list[$plugin_db_version]) ) {
1251
+									if (!empty($error_list[$plugin_db_version])) {
1252 1252
 										$error_list[$plugin_db_version] += 1;
1253 1253
 									}
1254 1254
 									else {
1255 1255
 										$error_list[$plugin_db_version] = 1;
1256 1256
 									}
1257 1257
 								}
1258
-								else{
1258
+								else {
1259 1259
 									$deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />';
1260 1260
 									$warning_nb++;
1261
-									if ( !empty($warning_list[$plugin_db_version]) ) {
1261
+									if (!empty($warning_list[$plugin_db_version])) {
1262 1262
 										$warning_list[$plugin_db_version] += 1;
1263 1263
 									}
1264 1264
 									else {
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 								}
1268 1268
 								$sub_modif .= $deleted_table_result;
1269 1269
 							}
1270
-							else{
1270
+							else {
1271 1271
 								$sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />';
1272 1272
 							}
1273 1273
 							$sub_modif .= ' / ';
@@ -1282,57 +1282,57 @@  discard block
 block discarded – undo
1282 1282
 		}
1283 1283
 
1284 1284
 		$db_table_field_error = '';
1285
-		foreach($wpshop_db_table as $table_name => $table_definition){
1286
-			if(!empty($table_definition)){
1285
+		foreach ($wpshop_db_table as $table_name => $table_definition) {
1286
+			if (!empty($table_definition)) {
1287 1287
 				$table_line = explode("
1288 1288
 ", $table_definition);
1289 1289
 
1290 1290
 				$sub_db_table_field_error = '  ';
1291
-				foreach($table_line as $table_definition_line){
1291
+				foreach ($table_line as $table_definition_line) {
1292 1292
 					$def_line = trim($table_definition_line);
1293
-					if(substr($def_line, 0, 1) == "`"){
1293
+					if (substr($def_line, 0, 1) == "`") {
1294 1294
 						$line_element = explode(" ", $def_line);
1295 1295
 						$field_name = str_replace("`", "", $line_element[0]);
1296
-						$query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_name);
1296
+						$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_name);
1297 1297
 						$columns = $wpdb->get_row($query);
1298
-						if ( !empty($columns->Field) && ($columns->Field != $field_name)) {
1298
+						if (!empty($columns->Field) && ($columns->Field != $field_name)) {
1299 1299
 							$sub_db_table_field_error .= $field_name . ', '/*  . ' : <img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />' */;
1300 1300
 							$error_nb++;
1301 1301
 						}
1302 1302
 					}
1303 1303
 				}
1304 1304
 				$sub_db_table_field_error = trim(substr($sub_db_table_field_error, 0, -2));
1305
-				if(!empty($sub_db_table_field_error)){
1305
+				if (!empty($sub_db_table_field_error)) {
1306 1306
 					$db_table_field_error .= sprintf(__('Following fields of %s don\'t exists: %s', 'wpshop'), '<span class="bold" >' . $table_name . '</span>', $sub_db_table_field_error) . '<br/>';
1307 1307
 				}
1308 1308
 			}
1309 1309
 		}
1310
-		if(!empty($db_table_field_error)){
1310
+		if (!empty($db_table_field_error)) {
1311 1311
 			$db_table_field_error = '<hr class="clear" />' . $db_table_field_error . '<hr/>';
1312 1312
 		}
1313 1313
 
1314 1314
 		/*	Start display	*/
1315 1315
 		$plugin_install_error = '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Wpshop install is ok', 'wpshop') . '" title="' . __('Wpshop install is ok', 'wpshop') . '" />&nbsp;' . __('There is no error in your wpshop installation. Please find details below', 'wpshop') . '<hr/>';
1316
-		if($error_nb > 0){
1316
+		if ($error_nb > 0) {
1317 1317
 			$plugin_install_error = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Error in wpshop install', 'wpshop') . '" title="' . __('Error in wpshop install', 'wpshop') . '" />&nbsp;' . __('There are ne or more errors into your wpshop installation. Please find details below', 'wpshop') . '<br/>
1318 1318
 							<ul>';
1319
-			foreach($error_list as $version => $element_nb){
1320
-				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version  . '" data-nonce="' . wp_create_nonce( 'wpshop_ajax_db_repair_tool ' ) .'" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1319
+			foreach ($error_list as $version => $element_nb) {
1320
+				$plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version . '" data-nonce="' . wp_create_nonce('wpshop_ajax_db_repair_tool ') . '" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>';
1321 1321
 			}
1322 1322
 			$plugin_install_error .= '
1323 1323
 							</ul>';
1324 1324
 		}
1325
-		if($warning_nb > 0){
1325
+		if ($warning_nb > 0) {
1326 1326
 			$plugin_install_error .= '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Warning in wpshop install', 'wpshop') . '" title="' . __('Warning in wpshop install', 'wpshop') . '" />&nbsp;' . __('Some element need your attention. They have no consequences on wpshop operation. Please find details below', 'wpshop') . '<br/>';
1327
-			foreach($warning_list as $version => $element_nb){
1327
+			foreach ($warning_list as $version => $element_nb) {
1328 1328
 				$plugin_install_error .= '&nbsp;&nbsp;' . sprintf(__('There are %d warning into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - ';
1329 1329
 			}
1330 1330
 			$plugin_install_error = substr($plugin_install_error, 0, -3) . '<hr/>';
1331 1331
 		}
1332 1332
 
1333 1333
 		$max_number = 0;
1334
-		foreach($wpshop_update_way as $number => $operation){
1335
-			if($number > $max_number){
1334
+		foreach ($wpshop_update_way as $number => $operation) {
1335
+			if ($number > $max_number) {
1336 1336
 				$max_number = $number;
1337 1337
 			}
1338 1338
 		}
@@ -1342,30 +1342,30 @@  discard block
 block discarded – undo
1342 1342
 	add_action('wp_ajax_wpshop_tool_db_check', 'wpshop_ajax_db_check_tool');
1343 1343
 
1344 1344
 	function wpshop_tool_default_datas_check() {
1345
-		check_ajax_referer( 'wpshop_tool_default_datas_check' );
1345
+		check_ajax_referer('wpshop_tool_default_datas_check');
1346 1346
 
1347 1347
 		$output_ok = $output_error = '';
1348 1348
 
1349 1349
 		/**	Get defined default datas type	*/
1350
-		$default_custom_post_type = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES );
1350
+		$default_custom_post_type = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES);
1351 1351
 
1352 1352
 		/**	Read the default data saved to check	*/
1353
-		if ( !empty($default_custom_post_type) ) {
1354
-			foreach ( $default_custom_post_type as $type ) {
1353
+		if (!empty($default_custom_post_type)) {
1354
+			foreach ($default_custom_post_type as $type) {
1355 1355
 				$has_error = false;
1356 1356
 				$file_uri = WPSHOP_TEMPLATES_DIR . 'default_datas/' . $type . '.csv';
1357
-				if ( is_file( $file_uri ) ) {
1357
+				if (is_file($file_uri)) {
1358 1358
 					unset($tpl_component);
1359 1359
 					$tpl_component = array();
1360 1360
 					$tpl_component['CUSTOM_POST_TYPE_NAME'] = 'wpshop_cpt_' . $type;
1361 1361
 
1362 1362
 					/**	Launch check on custom post type	*/
1363
-					$check_cpt = wpshop_entities::check_default_custom_post_type( $type, $tpl_component );
1363
+					$check_cpt = wpshop_entities::check_default_custom_post_type($type, $tpl_component);
1364 1364
 					$has_error = $check_cpt[0];
1365 1365
 					$tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER'] = $check_cpt[1];
1366
-					$tpl_component = array_merge( $tpl_component, $check_cpt[2] );
1366
+					$tpl_component = array_merge($tpl_component, $check_cpt[2]);
1367 1367
 
1368
-					if ( $has_error ) {
1368
+					if ($has_error) {
1369 1369
 						$output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin');
1370 1370
 					}
1371 1371
 					else {
@@ -1381,77 +1381,77 @@  discard block
 block discarded – undo
1381 1381
 	add_action('wp_ajax_wpshop_tool_default_datas_check', 'wpshop_tool_default_datas_check');
1382 1382
 
1383 1383
 	function wpshop_ajax_repair_default_datas() {
1384
-		check_ajax_referer( 'wpshop_ajax_repair_default_datas' );
1384
+		check_ajax_referer('wpshop_ajax_repair_default_datas');
1385 1385
 
1386 1386
 		global $wpdb;
1387 1387
 		$output = '';
1388 1388
 		$container = '';
1389 1389
 		$result = '';
1390 1390
 
1391
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1392
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1391
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1392
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1393 1393
 
1394
-		switch ( $selected_type ) {
1394
+		switch ($selected_type) {
1395 1395
 			case WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES:
1396
-				$result = wpshop_entities::create_cpt_from_csv_file( $identifier );
1396
+				$result = wpshop_entities::create_cpt_from_csv_file($identifier);
1397 1397
 			break;
1398 1398
 			case WPSHOP_DBT_ATTRIBUTE:
1399
-				$result = wpshop_entities::create_cpt_attributes_from_csv_file( $identifier );
1399
+				$result = wpshop_entities::create_cpt_attributes_from_csv_file($identifier);
1400 1400
 			break;
1401 1401
 		}
1402 1402
 
1403
-		echo json_encode( $result );
1403
+		echo json_encode($result);
1404 1404
 		die();
1405 1405
 	}
1406 1406
 	add_action('wp_ajax_wpshop_ajax_repair_default_datas', 'wpshop_ajax_repair_default_datas');
1407 1407
 
1408 1408
 	function wpshop_ajax_translate_default_datas() {
1409
-		check_ajax_referer( 'wpshop_ajax_translate_default_datas' );
1409
+		check_ajax_referer('wpshop_ajax_translate_default_datas');
1410 1410
 		global $wpdb;
1411 1411
 		$result = array('status' => true);
1412 1412
 
1413
-		$selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? sanitize_text_field( $_POST['type'] ) : null;
1414
-		$identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? sanitize_text_field( $_POST['identifier'] ) : null;
1413
+		$selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? sanitize_text_field($_POST['type']) : null;
1414
+		$identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? sanitize_text_field($_POST['identifier']) : null;
1415 1415
 
1416
-		$entity_id = wpshop_entities::get_entity_identifier_from_code( $identifier );
1416
+		$entity_id = wpshop_entities::get_entity_identifier_from_code($identifier);
1417 1417
 		$query = $wpdb->prepare("SELECT id, frontend_label FROM " . $selected_type . " WHERE entity_id = %d", $entity_id);
1418
-		$attribute_list = $wpdb->get_results( $query );
1419
-		if ( !empty($attribute_list) ) {
1420
-			foreach ( $attribute_list as $attribute) {
1421
-				$update_result = $wpdb->update( $selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id) );
1422
-				if ( $update_result === false ) {
1418
+		$attribute_list = $wpdb->get_results($query);
1419
+		if (!empty($attribute_list)) {
1420
+			foreach ($attribute_list as $attribute) {
1421
+				$update_result = $wpdb->update($selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id));
1422
+				if ($update_result === false) {
1423 1423
 					$result['status'] = false;
1424 1424
 				}
1425 1425
 			}
1426 1426
 		}
1427 1427
 
1428
-		echo json_encode( $result );
1428
+		echo json_encode($result);
1429 1429
 		die();
1430 1430
 	}
1431 1431
 	add_action('wp_ajax_wpshop_ajax_translate_default_datas', 'wpshop_ajax_translate_default_datas');
1432 1432
 
1433 1433
 	function wpshop_ajax_db_repair_tool() {
1434
-		check_ajax_referer( 'wpshop_ajax_db_repair_tool' );
1434
+		check_ajax_referer('wpshop_ajax_db_repair_tool');
1435 1435
 
1436 1436
 		$version_id = isset($_POST['version_id']) ? wpshop_tools::varSanitizer($_POST['version_id']) : null;
1437 1437
 
1438
-		echo wpshop_install::alter_db_structure_on_update( $version_id );
1438
+		echo wpshop_install::alter_db_structure_on_update($version_id);
1439 1439
 
1440 1440
 		die();
1441 1441
 	}
1442 1442
 	add_action('wp_ajax_wpshop_ajax_db_repair_tool', 'wpshop_ajax_db_repair_tool');
1443 1443
 
1444 1444
 	function wps_mass_action_main_interface() {
1445
-		check_ajax_referer( 'wps_mass_action_main_interface' );
1445
+		check_ajax_referer('wps_mass_action_main_interface');
1446 1446
 		$tpl_component = array();
1447 1447
 
1448 1448
 		/**	Copy an attribute content to another	*/
1449
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ), "'valid'", 'entity_id', true);
1449
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), "'valid'", 'entity_id', true);
1450 1450
 		$possible_values = array('' => __('Choose an attribute', 'wpshop'));
1451 1451
 		$possible_values_for_variation = array('' => __('Choose an attribute', 'wpshop'));
1452
-		foreach ( $attribute_list as $attribute ) {
1452
+		foreach ($attribute_list as $attribute) {
1453 1453
 			$possible_values[$attribute->id] = $attribute->frontend_label;
1454
-			if ( $attribute->is_used_for_variation == 'yes' ) {
1454
+			if ($attribute->is_used_for_variation == 'yes') {
1455 1455
 				$possible_values_for_variation[$attribute->id] = $attribute->frontend_label;
1456 1456
 			}
1457 1457
 		}
@@ -1482,22 +1482,22 @@  discard block
 block discarded – undo
1482 1482
 	add_action('wp_ajax_wps_mass_action', 'wps_mass_action_main_interface');
1483 1483
 
1484 1484
 	function wps_mass_action_update_attribute_value() {
1485
-		check_ajax_referer( 'wps_mass_action_update_attribute_value' );
1485
+		check_ajax_referer('wps_mass_action_update_attribute_value');
1486 1486
 		global $wpdb;
1487 1487
 		$response = array();
1488 1488
 
1489
-		$from = !empty( $_POST['wps_update_att_values']['from'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['from'] ) : '';
1490
-		$to = !empty( $_POST['wps_update_att_values']['to'] ) ? sanitize_text_field( $_POST['wps_update_att_values']['to'] ) : '';
1491
-		$entity_to_transfert = !empty( $_POST['wps_entity_to_transfert'] ) ? sanitize_text_field( $_POST['wps_entity_to_transfert'] ) : '';
1489
+		$from = !empty($_POST['wps_update_att_values']['from']) ? sanitize_text_field($_POST['wps_update_att_values']['from']) : '';
1490
+		$to = !empty($_POST['wps_update_att_values']['to']) ? sanitize_text_field($_POST['wps_update_att_values']['to']) : '';
1491
+		$entity_to_transfert = !empty($_POST['wps_entity_to_transfert']) ? sanitize_text_field($_POST['wps_entity_to_transfert']) : '';
1492 1492
 
1493
-		if ( $from != $to ) {
1493
+		if ($from != $to) {
1494 1494
 			$from_attribute = wpshop_attributes::getElement($from, "'valid'");
1495 1495
 			$to_attribute = wpshop_attributes::getElement($to, "'valid'");
1496
-			if ( $from_attribute->data_type == $to_attribute->data_type ) {
1496
+			if ($from_attribute->data_type == $to_attribute->data_type) {
1497 1497
 
1498 1498
 				/**	Manage specific case	*/
1499 1499
 				$query_more_args = array();
1500
-				switch( $to_attribute->code ){
1500
+				switch ($to_attribute->code) {
1501 1501
 					case "barcode":
1502 1502
 							$more_query = "
1503 1503
 						AND VAL.value NOT LIKE %s";
@@ -1513,22 +1513,22 @@  discard block
 block discarded – undo
1513 1513
 					WHERE VAL.attribute_id = %d
1514 1514
 						AND P.post_type = %s
1515 1515
 						AND VAL.value != ''" . $more_query,
1516
-					array_merge( array( $from, $entity_to_transfert ), $query_more_args )
1516
+					array_merge(array($from, $entity_to_transfert), $query_more_args)
1517 1517
 				);
1518
-				$element_list_to_update = $wpdb->get_results( $query );
1518
+				$element_list_to_update = $wpdb->get_results($query);
1519 1519
 
1520
-				if ( !empty($element_list_to_update) ) {
1520
+				if (!empty($element_list_to_update)) {
1521 1521
 					$has_error = false;
1522 1522
 					$error_count = 0;
1523
-					foreach ( $element_list_to_update as $element ) {
1523
+					foreach ($element_list_to_update as $element) {
1524 1524
 
1525 1525
 						/**	Historicize the old value of recevier attribute	*/
1526
-						if (  $to_attribute->is_historisable == 'yes' ) {
1526
+						if ($to_attribute->is_historisable == 'yes') {
1527 1527
 							$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $to_attribute->id, $element->ID);
1528
-							$attribute_histos = $wpdb->get_results( $query );
1529
-							if ( !empty( $attribute_histos ) ) {
1530
-								foreach ( $attribute_histos as $attribute_histo ) {
1531
-									if ( !empty( $attribute_histo->value ) ) {
1528
+							$attribute_histos = $wpdb->get_results($query);
1529
+							if (!empty($attribute_histos)) {
1530
+								foreach ($attribute_histos as $attribute_histo) {
1531
+									if (!empty($attribute_histo->value)) {
1532 1532
 										$attribute_histo_content['status'] = 'valid';
1533 1533
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1534 1534
 										$attribute_histo_content['creation_date_value'] = $attribute_histo->creation_date_value;
@@ -1541,12 +1541,12 @@  discard block
 block discarded – undo
1541 1541
 										$attribute_histo_content['value'] = $attribute_histo->value;
1542 1542
 										$attribute_histo_content['value_type'] = WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType;
1543 1543
 										$last_histo = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO, $attribute_histo_content);
1544
-										if ( $last_histo === false ) {
1544
+										if ($last_histo === false) {
1545 1545
 											$has_error = true;
1546 1546
 											$error_count++;
1547 1547
 										}
1548 1548
 										else {
1549
-											$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) );
1549
+											$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array('value_id' => $attribute_histo->value_id));
1550 1550
 										}
1551 1551
 									}
1552 1552
 								}
@@ -1555,36 +1555,36 @@  discard block
 block discarded – undo
1555 1555
 
1556 1556
 						/**		*/
1557 1557
 						$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $from_attribute->id, $element->ID);
1558
-						$attribute_to_save = $wpdb->get_row( $query, ARRAY_A );
1558
+						$attribute_to_save = $wpdb->get_row($query, ARRAY_A);
1559 1559
 						unset($attribute_to_save['value_id']);
1560 1560
 						$attribute_to_save['attribute_id'] = $to_attribute->id;
1561 1561
 						$attribute_to_save['creation_date_value'] = current_time('mysql', 0);
1562 1562
 						$attribute_to_save['user_id'] = get_current_user_id();
1563
-						$new_value = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save );
1564
-						if ( $new_value === false ) {
1563
+						$new_value = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save);
1564
+						if ($new_value === false) {
1565 1565
 							$has_error = true;
1566 1566
 							$error_count++;
1567 1567
 						}
1568 1568
 						else {
1569 1569
 							/**	Save new atribute values in product metadata	*/
1570
-							$current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true);
1570
+							$current_product_metadata = get_post_meta($element->ID, '_wpshop_product_metadata', true);
1571 1571
 							$current_product_metadata[$to_attribute->code] = $element->value;
1572
-							update_post_meta( $element->ID, '_wpshop_product_metadata', $current_product_metadata );
1572
+							update_post_meta($element->ID, '_wpshop_product_metadata', $current_product_metadata);
1573 1573
 
1574 1574
 							/**	Save a single meta for attribute in case it will be used in specific case where meta needs to be alone	*/
1575
-							if ( ( ($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes'))  || ( $to_attribute->is_filterable == 'yes') && !empty($element->value) ) :
1576
-								update_post_meta( $element->ID, '_' . $to_attribute->code, $element->value );
1575
+							if ((($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ($to_attribute->is_filterable == 'yes') && !empty($element->value)) :
1576
+								update_post_meta($element->ID, '_' . $to_attribute->code, $element->value);
1577 1577
 							endif;
1578 1578
 						}
1579 1579
 					}
1580 1580
 
1581
-					if ( !$has_error ) {
1581
+					if (!$has_error) {
1582 1582
 						$response['status'] = true;
1583 1583
 						$response['error'] = __('Transfert between attribute is done', 'wpshop');
1584 1584
 					}
1585 1585
 					else {
1586 1586
 						$response['status'] = false;
1587
-						$response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1587
+						$response['error'] = sprinttf(__('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count);
1588 1588
 					}
1589 1589
 				}
1590 1590
 				else {
@@ -1602,20 +1602,20 @@  discard block
 block discarded – undo
1602 1602
 			$response['error'] = __('You have to choose attributes in order to update values', 'wpshop');
1603 1603
 		}
1604 1604
 
1605
-		echo json_encode( $response );
1605
+		echo json_encode($response);
1606 1606
 		die();
1607 1607
 	}
1608 1608
 	add_action('wp_ajax_wps_mass_action_update_attribute', 'wps_mass_action_update_attribute_value');
1609 1609
 
1610 1610
 	function wps_tools_mass_action_load_possible_options_for_variations_attributes() {
1611 1611
 		// @TODO attribute_id est introuvable
1612
-		check_ajax_referer( 'wps_tools_mass_action_load_possible_options_for_variations_attributes' );
1612
+		check_ajax_referer('wps_tools_mass_action_load_possible_options_for_variations_attributes');
1613 1613
 		$output = '';
1614
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1615
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1614
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1615
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1616 1616
 
1617 1617
 		/**	Define new default value	*/
1618
-		$attribute_possible_values_output = wpshop_attributes::get_select_output( $attribute, array() );
1618
+		$attribute_possible_values_output = wpshop_attributes::get_select_output($attribute, array());
1619 1619
 		$attribute_possible_values_output['possible_value']['no_changes'] = __('No changes', 'wpshop');
1620 1620
 		$attribute_possible_values_output['possible_value']['none'] = __('No default value', 'wpshop');
1621 1621
 		ksort($attribute_possible_values_output['possible_value']);
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 		$input_def['valueToPut'] = 'index';
1625 1625
 		$input_def['name'] = 'wps_update_att_for_variation_options_values';
1626 1626
 		$input_def['id'] = 'wps_update_att_for_variation_options_values';
1627
-		$output .= __( 'Default value to affect for this attribute to all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1627
+		$output .= __('Default value to affect for this attribute to all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1628 1628
 
1629 1629
 		/**	Define if attribute is required for adding product to cart	*/
1630 1630
 		$input_def = array();
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 		$input_def['valueToPut'] = 'index';
1634 1634
 		$input_def['name'] = 'wps_update_att_for_variation_required_state';
1635 1635
 		$input_def['id'] = 'wps_update_att_for_variation_required_state';
1636
-		$output .= '<br/>' . __( 'Put this attribute as required for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1636
+		$output .= '<br/>' . __('Put this attribute as required for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1637 1637
 
1638 1638
 
1639 1639
 		$input_def = array();
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
 		$input_def['valueToPut'] = 'index';
1643 1643
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][text_from]';
1644 1644
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_text_from';
1645
-		$output .= '<br/>' . __( 'Display "Price from" text before price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1645
+		$output .= '<br/>' . __('Display "Price from" text before price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1646 1646
 
1647 1647
 		$input_def = array();
1648 1648
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'no' => __('No', 'wpshop'), 'yes' => __('Yes', 'wpshop'));
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 		$input_def['valueToPut'] = 'index';
1651 1651
 		$input_def['name'] = 'wps_update_att_for_variation[price_display][lower_price]';
1652 1652
 		$input_def['id'] = 'wps_update_att_for_variation_price_display_lower_price';
1653
-		$output .= '<br/>' . __( 'Display lower price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1653
+		$output .= '<br/>' . __('Display lower price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1654 1654
 
1655 1655
 		$input_def = array();
1656 1656
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'replacement' => __('Replace product price with option price', 'wpshop'), 'addition' => __('Add option price to product price', 'wpshop'));
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 		$input_def['valueToPut'] = 'index';
1659 1659
 		$input_def['name'] = 'wps_update_att_for_variation[price_behaviour]';
1660 1660
 		$input_def['id'] = 'wps_update_att_for_variation_price_behaviour';
1661
-		$output .= '<br/>' . __( 'Price calculation behaviour', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1661
+		$output .= '<br/>' . __('Price calculation behaviour', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1662 1662
 
1663 1663
 		$input_def = array();
1664 1664
 		$input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'single' => __('Priority to single options', 'wpshop'), 'combined' => __('Priority to combined options', 'wpshop'));
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 		$input_def['valueToPut'] = 'index';
1667 1667
 		$input_def['name'] = 'wps_update_att_for_variation[priority]';
1668 1668
 		$input_def['id'] = 'wps_update_att_for_variation_priority';
1669
-		$output .= '<br/>' . __( 'Choose priority combination for calculating options', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def );
1669
+		$output .= '<br/>' . __('Choose priority combination for calculating options', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def);
1670 1670
 
1671 1671
 		echo $output;
1672 1672
 		die();
@@ -1674,69 +1674,69 @@  discard block
 block discarded – undo
1674 1674
 	add_action('wp_ajax_wps_tools_mass_action_load_possible_options_for_variations_attributes', 'wps_tools_mass_action_load_possible_options_for_variations_attributes');
1675 1675
 
1676 1676
 	function wps_mass_action_change_variation_option() {
1677
-		check_ajax_referer( 'wps_mass_action_change_variation_option' );
1677
+		check_ajax_referer('wps_mass_action_change_variation_option');
1678 1678
 		global $wpdb;
1679 1679
 
1680
-		$attribute_id = !empty( $_POST['attribute_id'] ) ? (int) $_POST['attribute_id'] : 0;
1681
-		$attribute = wpshop_attributes::getElement( $attribute_id, "'valid'" );
1682
-		$query = $wpdb->prepare( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code );
1683
-		$meta_to_update = $wpdb->get_results( $query );
1680
+		$attribute_id = !empty($_POST['attribute_id']) ? (int)$_POST['attribute_id'] : 0;
1681
+		$attribute = wpshop_attributes::getElement($attribute_id, "'valid'");
1682
+		$query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code);
1683
+		$meta_to_update = $wpdb->get_results($query);
1684 1684
 		$has_error = false;
1685
-		if ( !empty($meta_to_update) ) {
1686
-			foreach ( $meta_to_update as $meta_def ) {
1687
-				$meta_value = unserialize( $meta_def->meta_value );
1688
-				if ( !empty($meta_value) && !empty( $meta_value['attributes'] ) && in_array( $attribute->code, $meta_value['attributes']) ) {
1685
+		if (!empty($meta_to_update)) {
1686
+			foreach ($meta_to_update as $meta_def) {
1687
+				$meta_value = unserialize($meta_def->meta_value);
1688
+				if (!empty($meta_value) && !empty($meta_value['attributes']) && in_array($attribute->code, $meta_value['attributes'])) {
1689 1689
 
1690
-					$update_att_for_variation_options_values = !empty( $_POST['wps_update_att_for_variation_options_values'] ) ? sanitize_text_field( $_POST['wps_update_att_for_variation_options_values'] ) : '';
1691
-					if ( $update_att_for_variation_options_values != 'no_changes' ) {
1690
+					$update_att_for_variation_options_values = !empty($_POST['wps_update_att_for_variation_options_values']) ? sanitize_text_field($_POST['wps_update_att_for_variation_options_values']) : '';
1691
+					if ($update_att_for_variation_options_values != 'no_changes') {
1692 1692
 						$meta_value['options']['attributes_default_value'][$attribute->code] = $update_att_for_variation_options_values;
1693 1693
 					}
1694 1694
 
1695
-					$wps_update_att_for_variation_required_state = !empty( $_POST['wps_update_att_for_variation_required_state'] ) ? sanitize_text_field( $_POST['wps_update_att_for_variation_required_state'] ) : '';
1696
-					if ( !empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes') ) {
1697
-						if ( $wps_update_att_for_variation_required_state == 'yes') {
1695
+					$wps_update_att_for_variation_required_state = !empty($_POST['wps_update_att_for_variation_required_state']) ? sanitize_text_field($_POST['wps_update_att_for_variation_required_state']) : '';
1696
+					if (!empty($wps_update_att_for_variation_required_state) && ($wps_update_att_for_variation_required_state != 'no_changes')) {
1697
+						if ($wps_update_att_for_variation_required_state == 'yes') {
1698 1698
 							$meta_value['options']['required_attributes'][$attribute->code] = $attribute->code;
1699 1699
 						}
1700
-						else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) {
1700
+						else if (!empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code])) {
1701 1701
 							unset($meta_value['options']['required_attributes'][$attribute->code]);
1702 1702
 						}
1703 1703
 					}
1704 1704
 
1705
-					$update_att_for_variation = !empty( $_POST['wps_update_att_for_variation'] ) ? (array) $_POST['wps_update_att_for_variation'] : array();
1706
-					$text_from = !empty( $update_att_for_variation['text_from'] ) ? sanitize_text_field( $update_att_for_variation['text_from'] ) : '';
1707
-					if ( !empty( $update_att_for_variation ) ) {
1708
-						if ( !empty($text_from) && ($text_from != 'no_changes') ) {
1709
-							if ( $text_from == 'yes' ) {
1705
+					$update_att_for_variation = !empty($_POST['wps_update_att_for_variation']) ? (array)$_POST['wps_update_att_for_variation'] : array();
1706
+					$text_from = !empty($update_att_for_variation['text_from']) ? sanitize_text_field($update_att_for_variation['text_from']) : '';
1707
+					if (!empty($update_att_for_variation)) {
1708
+						if (!empty($text_from) && ($text_from != 'no_changes')) {
1709
+							if ($text_from == 'yes') {
1710 1710
 								$meta_value['options']['price_display']['text_from'] = 'on';
1711 1711
 							}
1712
-							else if( !empty($meta_value['options']['price_display']['text_from']) ) {
1712
+							else if (!empty($meta_value['options']['price_display']['text_from'])) {
1713 1713
 								unset($meta_value['options']['price_display']['text_from']);
1714 1714
 							}
1715 1715
 						}
1716 1716
 
1717
-						$lower_price = !empty( $update_att_for_variation['lower_price'] ) ? sanitize_text_field( $update_att_for_variation['lower_price'] ) : '';
1718
-						if ( !empty($lower_price) && ($lower_price != 'no_changes') ) {
1719
-							if ( $lower_price == 'yes' ) {
1717
+						$lower_price = !empty($update_att_for_variation['lower_price']) ? sanitize_text_field($update_att_for_variation['lower_price']) : '';
1718
+						if (!empty($lower_price) && ($lower_price != 'no_changes')) {
1719
+							if ($lower_price == 'yes') {
1720 1720
 								$meta_value['options']['price_display']['lower_price'] = 'on';
1721 1721
 							}
1722
-							else if( !empty($meta_value['options']['price_display']['lower_price']) ) {
1722
+							else if (!empty($meta_value['options']['price_display']['lower_price'])) {
1723 1723
 								unset($meta_value['options']['price_display']['lower_price']);
1724 1724
 							}
1725 1725
 						}
1726 1726
 
1727
-						$price_behaviour = !empty( $update_att_for_variation['price_behaviour'] ) ? sanitize_text_field( $update_att_for_variation['price_behaviour'] ) : '';
1728
-						if ( !empty($price_behaviour) && ($price_behaviour != 'no_changes') ) {
1727
+						$price_behaviour = !empty($update_att_for_variation['price_behaviour']) ? sanitize_text_field($update_att_for_variation['price_behaviour']) : '';
1728
+						if (!empty($price_behaviour) && ($price_behaviour != 'no_changes')) {
1729 1729
 							$meta_value['options']['price_behaviour'][0] = $price_behaviour;
1730 1730
 						}
1731 1731
 
1732
-						$priority = !empty( $update_att_for_variation['priority'] ) ? sanitize_text_field( $update_att_for_variation['priority'] ) : '';
1733
-						if ( !empty($priority) && ($priority != 'no_changes') ) {
1732
+						$priority = !empty($update_att_for_variation['priority']) ? sanitize_text_field($update_att_for_variation['priority']) : '';
1733
+						if (!empty($priority) && ($priority != 'no_changes')) {
1734 1734
 							$meta_value['options']['priority'][0] = $priority;
1735 1735
 						}
1736 1736
 					}
1737 1737
 
1738
-					$meta_save = update_meta( $meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1739
-					if ( $meta_save === false ) {
1738
+					$meta_save = update_meta($meta_def->meta_id, '_wpshop_variation_defining', $meta_value);
1739
+					if ($meta_save === false) {
1740 1740
 						$has_error = true;
1741 1741
 					}
1742 1742
 
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			}
1745 1745
 		}
1746 1746
 
1747
-		echo json_encode( array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))) );
1747
+		echo json_encode(array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))));
1748 1748
 		die();
1749 1749
 	}
1750 1750
 	add_action('wp_ajax_wps_mass_action_change_variation_option', 'wps_mass_action_change_variation_option');
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
 	 */
1757 1757
 	function ajax_activate_addons() {
1758 1758
 		global $wpdb;
1759
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1759
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1760 1760
 
1761 1761
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1762 1762
 		$addon_code = isset($_POST['code']) ? wpshop_tools::varSanitizer($_POST['code']) : null;
@@ -1765,56 +1765,56 @@  discard block
 block discarded – undo
1765 1765
 		if (!empty($addon_name) && !empty($addon_code)) {
1766 1766
 			$addons_list = (unserialize(WPSHOP_ADDONS_LIST));
1767 1767
 			if (in_array($addon_name, array_keys($addons_list))) {
1768
-				$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
1768
+				$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
1769 1769
 				$code_part = array();
1770
-				$code_part[] = substr(hash ( "sha256" , $addons_list[$addon_name][0] ),  $addons_list[$addon_name][1], 5);
1771
-				$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
1772
-				$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
1770
+				$code_part[] = substr(hash("sha256", $addons_list[$addon_name][0]), $addons_list[$addon_name][1], 5);
1771
+				$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
1772
+				$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
1773 1773
 				$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
1774 1774
 
1775 1775
 				$current_web_site = site_url('/');
1776 1776
 
1777
-				if ( $addons_list[$addon_name][2] == 'per_site') {
1778
-					$code .= '-' . substr(hash ( "sha256" , $current_web_site ),  $addons_list[$addon_name][1], 5);
1777
+				if ($addons_list[$addon_name][2] == 'per_site') {
1778
+					$code .= '-' . substr(hash("sha256", $current_web_site), $addons_list[$addon_name][1], 5);
1779 1779
 				}
1780 1780
 
1781
-				if ( !empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1782
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1783
-					if ( empty($admin_new_quotation_message) ) {
1784
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1781
+				if (!empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') {
1782
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1783
+					if (empty($admin_new_quotation_message)) {
1784
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1785 1785
 					}
1786
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1787
-					if ( empty($admin_new_quotation_confirm_message) ) {
1788
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1786
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1787
+					if (empty($admin_new_quotation_confirm_message)) {
1788
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1789 1789
 					}
1790 1790
 				}
1791 1791
 
1792 1792
 				if ($code == $addon_code) {
1793
-					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array() );
1793
+					$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1794 1794
 					$extra_options[$addon_name]['activate'] = true;
1795 1795
 					$extra_options[$addon_name]['activation_date'] = current_time('mysql', 0);
1796 1796
 					$extra_options[$addon_name]['activation_code'] = $addon_code;
1797
-					if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1798
-						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated','wpshop'));
1799
-						if( !empty($addons_list[$addon_name][3]) ) {
1797
+					if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1798
+						$result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated', 'wpshop'));
1799
+						if (!empty($addons_list[$addon_name][3])) {
1800 1800
 							$activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3]));
1801 1801
 						}
1802 1802
 						$state = true;
1803 1803
 					}
1804 1804
 					else {
1805
-						$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1805
+						$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1806 1806
 					}
1807 1807
 				}
1808 1808
 				else {
1809
-					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop'));
1809
+					$result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1810 1810
 				}
1811 1811
 			}
1812 1812
 			else {
1813
-				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop'));
1813
+				$result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated', 'wpshop'));
1814 1814
 			}
1815 1815
 		}
1816 1816
 		else {
1817
-			$result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop'));
1817
+			$result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop'));
1818 1818
 		}
1819 1819
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
1820 1820
 
@@ -1827,27 +1827,27 @@  discard block
 block discarded – undo
1827 1827
 	 * Addons desactivate
1828 1828
 	 */
1829 1829
 	function ajax_desactivate_wpshop_addons() {
1830
-		check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' );
1830
+		check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce');
1831 1831
 
1832 1832
 		$addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null;
1833 1833
 		$state = true;
1834 1834
 
1835
-		if ( !empty($addon_name) ) {
1835
+		if (!empty($addon_name)) {
1836 1836
 			$addons_list = array_keys(unserialize(WPSHOP_ADDONS_LIST));
1837 1837
 			if (in_array($addon_name, $addons_list)) {
1838 1838
 				$extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array());
1839 1839
 				$extra_options[$addon_name]['activate'] = false;
1840 1840
 				$extra_options[$addon_name]['deactivation_date'] = current_time('mysql', 0);
1841
-				if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) {
1842
-					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop'));
1841
+				if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) {
1842
+					$result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated', 'wpshop'));
1843 1843
 					$state = false;
1844 1844
 				}
1845 1845
 				else {
1846
-					$result = array(false, __('An error occured','wpshop'), __('Activated','wpshop'));
1846
+					$result = array(false, __('An error occured', 'wpshop'), __('Activated', 'wpshop'));
1847 1847
 				}
1848 1848
 			}
1849 1849
 			else {
1850
-				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop'));
1850
+				$result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated', 'wpshop'));
1851 1851
 			}
1852 1852
 		}
1853 1853
 		$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
@@ -1861,39 +1861,39 @@  discard block
 block discarded – undo
1861 1861
 	 * Display opttions for including user address into account form
1862 1862
 	 */
1863 1863
 	function ajax_integrate_billing_into_register() {
1864
-		check_ajax_referer( 'wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce' );
1864
+		check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce');
1865 1865
 		global $wpshop_account;
1866 1866
 		$wpshop_billing_address = get_option('wpshop_billing_address');
1867 1867
 		$current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null;
1868 1868
 		$selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null;
1869
-		$attribute = !empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array();
1870
-		$billing_form_fields = wps_address::get_addresss_form_fields_by_type ( $current_billing_address );
1869
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
1870
+		$billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address);
1871 1871
 		$possible_values_for_billing = array('' => __('No corresponding field', 'wpshop'));
1872
-		foreach ( $billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1873
-			foreach ( $attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1872
+		foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
1873
+			foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
1874 1874
 				$possible_values_for_billing[$attribute_build_code] = $attribute_definition['label'];
1875 1875
 			}
1876 1876
 		}
1877
-		$attributes_set = wpshop_attributes_set::getElement( 'yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1877
+		$attributes_set = wpshop_attributes_set::getElement('yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
1878 1878
 		/*	Get the attribute set details in order to build the product interface	*/
1879
-		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'");
1880
-		if(!empty($productAttributeSetDetails)){
1881
-			foreach($productAttributeSetDetails as $productAttributeSetDetail){
1882
-				if(count($productAttributeSetDetail['attribut']) >= 1){
1883
-					foreach($productAttributeSetDetail['attribut'] as $attribute) {
1884
-						if(!empty($attribute->id)) {
1885
-							$submitOrderInfos = !empty( $_POST['submitOrderInfos'] ) ? (int) $_POST['submitOrderInfos'] : 0;
1886
-							if( !empty($submitOrderInfos) ) {
1879
+		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'");
1880
+		if (!empty($productAttributeSetDetails)) {
1881
+			foreach ($productAttributeSetDetails as $productAttributeSetDetail) {
1882
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
1883
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
1884
+						if (!empty($attribute->id)) {
1885
+							$submitOrderInfos = !empty($_POST['submitOrderInfos']) ? (int)$_POST['submitOrderInfos'] : 0;
1886
+							if (!empty($submitOrderInfos)) {
1887 1887
 								$value = $attribute[$attribute->data_type][$attribute->code];
1888 1888
 							}
1889 1889
 							else {
1890 1890
 								$value = '';
1891
-								if ( $attribute->code != 'user_pass') {
1891
+								if ($attribute->code != 'user_pass') {
1892 1892
 									$code = $attribute->code;
1893 1893
 									$value = $user->$code;
1894 1894
 								}
1895 1895
 							}
1896
-							$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute, $value, array() );
1896
+							$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array());
1897 1897
 							$account_form_field[$attribute->code] = $attribute_output_def;
1898 1898
 						}
1899 1899
 					}
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
 
1904 1904
 		$possible_values = array();
1905 1905
 		$matching_field = '';
1906
-		foreach ( $account_form_field as $attribute_code => $attribute_detail) {
1906
+		foreach ($account_form_field as $attribute_code => $attribute_detail) {
1907 1907
 			$possible_values[$attribute_code] = $attribute_detail['label'];
1908 1908
 
1909 1909
 			$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']';
@@ -1935,13 +1935,13 @@  discard block
 block discarded – undo
1935 1935
 	 * Search element in database for shortcode insertion interface
1936 1936
 	 */
1937 1937
 	function ajax_wpshop_element_search() {
1938
-		check_ajax_referer( 'wpshop_element_search', 'wpshop_ajax_nonce' );
1938
+		check_ajax_referer('wpshop_element_search', 'wpshop_ajax_nonce');
1939 1939
 
1940 1940
 		$wpshop_element_searched = isset($_REQUEST['wpshop_element_searched']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_searched']) : null;
1941 1941
 		$wpshop_element_type = isset($_REQUEST['wpshop_element_type']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_type']) : null;
1942 1942
 		$wpshop_format_result = isset($_REQUEST['wpshop_format_result']) ? (bool)wpshop_tools::varSanitizer($_REQUEST['wpshop_format_result']) : true;
1943 1943
 
1944
-		switch ( $wpshop_element_type ) {
1944
+		switch ($wpshop_element_type) {
1945 1945
 			case 'product':
1946 1946
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
1947 1947
 				$data = wpshop_products::product_list($wpshop_format_result, $wpshop_element_searched);
@@ -1951,18 +1951,18 @@  discard block
 block discarded – undo
1951 1951
 				break;
1952 1952
 			case WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS:
1953 1953
 				$wps_provider_ctr = new wps_provider_ctr();
1954
-				$data = $wps_provider_ctr->read( array( 's' => $wpshop_element_searched ) );
1954
+				$data = $wps_provider_ctr->read(array('s' => $wpshop_element_searched));
1955 1955
 				break;
1956 1956
 		}
1957 1957
 
1958
-		if ( $wpshop_format_result ) {
1958
+		if ($wpshop_format_result) {
1959 1959
 			$data = empty($data) ? __('No match', 'wpshop') : $data;
1960 1960
 		}
1961 1961
 		else {
1962
-			if ( !empty($data) ) {
1962
+			if (!empty($data)) {
1963 1963
 				$temp_data = $data;
1964
-				unset( $data );
1965
-				foreach ( $temp_data as $post) {
1964
+				unset($data);
1965
+				foreach ($temp_data as $post) {
1966 1966
 					$data[$post->ID] = $post->ID . ' - ' . $post->post_title;
1967 1967
 				}
1968 1968
 			}
@@ -1983,35 +1983,35 @@  discard block
 block discarded – undo
1983 1983
 	 * Add product to the end user cart
1984 1984
 	 */
1985 1985
 	function ajax_wpshop_add_to_cart() {
1986
-		check_ajax_referer( 'ajax_pos_product_variation_selection' );
1986
+		check_ajax_referer('ajax_pos_product_variation_selection');
1987 1987
 
1988 1988
 		global $wpdb;
1989 1989
 		$wpshop_cart = new wps_cart();
1990 1990
 
1991 1991
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
1992 1992
 		$product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1;
1993
-		$cart_option = get_option('wpshop_cart_option', array() );
1993
+		$cart_option = get_option('wpshop_cart_option', array());
1994 1994
 		$wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? (array)$_POST['wps_pdt_variations'] : array();
1995
-		$from_administration =  ( !empty($_POST['from_admin']) ) ? (int)$_POST['from_admin'] : false;
1996
-		$order_id =  ( !empty($_POST['wps_orders_order_id']) ) ? wpshop_tools::varSanitizer( $_POST['wps_orders_order_id'] ) : null;
1995
+		$from_administration = (!empty($_POST['from_admin'])) ? (int)$_POST['from_admin'] : false;
1996
+		$order_id = (!empty($_POST['wps_orders_order_id'])) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null;
1997 1997
 
1998 1998
 
1999 1999
 		// Check Cart Animation
2000
-		$cart_animation_choice = ( !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2001
-		if ( !empty($cart_option['total_nb_of_item_allowed']) && ((int) $cart_option['total_nb_of_item_allowed'][0] == 1) ) {
2000
+		$cart_animation_choice = (!empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null);
2001
+		if (!empty($cart_option['total_nb_of_item_allowed']) && ((int)$cart_option['total_nb_of_item_allowed'][0] == 1)) {
2002 2002
 			$wpshop_cart->empty_cart();
2003 2003
 		}
2004 2004
 
2005 2005
 		// Prepare Product to be added to cart
2006
-		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected );
2006
+		$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected);
2007 2007
 		$product_to_add_to_cart = $formatted_product[0];
2008 2008
 		$new_pid = $formatted_product[1];
2009 2009
 
2010 2010
 		// Check cart Type
2011 2011
 		$cart_type_for_adding = 'normal';
2012
-		$wpshop_cart_type = !empty( $_POST['wpshop_cart_type'] ) ? sanitize_text_field( $_POST['wpshop_cart_type'] ) : '';
2013
-		if (!empty($wpshop_cart_type) ) {
2014
-			switch(wpshop_tools::varSanitizer($wpshop_cart_type)){
2012
+		$wpshop_cart_type = !empty($_POST['wpshop_cart_type']) ? sanitize_text_field($_POST['wpshop_cart_type']) : '';
2013
+		if (!empty($wpshop_cart_type)) {
2014
+			switch (wpshop_tools::varSanitizer($wpshop_cart_type)) {
2015 2015
 				case 'quotation':
2016 2016
 					$wpshop_cart_type = 'quotation';
2017 2017
 					break;
@@ -2022,43 +2022,43 @@  discard block
 block discarded – undo
2022 2022
 		}
2023 2023
 
2024 2024
 		// Check Product image
2025
-		$product = get_post( $product_id );
2026
-		$product_img = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="no picture" />';
2027
-		if ( !empty($product_id) ) {
2028
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2029
-				$parent_def = wpshop_products::get_parent_variation( $product_id );
2030
-				$parent_post = ( !empty($parent_def['parent_post']) ) ? $parent_def['parent_post'] : array();
2031
-				$product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : '';
2032
-				$product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : '';
2033
-				$product_img =  ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : '';
2025
+		$product = get_post($product_id);
2026
+		$product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />';
2027
+		if (!empty($product_id)) {
2028
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2029
+				$parent_def = wpshop_products::get_parent_variation($product_id);
2030
+				$parent_post = (!empty($parent_def['parent_post'])) ? $parent_def['parent_post'] : array();
2031
+				$product_title = (!empty($parent_post) && !empty($parent_post->post_title)) ? $parent_post->post_title : '';
2032
+				$product_description = (!empty($parent_post) && !empty($parent_post->post_content)) ? $parent_post->post_content : '';
2033
+				$product_img = (!empty($parent_post->ID)) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : '';
2034 2034
 			}
2035 2035
 			else {
2036 2036
 				$product_title = $product->post_title;
2037 2037
 				$product_description = $product->post_content;
2038
-				$product_img =  get_the_post_thumbnail( $product_id, 'thumbnail');
2038
+				$product_img = get_the_post_thumbnail($product_id, 'thumbnail');
2039 2039
 			}
2040 2040
 		}
2041 2041
 
2042
-		$wps_orders_from_admin = !empty( $_POST['wps_orders_from_admin'] ) ? (int) $_POST['wps_orders_from_admin'] : 0;
2043
-		if ( !empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2042
+		$wps_orders_from_admin = !empty($_POST['wps_orders_from_admin']) ? (int)$_POST['wps_orders_from_admin'] : 0;
2043
+		if (!empty($wps_orders_from_admin) && $wps_orders_from_admin) {
2044 2044
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2045
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type, array(), true, $order_meta, $order_id );
2045
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type, array(), true, $order_meta, $order_id);
2046 2046
 
2047
-			echo json_encode( array(true) );
2047
+			echo json_encode(array(true));
2048 2048
 			die();
2049 2049
 		}
2050 2050
 		else {
2051
-			$return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type );
2051
+			$return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type);
2052 2052
 		}
2053 2053
 
2054
-		if ( $return == 'success' ) {
2055
-			$cart_page_url = apply_filters( 'wps_cart_page_url', get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_cart_page_id' ) ) ) );
2054
+		if ($return == 'success') {
2055
+			$cart_page_url = apply_filters('wps_cart_page_url', get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))));
2056 2056
 			/** Template parameters	*/
2057 2057
 			$template_part = 'product_added_to_cart_message';
2058 2058
 
2059 2059
 			/** Build template	*/
2060 2060
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2061
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2061
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2062 2062
 				/*	Include the old way template part	*/
2063 2063
 				ob_start();
2064 2064
 				require_once(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2077,14 +2077,14 @@  discard block
 block discarded – undo
2077 2077
 
2078 2078
 			/** Product Price **/
2079 2079
 			$product_price = '';
2080
-			if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart) ) {
2080
+			if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) {
2081 2081
 				$idp = '';
2082 2082
 
2083
-				if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) {
2083
+				if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) {
2084 2084
 					$idp = $product_to_add_to_cart[$new_pid]['variations'][0];
2085 2085
 				}
2086 2086
 				else {
2087
-					if( strstr( $new_pid, '__') ) {
2087
+					if (strstr($new_pid, '__')) {
2088 2088
 						$idp = $new_pid;
2089 2089
 					}
2090 2090
 					else {
@@ -2092,43 +2092,43 @@  discard block
 block discarded – undo
2092 2092
 					}
2093 2093
 				}
2094 2094
 
2095
-				if( !empty($idp) ) {
2096
-					$default_currency = wpshop_tools::wpshop_get_currency( false );
2097
-					$price_piloting_option = get_option( 'wpshop_shop_price_piloting' );
2095
+				if (!empty($idp)) {
2096
+					$default_currency = wpshop_tools::wpshop_get_currency(false);
2097
+					$price_piloting_option = get_option('wpshop_shop_price_piloting');
2098 2098
 
2099 2099
 					$real_price = null;
2100
-					if ( !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid]['item_amount_to_pay_now'] ) ) {
2101
-						$real_price = ( $_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty );
2100
+					if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$new_pid]) && !empty($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'])) {
2101
+						$real_price = ($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty);
2102 2102
 					}
2103 2103
 
2104
-					$pr = empty( $real_price ) ? ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ht']  * $product_qty ) : ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty ) : $real_price;
2105
-					$product_price = wpshop_tools::formate_number( $pr ).$default_currency;
2104
+					$pr = empty($real_price) ? (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty) : ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty) : $real_price;
2105
+					$product_price = wpshop_tools::formate_number($pr) . $default_currency;
2106 2106
 				}
2107 2107
 			}
2108 2108
 			/** Check if there are linked products **/
2109
-			$related_products = get_post_meta( $product_id, '_wpshop_product_related_products', true);
2109
+			$related_products = get_post_meta($product_id, '_wpshop_product_related_products', true);
2110 2110
 			$tpl_component = array();
2111 2111
 			$linked_products = '';
2112
-			if ( !empty($related_products) ) {
2112
+			if (!empty($related_products)) {
2113 2113
 				// $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>';
2114
-				$linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>';
2114
+				$linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>';
2115 2115
 			}
2116 2116
 			else {
2117 2117
 				$linked_products = '';
2118 2118
 			}
2119 2119
 
2120
-			$message_confirmation = sprintf( __('%s has been add to the cart', 'wpshop'), $product->post_title );
2120
+			$message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title);
2121 2121
 
2122
-			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array( 'RELATED_PRODUCTS' => $linked_products , 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description) );
2123
-			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array( 'LINK_CART_PAGE' => wpshop_tools::get_page_id( get_permalink( get_option('wpshop_cart_page_id') ) ) ) );
2122
+			$modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array('RELATED_PRODUCTS' => $linked_products, 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description));
2123
+			$modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array('LINK_CART_PAGE' => wpshop_tools::get_page_id(get_permalink(get_option('wpshop_cart_page_id')))));
2124 2124
 
2125
-			$response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content );
2125
+			$response = array(true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content);
2126 2126
 		}
2127 2127
 		else {
2128
-			$response = array( false, $return );
2128
+			$response = array(false, $return);
2129 2129
 		}
2130 2130
 
2131
-		wp_die( json_encode( $response ) );
2131
+		wp_die(json_encode($response));
2132 2132
 	}
2133 2133
  	add_action('wp_ajax_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
2134 2134
 	add_action('wp_ajax_nopriv_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart');
@@ -2138,45 +2138,45 @@  discard block
 block discarded – undo
2138 2138
 	 * Set product qty into customer cart
2139 2139
 	 */
2140 2140
 	function ajax_wpshop_set_qty_for_product_into_cart() {
2141
-		check_ajax_referer( 'ajax_wpshop_set_qty_for_product_into_cart' );
2141
+		check_ajax_referer('ajax_wpshop_set_qty_for_product_into_cart');
2142 2142
 		$response = array();
2143 2143
 		$wpshop_cart = new wps_cart();
2144 2144
 		$product_id = isset($_POST['product_id']) ? wpshop_tools::varSanitizer($_POST['product_id']) : null;
2145 2145
 		$product_qty = isset($_POST['product_qty']) ? intval(wpshop_tools::varSanitizer($_POST['product_qty'])) : null;
2146 2146
 
2147 2147
 		$pid = $product_id;
2148
-		if (strpos($product_id,'__') !== false) {
2148
+		if (strpos($product_id, '__') !== false) {
2149 2149
 			//$pid = $_SESSION['cart']['order_items'][$product_id]['item_id'];
2150
-			foreach( $_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation ) {
2150
+			foreach ($_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation) {
2151 2151
 				$pid = $variation['product_id'];
2152 2152
 				break;
2153 2153
 			}
2154 2154
 		}
2155 2155
 
2156
-		$global_discount = !empty( $_POST['global_discount'] ) ? (int) $_POST['global_discount'] : 0;
2157
-		if ( !empty($global_discount) ) {
2156
+		$global_discount = !empty($_POST['global_discount']) ? (int)$_POST['global_discount'] : 0;
2157
+		if (!empty($global_discount)) {
2158 2158
 			$_SESSION['cart']['pos_global_discount'] = $global_discount;
2159 2159
 		}
2160 2160
 
2161 2161
 		if (!empty($product_id)) {
2162 2162
 			if (isset($product_qty)) {
2163
-				if ( $product_qty == 0 ) {
2164
-					$variation_of_product = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1) );
2165
-					if ( !empty($variation_of_product) ) {
2166
-						foreach ( $variation_of_product as $p_id) {
2163
+				if ($product_qty == 0) {
2164
+					$variation_of_product = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1));
2165
+					if (!empty($variation_of_product)) {
2166
+						foreach ($variation_of_product as $p_id) {
2167 2167
 							$wpshop_cart->set_product_qty($p_id->ID, $product_qty);
2168 2168
 						}
2169 2169
 					}
2170 2170
 				}
2171
-				$return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid );
2171
+				$return = $wpshop_cart->set_product_qty($product_id, $product_qty, $pid);
2172 2172
 				$response[] = $return;
2173 2173
 			}
2174 2174
 			else {
2175 2175
 				$response[] = false;
2176
-				$response[] = __('Parameters error.','wpshop');
2176
+				$response[] = __('Parameters error.', 'wpshop');
2177 2177
 			}
2178 2178
 		}
2179
-		wp_die( json_encode( $response ) );
2179
+		wp_die(json_encode($response));
2180 2180
 	}
2181 2181
 	add_action('wp_ajax_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
2182 2182
 	add_action('wp_ajax_nopriv_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart');
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 	 * Display cart after doing an action on it
2186 2186
 	 */
2187 2187
 	function ajax_wpshop_display_cart() {
2188
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2188
+		check_ajax_referer('ajax_wpshop_display_cart');
2189 2189
 		ini_set('display_errors', true);
2190 2190
 		error_reporting(E_ALL);
2191 2191
 		$wps_cart_ctr = new wps_cart();
@@ -2199,8 +2199,8 @@  discard block
 block discarded – undo
2199 2199
 	/**
2200 2200
 	 * Display mini cart widgte after doing an action on it
2201 2201
 	 */
2202
-	function ajax_wpshop_reload_mini_cart(){
2203
-		check_ajax_referer( 'ajax_wpshop_display_cart' );
2202
+	function ajax_wpshop_reload_mini_cart() {
2203
+		check_ajax_referer('ajax_wpshop_display_cart');
2204 2204
 		echo wpshop_cart::mini_cart_content();
2205 2205
 		die();
2206 2206
 	}
@@ -2211,16 +2211,16 @@  discard block
 block discarded – undo
2211 2211
 	 * Refresh Price in complete product sheet and Cart summary display
2212 2212
 	 */
2213 2213
 	function wpshop_ajax_wpshop_variation_selection() {
2214
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2214
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2215 2215
 		$product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
2216 2216
 		$wpshop_variation_selected = isset($_POST['wpshop_variation']) ? (array)$_POST['wpshop_variation'] : null;
2217 2217
 		$wpshop_free_variation = isset($_POST['wpshop_free_variation']) ? (array)$_POST['wpshop_free_variation'] : null;
2218
-		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field( $_POST['wpshop_current_for_display'] ) : null;
2218
+		$wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? sanitize_text_field($_POST['wpshop_current_for_display']) : null;
2219 2219
 		$product_qty = isset($_POST['product_qty']) ? (int)$_POST['product_qty'] : 1;
2220 2220
 
2221
-		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty );
2221
+		$product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty);
2222 2222
 
2223
-		wp_die( json_encode( $product_variation_summary ) );
2223
+		wp_die(json_encode($product_variation_summary));
2224 2224
 	}
2225 2225
 	add_action('wp_ajax_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
2226 2226
 	add_action('wp_ajax_nopriv_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection');
@@ -2230,23 +2230,23 @@  discard block
 block discarded – undo
2230 2230
 	function wpshop_ajax_variation_selection_show_detail_for_value() {
2231 2231
 		global $wpdb;
2232 2232
 
2233
-		check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' );
2233
+		check_ajax_referer('wpshop_ajax_wpshop_variation_selection');
2234 2234
 
2235 2235
 		$display = '';
2236 2236
 		$attribute_for_detail = isset($_POST['attribute_for_detail']) ? (array)$_POST['attribute_for_detail'] : array();
2237 2237
 
2238
-		if ( !empty( $attribute_for_detail ) ) {
2238
+		if (!empty($attribute_for_detail)) {
2239 2239
 			$selection = array();
2240
-			foreach ( $attribute_for_detail as $selected_variation ) {
2240
+			foreach ($attribute_for_detail as $selected_variation) {
2241 2241
 				$variation_definition = explode('-_variation_val_-', $selected_variation);
2242 2242
 				$attribute_definition = wpshop_attributes::getElement($variation_definition[0], "'valid'", 'code');
2243 2243
 				$post_definition = get_post($variation_definition[1]);
2244 2244
 
2245
-				if ( !empty($post_definition) ) {
2246
-					$post_content = ( !empty($post_definition) && !empty($post_definition->post_content) ) ? $post_definition->post_content : '';
2247
-					if ( empty($post_content) && !empty($post_definition->post_parent) ) {
2245
+				if (!empty($post_definition)) {
2246
+					$post_content = (!empty($post_definition) && !empty($post_definition->post_content)) ? $post_definition->post_content : '';
2247
+					if (empty($post_content) && !empty($post_definition->post_parent)) {
2248 2248
 						$post_parent_definition = get_post($post_definition->post_parent);
2249
-						if ( !empty($post_parent_definition) ) {
2249
+						if (!empty($post_parent_definition)) {
2250 2250
 							$post_content = $post_parent_definition->post_content;
2251 2251
 						}
2252 2252
 					}
@@ -2273,74 +2273,74 @@  discard block
 block discarded – undo
2273 2273
 	 * Save customer account informations
2274 2274
 	 */
2275 2275
 	function wpshop_ajax_save_customer_account() {
2276
-		check_ajax_referer( 'wpshop_customer_register', 'wpshop_ajax_nonce' );
2276
+		check_ajax_referer('wpshop_customer_register', 'wpshop_ajax_nonce');
2277 2277
 		global $wpshop, $wpshop_account, $wpdb;
2278
-		$reponse='';
2278
+		$reponse = '';
2279 2279
 		$status = false;
2280 2280
 		$validate = true;
2281 2281
 
2282
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2282
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2283 2283
 
2284 2284
 		$user_id = get_current_user_id();
2285
-		$current_connected_user = !empty( $user_id ) ? $user_id : null;
2285
+		$current_connected_user = !empty($user_id) ? $user_id : null;
2286 2286
 		$wpshop_billing_address = get_option('wpshop_billing_address');
2287
-		if ( !empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']]) ) {
2288
-			if ( !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) ) {
2289
-				$address_fields = wps_address::get_addresss_form_fields_by_type ( $wpshop_billing_address['choice'] );
2287
+		if (!empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($attribute[$wpshop_billing_address['choice']])) {
2288
+			if (!empty($wpshop_billing_address['integrate_into_register_form_matching_field'])) {
2289
+				$address_fields = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2290 2290
 				$address_field = $address_fields[$wpshop_billing_address['choice']];
2291 2291
 				$temp_aray_for_matching = array_flip($wpshop_billing_address['integrate_into_register_form_matching_field']);
2292
-				foreach ( $address_field as $group_id => $group_detail) {
2293
-					foreach ( $group_detail['content'] as $attribute_build_code => $attribute_def) {
2294
-						if ( in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty( $attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] ) && !empty(  $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]] ) ) {
2292
+				foreach ($address_field as $group_id => $group_detail) {
2293
+					foreach ($group_detail['content'] as $attribute_build_code => $attribute_def) {
2294
+						if (in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']]) && !empty($attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]])) {
2295 2295
 							$attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] = $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]];
2296
-							if ( $attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2']) ) {
2296
+							if ($attribute_def['_need_verification'] == 'yes' && !empty($attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'])) {
2297 2297
 								$attribute[$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'] = $attribute[$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code] . '2'];
2298 2298
 							}
2299 2299
 						}
2300 2300
 					}
2301 2301
 				}
2302
-				$attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty( $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] ) ? $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2302
+				$attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty($attribute[$wpshop_billing_address['choice']]['varchar']['address_title']) ? $attribute[$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop');
2303 2303
 			}
2304 2304
 			$group = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']);
2305 2305
 			$validate = false;
2306
-			foreach ( $group as $attribute_sets ) {
2307
-				foreach ( $attribute_sets as $attribute_set_field ) {
2306
+			foreach ($group as $attribute_sets) {
2307
+				foreach ($attribute_sets as $attribute_set_field) {
2308 2308
 					$validate = $wpshop->validateForm($attribute_set_field['content'], $attribute[$wpshop_billing_address['choice']], '');
2309 2309
 				}
2310 2310
 			}
2311 2311
 		}
2312
-		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') )) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2312
+		$cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2313 2313
 
2314
-		$account_form_type = !empty( $_POST['account_form_type'] ) ? sanitize_text_field( $_POST['account_form_type'] ) : '';
2315
-		$validate_personal_form_infos = ( !empty( $account_form_type ) && $account_form_type == 'partial' ) ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2316
-		if( $validate && $validate_personal_form_infos ) {
2317
-			$account_creation_result = $wpshop_account->save_account_form($user_id,  ( ( !empty($account_form_type) && $account_form_type == 'partial' ) ? 'partial' : 'complete') );
2314
+		$account_form_type = !empty($_POST['account_form_type']) ? sanitize_text_field($_POST['account_form_type']) : '';
2315
+		$validate_personal_form_infos = (!empty($account_form_type) && $account_form_type == 'partial') ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields);
2316
+		if ($validate && $validate_personal_form_infos) {
2317
+			$account_creation_result = $wpshop_account->save_account_form($user_id, ((!empty($account_form_type) && $account_form_type == 'partial') ? 'partial' : 'complete'));
2318 2318
 			$status = $account_creation_result[0];
2319 2319
 			$user_id = $account_creation_result[1];
2320
-			$is_partial_account_creation  = $account_creation_result[2];
2321
-			if ( $is_partial_account_creation == 'partial' ) {
2320
+			$is_partial_account_creation = $account_creation_result[2];
2321
+			if ($is_partial_account_creation == 'partial') {
2322 2322
 				$permalink_option = get_option('permalink_structure');
2323
-				if ( !empty($permalink_option) ) {
2324
-					$cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok';
2323
+				if (!empty($permalink_option)) {
2324
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '?complete_sign_up=ok';
2325 2325
 				}
2326 2326
 				else {
2327
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok';
2327
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '&complete_sign_up=ok';
2328 2328
 				}
2329 2329
 			}
2330 2330
 			else {
2331
-				if ( !empty($_SESSION['cart']) ) {
2332
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) );
2331
+				if (!empty($_SESSION['cart'])) {
2332
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')));
2333 2333
 				}
2334 2334
 				else {
2335
-					$cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) );
2335
+					$cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')));
2336 2336
 				}
2337 2337
 			}
2338 2338
 			// check if the customer have already register an address
2339
-			$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2339
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
2340 2340
 			$exist_address = $wpdb->get_results($query);
2341 2341
 		}
2342 2342
 		// If there is errors
2343
-		if($wpshop->error_count()>0) {
2343
+		if ($wpshop->error_count() > 0) {
2344 2344
 			$reponse = $wpshop->show_messages();
2345 2345
 		}
2346 2346
 
@@ -2357,24 +2357,24 @@  discard block
 block discarded – undo
2357 2357
 	function wpshop_ajax_order_customer_adress_load() {
2358 2358
 		global $wpshop_account;
2359 2359
 		global $wpdb;
2360
-		check_ajax_referer( 'wpshop_order_customer_adress_load', 'wpshop_ajax_nonce' );
2361
-		$current_customer_id = !empty( $_REQUEST['customer_id'] ) ? (int)$_REQUEST['customer_id'] : 0;
2362
-		$order_id = !empty( $_REQUEST['order_id'] ) ? (int)$_REQUEST['order_id'] : 0;
2360
+		check_ajax_referer('wpshop_order_customer_adress_load', 'wpshop_ajax_nonce');
2361
+		$current_customer_id = !empty($_REQUEST['customer_id']) ? (int)$_REQUEST['customer_id'] : 0;
2362
+		$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2363 2363
 
2364
-		$order_postmeta = get_post_meta ($order_id, '_order_postmeta', true);
2365
-		$order_infos_postmeta = get_post_meta ($order_id, '_order_info', true);
2364
+		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
2365
+		$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
2366 2366
 
2367
-		if ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded')) ) {
2367
+		if (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded'))) {
2368 2368
 			/** Billing address display **/
2369 2369
 			$tpl_component['ADDRESS_COMBOBOX'] = '';
2370 2370
 			$tpl_component['ADDRESS_BUTTONS'] = '';
2371 2371
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Billing address', 'wpshop');
2372 2372
 			$tpl_component['ADDRESS_TYPE'] = 'billing_address';
2373 2373
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['billing']['id']);
2374
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['billing']['address'] );
2374
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['billing']['address']);
2375 2375
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2376
-			$retour =  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2377
-			unset( $tpl_component );
2376
+			$retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2377
+			unset($tpl_component);
2378 2378
 
2379 2379
 			/** Shipping address display **/
2380 2380
 			$retour .= '<div id="shipping_infos_bloc" class="wpshop_order_customer_container wpshop_order_customer_container_user_information">';
@@ -2383,67 +2383,67 @@  discard block
 block discarded – undo
2383 2383
 			$tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Shipping address', 'wpshop');
2384 2384
 			$tpl_component['ADDRESS_TYPE'] = 'shipping_address';
2385 2385
 			$address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['shipping']['id']);
2386
-			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['shipping']['address']);
2386
+			$tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['shipping']['address']);
2387 2387
 			$tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component);
2388
-			$retour .=  wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2389
-			unset( $tpl_component );
2388
+			$retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component);
2389
+			unset($tpl_component);
2390 2390
 			$retour .= '</div>';
2391 2391
 			$retour .= '<div class="wpshop_cls"></div>';
2392
-			$result = json_encode( array(true, $retour) );
2392
+			$result = json_encode(array(true, $retour));
2393 2393
 
2394 2394
 		}
2395 2395
 
2396
- 		elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2397
-			$order_id = !empty( $_REQUEST['order_id'] ) ? (int) $_REQUEST['order_id'] : 0;
2396
+ 		elseif (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
2397
+			$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;
2398 2398
  			$order_info_postmeta = get_post_meta($order_id, '_order_info', true);
2399 2399
 
2400 2400
  			$billing_id_attribute_set = get_option('wpshop_billing_address');
2401 2401
  			$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2402 2402
 
2403
- 			$order_billing_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address']) ) ? $order_info_postmeta['billing']['address'] : array();
2404
- 			$order_shipping_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address']) ) ? $order_info_postmeta['shipping']['address'] : array();
2403
+ 			$order_billing_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address'])) ? $order_info_postmeta['billing']['address'] : array();
2404
+ 			$order_shipping_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address'])) ? $order_info_postmeta['shipping']['address'] : array();
2405 2405
 
2406
- 			$billing_form = $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address );
2407
- 			if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2408
- 				$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address );
2406
+ 			$billing_form = $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address);
2407
+ 			if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2408
+ 				$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address);
2409 2409
  			}
2410 2410
 
2411
- 			$result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) );
2411
+ 			$result = json_encode(array(true, $billing_form, $shipping_form, $current_customer_id));
2412 2412
  		}
2413 2413
 		else {
2414 2414
 				// Check the attribute set id of Billing Address
2415
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', '');
2415
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Billing address', 'wpshop') . '"', '');
2416 2416
 				$attribute_set_id = $wpdb->get_var($query);
2417 2417
 				$billing_id_attribute_set = get_option('wpshop_billing_address');
2418 2418
 				//Check the billing address id of the customer
2419
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2419
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2420 2420
 				$post_addresses = $wpdb->get_results($query);
2421 2421
 				$address_id = '';
2422
-				foreach ( $post_addresses as $post_address ) {
2423
-					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2424
-					if ( $address_type == $attribute_set_id ) {
2422
+				foreach ($post_addresses as $post_address) {
2423
+					$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2424
+					if ($address_type == $attribute_set_id) {
2425 2425
 						$address_id = $post_address->ID;
2426 2426
 					}
2427 2427
 				}
2428 2428
 				$shipping_id_attribute_set = get_option('wpshop_shipping_address_choice');
2429 2429
 				$shipping_form = '';
2430
-				if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) {
2430
+				if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) {
2431 2431
 					// Check the attribute set id of Shipping Address
2432
-					$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Shipping address', 'wpshop'). '"', '');
2432
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Shipping address', 'wpshop') . '"', '');
2433 2433
 					$attribute_set_id = $wpdb->get_var($query);
2434 2434
 					//Check the billing address id of the customer
2435
-					$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', '');
2435
+					$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', '');
2436 2436
 					$post_addresses = $wpdb->get_results($query);
2437 2437
 					$shipping_address_id = '';
2438
-					foreach ( $post_addresses as $post_address ) {
2439
-						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true);
2440
-						if ( $address_type == $attribute_set_id ) {
2438
+					foreach ($post_addresses as $post_address) {
2439
+						$address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
2440
+						if ($address_type == $attribute_set_id) {
2441 2441
 							$shipping_address_id = $post_address->ID;
2442 2442
 						}
2443 2443
 					}
2444
-					$shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], $shipping_address_id );
2444
+					$shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], $shipping_address_id);
2445 2445
 				}
2446
-				$result = json_encode( array(true, $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], $address_id ), $shipping_form, $current_customer_id) );
2446
+				$result = json_encode(array(true, $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], $address_id), $shipping_form, $current_customer_id));
2447 2447
 		}
2448 2448
 		echo $result;
2449 2449
 		die();
@@ -2455,23 +2455,23 @@  discard block
 block discarded – undo
2455 2455
 	 */
2456 2456
 	function ajax_wpshop_add_entity() {
2457 2457
 		global $wpdb;
2458
-		check_ajax_referer( 'wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce' );
2458
+		check_ajax_referer('wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce');
2459 2459
 
2460
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
2460
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
2461 2461
 		$attributes = array();
2462 2462
 		/** Get the attribute to create	*/
2463 2463
 		$attribute_to_reload = null;
2464
-		if ( !empty($attribute['new_value_creation']) && is_array( $attribute['new_value_creation'] ) ) {
2465
-			foreach ( $attribute['new_value_creation'] as $attribute_code=>$value) {
2466
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', $attribute_code);
2464
+		if (!empty($attribute['new_value_creation']) && is_array($attribute['new_value_creation'])) {
2465
+			foreach ($attribute['new_value_creation'] as $attribute_code=>$value) {
2466
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $attribute_code);
2467 2467
 				$attribute_def = $wpdb->get_row($query);
2468
-				if ( $value != "" ) {
2469
-					if ( $attribute_def->data_type_to_use == 'internal' ) {
2468
+				if ($value != "") {
2469
+					if ($attribute_def->data_type_to_use == 'internal') {
2470 2470
 						$attribute_default_value = unserialize($attribute_def->default_value);
2471
-						if ( $attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) {
2472
-							$user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) );
2473
-							$query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id );
2474
-							$attribute_option_id = $wpdb->get_var( $query );
2471
+						if ($attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
2472
+							$user_id = wp_create_user(sanitize_user($value), wp_generate_password(12, false));
2473
+							$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id);
2474
+							$attribute_option_id = $wpdb->get_var($query);
2475 2475
 						}
2476 2476
 						else {
2477 2477
 							$entity_args = array(
@@ -2484,13 +2484,13 @@  discard block
 block discarded – undo
2484 2484
 						}
2485 2485
 					}
2486 2486
 					else {
2487
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) );
2487
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value));
2488 2488
 						$attribute_option_id = $wpdb->insert_id;
2489 2489
 					}
2490 2490
 
2491
-					foreach ( $attribute as $attribute => $val) {
2491
+					foreach ($attribute as $attribute => $val) {
2492 2492
 						foreach ($val as $k=>$v) {
2493
-							if ( $k == $attribute_code) {
2493
+							if ($k == $attribute_code) {
2494 2494
 								$attribute[$attribute][$k] = $attribute_option_id;
2495 2495
 							}
2496 2496
 						}
@@ -2499,82 +2499,82 @@  discard block
 block discarded – undo
2499 2499
 			}
2500 2500
 		}
2501 2501
 		/** Store send attribute into a new array for save purpose	*/
2502
-		if ( is_array( $attribute ) ) {
2503
-			foreach ( $attribute as $attribute_type => $attribute ) {
2504
-				foreach ( $attribute as $attribute_code => $attribute_value ) {
2505
-					if ( !isset( $attributes[$attribute_code] ) ) {
2502
+		if (is_array($attribute)) {
2503
+			foreach ($attribute as $attribute_type => $attribute) {
2504
+				foreach ($attribute as $attribute_code => $attribute_value) {
2505
+					if (!isset($attributes[$attribute_code])) {
2506 2506
 						$attributes[$attribute_code] = $attribute_value;
2507 2507
 					}
2508 2508
 				}
2509 2509
 			}
2510 2510
 		}
2511 2511
 
2512
-		$post_title = !empty( $_POST['wp_fields']['post_title'] ) ? sanitize_text_field( $_POST['wp_fields']['post_title'] ) : '';
2513
-		$entity_type = !empty( $_POST['entity_type'] ) ? sanitize_text_field( $_POST['entity_type'] ) : '';
2514
-		$attribute_set_id = !empty( $_POST['attribute_set_id'] ) ? (int) $_POST['attribute_set_id'] : 0;
2515
-		$type_of_form = !empty( $_POST['type_of_form'] ) ? sanitize_text_field( $_POST['type_of_form'] ) : '';
2512
+		$post_title = !empty($_POST['wp_fields']['post_title']) ? sanitize_text_field($_POST['wp_fields']['post_title']) : '';
2513
+		$entity_type = !empty($_POST['entity_type']) ? sanitize_text_field($_POST['entity_type']) : '';
2514
+		$attribute_set_id = !empty($_POST['attribute_set_id']) ? (int)$_POST['attribute_set_id'] : 0;
2515
+		$type_of_form = !empty($_POST['type_of_form']) ? sanitize_text_field($_POST['type_of_form']) : '';
2516 2516
 
2517 2517
 		/** Save the new entity into database */
2518
-		$result = wpshop_entities::create_new_entity( $entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id) );
2518
+		$result = wpshop_entities::create_new_entity($entity_type, $post_title, '', $attributes, array('attribute_set_id' => $attribute_set_id));
2519 2519
 		$new_entity_id = $result[1];
2520 2520
 
2521
-		if ( !empty($new_entity_id) ) {
2521
+		if (!empty($new_entity_id)) {
2522 2522
 			/**	Save address for current entity	*/
2523
-			if ( !empty( $type_of_form ) && !empty( $attribute[$type_of_form] ) ) {
2523
+			if (!empty($type_of_form) && !empty($attribute[$type_of_form])) {
2524 2524
 				global $wpshop_account;
2525
-				$result = wps_address::wps_address( $type_of_form );
2526
-				update_post_meta ($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2525
+				$result = wps_address::wps_address($type_of_form);
2526
+				update_post_meta($new_entity_id, '_wpshop_attached_address', $result['current_id']);
2527 2527
 			}
2528 2528
 
2529 2529
 			/** Make price calculation if entity is a product	*/
2530
-			if ( $entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2530
+			if ($entity_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2531 2531
 				$wpshop_prices_attribute = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2532 2532
 				$calculate_price = false;
2533
-				foreach( $wpshop_prices_attribute as $attribute_price_code ){
2534
-					if ( array_key_exists($attribute_price_code, $attributes) ) {
2533
+				foreach ($wpshop_prices_attribute as $attribute_price_code) {
2534
+					if (array_key_exists($attribute_price_code, $attributes)) {
2535 2535
 						$calculate_price = true;
2536 2536
 					}
2537 2537
 				}
2538
-				if ( $calculate_price ) {
2538
+				if ($calculate_price) {
2539 2539
 					wpshop_products::calculate_price($new_entity_id);
2540 2540
 				}
2541 2541
 			}
2542 2542
 
2543 2543
 			/** Add picture if a file has been send	*/
2544
-			if ( !empty($_FILES) ) {
2544
+			if (!empty($_FILES)) {
2545 2545
 				$wp_upload_dir = wp_upload_dir();
2546 2546
 				$final_dir = $wp_upload_dir['path'] . '/';
2547
-				if ( !is_dir($final_dir) ) {
2547
+				if (!is_dir($final_dir)) {
2548 2548
 					mkdir($final_dir, 0755, true);
2549 2549
 				}
2550 2550
 
2551
-				foreach ( $_FILES as $file ) {
2551
+				foreach ($_FILES as $file) {
2552 2552
 					$tmp_name = $file['tmp_name']['post_thumbnail'];
2553 2553
 					$name = $file['name']['post_thumbnail'];
2554 2554
 
2555 2555
 					$filename = $final_dir . $name;
2556 2556
 					@move_uploaded_file($tmp_name, $filename);
2557 2557
 
2558
-					$wp_filetype = wp_check_filetype(basename($filename), null );
2558
+					$wp_filetype = wp_check_filetype(basename($filename), null);
2559 2559
 					$attachment = array(
2560
-						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ),
2560
+						'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path($filename),
2561 2561
 						'post_mime_type' => $wp_filetype['type'],
2562
-						'post_title' => preg_replace( '/\.[^.]+$/', '', basename($filename) ),
2562
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
2563 2563
 						'post_content' => '',
2564 2564
 						'post_status' => 'inherit'
2565 2565
 					);
2566
-					$attach_id = wp_insert_attachment( $attachment, $filename, $new_entity_id );
2566
+					$attach_id = wp_insert_attachment($attachment, $filename, $new_entity_id);
2567 2567
 					require_once(ABSPATH . 'wp-admin/includes/image.php');
2568
-					$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
2569
-					wp_update_attachment_metadata( $attach_id, $attach_data );
2568
+					$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
2569
+					wp_update_attachment_metadata($attach_id, $attach_data);
2570 2570
 					add_post_meta($new_entity_id, '_thumbnail_id', $attach_id, true);
2571 2571
 				}
2572 2572
 			}
2573 2573
 
2574
-			echo json_encode( array( true,  __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) );
2574
+			echo json_encode(array(true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id));
2575 2575
 		}
2576 2576
 		else {
2577
-			echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) );
2577
+			echo json_encode(array(false, __('An error occured while adding your element', 'wpshop')));
2578 2578
 		}
2579 2579
 
2580 2580
 		die();
@@ -2583,47 +2583,47 @@  discard block
 block discarded – undo
2583 2583
 // 	add_action('wp_ajax_nopriv_wpshop_quick_add_entity', 'ajax_wpshop_add_entity');
2584 2584
 
2585 2585
 	function ajax_wpshop_reload_attribute_for_quick_add() {
2586
-		check_ajax_referer( 'ajax_wpshop_reload_attribute_for_quick_add' );
2586
+		check_ajax_referer('ajax_wpshop_reload_attribute_for_quick_add');
2587 2587
 		$output = '';
2588
-		$attribute_to_reload = !empty( $_POST['attribute_to_reload'] ) ? (array) $_POST['attribute_to_reload'] : array();
2589
-		if ( !empty($attribute_to_reload) ) {
2590
-			foreach ( $attribute_to_reload as $attribute_code ) {
2591
-				$attr_field = wpshop_attributes::display_attribute( $attribute_code, 'frontend' );
2588
+		$attribute_to_reload = !empty($_POST['attribute_to_reload']) ? (array)$_POST['attribute_to_reload'] : array();
2589
+		if (!empty($attribute_to_reload)) {
2590
+			foreach ($attribute_to_reload as $attribute_code) {
2591
+				$attr_field = wpshop_attributes::display_attribute($attribute_code, 'frontend');
2592 2592
 				$output[$attribute_code]['result'] = $attr_field['field_definition']['output'] . $attr_field['field_definition']['options'];
2593 2593
 			}
2594 2594
 		}
2595
-		echo json_encode( array($output) );
2595
+		echo json_encode(array($output));
2596 2596
 		die();
2597 2597
 	}
2598 2598
 	add_action('wp_ajax_reload_attribute_for_quick_add', 'ajax_wpshop_reload_attribute_for_quick_add');
2599 2599
 
2600 2600
 	function ajax_wpshop_change_address() {
2601
-		check_ajax_referer( 'ajax_wpshop_change_address' );
2602
-		$address_id = ( !empty($_POST['address_id']) ? (int) $_POST['address_id'] : null);
2603
-		$address_type = ( !empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2604
-		$is_allowed_destination  = true;
2605
-		if ( !empty($address_id) && !empty($address_type) ) {
2601
+		check_ajax_referer('ajax_wpshop_change_address');
2602
+		$address_id = (!empty($_POST['address_id']) ? (int)$_POST['address_id'] : null);
2603
+		$address_type = (!empty($_POST['address_type']) ? sanitize_text_field($_POST['address_type']) : null);
2604
+		$is_allowed_destination = true;
2605
+		if (!empty($address_id) && !empty($address_type)) {
2606 2606
 			//Check if it's an allowed address for shipping
2607 2607
 			$checkout_payment_button = '';
2608
-			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type'])=='quotation') ? 'quotation' : 'cart';
2609
-			$is_allowed_destination = true;//wpshop_shipping_configuration::is_allowed_country ( $address_id );
2610
-			if ( $is_allowed_destination ) {
2608
+			$cart_type = (!empty($_SESSION['cart']['cart_type']) && sanitize_text_field($_SESSION['cart']['cart_type']) == 'quotation') ? 'quotation' : 'cart';
2609
+			$is_allowed_destination = true; //wpshop_shipping_configuration::is_allowed_country ( $address_id );
2610
+			if ($is_allowed_destination) {
2611 2611
 				$available_payement_method = wpshop_payment::display_payment_methods_choice_form(0, $cart_type);
2612 2612
 				//if(!empty($available_payement_method[1]['paypal']) || !empty($available_payement_method[1]['banktransfer']) || !empty($available_payement_method[1]['checks']) || WPSHOP_PAYMENT_METHOD_CIC || !empty($available_payement_method[1]['cic']) || ($cart_type == 'quotation')) {
2613
-				if ( !empty($available_payement_method[0]) ) {
2614
-					if ( $cart_type=='quotation' ) {
2615
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() );
2613
+				if (!empty($available_payement_method[0])) {
2614
+					if ($cart_type == 'quotation') {
2615
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array());
2616 2616
 					}
2617 2617
 					else {
2618
-						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() );
2618
+						$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array());
2619 2619
 					}
2620 2620
 				}
2621 2621
 			}
2622 2622
 			else {
2623 2623
 				$checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array());
2624 2624
 			}
2625
-			if( $address_type == 'billing_address') {
2626
-				$billing_option = get_option( 'wpshop_billing_address' );
2625
+			if ($address_type == 'billing_address') {
2626
+				$billing_option = get_option('wpshop_billing_address');
2627 2627
 				$address_option = $billing_option['choice'];
2628 2628
 			}
2629 2629
 			else {
@@ -2631,16 +2631,16 @@  discard block
 block discarded – undo
2631 2631
 				$address_option = $shipping_address_option['choice'];
2632 2632
 			}
2633 2633
 			$add = wps_address::get_addresss_form_fields_by_type($address_option);
2634
-			$address_infos = get_post_meta($address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
2635
-			$retour = wpshop_account::display_an_address ( $add, $address_infos, $address_id);
2634
+			$address_infos = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
2635
+			$retour = wpshop_account::display_an_address($add, $address_infos, $address_id);
2636 2636
 
2637 2637
 			$_SESSION[$address_type] = $address_id;
2638 2638
 
2639
-			$edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&amp;id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>';
2640
-			$result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) );
2639
+			$edit_link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?') === false ? '?' : '&') . 'action=editAddress&amp;id=' . $address_id . '" title="' . __('Edit', 'wpshop') . '">' . __('Edit', 'wpshop') . '</a>';
2640
+			$result = json_encode(array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button));
2641 2641
 		}
2642 2642
 		else {
2643
-			$result = json_encode( array(false, 'missing_informations') );
2643
+			$result = json_encode(array(false, 'missing_informations'));
2644 2644
 		}
2645 2645
 		echo $result;
2646 2646
 
@@ -2650,26 +2650,26 @@  discard block
 block discarded – undo
2650 2650
 	add_action('wp_ajax_nopriv_change_address', 'ajax_wpshop_change_address');
2651 2651
 
2652 2652
 	function ajax_wpshop_load_create_new_customer_interface() {
2653
-		check_ajax_referer( 'ajax_wpshop_load_create_new_customer_interface' );
2653
+		check_ajax_referer('ajax_wpshop_load_create_new_customer_interface');
2654 2654
 		$billing_address_option = get_option('wpshop_billing_address');
2655 2655
 		$shipping_address_option = get_option('wpshop_shipping_address_choice');
2656 2656
 
2657 2657
 		$tpl_component = array();
2658 2658
 		$tpl_component['LOADING_ICON'] = WPSHOP_LOADING_ICON;
2659
-		if ( !empty($billing_address) ) {
2660
-			echo wpshop_account::get_addresses_by_type( $billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2659
+		if (!empty($billing_address)) {
2660
+			echo wpshop_account::get_addresses_by_type($billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes'));
2661 2661
 		}
2662 2662
 		$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] = wpshop_account::display_form_fields($billing_address_option['choice'], '', 'first');
2663 2663
 
2664
-		if ( $shipping_address_option['activate'] ) {
2665
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> '.__('Use as shipping information','wpshop').'</label></p><br/>';
2664
+		if ($shipping_address_option['activate']) {
2665
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> ' . __('Use as shipping information', 'wpshop') . '</label></p><br/>';
2666 2666
 			$display = 'display:none;';
2667
-			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="'.$display.'">';
2667
+			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="' . $display . '">';
2668 2668
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= wpshop_account::display_form_fields($shipping_address_option['choice'], '', 'first');
2669 2669
 			$tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '</div><br/>';
2670 2670
 		}
2671 2671
 
2672
-		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save','wpshop') . '" /></p>';
2672
+		$tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save', 'wpshop') . '" /></p>';
2673 2673
 		$output = wpshop_display::display_template_element('wpshop_customer_addresses_form_admin', $tpl_component, array(), 'admin');
2674 2674
 		unset($tpl_component);
2675 2675
 		$result = json_encode(array(true, $output));
@@ -2679,18 +2679,18 @@  discard block
 block discarded – undo
2679 2679
 	add_action('wp_ajax_load_create_new_customer_interface', 'ajax_wpshop_load_create_new_customer_interface');
2680 2680
 
2681 2681
 	function ajax_wpshop_create_new_customer() {
2682
-		check_ajax_referer( 'ajax_wpshop_create_new_customer' );
2682
+		check_ajax_referer('ajax_wpshop_create_new_customer');
2683 2683
 		$result = '';
2684 2684
 		$billing_address = !empty($_REQUEST['billing_address']) ? sanitize_key($_REQUEST['billing_address']) : '';
2685 2685
 		$shipping_address = !empty($_REQUEST['shipping_address']) ? sanitize_key($_REQUEST['shipping_address']) : '';
2686 2686
 		$shiptobilling = !empty($_REQUEST['shiptobilling']) ? sanitize_key($_REQUEST['shiptobilling']) : null;
2687 2687
 		$username = !empty($_POST['attribute'][$billing_address]['varchar']['address_user_email']) ? sanitize_text_field($_POST['attribute'][$billing_address]['varchar']['address_user_email']) : null;
2688
-		if ( $username != null ) {
2688
+		if ($username != null) {
2689 2689
 			/** Crerate the new customer user account */
2690
-			$password = wp_generate_password( $length=12, $include_standard_special_chars=false );
2690
+			$password = wp_generate_password($length = 12, $include_standard_special_chars = false);
2691 2691
 			$email = $username;
2692
-			if ( !empty($username) && !username_exists($username) && !empty($email) && !email_exists($email) ) {
2693
-				$user_id = wp_create_user( $username, $password, $email );
2692
+			if (!empty($username) && !username_exists($username) && !empty($email) && !email_exists($email)) {
2693
+				$user_id = wp_create_user($username, $password, $email);
2694 2694
 				// @TODO : REQUEST
2695 2695
 				// $_REQUEST['user']['customer_id'] = $user_id;
2696 2696
 				/** Save addresses */
@@ -2701,21 +2701,21 @@  discard block
 block discarded – undo
2701 2701
 					wpshop_account::same_billing_and_shipping_address($billing_address, $shipping_address);
2702 2702
 				}
2703 2703
 
2704
-				if ( !empty($billing_address) ) {
2705
-					wps_address::save_address_infos( $billing_address );
2704
+				if (!empty($billing_address)) {
2705
+					wps_address::save_address_infos($billing_address);
2706 2706
 				}
2707
-				if( !empty($shipping_address ) ) {
2708
-					wps_address::save_address_infos( $shipping_address);
2707
+				if (!empty($shipping_address)) {
2708
+					wps_address::save_address_infos($shipping_address);
2709 2709
 				}
2710
-				$result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) );
2710
+				$result = json_encode(array(true, __('Customer created', 'wpshop'), $user_id));
2711 2711
 			}
2712 2712
 			else {
2713
-				$result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) );
2713
+				$result = json_encode(array(false, __('A customer account is already created with this email address', 'wpshop')));
2714 2714
 			}
2715 2715
 
2716 2716
 		}
2717 2717
 		else {
2718
-			$result = json_encode( array(false, __('An email address is required', 'wpshop')) );
2718
+			$result = json_encode(array(false, __('An email address is required', 'wpshop')));
2719 2719
 		}
2720 2720
 		echo $result;
2721 2721
 		die();
@@ -2725,26 +2725,26 @@  discard block
 block discarded – undo
2725 2725
 	/**
2726 2726
 	 * Send a message to customer
2727 2727
 	 */
2728
-	function ajax_wpshop_send_message_by_type () {
2729
-		check_ajax_referer( 'ajax_wpshop_send_message_by_type' );
2728
+	function ajax_wpshop_send_message_by_type() {
2729
+		check_ajax_referer('ajax_wpshop_send_message_by_type');
2730 2730
 		global $wpdb;
2731 2731
 		$result = array();
2732
-		$message_type_id = ( !empty( $_POST['message_type_id'])) ? (int) $_POST['message_type_id'] : null;
2733
-		$customer_id = ( !empty( $_POST['customer_user_id'])) ? (int) $_POST['customer_user_id'] : null;
2734
-		$model_name = ( !empty( $_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2735
-		$order_id = ( !empty( $_POST['order_id'])) ? (int) $_POST['order_id'] : null;
2736
-		if ( !empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2732
+		$message_type_id = (!empty($_POST['message_type_id'])) ? (int)$_POST['message_type_id'] : null;
2733
+		$customer_id = (!empty($_POST['customer_user_id'])) ? (int)$_POST['customer_user_id'] : null;
2734
+		$model_name = (!empty($_POST['message_model_name'])) ? sanitize_text_field($_POST['message_model_name']) : null;
2735
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2736
+		if (!empty($customer_id) && !empty($message_type_id) && !empty($model_name)) {
2737 2737
 			$order_post_meta = get_post_meta($order_id, '_order_postmeta', true);
2738
-			$receiver_infos = get_userdata( $customer_id );
2738
+			$receiver_infos = get_userdata($customer_id);
2739 2739
 			$email = $receiver_infos->user_email;
2740 2740
 			$first_name = get_user_meta($customer_id, 'first_name', true);
2741 2741
 			$last_name = get_user_meta($customer_id, 'last_name', true);
2742 2742
 			$wps_message = new wps_message_ctr();
2743
-			$wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) );
2744
-			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) );
2743
+			$wps_message->wpshop_prepared_email($email, $model_name, array('order_id' => $order_id, 'order_key' => ((!empty($order_post_meta) && !empty($order_post_meta['order_key'])) ? $order_post_meta['order_key'] : ''), 'order_date' => ((!empty($order_post_meta) && !empty($order_post_meta['order_date'])) ? $order_post_meta['order_date'] : ''), 'customer_first_name' => $first_name, 'customer_last_name' => $last_name));
2744
+			$result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id));
2745 2745
 		}
2746 2746
 		else {
2747
-			$result = array('status' => false, 'response' => __('An error occured', 'wpshop') );
2747
+			$result = array('status' => false, 'response' => __('An error occured', 'wpshop'));
2748 2748
 		}
2749 2749
 		echo json_encode($result);
2750 2750
 		die();
@@ -2753,23 +2753,23 @@  discard block
 block discarded – undo
2753 2753
 
2754 2754
 
2755 2755
 	function ajax_wpshop_upload_downloadable_file_action() {
2756
-		check_ajax_referer( 'ajax_wpshop_upload_downloadable_file_action' );
2756
+		check_ajax_referer('ajax_wpshop_upload_downloadable_file_action');
2757 2757
 		$result = '';
2758
-		$element_identifier = ( !empty( $_POST ) && !empty( $_POST[ 'element_identifier' ] ) && is_int( (int)$_POST[ 'element_identifier' ] ) ) ? (int)$_POST[ 'element_identifier' ] : 0;
2759
-		$wpshop_uploaded_file = ( !empty( $_FILES ) && !empty( $_FILES[ 'wpshop_file' ] ) && is_array( (array)$_FILES[ 'wpshop_file' ] ) ) ? (array)$_FILES[ 'wpshop_file' ] : array();
2758
+		$element_identifier = (!empty($_POST) && !empty($_POST['element_identifier']) && is_int((int)$_POST['element_identifier'])) ? (int)$_POST['element_identifier'] : 0;
2759
+		$wpshop_uploaded_file = (!empty($_FILES) && !empty($_FILES['wpshop_file']) && is_array((array)$_FILES['wpshop_file'])) ? (array)$_FILES['wpshop_file'] : array();
2760 2760
 
2761
-		if ( !empty( $wpshop_uploaded_file ) && !empty( $element_identifier ) ) {
2762
-			if(!is_dir(WPSHOP_UPLOAD_DIR)){
2761
+		if (!empty($wpshop_uploaded_file) && !empty($element_identifier)) {
2762
+			if (!is_dir(WPSHOP_UPLOAD_DIR)) {
2763 2763
 				mkdir(WPSHOP_UPLOAD_DIR, 0755, true);
2764 2764
 			}
2765 2765
 			$file = $wpshop_uploaded_file;
2766 2766
 			$tmp_name = $file['tmp_name'];
2767
-			$name = sanitize_file_name( current_time( 'mysql', 0 ).'__'.$file["name"] );
2768
-			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR.$name);
2767
+			$name = sanitize_file_name(current_time('mysql', 0) . '__' . $file["name"]);
2768
+			move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR . $name);
2769 2769
 
2770
-			$n = WPSHOP_UPLOAD_URL.'/'.$name;
2771
-			update_post_meta( $element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2772
-			$result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>';
2770
+			$n = WPSHOP_UPLOAD_URL . '/' . $name;
2771
+			update_post_meta($element_identifier, 'attribute_option_is_downloadable_', array('file_url' => $n));
2772
+			$result = '<a href="' . $n . '" target="_blank" download>' . $name . '</a>';
2773 2773
 		}
2774 2774
 		else {
2775 2775
 			$result = '';
@@ -2780,91 +2780,91 @@  discard block
 block discarded – undo
2780 2780
 	add_action('wp_ajax_upload_downloadable_file_action', 'ajax_wpshop_upload_downloadable_file_action');
2781 2781
 
2782 2782
 	function ajax_wpshop_fill_the_downloadable_dialog() {
2783
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2784
-		check_ajax_referer( "ajax_wpshop_fill_the_downloadable_dialog".$product_id );
2783
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2784
+		check_ajax_referer("ajax_wpshop_fill_the_downloadable_dialog" . $product_id);
2785 2785
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2786 2786
 	}
2787 2787
 	function ajax_wpshop_fill_the_downloadable_dialog_unnonced() {
2788
-		$product_id = ( !empty( $_POST ) && !empty( $_POST[ 'product_identifier' ] ) ) ? (int)$_POST[ 'product_identifier' ] : 0;
2788
+		$product_id = (!empty($_POST) && !empty($_POST['product_identifier'])) ? (int)$_POST['product_identifier'] : 0;
2789 2789
 		ajax_wpshop_fill_the_downloadable_dialog_exec($product_id);
2790 2790
 	}
2791
-	function ajax_wpshop_fill_the_downloadable_dialog_exec( $product_id ) {
2792
-		$output  = '<form method="post" action="' .admin_url('admin-ajax.php') .'" id="upload_downloadable_file" enctype="multipart/form-data" >';
2793
-		$output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>';
2791
+	function ajax_wpshop_fill_the_downloadable_dialog_exec($product_id) {
2792
+		$output  = '<form method="post" action="' . admin_url('admin-ajax.php') . '" id="upload_downloadable_file" enctype="multipart/form-data" >';
2793
+		$output .= '<p class="formField"><label for="wpshop_file">' . __('Choose your file to send', 'wpshop') . '</label><input type="file" name="wpshop_file" /></p>';
2794 2794
 		$output .= '<input type="hidden" name="action" value="upload_downloadable_file_action" />';
2795
-		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' .esc_attr( $product_id). '" />';
2796
-		$output .= wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false );
2797
-		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' .__('Send your file', 'wpshop'). '</a></p>';
2795
+		$output .= '<input type="hidden" name="element_identifier" id="element_identifier" value="' . esc_attr($product_id) . '" />';
2796
+		$output .= wp_nonce_field('ajax_wpshop_upload_downloadable_file_action', '_wpnonce', true, false);
2797
+		$output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' . __('Send your file', 'wpshop') . '</a></p>';
2798 2798
 		$output .= '</form>';
2799
-		$output .='<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2799
+		$output .= '<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({
2800 2800
 		beforeSubmit : function() { },success: function(response) {
2801
-		jQuery(".is_downloadable_statut_'.$product_id.'").html( response );
2801
+		jQuery(".is_downloadable_statut_'.$product_id . '").html( response );
2802 2802
 		jQuery(".send_downloadable_file_dialog").dialog("close");
2803 2803
 		}});</script>';
2804
-		$output = apply_filters( 'wpshop_download_file_dialog', $output, $product_id );
2804
+		$output = apply_filters('wpshop_download_file_dialog', $output, $product_id);
2805 2805
 
2806
-		$response = array( 'status' => true, 'response' => $output);
2807
-		echo json_encode( $response );
2806
+		$response = array('status' => true, 'response' => $output);
2807
+		echo json_encode($response);
2808 2808
 		die();
2809 2809
 	}
2810 2810
 	add_action('wp_ajax_fill_the_downloadable_dialog', 'ajax_wpshop_fill_the_downloadable_dialog');
2811 2811
 	add_action('wp_ajax_fill_the_downloadable_dialog_unnonced', 'ajax_wpshop_fill_the_downloadable_dialog_unnonced');
2812 2812
 
2813 2813
 	function ajax_wpshop_show_downloadable_interface_in_admin() {
2814
-		$post_id = !empty( $_POST ) && !empty( $_POST[ 'post_id' ] ) && is_int( (int)$_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : 0;
2815
-		check_ajax_referer( 'ajax_wpshop_show_downloadable_interface_in_admin'.$post_id );
2814
+		$post_id = !empty($_POST) && !empty($_POST['post_id']) && is_int((int)$_POST['post_id']) ? (int)$_POST['post_id'] : 0;
2815
+		check_ajax_referer('ajax_wpshop_show_downloadable_interface_in_admin' . $post_id);
2816 2816
 		global $wpdb;
2817 2817
 		$status = false;
2818
-		$selected_value = ( !empty($_POST['selected_value']) ) ? sanitize_text_field( $_POST['selected_value'] ) : '';
2819
-		$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $selected_value);
2820
-		$value = $wpdb->get_var( $query );
2818
+		$selected_value = (!empty($_POST['selected_value'])) ? sanitize_text_field($_POST['selected_value']) : '';
2819
+		$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $selected_value);
2820
+		$value = $wpdb->get_var($query);
2821 2821
 
2822
-		if ( !empty($value) && __( $value, 'wpshop') == __('Yes', 'wpshop') ) {
2822
+		if (!empty($value) && __($value, 'wpshop') == __('Yes', 'wpshop')) {
2823 2823
 			$status = true;
2824 2824
 		}
2825
-		$response = array( 'status' => $status );
2826
-		echo json_encode( $response );
2825
+		$response = array('status' => $status);
2826
+		echo json_encode($response);
2827 2827
 		die();
2828 2828
 	}
2829
-	add_action( 'wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2829
+	add_action('wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin');
2830 2830
 
2831 2831
 	function ajax_wpshop_restart_the_order() {
2832
-		check_ajax_referer( 'ajax_wpshop_restart_the_order' );
2832
+		check_ajax_referer('ajax_wpshop_restart_the_order');
2833 2833
 
2834 2834
 		global $wpshop_cart, $wpdb;
2835 2835
 		$status = $add_to_cart_checking = $manage_stock_checking_bool = false;
2836 2836
 		$add_to_cart_checking_message = '';
2837 2837
 		$result = __('Error, you cannot restart this order', 'wpshop');
2838
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2839
-		$is_make_order_again = ( !empty($_POST['make_order_again']) ) ? sanitize_text_field( $_POST['make_order_again'] ) : null;
2840
-		if( !empty( $order_id ) ) {
2838
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2839
+		$is_make_order_again = (!empty($_POST['make_order_again'])) ? sanitize_text_field($_POST['make_order_again']) : null;
2840
+		if (!empty($order_id)) {
2841 2841
 			$order_meta = get_post_meta($order_id, '_order_postmeta', true);
2842 2842
 			$_SESSION['cart'] = array();
2843 2843
 			$_SESSION['cart']['order_items'] = array();
2844 2844
 			$wpshop_cart_type = $order_meta['cart_type'];
2845 2845
 
2846
-			if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
2846
+			if (!empty($order_meta) && !empty($order_meta['order_items'])) {
2847 2847
 				$wpshop_cart_type = $order_meta['cart_type'];
2848
-				foreach( $order_meta['order_items'] as $item_key => $item ) {
2849
-					$item_meta = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true );
2848
+				foreach ($order_meta['order_items'] as $item_key => $item) {
2849
+					$item_meta = get_post_meta($item['item_id'], '_wpshop_product_metadata', true);
2850 2850
 					$stock = $item_meta['product_stock'];
2851 2851
 					$qty = $item['item_qty'];
2852
-					$item_option = get_post_meta( $item['item_id'], '_wpshop_product_options', true );
2853
-					if( !empty($item_meta['manage_stock']) ) {
2854
-						$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $item_meta['manage_stock']);
2855
-						$manage_stock_checking = $wpdb->get_var( $query );
2856
-						if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2852
+					$item_option = get_post_meta($item['item_id'], '_wpshop_product_options', true);
2853
+					if (!empty($item_meta['manage_stock'])) {
2854
+						$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $item_meta['manage_stock']);
2855
+						$manage_stock_checking = $wpdb->get_var($query);
2856
+						if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2857 2857
 							$manage_stock_checking_bool = true;
2858 2858
 						}
2859 2859
 					} else {
2860
-						if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2861
-							$parent_product = wpshop_products::get_parent_variation( $item['item_id'] );
2862
-							if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) {
2860
+						if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2861
+							$parent_product = wpshop_products::get_parent_variation($item['item_id']);
2862
+							if (!empty($parent_product) && !empty($parent_product['parent_post_meta'])) {
2863 2863
 								$parent_metadata = $parent_product['parent_post_meta'];
2864
-								if( !empty($parent_product['parent_post_meta']['manage_stock']) ) {
2865
-									$query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2866
-									$manage_stock_checking = $wpdb->get_var( $query );
2867
-									if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') )  ) {
2864
+								if (!empty($parent_product['parent_post_meta']['manage_stock'])) {
2865
+									$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']);
2866
+									$manage_stock_checking = $wpdb->get_var($query);
2867
+									if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
2868 2868
 										$manage_stock_checking_bool = true;
2869 2869
 										$stock = $parent_product['parent_post_meta']['product_stock'];
2870 2870
 									}
@@ -2874,8 +2874,8 @@  discard block
 block discarded – undo
2874 2874
 					}
2875 2875
 
2876 2876
 					/** Checking stock **/
2877
-					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 ) ) {
2878
-						$_SESSION['cart']['order_items'][ $item_key ] = $item;
2877
+					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)) {
2878
+						$_SESSION['cart']['order_items'][$item_key] = $item;
2879 2879
 					} else {
2880 2880
 						$add_to_cart_checking = true;
2881 2881
 						$add_to_cart_checking_message = __('Some products cannot be added to cart because they are out of stock', 'wpshop');
@@ -2883,40 +2883,40 @@  discard block
 block discarded – undo
2883 2883
 				}
2884 2884
 
2885 2885
 				$wps_cart_ctr = new wps_cart();
2886
-				$order = $wps_cart_ctr->calcul_cart_information( array() );
2886
+				$order = $wps_cart_ctr->calcul_cart_information(array());
2887 2887
 				$order['cart_type'] = $wpshop_cart_type;
2888
-				$wps_cart_ctr->store_cart_in_session( $order );
2888
+				$wps_cart_ctr->store_cart_in_session($order);
2889 2889
 			}
2890 2890
 
2891
-			if ( empty($is_make_order_again) ) {
2891
+			if (empty($is_make_order_again)) {
2892 2892
 				$_SESSION['order_id'] = $order_id;
2893 2893
 			}
2894 2894
 			$status = true;
2895 2895
 
2896
-			$result = get_permalink( get_option('wpshop_cart_page_id') );
2896
+			$result = get_permalink(get_option('wpshop_cart_page_id'));
2897 2897
 		}
2898 2898
 
2899
-		$response = array( 'status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2900
-		echo json_encode( $response );
2899
+		$response = array('status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message);
2900
+		echo json_encode($response);
2901 2901
 		die();
2902 2902
 	}
2903
-	add_action( 'wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2903
+	add_action('wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order');
2904 2904
 
2905 2905
 
2906 2906
 
2907 2907
 	function wps_hide_notice_messages() {
2908
-		check_ajax_referer( 'wps_hide_notice_messages' );
2908
+		check_ajax_referer('wps_hide_notice_messages');
2909 2909
 
2910 2910
 		$status = false;
2911
-		$indicator = !empty($_POST['indicator'] ) ? sanitize_text_field($_POST['indicator']) : null;
2912
-		if ( !empty($indicator) ) {
2911
+		$indicator = !empty($_POST['indicator']) ? sanitize_text_field($_POST['indicator']) : null;
2912
+		if (!empty($indicator)) {
2913 2913
 			$user_id = get_current_user_id();
2914
-			$hide_notice_meta = get_user_meta( $user_id, '_wps_hide_notice_messages_indicator', true);
2914
+			$hide_notice_meta = get_user_meta($user_id, '_wps_hide_notice_messages_indicator', true);
2915 2915
 			$hide_notice_meta = !empty($hide_notice_meta) ? $hide_notice_meta : array();
2916 2916
 			$indicators = explode(',', $indicator);
2917
-			if ( !empty($indicators) && is_array($indicators) ) {
2918
-				foreach( $indicators as $i ) {
2919
-					if ( !empty($i) ) {
2917
+			if (!empty($indicators) && is_array($indicators)) {
2918
+				foreach ($indicators as $i) {
2919
+					if (!empty($i)) {
2920 2920
 						$hide_notice_meta[$i] = true;
2921 2921
 					}
2922 2922
 				}
@@ -2925,7 +2925,7 @@  discard block
 block discarded – undo
2925 2925
 			$status = true;
2926 2926
 		}
2927 2927
 		$response = array('status' => $status);
2928
-		echo json_encode( $response );
2928
+		echo json_encode($response);
2929 2929
 		die();
2930 2930
 	}
2931 2931
 	add_action('wp_ajax_wps_hide_notice_messages', 'wps_hide_notice_messages');
@@ -2933,106 +2933,106 @@  discard block
 block discarded – undo
2933 2933
 
2934 2934
 
2935 2935
 	function wps_update_products_prices() {
2936
-		check_ajax_referer( 'wps_update_products_prices' );
2936
+		check_ajax_referer('wps_update_products_prices');
2937 2937
 		$action = wpshop_prices::mass_update_prices();
2938
-		$response = array( 'status' => $action[0], 'response' => $action[1] );
2939
-		echo json_encode( $response );
2938
+		$response = array('status' => $action[0], 'response' => $action[1]);
2939
+		echo json_encode($response);
2940 2940
 		die();
2941 2941
 	}
2942
-	add_action( 'wp_ajax_update_products_prices', 'wps_update_products_prices' );
2942
+	add_action('wp_ajax_update_products_prices', 'wps_update_products_prices');
2943 2943
 
2944 2944
 	/** Quotation is payable by customer **/
2945 2945
 	function wps_quotation_is_payable_by_customer() {
2946
-		check_ajax_referer( 'wps_quotation_is_payable_by_customer' );
2946
+		check_ajax_referer('wps_quotation_is_payable_by_customer');
2947 2947
 		global $wpdb;
2948 2948
 		$status = false;
2949 2949
 		$response = '';
2950
-		$order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null;
2951
-		if( isset($order_id) ) {
2952
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2953
-			if( isset( $order_metadata['pay_quotation'] ) ) {
2954
-				unset( $order_metadata['pay_quotation'] );
2950
+		$order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null;
2951
+		if (isset($order_id)) {
2952
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2953
+			if (isset($order_metadata['pay_quotation'])) {
2954
+				unset($order_metadata['pay_quotation']);
2955 2955
 			} else {
2956 2956
 				$order_metadata['pay_quotation'] = 'on';
2957 2957
 			}
2958
-			update_post_meta( $order_id, '_order_postmeta', $order_metadata );
2958
+			update_post_meta($order_id, '_order_postmeta', $order_metadata);
2959 2959
 
2960
-			$response = wpshop_orders::display_customer_pay_quotation( isset( $order_metadata['pay_quotation'] ), $order_id );
2960
+			$response = wpshop_orders::display_customer_pay_quotation(isset($order_metadata['pay_quotation']), $order_id);
2961 2961
 			$status = true;
2962 2962
 		} else {
2963
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
2963
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
2964 2964
 		}
2965
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
2965
+		echo json_encode(array('status' => $status, 'response' => $response));
2966 2966
 		die();
2967 2967
 	}
2968
-	add_action( 'wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer' );
2968
+	add_action('wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer');
2969 2969
 
2970 2970
 	/** Send a direct payment Link **/
2971 2971
 	function wps_send_direct_payment_link() {
2972
-		check_ajax_referer( 'wps_send_direct_payment_link' );
2972
+		check_ajax_referer('wps_send_direct_payment_link');
2973 2973
 		global $wpdb;
2974 2974
 		$status = false; $response = '';
2975
-		$order_id = ( !empty($_POST['order_id']) ) ? (int) $_POST['order_id'] : null;
2976
-		if( !empty($order_id) ) {
2975
+		$order_id = (!empty($_POST['order_id'])) ? (int)$_POST['order_id'] : null;
2976
+		if (!empty($order_id)) {
2977 2977
 			/** Get the customer **/
2978
-			$order_metadata = get_post_meta( $order_id, '_order_postmeta', true );
2979
-			if( !empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) {
2980
-				$user_infos = get_userdata( $order_metadata['customer_id'] );
2978
+			$order_metadata = get_post_meta($order_id, '_order_postmeta', true);
2979
+			if (!empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') {
2980
+				$user_infos = get_userdata($order_metadata['customer_id']);
2981 2981
 
2982
-				$first_name =  get_user_meta($user_infos->ID, 'first_name', true);
2983
-				$last_name =  get_user_meta($user_infos->ID, 'last_name', true);
2982
+				$first_name = get_user_meta($user_infos->ID, 'first_name', true);
2983
+				$last_name = get_user_meta($user_infos->ID, 'last_name', true);
2984 2984
 
2985 2985
 
2986 2986
 				/** Create an activation key **/
2987
-				$token = wps_orders_ctr::wps_token_order_customer( $order_id );
2987
+				$token = wps_orders_ctr::wps_token_order_customer($order_id);
2988 2988
 				/*$token = wp_generate_password(20, false);
2989 2989
 				$wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login) );*/
2990 2990
 
2991
-				$permalink_option = get_option( 'permalink_structure' );
2992
-				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url( $order_id ) . '">' .__( 'Click here to pay your order', 'wpshop' ). '</a>';
2991
+				$permalink_option = get_option('permalink_structure');
2992
+				$link = '<a href="' . wpshop_checkout::wps_direct_payment_link_url($order_id) . '">' . __('Click here to pay your order', 'wpshop') . '</a>';
2993 2993
 
2994 2994
 				/** Send message **/
2995 2995
 				$wps_message = new wps_message_ctr();
2996 2996
 				$wps_message->wpshop_prepared_email($user_infos->user_email,
2997 2997
 				'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE',
2998
-				array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '' )
2998
+				array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '')
2999 2999
 				);
3000 3000
 
3001
-				$response = __( 'Direct payment link has been send', 'wpshop' );
3001
+				$response = __('Direct payment link has been send', 'wpshop');
3002 3002
 				$status = true;
3003 3003
 			}
3004 3004
 			else {
3005
-				$response = __( 'An error was occured', 'wpshop' );
3005
+				$response = __('An error was occured', 'wpshop');
3006 3006
 			}
3007 3007
 		}
3008 3008
 		else {
3009
-			$response = __( 'An error was occured, no Order ID defined', 'wpshop' );
3009
+			$response = __('An error was occured, no Order ID defined', 'wpshop');
3010 3010
 		}
3011
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3011
+		echo json_encode(array('status' => $status, 'response' => $response));
3012 3012
 		die();
3013 3013
 	}
3014
-	add_action( 'wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link' );
3014
+	add_action('wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link');
3015 3015
 
3016 3016
 	function wps_mass_action_product() {
3017
-		check_ajax_referer( 'wps_mass_action_product' );
3017
+		check_ajax_referer('wps_mass_action_product');
3018 3018
 		$mass_actions_tools_page = '';
3019
-		$default_attributes = array( 'product_stock', 'barcode', 'product_price', 'special_price', );
3019
+		$default_attributes = array('product_stock', 'barcode', 'product_price', 'special_price',);
3020 3020
 
3021 3021
 		/**	Copy an attribute content to another	*/
3022
-		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_PRODUCT ), "'valid'", 'entity_id', true);
3023
-		if ( !empty( $attribute_list ) ) {
3022
+		$attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_PRODUCT), "'valid'", 'entity_id', true);
3023
+		if (!empty($attribute_list)) {
3024 3024
 			$mass_actions_tools_page .= '
3025
-			<form action="' . admin_url( "admin-ajax.php" ) . '" method="POST" id="wps_mass_action_on_entity_form" >
3025
+			<form action="' . admin_url("admin-ajax.php") . '" method="POST" id="wps_mass_action_on_entity_form" >
3026 3026
 				<input type="hidden" value="wps_mass_action_on_entity_launch" name="action" />
3027
-				<!--<div>' . __( 'Choose attribute to display into list', 'wpshop' ) . '
3027
+				<!--<div>' . __('Choose attribute to display into list', 'wpshop') . '
3028 3028
 					<ul>';
3029
-			foreach ( $attribute_list as $attribute ) {
3029
+			foreach ($attribute_list as $attribute) {
3030 3030
 				$mass_actions_tools_page .= '
3031
-						<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>';
3031
+						<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>';
3032 3032
 			}
3033 3033
 			$mass_actions_tools_page .= '
3034 3034
 					</ul>
3035
-					<button>' . __( 'Voir la liste des produits', 'wpshop' ) . '</button> -->
3035
+					<button>' . __('Voir la liste des produits', 'wpshop') . '</button> -->
3036 3036
 				</div>
3037 3037
 			</form>
3038 3038
 			<div id="wps_entity_list" >' . wps_mass_action_on_entity_launch() . '</div>
@@ -3045,32 +3045,32 @@  discard block
 block discarded – undo
3045 3045
 			</script>';
3046 3046
 		}
3047 3047
 
3048
-		wp_die( $mass_actions_tools_page );
3048
+		wp_die($mass_actions_tools_page);
3049 3049
 	}
3050
-	add_action( 'wp_ajax_wps_mass_action_product', 'wps_mass_action_product' );
3050
+	add_action('wp_ajax_wps_mass_action_product', 'wps_mass_action_product');
3051 3051
 
3052 3052
 	function wps_put_history_back() {
3053
-		check_ajax_referer( 'wps_put_history_back' );
3053
+		check_ajax_referer('wps_put_history_back');
3054 3054
 
3055 3055
 		global $wpdb;
3056 3056
 		$upload_dir = wp_upload_dir();
3057
-		$log_dir = $upload_dir[ 'basedir' ] . '/wps_repair/';
3058
-		wp_mkdir_p( $log_dir );
3059
-		$value_to_take = !empty($_POST[ 'value_to_take' ]) ? (array) $_POST[ 'value_to_take' ] : array();
3060
-		foreach ( $value_to_take as $product_id => $product_element ) {
3061
-			foreach( $product_element as $attribute_id => $attribute_value_to_take ){
3062
-				$query = $wpdb->prepare( "SELECT value, value_type FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO . " WHERE value_id = %d", $attribute_value_to_take );
3063
-				$the_new_value = $wpdb->get_row( $query );
3064
-				if ( 6 == $attribute_id ) {
3065
-					$query = $wpdb->prepare( "SELECT OPT.value, HISTO.value AS rate_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS OPT INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_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 );
3066
-					$the_tax = $wpdb->get_row( $query );
3067
-					$pttc = number_format( $the_new_value->value, 5, ".", " " );
3068
-					$ht = number_format( $pttc / ( 1 + ( $the_tax->value / 100 ) ), 5, ".", " " );
3069
-					$tax_amount = number_format( $pttc - $ht, 5, ".", " " );
3070
-					$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array( "entity_id" => $product_id, "attribute_id" => 6 ) );
3071
-					$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array( "entity_id" => $product_id, "attribute_id" => 28 ) );
3072
-					$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER, array( "entity_id" => $product_id, "attribute_id" => 29 ) );
3073
-					$wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array( "entity_id" => $product_id, "attribute_id" => 30 ) );
3057
+		$log_dir = $upload_dir['basedir'] . '/wps_repair/';
3058
+		wp_mkdir_p($log_dir);
3059
+		$value_to_take = !empty($_POST['value_to_take']) ? (array)$_POST['value_to_take'] : array();
3060
+		foreach ($value_to_take as $product_id => $product_element) {
3061
+			foreach ($product_element as $attribute_id => $attribute_value_to_take) {
3062
+				$query = $wpdb->prepare("SELECT value, value_type FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO . " WHERE value_id = %d", $attribute_value_to_take);
3063
+				$the_new_value = $wpdb->get_row($query);
3064
+				if (6 == $attribute_id) {
3065
+					$query = $wpdb->prepare("SELECT OPT.value, HISTO.value AS rate_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS OPT INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_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);
3066
+					$the_tax = $wpdb->get_row($query);
3067
+					$pttc = number_format($the_new_value->value, 5, ".", " ");
3068
+					$ht = number_format($pttc / (1 + ($the_tax->value / 100)), 5, ".", " ");
3069
+					$tax_amount = number_format($pttc - $ht, 5, ".", " ");
3070
+					$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array("entity_id" => $product_id, "attribute_id" => 6));
3071
+					$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array("entity_id" => $product_id, "attribute_id" => 28));
3072
+					$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER, array("entity_id" => $product_id, "attribute_id" => 29));
3073
+					$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array("entity_id" => $product_id, "attribute_id" => 30));
3074 3074
 
3075 3075
 					$common_datas = array(
3076 3076
 						'value_id' => null,
@@ -3078,20 +3078,20 @@  discard block
 block discarded – undo
3078 3078
 						'entity_id' => $product_id,
3079 3079
 						'unit_id' => null,
3080 3080
 						'user_id' => 1,
3081
-						'creation_date_value' => current_time( "mysql", 0 ),
3081
+						'creation_date_value' => current_time("mysql", 0),
3082 3082
 						'language' => 'fr_FR',
3083 3083
 					);
3084 3084
 
3085
-					$content_to_write =  "
3086
-" . 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,  ) );
3087
-					$fp = fopen( $log_dir . 'correction_prix.txt', 'a' );
3088
-					fwrite( $fp, $content_to_write );
3089
-					fclose( $fp );
3085
+					$content_to_write = "
3086
+" . 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,));
3087
+					$fp = fopen($log_dir . 'correction_prix.txt', 'a');
3088
+					fwrite($fp, $content_to_write);
3089
+					fclose($fp);
3090 3090
 
3091
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge( $common_datas, array( 'attribute_id' => 6, 'value' => $pttc ) ) );
3092
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) );
3093
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER, array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) );
3094
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) );
3091
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge($common_datas, array('attribute_id' => 6, 'value' => $pttc)));
3092
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge($common_datas, array('attribute_id' => 28, 'value' => $ht)));
3093
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER, array_merge($common_datas, array('attribute_id' => 29, 'value' => $the_tax->rate_id)));
3094
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array_merge($common_datas, array('attribute_id' => 30, 'value' => $tax_amount)));
3095 3095
 				}
3096 3096
 				else {
3097 3097
 					$common_datas = array(
@@ -3100,33 +3100,33 @@  discard block
 block discarded – undo
3100 3100
 						'entity_id' => $product_id,
3101 3101
 						'unit_id' => null,
3102 3102
 						'user_id' => 1,
3103
-						'creation_date_value' => current_time( "mysql", 0 ),
3103
+						'creation_date_value' => current_time("mysql", 0),
3104 3104
 						'language' => 'fr_FR',
3105 3105
 					);
3106
-					$wpdb->delete( $the_new_value->value_type, array( "entity_id" => $product_id, "attribute_id" => $attribute_id ) );
3107
-					$wpdb->insert( $the_new_value->value_type, array_merge( $common_datas, array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ) ) ) );
3108
-
3109
-					$content_to_write =  "
3110
-" . 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 ),  ) ). '';
3111
-					$fp = fopen( $log_dir . 'correction_attribut.txt', 'a' );
3112
-					fwrite( $fp, $content_to_write );
3113
-					fclose( $fp );
3106
+					$wpdb->delete($the_new_value->value_type, array("entity_id" => $product_id, "attribute_id" => $attribute_id));
3107
+					$wpdb->insert($the_new_value->value_type, array_merge($common_datas, array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value))));
3108
+
3109
+					$content_to_write = "
3110
+" . 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),)) . '';
3111
+					$fp = fopen($log_dir . 'correction_attribut.txt', 'a');
3112
+					fwrite($fp, $content_to_write);
3113
+					fclose($fp);
3114 3114
 				}
3115 3115
 			}
3116 3116
 		}
3117 3117
 		wp_die();
3118 3118
 	}
3119
-	add_action( 'wp_ajax_wps_put_history_back', 'wps_put_history_back' );
3119
+	add_action('wp_ajax_wps_put_history_back', 'wps_put_history_back');
3120 3120
 
3121 3121
 	function wps_mass_action_on_entity_launch() {
3122 3122
 		global $wpdb;
3123 3123
 		$response = '';
3124 3124
 		$element_to_output = array();
3125 3125
 
3126
-		$attributes_to_test = array( 'decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118' );
3126
+		$attributes_to_test = array('decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118');
3127 3127
 
3128 3128
 		$decimal_attribute = $attributes_to_test['decimal']; //,30,28
3129
-		$query = $wpdb->prepare( "
3129
+		$query = $wpdb->prepare("
3130 3130
 				SELECT P.ID, P.post_title,
3131 3131
 					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
3132 3132
 				FROM {$wpdb->posts} AS P
@@ -3140,21 +3140,21 @@  discard block
 block discarded – undo
3140 3140
 					AND H.value_type = %s
3141 3141
 
3142 3142
 				ORDER BY H.entity_id ASC, H.value_id DESC",
3143
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL )
3143
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL)
3144 3144
 		);
3145
-		 $list_of_element = $wpdb->get_results( $query );
3146
-		 if ( !empty( $list_of_element ) ) {
3147
-			foreach ( $list_of_element as $element ) {
3148
-				$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3149
-				$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3150
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3151
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3152
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3145
+		 $list_of_element = $wpdb->get_results($query);
3146
+		 if (!empty($list_of_element)) {
3147
+			foreach ($list_of_element as $element) {
3148
+				$element_to_output[$element->ID]['title'] = $element->post_title;
3149
+				$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3150
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3151
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3152
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3153 3153
 			}
3154 3154
 		}
3155 3155
 
3156 3156
 		$attribute_list = $attributes_to_test['varchar'];
3157
-		$query = $wpdb->prepare( "
3157
+		$query = $wpdb->prepare("
3158 3158
 			SELECT P.ID, P.post_title,
3159 3159
 				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
3160 3160
 			FROM {$wpdb->posts} AS P
@@ -3167,22 +3167,22 @@  discard block
 block discarded – undo
3167 3167
 				AND H.value != ''
3168 3168
 				AND H.value_type = %s
3169 3169
 			ORDER BY H.creation_date",
3170
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR )
3170
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR)
3171 3171
 		);
3172
-		$list_of_element = $wpdb->get_results( $query );
3173
-		if ( !empty( $list_of_element ) ) {
3174
-			foreach ( $list_of_element as $element ) {
3175
-			 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3176
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3177
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3178
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3179
-			 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3172
+		$list_of_element = $wpdb->get_results($query);
3173
+		if (!empty($list_of_element)) {
3174
+			foreach ($list_of_element as $element) {
3175
+			 	$element_to_output[$element->ID]['title'] = $element->post_title;
3176
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3177
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3178
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3179
+			 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3180 3180
 			}
3181 3181
 		}
3182 3182
 
3183 3183
 
3184 3184
 		$attribute_list = $attributes_to_test['text'];
3185
-		$query = $wpdb->prepare( "
3185
+		$query = $wpdb->prepare("
3186 3186
 				SELECT P.ID, P.post_title,
3187 3187
 				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
3188 3188
 				FROM {$wpdb->posts} AS P
@@ -3195,21 +3195,21 @@  discard block
 block discarded – undo
3195 3195
 				AND H.value != ''
3196 3196
 				AND H.value_type = %s
3197 3197
 			ORDER BY H.creation_date",
3198
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT )
3198
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT)
3199 3199
 		);
3200
-		$list_of_element = $wpdb->get_results( $query );
3201
-		if ( !empty( $list_of_element ) ) {
3202
-		foreach ( $list_of_element as $element ) {
3203
-		 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3204
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3205
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3206
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3207
-		 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3200
+		$list_of_element = $wpdb->get_results($query);
3201
+		if (!empty($list_of_element)) {
3202
+		foreach ($list_of_element as $element) {
3203
+		 	$element_to_output[$element->ID]['title'] = $element->post_title;
3204
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3205
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3206
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3207
+		 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3208 3208
 		 	}
3209 3209
 		}
3210 3210
 
3211 3211
 		$attribute_list = $attributes_to_test['integer'];
3212
-		$query = $wpdb->prepare( "
3212
+		$query = $wpdb->prepare("
3213 3213
 				SELECT P.ID, P.post_title,
3214 3214
 				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
3215 3215
 				FROM {$wpdb->posts} AS P
@@ -3222,21 +3222,21 @@  discard block
 block discarded – undo
3222 3222
 				AND H.value != ''
3223 3223
 				AND H.value_type = %s
3224 3224
 			ORDER BY H.creation_date",
3225
-			array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER )
3225
+			array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER)
3226 3226
 		);
3227
-							$list_of_element = $wpdb->get_results( $query );
3228
-							if ( !empty( $list_of_element ) ) {
3229
-							foreach ( $list_of_element as $element ) {
3230
-					 	$element_to_output[ $element->ID ][ 'title' ] = $element->post_title;
3231
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value;
3232
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id;
3233
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date;
3234
-					 	$element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value;
3227
+							$list_of_element = $wpdb->get_results($query);
3228
+							if (!empty($list_of_element)) {
3229
+							foreach ($list_of_element as $element) {
3230
+					 	$element_to_output[$element->ID]['title'] = $element->post_title;
3231
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value;
3232
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id;
3233
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date;
3234
+					 	$element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value;
3235 3235
 					 	}
3236 3236
 							}
3237 3237
 
3238 3238
 		$array_done = array();
3239
-		if ( !empty( $element_to_output ) ) {
3239
+		if (!empty($element_to_output)) {
3240 3240
 			$lines = '';
3241 3241
 			$done_header = array();
3242 3242
 
@@ -3244,23 +3244,23 @@  discard block
 block discarded – undo
3244 3244
 			/** Formate informations **/
3245 3245
 			$formatted_datas = array();
3246 3246
 			$controller_rows_array = array();
3247
-			foreach( $attributes_to_test as $attribute_to_test ) {
3248
-				$atts = explode( ',', $attribute_to_test );
3249
-				foreach( $atts as $att ) {
3250
-					$controller_rows_array[ $att ] = false;
3247
+			foreach ($attributes_to_test as $attribute_to_test) {
3248
+				$atts = explode(',', $attribute_to_test);
3249
+				foreach ($atts as $att) {
3250
+					$controller_rows_array[$att] = false;
3251 3251
 				}
3252 3252
 			}
3253 3253
 
3254
-			foreach(  $element_to_output as $element_id => $element_definition ) {
3254
+			foreach ($element_to_output as $element_id => $element_definition) {
3255 3255
 				$formatted_datas[$element_id]['title'] = $element_definition['title'];
3256 3256
 				$formatted_datas[$element_id]['content'] = array();
3257 3257
 
3258
-				foreach( $attributes_to_test as $attribute_to_test ) {
3259
-					$atts = explode( ',', $attribute_to_test );
3260
-					foreach( $atts as $att ) {
3261
-						if( !empty($element_definition['content'][$att]) ) {
3258
+				foreach ($attributes_to_test as $attribute_to_test) {
3259
+					$atts = explode(',', $attribute_to_test);
3260
+					foreach ($atts as $att) {
3261
+						if (!empty($element_definition['content'][$att])) {
3262 3262
 							$formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att];
3263
-							$controller_rows_array[ $att ] = true;
3263
+							$controller_rows_array[$att] = true;
3264 3264
 						}
3265 3265
 						else {
3266 3266
 							$formatted_datas[$element_id]['content'][$att] = array();
@@ -3269,39 +3269,39 @@  discard block
 block discarded – undo
3269 3269
 				}
3270 3270
 			}
3271 3271
 
3272
-			foreach ( $formatted_datas as $element_id => $element_definition ) {
3273
-				if ( !in_array( $element_id, $array_done ) ) {
3274
-					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition[ 'title' ] . '</td>';
3275
-					ksort( $element_definition[ 'content' ] );
3276
-					foreach ( $element_definition[ 'content' ] as $atribute_id => $value_on_date ) {
3277
-						if( $controller_rows_array[$atribute_id] ) {
3278
-							$current_attribute = wpshop_attributes::getElement( $atribute_id );
3279
-							if ( !in_array( $atribute_id, $done_header ) ) {
3280
-								$more_header .= '<td style="border:1px solid black;" >' . __( $current_attribute->frontend_label, 'wpshop' ) . '</td>';
3272
+			foreach ($formatted_datas as $element_id => $element_definition) {
3273
+				if (!in_array($element_id, $array_done)) {
3274
+					$lines .= '<tr  style="border:1px solid black;"><td  style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition['title'] . '</td>';
3275
+					ksort($element_definition['content']);
3276
+					foreach ($element_definition['content'] as $atribute_id => $value_on_date) {
3277
+						if ($controller_rows_array[$atribute_id]) {
3278
+							$current_attribute = wpshop_attributes::getElement($atribute_id);
3279
+							if (!in_array($atribute_id, $done_header)) {
3280
+								$more_header .= '<td style="border:1px solid black;" >' . __($current_attribute->frontend_label, 'wpshop') . '</td>';
3281 3281
 								$done_header[] = $atribute_id;
3282 3282
 							}
3283 3283
 							$last_value = 'XXXXX';
3284 3284
 							$counter_for_line = 0;
3285 3285
 							$content_line = '';
3286
-							foreach ( $value_on_date as $date => $value ) {
3287
-								if ( $value[ 'histo' ][ 'value' ] != $last_value ) {
3288
-									$current_val = $value[ 'current' ];
3289
-									$old_val = $value[ 'histo' ][ 'value' ];
3286
+							foreach ($value_on_date as $date => $value) {
3287
+								if ($value['histo']['value'] != $last_value) {
3288
+									$current_val = $value['current'];
3289
+									$old_val = $value['histo']['value'];
3290 3290
 									// Test if attribute data Type is integer
3291
-									if ( $current_attribute->data_type == 'integer' ) {
3292
-										if( $current_attribute->data_type_to_use == 'internal' ) {
3291
+									if ($current_attribute->data_type == 'integer') {
3292
+										if ($current_attribute->data_type_to_use == 'internal') {
3293 3293
 											$current_val = get_the_title($current_val);
3294 3294
 											$old_val = get_the_title($old_val);
3295 3295
 										}
3296 3296
 										else {
3297
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val);
3298
-											$old_val = $wpdb->get_var( $query );
3299
-											$query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val);
3300
-											$current_val = $wpdb->get_var( $query );
3297
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $old_val);
3298
+											$old_val = $wpdb->get_var($query);
3299
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $current_val);
3300
+											$current_val = $wpdb->get_var($query);
3301 3301
 										}
3302 3302
 									}
3303
-									$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/>';
3304
-									$last_value = $value[ 'histo' ][ 'value' ];
3303
+									$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/>';
3304
+									$last_value = $value['histo']['value'];
3305 3305
 									$counter_for_line++;
3306 3306
 								}
3307 3307
 							}
@@ -3311,16 +3311,16 @@  discard block
 block discarded – undo
3311 3311
 						}
3312 3312
 					}
3313 3313
 					$lines .= '</tr>';
3314
-					$array_done[ $element_id ];
3314
+					$array_done[$element_id];
3315 3315
 				}
3316 3316
 			}
3317 3317
 
3318 3318
 			$response = '
3319
-				<form action="' . admin_url( 'admin-ajax.php' ) . '" method="POST" id="wps_put_histo_back" >
3319
+				<form action="' . admin_url('admin-ajax.php') . '" method="POST" id="wps_put_histo_back" >
3320 3320
 					<input type="text" name="action" value="wps_put_history_back" />
3321
-					' . wp_nonce_field( 'wps_put_history_back' ) . '
3321
+					' . wp_nonce_field('wps_put_history_back') . '
3322 3322
 					<table style="border-collapse: collapse;border:1px solid black;" cellpadding="0" cellspacing="0" >
3323
-						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __( 'Product', 'wpshop' ) . '</td>'.$more_header.'</tr>
3323
+						<tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __('Product', 'wpshop') . '</td>' . $more_header . '</tr>
3324 3324
 						' . $lines . '
3325 3325
 					</table>
3326 3326
 				</form><script type="text/javascript" >
@@ -3337,36 +3337,36 @@  discard block
 block discarded – undo
3337 3337
 
3338 3338
 
3339 3339
 	function wps_delete_picture_category() {
3340
-		check_ajax_referer( 'wps_delete_picture_category' );
3340
+		check_ajax_referer('wps_delete_picture_category');
3341 3341
 		$status = false; $response = '';
3342
-		$cat_id = ( !empty($_POST['cat_id']) ) ? (int) $_POST['cat_id'] : null;
3343
-		if( !empty($cat_id) ) {
3342
+		$cat_id = (!empty($_POST['cat_id'])) ? (int)$_POST['cat_id'] : null;
3343
+		if (!empty($cat_id)) {
3344 3344
 			// Get Category option
3345
-			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id );
3346
-			if( !empty($category_option) && !empty($category_option['wpshop_category_picture']) ) {
3347
-				unset( $category_option['wpshop_category_picture'] );
3348
-				update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option );
3349
-				$response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>';
3345
+			$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id);
3346
+			if (!empty($category_option) && !empty($category_option['wpshop_category_picture'])) {
3347
+				unset($category_option['wpshop_category_picture']);
3348
+				update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option);
3349
+				$response = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview"/>';
3350 3350
 				$status = true;
3351 3351
 			}
3352 3352
 			else {
3353
-				$response = __( 'Category options are not defined', 'wpshop');
3353
+				$response = __('Category options are not defined', 'wpshop');
3354 3354
 			}
3355 3355
 		}
3356 3356
 		else {
3357
-			$response = __( 'Category ID is not defined', 'wpshop');
3357
+			$response = __('Category ID is not defined', 'wpshop');
3358 3358
 		}
3359
-		echo json_encode( array( 'status' => $status, 'response' => $response) );
3359
+		echo json_encode(array('status' => $status, 'response' => $response));
3360 3360
 		wp_die();
3361 3361
 	}
3362
-	add_action( 'wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category' );
3362
+	add_action('wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category');
3363 3363
 
3364 3364
 	/* EAV */
3365 3365
 
3366 3366
 	/* ATTRIBUTES SET */
3367 3367
 
3368 3368
 	function saveNewAttributeSetSection() {
3369
-		check_ajax_referer( 'saveNewAttributeSetSection' );
3369
+		check_ajax_referer('saveNewAttributeSetSection');
3370 3370
 		global $wpdb;
3371 3371
 		$attributeSetSectionName = sanitize_text_field($_REQUEST['attributeSetSectionName']);
3372 3372
 		$elementIdentifier = (int)$_REQUEST['elementIdentifier'];
@@ -3374,37 +3374,37 @@  discard block
 block discarded – undo
3374 3374
 		$attributeSetInfos['id'] = '';
3375 3375
 		$attributeSetInfos['status'] = 'valid';
3376 3376
 		$attributeSetInfos['attribute_set_id'] = $elementIdentifier;
3377
-		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM ". WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3377
+		$query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier);
3378 3378
 		$attributeSetInfos['position'] = $wpdb->get_var($query);
3379 3379
 		$attributeSetInfos['creation_date'] = date('Y-m-d H:i:s');
3380 3380
 		$attributeSetInfos['code'] = wpshop_tools::slugify($attributeSetSectionName, array('noAccent', 'noSpaces', 'lowerCase'));
3381 3381
 		$attributeSetInfos['name'] = $attributeSetSectionName;
3382 3382
 
3383
-		$more_script='';
3383
+		$more_script = '';
3384 3384
 		$attributeSetSectionCreation = wpshop_database::save($attributeSetInfos, WPSHOP_DBT_ATTRIBUTE_GROUP);
3385
-		if ( $attributeSetSectionCreation == 'done' ) {
3385
+		if ($attributeSetSectionCreation == 'done') {
3386 3386
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop');
3387
-			$more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")';
3387
+			$more_script = 'wpshop_go_to("#attribute_group_' . $wpdb->insert_id . '")';
3388 3388
 		}
3389 3389
 		else {
3390 3390
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop');
3391 3391
 		}
3392 3392
 
3393
-		$script = '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3394
-		wp_die( wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script );
3393
+		$script = '<script type="text/javascript" >wpshop(document).ready(function(){	jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
3394
+		wp_die(wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . $script);
3395 3395
 	}
3396
-	add_action( 'wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection' );
3396
+	add_action('wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection');
3397 3397
 
3398 3398
 	function editAttributeSetSection() {
3399
-		check_ajax_referer( 'editAttributeSetSection' );
3399
+		check_ajax_referer('editAttributeSetSection');
3400 3400
 		$attributeSetSectionName = sanitize_title($_REQUEST['attributeSetSectionName']);
3401 3401
 		$attributeSetSectionId = sanitize_key($_REQUEST['attributeSetSectionId']);
3402 3402
 		$attributeSetSectionDefault = sanitize_text_field($_REQUEST['attributeSetSectionDefault']);
3403 3403
 		$backend_display_type = sanitize_text_field($_REQUEST['attributeSetSectionDisplayType']);
3404 3404
 		$display_on_frontend = sanitize_text_field($_REQUEST['attributeSetSectionDisplayinFrontEnd']);
3405
-		$backend_display_type = in_array($backend_display_type, array('movable-tab','fixed-tab')) ? $backend_display_type : 'fixed-tab';
3405
+		$backend_display_type = in_array($backend_display_type, array('movable-tab', 'fixed-tab')) ? $backend_display_type : 'fixed-tab';
3406 3406
 
3407
-		if($attributeSetSectionDefault == 'yes'){
3407
+		if ($attributeSetSectionDefault == 'yes') {
3408 3408
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, array('last_update_date' => current_time('mysql', 0), 'default_group' => 'no'), array('attribute_set_id' => $elementIdentifier));
3409 3409
 		}
3410 3410
 		$attributeSetInfos = array();
@@ -3414,18 +3414,18 @@  discard block
 block discarded – undo
3414 3414
 		$attributeSetInfos['backend_display_type'] = $backend_display_type;
3415 3415
 		$attributeSetInfos['display_on_frontend'] = $display_on_frontend;
3416 3416
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3417
-		if ( $attributeSetSectionCreation == 'done' )
3417
+		if ($attributeSetSectionCreation == 'done')
3418 3418
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop');
3419 3419
 		else
3420 3420
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop');
3421 3421
 		echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>';
3422 3422
 		wp_die();
3423 3423
 	}
3424
-	add_action( 'wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection' );
3424
+	add_action('wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection');
3425 3425
 
3426 3426
 	function deleteAttributeSetSection() {
3427
-		check_ajax_referer( 'deleteAttributeSetSection' );
3428
-		$attributeSetSectionId = (int) $_REQUEST['attributeSetSectionId'];
3427
+		check_ajax_referer('deleteAttributeSetSection');
3428
+		$attributeSetSectionId = (int)$_REQUEST['attributeSetSectionId'];
3429 3429
 		$attributeSetInfos = array();
3430 3430
 		$attributeSetInfos['status'] = 'deleted';
3431 3431
 		$attributeSetInfos['last_update_date'] = current_time('mysql', 0);
@@ -3434,21 +3434,21 @@  discard block
 block discarded – undo
3434 3434
 		$attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP);
3435 3435
 
3436 3436
 		$more_script = '';
3437
-		if ( $attributeSetSectionCreation == 'done' ) {
3437
+		if ($attributeSetSectionCreation == 'done') {
3438 3438
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop');
3439
-			$more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();';
3439
+			$more_script .= 'jQuery("#attribute_group_' . $attributeSetSectionId . '").remove();';
3440 3440
 		}
3441 3441
 		else
3442 3442
 			$attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop');
3443
-		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>';
3443
+		echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>';
3444 3444
 		wp_die();
3445 3445
 	}
3446
-	add_action( 'wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection' );
3446
+	add_action('wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection');
3447 3447
 
3448 3448
 	/* ATTRIBUTES UNIT */
3449 3449
 
3450 3450
 	function load_unit_interface() {
3451
-		check_ajax_referer( 'load_unit_interface' );
3451
+		check_ajax_referer('load_unit_interface');
3452 3452
 		?>
3453 3453
 		<div id="wpshop_unit_main_listing_interface">
3454 3454
 			<div class="wpshop_full_page_tabs">
@@ -3467,28 +3467,28 @@  discard block
 block discarded – undo
3467 3467
 
3468 3468
 		wp_die();
3469 3469
 	}
3470
-	add_action( 'wp_ajax_wps_attribute_unit_interface', 'load_unit_interface' );
3470
+	add_action('wp_ajax_wps_attribute_unit_interface', 'load_unit_interface');
3471 3471
 
3472 3472
 	function load_attribute_units() {
3473
-		check_ajax_referer( 'load_attribute_units' );
3474
-		wp_die( wpshop_attributes_unit::elementList() );
3473
+		check_ajax_referer('load_attribute_units');
3474
+		wp_die(wpshop_attributes_unit::elementList());
3475 3475
 	}
3476
-	add_action( 'wp_ajax_wps_attribute_unit_load', 'load_attribute_units' );
3476
+	add_action('wp_ajax_wps_attribute_unit_load', 'load_attribute_units');
3477 3477
 
3478 3478
 	function add_attribute_unit() {
3479
-		check_ajax_referer( 'add_attribute_unit' );
3480
-		wp_die( wpshop_attributes_unit::elementEdition( '' ) );
3479
+		check_ajax_referer('add_attribute_unit');
3480
+		wp_die(wpshop_attributes_unit::elementEdition(''));
3481 3481
 	}
3482
-	add_action( 'wp_ajax_wps_attribute_unit_add', 'add_attribute_unit' );
3482
+	add_action('wp_ajax_wps_attribute_unit_add', 'add_attribute_unit');
3483 3483
 
3484 3484
 	function edit_attribute_unit() {
3485
-		check_ajax_referer( 'edit_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3486
-		wp_die( wpshop_attributes_unit::elementEdition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3485
+		check_ajax_referer('edit_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3486
+		wp_die(wpshop_attributes_unit::elementEdition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3487 3487
 	}
3488
-	add_action( 'wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit' );
3488
+	add_action('wp_ajax_wps_attribute_unit_edit', 'edit_attribute_unit');
3489 3489
 
3490 3490
 	function save_new_attribute_unit() {
3491
-		check_ajax_referer( 'save_new_attribute_unit' );
3491
+		check_ajax_referer('save_new_attribute_unit');
3492 3492
 		$save_output = '';
3493 3493
 
3494 3494
 		$attribute_unit_informations['id'] = '';
@@ -3502,11 +3502,11 @@  discard block
 block discarded – undo
3502 3502
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3503 3503
 
3504 3504
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT);
3505
-		if($save_unit_result == 'done'){
3505
+		if ($save_unit_result == 'done') {
3506 3506
 			$save_output = wpshop_attributes_unit::elementList();
3507 3507
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop');
3508 3508
 		}
3509
-		else{
3509
+		else {
3510 3510
 			$save_output = wpshop_attributes_unit::elementEdition();
3511 3511
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop');
3512 3512
 		}
@@ -3514,10 +3514,10 @@  discard block
 block discarded – undo
3514 3514
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3515 3515
 		wp_die();
3516 3516
 	}
3517
-	add_action( 'wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit' );
3517
+	add_action('wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit');
3518 3518
 
3519 3519
 	function update_attribute_unit() {
3520
-		check_ajax_referer( 'update_attribute_unit' );
3520
+		check_ajax_referer('update_attribute_unit');
3521 3521
 		$save_output = '';
3522 3522
 
3523 3523
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['id']);
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
 		$attribute_unit_informations['change_rate'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['change_rate']);
3531 3531
 		$attribute_unit_informations['code_iso'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']);
3532 3532
 
3533
-		if ( $attribute_unit_informations['is_default_of_group'] == 'yes' ) {
3533
+		if ($attribute_unit_informations['is_default_of_group'] == 'yes') {
3534 3534
 			$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array(
3535 3535
 				'is_default_of_group' => 'no'
3536 3536
 			), array(
@@ -3538,8 +3538,8 @@  discard block
 block discarded – undo
3538 3538
 			));
3539 3539
 		}
3540 3540
 
3541
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3542
-		if ( $save_unit_result == 'done' ) {
3541
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT);
3542
+		if ($save_unit_result == 'done') {
3543 3543
 			$save_output = wpshop_attributes_unit::elementList();
3544 3544
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop');
3545 3545
 		}
@@ -3551,17 +3551,17 @@  discard block
 block discarded – undo
3551 3551
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3552 3552
 		wp_die();
3553 3553
 	}
3554
-	add_action( 'wp_ajax_wps_attribute_unit_update', 'update_attribute_unit' );
3554
+	add_action('wp_ajax_wps_attribute_unit_update', 'update_attribute_unit');
3555 3555
 
3556 3556
 	function delete_attribute_unit() {
3557
-		check_ajax_referer( 'delete_attribute_unit_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3557
+		check_ajax_referer('delete_attribute_unit_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3558 3558
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3559 3559
 		$save_output = '';
3560 3560
 
3561 3561
 		$attribute_unit_informations['status'] = 'deleted';
3562 3562
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3563 3563
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT);
3564
-		if ( $save_unit_result == 'done' ) {
3564
+		if ($save_unit_result == 'done') {
3565 3565
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop');
3566 3566
 		}
3567 3567
 		else {
@@ -3571,30 +3571,30 @@  discard block
 block discarded – undo
3571 3571
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::elementList();
3572 3572
 		wp_die();
3573 3573
 	}
3574
-	add_action( 'wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit' );
3574
+	add_action('wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit');
3575 3575
 
3576 3576
 	/* ATTRIBUTES UNIT GROUP */
3577 3577
 
3578 3578
 	function load_attribute_unit_groups() {
3579
-		check_ajax_referer( 'load_attribute_unit_groups' );
3580
-		wp_die( wpshop_attributes_unit::unit_group_list() );
3579
+		check_ajax_referer('load_attribute_unit_groups');
3580
+		wp_die(wpshop_attributes_unit::unit_group_list());
3581 3581
 	}
3582
-	add_action( 'wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups' );
3582
+	add_action('wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups');
3583 3583
 
3584 3584
 	function add_attribute_unit_group() {
3585
-		check_ajax_referer( 'add_attribute_unit_group' );
3586
-		wp_die( wpshop_attributes_unit::unit_group_edition( '' ) );
3585
+		check_ajax_referer('add_attribute_unit_group');
3586
+		wp_die(wpshop_attributes_unit::unit_group_edition(''));
3587 3587
 	}
3588
-	add_action( 'wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group' );
3588
+	add_action('wp_ajax_wps_attribute_group_unit_add', 'add_attribute_unit_group');
3589 3589
 
3590 3590
 	function edit_attribute_unit_group() {
3591
-		check_ajax_referer( 'edit_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? $_REQUEST['elementIdentifier'] : '' ) );
3592
-		wp_die( wpshop_attributes_unit::unit_group_edition( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3591
+		check_ajax_referer('edit_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? $_REQUEST['elementIdentifier'] : ''));
3592
+		wp_die(wpshop_attributes_unit::unit_group_edition(isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3593 3593
 	}
3594
-	add_action( 'wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group' );
3594
+	add_action('wp_ajax_wps_attribute_group_unit_edit', 'edit_attribute_unit_group');
3595 3595
 
3596 3596
 	function save_new_attribute_unit_group() {
3597
-		check_ajax_referer( 'save_new_attribute_unit_group' );
3597
+		check_ajax_referer('save_new_attribute_unit_group');
3598 3598
 		$save_output = '';
3599 3599
 
3600 3600
 		$attribute_unit_informations['id'] = '';
@@ -3603,11 +3603,11 @@  discard block
 block discarded – undo
3603 3603
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3604 3604
 
3605 3605
 		$save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3606
-		if($save_unit_result == 'done'){
3606
+		if ($save_unit_result == 'done') {
3607 3607
 			$save_output = wpshop_attributes_unit::unit_group_list();
3608 3608
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop');
3609 3609
 		}
3610
-		else{
3610
+		else {
3611 3611
 			$save_output = wpshop_attributes_unit::unit_group_edition();
3612 3612
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop');
3613 3613
 		}
@@ -3615,10 +3615,10 @@  discard block
 block discarded – undo
3615 3615
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3616 3616
 		wp_die();
3617 3617
 	}
3618
-	add_action( 'wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group' );
3618
+	add_action('wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group');
3619 3619
 
3620 3620
 	function update_attribute_unit_group() {
3621
-		check_ajax_referer( 'update_attribute_unit_group' );
3621
+		check_ajax_referer('update_attribute_unit_group');
3622 3622
 		$save_output = '';
3623 3623
 
3624 3624
 		$attributeUnitId = sanitize_key($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['id']);
@@ -3626,12 +3626,12 @@  discard block
 block discarded – undo
3626 3626
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3627 3627
 		$attribute_unit_informations['name'] = sanitize_text_field($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']);
3628 3628
 
3629
-		$save_unit_result =  wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3630
-		if($save_unit_result == 'done'){
3629
+		$save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3630
+		if ($save_unit_result == 'done') {
3631 3631
 			$save_output = wpshop_attributes_unit::unit_group_list();
3632 3632
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop');
3633 3633
 		}
3634
-		else{
3634
+		else {
3635 3635
 			$save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId);
3636 3636
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop');
3637 3637
 		}
@@ -3639,65 +3639,65 @@  discard block
 block discarded – undo
3639 3639
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output;
3640 3640
 		wp_die();
3641 3641
 	}
3642
-	add_action( 'wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group' );
3642
+	add_action('wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group');
3643 3643
 
3644 3644
 	function delete_attribute_unit_group() {
3645
-		check_ajax_referer( 'delete_attribute_unit_group_' . ( isset( $_REQUEST['elementIdentifier'] ) ? (int) $_REQUEST['elementIdentifier'] : '' ) );
3645
+		check_ajax_referer('delete_attribute_unit_group_' . (isset($_REQUEST['elementIdentifier']) ? (int)$_REQUEST['elementIdentifier'] : ''));
3646 3646
 		$unit_id = sanitize_key($_REQUEST['elementIdentifier']);
3647 3647
 		$save_output = '';
3648 3648
 
3649 3649
 		$attribute_unit_informations['status'] = 'deleted';
3650 3650
 		$attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s');
3651 3651
 		$save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
3652
-		if($save_unit_result == 'done'){
3652
+		if ($save_unit_result == 'done') {
3653 3653
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop');
3654 3654
 		}
3655
-		else{
3655
+		else {
3656 3656
 			$save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop');
3657 3657
 		}
3658 3658
 
3659 3659
 		echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::unit_group_list();
3660 3660
 		wp_die();
3661 3661
 	}
3662
-	add_action( 'wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group' );
3662
+	add_action('wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group');
3663 3663
 
3664 3664
 	function products_by_criteria() {
3665
-		check_ajax_referer( 'products_by_criteria' );
3665
+		check_ajax_referer('products_by_criteria');
3666 3666
 		$attr = !empty($_REQUEST['attr']) ? sanitize_text_field($_REQUEST['attr']) : '';
3667 3667
 		// If a filter by attribute is found, recalcul the products that matching it
3668
-		if(!empty($attr)) {
3669
-			$att = explode(':',$attr);
3670
-			$products_id = wpshop_products::get_products_matching_attribute($att[0],$att[1]);
3668
+		if (!empty($attr)) {
3669
+			$att = explode(':', $attr);
3670
+			$products_id = wpshop_products::get_products_matching_attribute($att[0], $att[1]);
3671 3671
 		}
3672
-		$products_id = !empty($products_id) ? $products_id : sanitize_text_field( $_REQUEST['pid'] );
3673
-		$page_number = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'page_number' ] ) && is_int( (int) $_REQUEST['page_number'] ) ? (int) $_REQUEST['page_number'] : 0;
3672
+		$products_id = !empty($products_id) ? $products_id : sanitize_text_field($_REQUEST['pid']);
3673
+		$page_number = !empty($_REQUEST) && !empty($_REQUEST['page_number']) && is_int((int)$_REQUEST['page_number']) ? (int)$_REQUEST['page_number'] : 0;
3674 3674
 
3675
-		$criteria = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'criteria' ] ) ? sanitize_text_field( $_REQUEST[ 'criteria' ] ) : null;
3676
-		$cid = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'cid' ] ) && is_int( (int)$_REQUEST[ 'cid' ] ) ? (int)$_REQUEST[ 'cid' ] : null;
3677
-		$display_type = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'display_type' ] ) ? sanitize_text_field( $_REQUEST[ 'display_type' ] ) : null;
3678
-		$order = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'order' ] ) ? sanitize_text_field( $_REQUEST[ 'order' ] ) : null;
3679
-		$products_per_page = !empty( $_REQUEST ) && !empty( $_REQUEST[ 'products_per_page' ] ) && is_int( (int)$_REQUEST[ 'products_per_page' ] ) ? (int)$_REQUEST[ 'products_per_page' ] : 0;
3675
+		$criteria = !empty($_REQUEST) && !empty($_REQUEST['criteria']) ? sanitize_text_field($_REQUEST['criteria']) : null;
3676
+		$cid = !empty($_REQUEST) && !empty($_REQUEST['cid']) && is_int((int)$_REQUEST['cid']) ? (int)$_REQUEST['cid'] : null;
3677
+		$display_type = !empty($_REQUEST) && !empty($_REQUEST['display_type']) ? sanitize_text_field($_REQUEST['display_type']) : null;
3678
+		$order = !empty($_REQUEST) && !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null;
3679
+		$products_per_page = !empty($_REQUEST) && !empty($_REQUEST['products_per_page']) && is_int((int)$_REQUEST['products_per_page']) ? (int)$_REQUEST['products_per_page'] : 0;
3680 3680
 
3681
-		$data = wpshop_products::wpshop_get_product_by_criteria( $criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page );
3682
-		if($data[0]) {
3681
+		$data = wpshop_products::wpshop_get_product_by_criteria($criteria, $cid, $products_id, $display_type, $order, $page_number, $products_per_page);
3682
+		if ($data[0]) {
3683 3683
 			echo json_encode(array(true, do_shortcode($data[1])));
3684
-		} else echo json_encode(array(false,__('No product found','wpshop')));
3684
+		} else echo json_encode(array(false, __('No product found', 'wpshop')));
3685 3685
 		wp_die();
3686 3686
 	}
3687
-	add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' );
3688
-	add_action( 'wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria' );
3687
+	add_action('wp_ajax_wps_products_by_criteria', 'products_by_criteria');
3688
+	add_action('wp_ajax_nopriv_wps_products_by_criteria', 'products_by_criteria');
3689 3689
 
3690 3690
 	function ajax_sendMessage() {
3691
-		check_ajax_referer( 'sendMessage' );
3692
-		$post_id = !empty($_REQUEST['postid']) ? (int) $_REQUEST['postid'] : null;
3691
+		check_ajax_referer('sendMessage');
3692
+		$post_id = !empty($_REQUEST['postid']) ? (int)$_REQUEST['postid'] : null;
3693 3693
 		$title = !empty($_REQUEST['title']) ? sanitize_title($_REQUEST['title']) : '';
3694 3694
 		$message = !empty($_REQUEST['message']) ? sanitize_text_field($_REQUEST['message']) : '';
3695
-		$recipient = !empty($_REQUEST['recipient']) ? (array) $_REQUEST['recipient'] : array();
3696
-		if ( isset($post_id) && isset($title) && isset($message) && !empty($recipient) ) {
3695
+		$recipient = !empty($_REQUEST['recipient']) ? (array)$_REQUEST['recipient'] : array();
3696
+		if (isset($post_id) && isset($title) && isset($message) && !empty($recipient)) {
3697 3697
 			$user_info = get_userdata($recipient);
3698 3698
 			$first_name = $user_info->user_firstname;
3699 3699
 			$last_name = $user_info->user_lastname;
3700
-			$data = array('customer_first_name'=>$first_name,'customer_last_name'=>$last_name);
3700
+			$data = array('customer_first_name'=>$first_name, 'customer_last_name'=>$last_name);
3701 3701
 
3702 3702
 			$wps_message_ctr = new wps_message_ctr();
3703 3703
 
@@ -3706,73 +3706,73 @@  discard block
 block discarded – undo
3706 3706
 			$message = $wps_message_ctr->customMessage($message, $data);
3707 3707
 
3708 3708
 			if (!empty($user_info->user_email)) {
3709
-				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$post_id, $object=array());
3709
+				$wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save = true, $model_id = $post_id, $object = array());
3710 3710
 				$array = array('result' => true, 'message' => '');
3711 3711
 			}
3712
-			else $array = array('result' => true, 'message' => __('An error occured','wpshop'));
3712
+			else $array = array('result' => true, 'message' => __('An error occured', 'wpshop'));
3713 3713
 		}
3714 3714
 		else {
3715
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3715
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3716 3716
 		}
3717 3717
 
3718 3718
 		echo json_encode($array);
3719 3719
 		wp_die();
3720 3720
 	}
3721
-	add_action( 'wp_ajax_wps_ajax_send_message', 'ajax_sendMessage' );
3721
+	add_action('wp_ajax_wps_ajax_send_message', 'ajax_sendMessage');
3722 3722
 
3723 3723
 	function ajax_resendMessage() {
3724
-		check_ajax_referer( 'resendMessage' );
3725
-		$message_id = !empty($_REQUEST['messageid']) ? (array) $_REQUEST['messageid'] : array();
3724
+		check_ajax_referer('resendMessage');
3725
+		$message_id = !empty($_REQUEST['messageid']) ? (array)$_REQUEST['messageid'] : array();
3726 3726
 		if (isset($message_id)) {
3727
-			$ids = explode('-',$message_id);
3727
+			$ids = explode('-', $message_id);
3728 3728
 			$postid = $ids[0];
3729
-			$date = $ids[1].'-'.$ids[2];
3729
+			$date = $ids[1] . '-' . $ids[2];
3730 3730
 			$arraykey = $ids[3];
3731 3731
 
3732
-			$historic = get_post_meta($postid, 'wpshop_messages_histo_'.$date, true);
3732
+			$historic = get_post_meta($postid, 'wpshop_messages_histo_' . $date, true);
3733 3733
 
3734 3734
 			if (isset($historic[$arraykey])) {
3735 3735
 				$historic[$arraykey]['mess_dispatch_date'][] = current_time('mysql', 0);
3736
-				update_post_meta($postid, 'wpshop_messages_histo_'.$date, $historic);
3736
+				update_post_meta($postid, 'wpshop_messages_histo_' . $date, $historic);
3737 3737
 
3738 3738
 				$data = $historic[$arraykey];
3739 3739
 				$wps_message_ctr = new wps_message_ctr();
3740
-				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array());
3740
+				$wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save = false, $object = array());
3741 3741
 
3742 3742
 				$array = array('result' => true, 'message' => '');
3743 3743
 			}
3744 3744
 			else {
3745
-				$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3745
+				$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3746 3746
 			}
3747 3747
 		}
3748 3748
 		else {
3749
-			$array = array('result' => false, 'message' => __('An error occured','wpshop'));
3749
+			$array = array('result' => false, 'message' => __('An error occured', 'wpshop'));
3750 3750
 		}
3751 3751
 
3752 3752
 		echo json_encode($array);
3753 3753
 		wp_die();
3754 3754
 	}
3755
-	add_action( 'wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage' );
3755
+	add_action('wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage');
3756 3756
 
3757 3757
 	function related_products() {
3758
-		check_ajax_referer( 'related_products' );
3758
+		check_ajax_referer('related_products');
3759 3759
 		$search = sanitize_text_field($_REQUEST['search']);
3760 3760
 		$data = wpshop_products::product_list(false, $search);
3761
-		$array=array();
3761
+		$array = array();
3762 3762
 		foreach ($data as $d) {
3763 3763
 			$array[] = array('id' => $d->ID, 'name' => $d->post_title);
3764 3764
 		}
3765 3765
 		echo json_encode($array);
3766 3766
 		wp_die();
3767 3767
 	}
3768
-	add_action( 'wp_ajax_wps_related_products', 'related_products' );
3768
+	add_action('wp_ajax_wps_related_products', 'related_products');
3769 3769
 
3770 3770
 	function applyCoupon() {
3771
-		check_ajax_referer( 'applyCoupon' );
3771
+		check_ajax_referer('applyCoupon');
3772 3772
 		$wps_coupon_ctr = new wps_coupon_ctr();
3773 3773
 		$coupon_code = sanitize_text_field($_REQUEST['coupon_code']);
3774 3774
 		$result = $wps_coupon_ctr->applyCoupon($coupon_code);
3775
-		if ($result['status']===true) {
3775
+		if ($result['status'] === true) {
3776 3776
 			$wps_cart_ctr = new wps_cart();
3777 3777
 			$order = $wps_cart_ctr->calcul_cart_information(array());
3778 3778
 			$wps_cart_ctr->store_cart_in_session($order);
@@ -3780,6 +3780,6 @@  discard block
 block discarded – undo
3780 3780
 		} else echo json_encode(array(false, $result['message']));
3781 3781
 		wp_die();
3782 3782
 	}
3783
-	add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' );
3783
+	add_action('wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon');
3784 3784
 
3785 3785
 ?>
Please login to merge, or discard this patch.