Completed
Pull Request — master (#2)
by Jimmy
1003:35 queued 970:52
created
core/module_management/controller/module_management.ctr.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,6 @@
 block discarded – undo
51 51
 	/**
52 52
 	 * OPTIONS -
53 53
 	 *
54
-	 * @param array $input
55 54
 	 *
56 55
 	 * @return array
57 56
 	 */
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Fichier du controleur principal pour la gestion des modules internes dans les extensions wordpress / Main controller file for internal modules management into wordpress plugins
4 4
  *
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 /*	Check if file is include. No direct access possible with file url	*/
10
-if ( !defined( 'WPSHOP_VERSION' ) ) {
11
-	die( __('Access is not allowed by this way', 'wpshop') );
10
+if (!defined('WPSHOP_VERSION')) {
11
+	die(__('Access is not allowed by this way', 'wpshop'));
12 12
 }
13 13
 
14 14
 /**
@@ -24,28 +24,28 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	function __construct() {
26 26
 		/**	Ajoute une interface aux options pour gérer les modules / Add an interface to plugin options screen in order to manage modules	*/
27
-		add_action( 'admin_init', array( $this, 'declare_options' ), 11 );
27
+		add_action('admin_init', array($this, 'declare_options'), 11);
28 28
 
29 29
 		/**	Appel des styles pour l'administration / Call style for administration	*/
30
-		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_assets' ) );
30
+		add_action('admin_enqueue_scripts', array(&$this, 'admin_assets'));
31 31
 	}
32 32
 
33 33
 	/**
34 34
 	 * Inclusion des feuilles de styles pour l'administration / Admin css enqueue
35 35
 	 */
36 36
 	function admin_assets() {
37
-		wp_register_style( 'eomodmanager-admin-css', EOMODMAN_URL . '/assets/css/backend.css', '', EOMODMAN_VERSION );
38
-		wp_enqueue_style( 'eomodmanager-admin-css' );
37
+		wp_register_style('eomodmanager-admin-css', EOMODMAN_URL . '/assets/css/backend.css', '', EOMODMAN_VERSION);
38
+		wp_enqueue_style('eomodmanager-admin-css');
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * OPTIONS - Déclare les options permettant de gérer les statuts des modules / Declare add-on configuration panel for managing modules status
43 43
 	 */
44 44
 	function declare_options() {
45
-		add_settings_section( 'wps_internal_modules', '<i class="dashicons dashicons-admin-plugins"></i>' . __( 'Internal modules management', 'eo-modmanager-i18n' ), '', 'wpshop_addons_options' );
46
-		register_setting( 'wpshop_options', 'wpshop_modules', array( &$this, 'validate_options' ) );
45
+		add_settings_section('wps_internal_modules', '<i class="dashicons dashicons-admin-plugins"></i>' . __('Internal modules management', 'eo-modmanager-i18n'), '', 'wpshop_addons_options');
46
+		register_setting('wpshop_options', 'wpshop_modules', array(&$this, 'validate_options'));
47 47
 
48
-		add_settings_field( 'wpshop_opinions_field', __( 'Internal modules management', 'eo-modmanager-i18n' ), array( &$this, 'module_listing' ), 'wpshop_addons_options', 'wps_internal_modules' );
48
+		add_settings_field('wpshop_opinions_field', __('Internal modules management', 'eo-modmanager-i18n'), array(&$this, 'module_listing'), 'wpshop_addons_options', 'wps_internal_modules');
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,41 +55,41 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array
57 57
 	 */
58
-	function validate_options( $settings ) {
59
-		if ( is_array( $settings ) ) {
60
-			$module_option = get_option( 'wpshop_modules' );
58
+	function validate_options($settings) {
59
+		if (is_array($settings)) {
60
+			$module_option = get_option('wpshop_modules');
61 61
 			$log_error = array();
62
-			foreach ( $settings as $module => $module_state ) {
63
-				if ( !array_key_exists( 'activated', $module_state ) && ( 'on' == $module_state[ 'old_activated' ] ) ) {
64
-					$module_option[ $module ][ 'activated' ] = 'off';
65
-					$module_option[ $module ][ 'date_off' ] = gmdate( "Y-m-d H:i:s", time() );
66
-					$module_option[ $module ][ 'author_off' ] = get_current_user_id();
67
-					$settings[ $module ] = $module_option[ $module ];
62
+			foreach ($settings as $module => $module_state) {
63
+				if (!array_key_exists('activated', $module_state) && ('on' == $module_state['old_activated'])) {
64
+					$module_option[$module]['activated'] = 'off';
65
+					$module_option[$module]['date_off'] = gmdate("Y-m-d H:i:s", time());
66
+					$module_option[$module]['author_off'] = get_current_user_id();
67
+					$settings[$module] = $module_option[$module];
68 68
 
69 69
 					/**	Log module activation	*/
70
-					$user = get_userdata( $module_option[ $folder ][ 'author_on' ] );
70
+					$user = get_userdata($module_option[$folder]['author_on']);
71 71
 					$author = $user->display_name;
72
-					$log_error[ 'message' ] = sprintf( __( 'Activation made on %1$s by %2$s', 'eo-modmanager-i18n' ), mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $settings[ $module ][ 'date_on' ], true ), $author);
72
+					$log_error['message'] = sprintf(__('Activation made on %1$s by %2$s', 'eo-modmanager-i18n'), mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $settings[$module]['date_on'], true), $author);
73 73
 				}
74
-				else if ( array_key_exists( 'activated', $module_state ) && ( 'off' == $module_state[ 'old_activated' ] ) ) {
75
-					$module_option[ $module ][ 'activated' ] = 'on';
76
-					$module_option[ $module ][ 'date_on' ] = gmdate( "Y-m-d H:i:s", time() );
77
-					$module_option[ $module ][ 'author_on' ] = get_current_user_id();
78
-					$settings[ $module ] = $module_option[ $module ];
74
+				else if (array_key_exists('activated', $module_state) && ('off' == $module_state['old_activated'])) {
75
+					$module_option[$module]['activated'] = 'on';
76
+					$module_option[$module]['date_on'] = gmdate("Y-m-d H:i:s", time());
77
+					$module_option[$module]['author_on'] = get_current_user_id();
78
+					$settings[$module] = $module_option[$module];
79 79
 
80 80
 					/**	Log module activation	*/
81
-					$user = get_userdata( $module_option[ $folder ][ 'author_off' ] );
81
+					$user = get_userdata($module_option[$folder]['author_off']);
82 82
 					$author = $user->display_name;
83
-					$log_error[ 'message' ] = sprintf( __( 'Deactivation made on %1$s by %2$s', 'eo-modmanager-i18n' ), mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $settings[ $module ][ 'date_off' ], true ), $author);
83
+					$log_error['message'] = sprintf(__('Deactivation made on %1$s by %2$s', 'eo-modmanager-i18n'), mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $settings[$module]['date_off'], true), $author);
84 84
 				}
85 85
 				else {
86
-					$settings[ $module ] = $module_option[ $module ];
86
+					$settings[$module] = $module_option[$module];
87 87
 				}
88
-				unset( $settings[ $module ][ 'old_activated' ] );
89
-				$log_error[ 'object_id' ] = $module;
88
+				unset($settings[$module]['old_activated']);
89
+				$log_error['object_id'] = $module;
90 90
 			}
91 91
 
92
-			wpeologs_ctr::log_datas_in_files( 'wps_addon', $log_error, 0 );
92
+			wpeologs_ctr::log_datas_in_files('wps_addon', $log_error, 0);
93 93
 
94 94
 		}
95 95
 
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 		$module_folder = WPSHOP_MODULES_DIR;
105 105
 
106 106
 		/**	Get	current modules options to know if they are activated or not */
107
-		$module_option = get_option( 'wpshop_modules' );
107
+		$module_option = get_option('wpshop_modules');
108 108
 
109 109
 		/**	Check if the defined directory exists for reading and displaying an input to activate/deactivate the module	*/
110
-		if( is_dir( $module_folder ) ) {
111
-			$parent_folder_content = scandir( $module_folder );
110
+		if (is_dir($module_folder)) {
111
+			$parent_folder_content = scandir($module_folder);
112 112
 
113
-			require_once( wpshop_tools::get_template_part( EOMODMAN_DIR, EOMODMAN_TEMPLATES_MAIN_DIR, 'backend', 'settings' ) );
113
+			require_once(wpshop_tools::get_template_part(EOMODMAN_DIR, EOMODMAN_TEMPLATES_MAIN_DIR, 'backend', 'settings'));
114 114
 		}
115 115
 		else {
116
-			_e( 'There is no modules to include into current plugin', 'eo-modmanager-i18n' );
116
+			_e('There is no modules to include into current plugin', 'eo-modmanager-i18n');
117 117
 		}
118 118
 
119 119
 	}
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 		$module_folder = WPSHOP_DIR . '/core/';
127 127
 
128 128
 		/**	Check if the defined directory exists for reading and including the different modules	*/
129
-		if( is_dir( $module_folder ) ) {
130
-			$parent_folder_content = scandir( $module_folder );
131
-			foreach ( $parent_folder_content as $folder ) {
132
-				if ( $folder && substr( $folder, 0, 1) != '.' && ( EOMODMAN_DIR != $folder ) ) {
133
-					if ( file_exists( $module_folder . $folder . '/' . $folder . '.php') ) {
134
-						$f =  $module_folder . $folder . '/' . $folder . '.php';
135
-						require( $f );
129
+		if (is_dir($module_folder)) {
130
+			$parent_folder_content = scandir($module_folder);
131
+			foreach ($parent_folder_content as $folder) {
132
+				if ($folder && substr($folder, 0, 1) != '.' && (EOMODMAN_DIR != $folder)) {
133
+					if (file_exists($module_folder . $folder . '/' . $folder . '.php')) {
134
+						$f = $module_folder . $folder . '/' . $folder . '.php';
135
+						require($f);
136 136
 					}
137 137
 				}
138 138
 			}
@@ -147,23 +147,23 @@  discard block
 block discarded – undo
147 147
 		$module_folder = WPSHOP_MODULES_DIR;
148 148
 
149 149
 		/**	Get	current modules options to know if they are activated or not */
150
-		$module_option = get_option( 'wpshop_modules' );
150
+		$module_option = get_option('wpshop_modules');
151 151
 
152 152
 		/**	Check if the defined directory exists for reading and including the different modules	*/
153
-		if( is_dir( $module_folder ) ) {
154
-			$parent_folder_content = scandir( $module_folder );
153
+		if (is_dir($module_folder)) {
154
+			$parent_folder_content = scandir($module_folder);
155 155
 			$update_option = false;
156
-			foreach ( $parent_folder_content as $folder ) {
157
-				if ( $folder && substr( $folder, 0, 1) != '.' ) {
156
+			foreach ($parent_folder_content as $folder) {
157
+				if ($folder && substr($folder, 0, 1) != '.') {
158 158
 					$is_activated = false;
159 159
 					/**	Check current module state to know if we have to include it or not	*/
160
-					if ( !empty( $module_option ) && array_key_exists( $folder, $module_option ) && ( 'on' == $module_option[ $folder ][ 'activated' ] ) ) {
160
+					if (!empty($module_option) && array_key_exists($folder, $module_option) && ('on' == $module_option[$folder]['activated'])) {
161 161
 						$is_activated = true;
162 162
 					}
163
-					else if ( empty( $module_option ) || ( !empty( $module_option ) && !array_key_exists( $folder, $module_option ) ) ) {
164
-						$modules_option[ $folder ] = array(
163
+					else if (empty($module_option) || (!empty($module_option) && !array_key_exists($folder, $module_option))) {
164
+						$modules_option[$folder] = array(
165 165
 							'activated' => 'on',
166
-							'date_on' => gmdate( "Y-m-d H:i:s", time() ),
166
+							'date_on' => gmdate("Y-m-d H:i:s", time()),
167 167
 							'author_on' => 'auto',
168 168
 						);
169 169
 						$is_activated = true;
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
 					}
172 172
 
173 173
 					/**	Finaly include module if the state allow it	*/
174
-					if ( $is_activated && file_exists( $module_folder . $folder . '/' . $folder . '.php') ) {
175
-						$f =  $module_folder . $folder . '/' . $folder . '.php';
176
-						require( $f );
174
+					if ($is_activated && file_exists($module_folder . $folder . '/' . $folder . '.php')) {
175
+						$f = $module_folder . $folder . '/' . $folder . '.php';
176
+						require($f);
177 177
 					}
178 178
 				}
179 179
 			}
180 180
 			/**	Update option only if it is necessary	*/
181
-			if ( $update_option ) {
182
-				update_option( 'wpshop_modules', $modules_option );
181
+			if ($update_option) {
182
+				update_option('wpshop_modules', $modules_option);
183 183
 			}
184 184
 		}
185 185
 	}
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier du controleur principal pour la gestion des modules internes dans les extensions wordpress / Main controller file for internal modules management into wordpress plugins
4 6
  *
@@ -70,8 +72,7 @@  discard block
 block discarded – undo
70 72
 					$user = get_userdata( $module_option[ $folder ][ 'author_on' ] );
71 73
 					$author = $user->display_name;
72 74
 					$log_error[ 'message' ] = sprintf( __( 'Activation made on %1$s by %2$s', 'eo-modmanager-i18n' ), mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $settings[ $module ][ 'date_on' ], true ), $author);
73
-				}
74
-				else if ( array_key_exists( 'activated', $module_state ) && ( 'off' == $module_state[ 'old_activated' ] ) ) {
75
+				} else if ( array_key_exists( 'activated', $module_state ) && ( 'off' == $module_state[ 'old_activated' ] ) ) {
75 76
 					$module_option[ $module ][ 'activated' ] = 'on';
76 77
 					$module_option[ $module ][ 'date_on' ] = gmdate( "Y-m-d H:i:s", time() );
77 78
 					$module_option[ $module ][ 'author_on' ] = get_current_user_id();
@@ -81,8 +82,7 @@  discard block
 block discarded – undo
81 82
 					$user = get_userdata( $module_option[ $folder ][ 'author_off' ] );
82 83
 					$author = $user->display_name;
83 84
 					$log_error[ 'message' ] = sprintf( __( 'Deactivation made on %1$s by %2$s', 'eo-modmanager-i18n' ), mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $settings[ $module ][ 'date_off' ], true ), $author);
84
-				}
85
-				else {
85
+				} else {
86 86
 					$settings[ $module ] = $module_option[ $module ];
87 87
 				}
88 88
 				unset( $settings[ $module ][ 'old_activated' ] );
@@ -111,8 +111,7 @@  discard block
 block discarded – undo
111 111
 			$parent_folder_content = scandir( $module_folder );
112 112
 
113 113
 			require_once( wpshop_tools::get_template_part( EOMODMAN_DIR, EOMODMAN_TEMPLATES_MAIN_DIR, 'backend', 'settings' ) );
114
-		}
115
-		else {
114
+		} else {
116 115
 			_e( 'There is no modules to include into current plugin', 'eo-modmanager-i18n' );
117 116
 		}
118 117
 
@@ -159,8 +158,7 @@  discard block
 block discarded – undo
159 158
 					/**	Check current module state to know if we have to include it or not	*/
160 159
 					if ( !empty( $module_option ) && array_key_exists( $folder, $module_option ) && ( 'on' == $module_option[ $folder ][ 'activated' ] ) ) {
161 160
 						$is_activated = true;
162
-					}
163
-					else if ( empty( $module_option ) || ( !empty( $module_option ) && !array_key_exists( $folder, $module_option ) ) ) {
161
+					} else if ( empty( $module_option ) || ( !empty( $module_option ) && !array_key_exists( $folder, $module_option ) ) ) {
164 162
 						$modules_option[ $folder ] = array(
165 163
 							'activated' => 'on',
166 164
 							'date_on' => gmdate( "Y-m-d H:i:s", time() ),
Please login to merge, or discard this patch.
core/wpeo_logs/controller/log.controller.01.php 4 patches
Doc Comments   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 		/**
199 199
 		 * DEBUG LOG - Save a file on the server with content for loggin different action sended
200 200
 		 *
201
-		 * @param string $service (Name module or post type)
202 201
 		 * @param array $array_message ('object_id', 'message')
203 202
 		 * @param int $criticality The message crit rate (0-2)
203
+		 * @param string $name
204 204
 		 */
205 205
 		public static function log_datas_in_files( $name, $array_message, $criticality ) {
206 206
 			$upload_dir = wp_upload_dir();
@@ -269,7 +269,8 @@  discard block
 block discarded – undo
269 269
 		/**
270 270
 		* check_need_rotate  Checks if the file exceeds the maximum size
271 271
 		*
272
-		* @param string $file_link The file path to write
272
+		* @param string $name
273
+		* @param string $message
273 274
 		*/
274 275
 		public static function check_need_rotate( $service, $name, $message ) {
275 276
 			$upload_dir = wp_upload_dir();
@@ -355,6 +356,9 @@  discard block
 block discarded – undo
355 356
 			return $getted_service;
356 357
 		}
357 358
 
359
+		/**
360
+		 * @param integer $id
361
+		 */
358 362
 		public static function get_service_by_id( $id ) {
359 363
 			$array_service = get_option( '_wpeo_log_settings', array() );
360 364
 
@@ -381,7 +385,7 @@  discard block
 block discarded – undo
381 385
 		 * @param float $input
382 386
 		 * @param string $format
383 387
 		 * @param boolean $convert
384
-		 * @return float|number
388
+		 * @return double
385 389
 		 */
386 390
 		function convert_to($input, $format, $convert = true) {
387 391
 			if($format == 'oc')
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -267,10 +267,10 @@
 block discarded – undo
267 267
 		}
268 268
 
269 269
 		/**
270
-		* check_need_rotate  Checks if the file exceeds the maximum size
271
-		*
272
-		* @param string $file_link The file path to write
273
-		*/
270
+		 * check_need_rotate  Checks if the file exceeds the maximum size
271
+		 *
272
+		 * @param string $file_link The file path to write
273
+		 */
274 274
 		public static function check_need_rotate( $service, $name, $message ) {
275 275
 			$upload_dir = wp_upload_dir();
276 276
 
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /**
4 4
  * Main controller file for WP logs module
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @subpackage controller
19 19
  */
20 20
 
21
-if ( !class_exists( "wpeologs_ctr" ) ) {
21
+if (!class_exists("wpeologs_ctr")) {
22 22
 
23 23
 	/**
24 24
 	 *
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 * @param array $args
28 28
 	 * @param int $criticality default 0
29 29
 	 */
30
-	function eo_log( $service_name, $args, $criticality = 0 ) {
31
-		wpeologs_ctr::log_datas_in_files( $service_name, $args, $criticality );
30
+	function eo_log($service_name, $args, $criticality = 0) {
31
+		wpeologs_ctr::log_datas_in_files($service_name, $args, $criticality);
32 32
 	}
33 33
 
34 34
 	class wpeologs_ctr {
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 		 * @return void
46 46
 		 */
47 47
 		public function __construct() {
48
-			add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
48
+			add_action('admin_menu', array(&$this, 'admin_menu'));
49 49
 
50 50
 			// Service action
51
-			add_action( 'admin_post_add', 'wpeo_log::add' );
52
-			add_action( 'admin_post_add', 'wpeologs_ctr::add' );
53
-			add_action( 'admin_post_edit_service', array( $this, 'edit_service' ) );
54
-			add_action( 'admin_post_to_trash', array( $this, 'to_trash' ) );
55
-			add_action( 'admin_post_file_to_trash', array( $this, 'file_to_trash' ) );
51
+			add_action('admin_post_add', 'wpeo_log::add');
52
+			add_action('admin_post_add', 'wpeologs_ctr::add');
53
+			add_action('admin_post_edit_service', array($this, 'edit_service'));
54
+			add_action('admin_post_to_trash', array($this, 'to_trash'));
55
+			add_action('admin_post_file_to_trash', array($this, 'file_to_trash'));
56 56
 
57 57
 			/**	Call administration style definition	*/
58
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
58
+			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
59 59
 
60 60
 			// Transfert des anciens services
61 61
 			$this->transfert();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		 * @return void
68 68
 		 */
69 69
 		public function admin_menu() {
70
-			add_submenu_page( 'tools.php', __( 'Logs', 'wpeolog-i18n' ), __( 'Logs', 'wpeolog-i18n' ), 'manage_options', 'wpeo-log-page', array( &$this, 'render_add_submenu_page' ) );
70
+			add_submenu_page('tools.php', __('Logs', 'wpeolog-i18n'), __('Logs', 'wpeolog-i18n'), 'manage_options', 'wpeo-log-page', array(&$this, 'render_add_submenu_page'));
71 71
 		}
72 72
 
73 73
 		/**
@@ -79,115 +79,115 @@  discard block
 block discarded – undo
79 79
 			$dir_file = $upload_dir['basedir'] . '/wpeolog/';
80 80
 
81 81
 			$array_size_format = $this->get_array_size_format();
82
-			$array_file_rotate_dropdown = array( 'on' => __( 'On', 'wpeolog-i18n' ), 'off' => __( 'Off', 'wpeolog-i18n' ) );
83
-			$array_service = get_option( '_wpeo_log_settings' );
84
-			$array_service = json_decode( $array_service, true );
82
+			$array_file_rotate_dropdown = array('on' => __('On', 'wpeolog-i18n'), 'off' => __('Off', 'wpeolog-i18n'));
83
+			$array_service = get_option('_wpeo_log_settings');
84
+			$array_service = json_decode($array_service, true);
85 85
 
86 86
 
87
-			if ( !empty( $array_service ) ) {
88
-				foreach ( $array_service as &$service ) {
89
-					$service['error'] = $this->open_log( $service['name'] . '-error' );
90
-					$service['warning'] = $this->open_log( $service['name'] . '-warning' );
87
+			if (!empty($array_service)) {
88
+				foreach ($array_service as &$service) {
89
+					$service['error'] = $this->open_log($service['name'] . '-error');
90
+					$service['warning'] = $this->open_log($service['name'] . '-warning');
91 91
 				}
92 92
 			}
93
-			unset( $service );
93
+			unset($service);
94 94
 
95 95
 			$count_service_active = 0;
96 96
 			$count_service_desactive = 0;
97 97
 
98
-			$page_transient = get_transient( 'log_message' );
99
-			if ( !empty( $page_transient ) ) {
100
-				delete_transient( 'log_message' );
101
-				$page_transient = json_decode( $page_transient, true );
98
+			$page_transient = get_transient('log_message');
99
+			if (!empty($page_transient)) {
100
+				delete_transient('log_message');
101
+				$page_transient = json_decode($page_transient, true);
102 102
 			}
103 103
 
104 104
 			$array_data = $this->check_page();
105 105
 
106 106
 			$count_warning = $array_data['count_warning'];
107 107
 			$count_error = $array_data['count_error'];
108
-			$count_info = count( $array_data['data']['data'] );
108
+			$count_info = count($array_data['data']['data']);
109 109
 
110 110
 			$file = $array_data['data']['data'];
111 111
 			$list_archive_file = $array_data['list_archive_file'];
112 112
 
113
-			require_once( wpeo_template_01::get_template_part( WPEO_LOGS_DIR, WPEO_LOGS_TEMPLATES_MAIN_DIR, 'backend', 'main' ) );
113
+			require_once(wpeo_template_01::get_template_part(WPEO_LOGS_DIR, WPEO_LOGS_TEMPLATES_MAIN_DIR, 'backend', 'main'));
114 114
 		}
115 115
 
116 116
 		private function check_page() {
117
-			if( empty( $_GET['action'] ) || empty( $_GET['type'] ) )
117
+			if (empty($_GET['action']) || empty($_GET['type']))
118 118
 				return false;
119 119
 
120
-			$action = sanitize_text_field( $_GET['action'] );
121
-			$type = sanitize_text_field( !empty( $_GET['type'] ) ?  $_GET['type'] : '' );
120
+			$action = sanitize_text_field($_GET['action']);
121
+			$type = sanitize_text_field(!empty($_GET['type']) ? $_GET['type'] : '');
122 122
 
123
-			if ( !isset( $_GET['service_id'] ) ) return false;
124
-			else $service_id = (int) $_GET['service_id'];
123
+			if (!isset($_GET['service_id'])) return false;
124
+			else $service_id = (int)$_GET['service_id'];
125 125
 
126
-			if ( isset( $_GET['key'] ) && 0 !== (int) $_GET['key'] ) $key = (int) $_GET['key'];
126
+			if (isset($_GET['key']) && 0 !== (int)$_GET['key']) $key = (int)$_GET['key'];
127 127
 
128
-			if ( 'view' == $action && isset( $service_id ) ) {
129
-				$service = self::get_service_by_id( $service_id );
128
+			if ('view' == $action && isset($service_id)) {
129
+				$service = self::get_service_by_id($service_id);
130 130
 
131
-				if( $service == null )
131
+				if ($service == null)
132 132
 					return false;
133 133
 
134 134
 				$service_name = $service['name'];
135 135
 
136
-				if ( !empty( $type ) ) {
136
+				if (!empty($type)) {
137 137
 					$service_name .= '-' . $type;
138 138
 				}
139 139
 
140 140
 				// Tous les fichiers
141
-				$list_archive_file = $this->get_archive_file( $service_name );
141
+				$list_archive_file = $this->get_archive_file($service_name);
142 142
 
143
-				if( !empty( $key ) ) {
143
+				if (!empty($key)) {
144 144
 					$service_name .= '_' . $key;
145 145
 				}
146 146
 
147
-				$count_warning = $this->open_log( $service['name'] . '-warning' );
148
-				$count_error = $this->open_log( $service['name'] . '-error' );
147
+				$count_warning = $this->open_log($service['name'] . '-warning');
148
+				$count_error = $this->open_log($service['name'] . '-error');
149 149
 
150
-				$array_data = $this->open_log( $service_name );
150
+				$array_data = $this->open_log($service_name);
151 151
 
152
-				return array( 'data' => $array_data, 'list_archive_file' => $list_archive_file, 'count_warning' => $count_warning['count'], 'count_error' => $count_error['count'] );
152
+				return array('data' => $array_data, 'list_archive_file' => $list_archive_file, 'count_warning' => $count_warning['count'], 'count_error' => $count_error['count']);
153 153
 			}
154 154
 		}
155 155
 
156 156
 		public function admin_enqueue_scripts() {
157
-			wp_register_script( 'wps_statistics_js_chart', WPEO_LOGS_URL . '/asset/js/chart.js');
158
-			wp_enqueue_script( 'wps_statistics_js_chart' );
157
+			wp_register_script('wps_statistics_js_chart', WPEO_LOGS_URL . '/asset/js/chart.js');
158
+			wp_enqueue_script('wps_statistics_js_chart');
159 159
 		}
160 160
 
161
-		private function open_log( $service_name ) {
161
+		private function open_log($service_name) {
162 162
 			$upload_dir = wp_upload_dir();
163 163
 			$dir_file = $upload_dir['basedir'] . '/wpeolog/' . $service_name . '.csv';
164 164
 
165
-			if ( file_exists( $dir_file ) ) {
166
-				$file = file( $dir_file );
165
+			if (file_exists($dir_file)) {
166
+				$file = file($dir_file);
167 167
 
168 168
 
169 169
 				// Remove the first case empty
170
-				array_shift( $file );
170
+				array_shift($file);
171 171
 
172
-				foreach( $file as &$data ) {
173
-					$data = explode( wpeologs_ctr::$file_separator, $data );
172
+				foreach ($file as &$data) {
173
+					$data = explode(wpeologs_ctr::$file_separator, $data);
174 174
 				}
175 175
 
176
-				return array( 'data' => $file, 'count' => count( $file ) );
176
+				return array('data' => $file, 'count' => count($file));
177 177
 			}
178 178
 			else {
179
-				return array( 'data' => null, 'count' => 0 );
179
+				return array('data' => null, 'count' => 0);
180 180
 			}
181 181
 		}
182 182
 
183
-		private function get_archive_file( $name ) {
183
+		private function get_archive_file($name) {
184 184
 			// Get archive
185 185
 			$upload_dir = wp_upload_dir();
186 186
 			$dir_file = $upload_dir['basedir'] . '/wpeolog/';
187 187
 
188
-			$array_glob_file = glob( $dir_file . $name . '*.csv' );
188
+			$array_glob_file = glob($dir_file . $name . '*.csv');
189 189
 
190
-			foreach( $array_glob_file as &$glob_file ) {
190
+			foreach ($array_glob_file as &$glob_file) {
191 191
 				$glob_file = explode('/', $glob_file);
192 192
 				$glob_file = $glob_file[count($glob_file) - 1];
193 193
 			}
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
 		 * @param array $array_message ('object_id', 'message')
203 203
 		 * @param int $criticality The message crit rate (0-2)
204 204
 		 */
205
-		public static function log_datas_in_files( $name, $array_message, $criticality ) {
205
+		public static function log_datas_in_files($name, $array_message, $criticality) {
206 206
 			$upload_dir = wp_upload_dir();
207 207
 
208 208
 			$backtrace = debug_backtrace();
209 209
 
210 210
 			// On récupère le service
211
-			$service = self::get_service_by_name( $name );
211
+			$service = self::get_service_by_name($name);
212 212
 
213
-			if( $service == null ) {
213
+			if ($service == null) {
214 214
 			/** Créer le service s'il n'existe pas */
215
-				$service = self::add( $name );
215
+				$service = self::add($name);
216 216
 			}
217 217
 
218
-			wp_mkdir_p( $upload_dir[ 'basedir' ] . '/wpeolog/' );
218
+			wp_mkdir_p($upload_dir['basedir'] . '/wpeolog/');
219 219
 
220
-			if( $service == null )
220
+			if ($service == null)
221 221
 				return null;
222 222
 
223 223
 			$message = "
@@ -225,44 +225,44 @@  discard block
 block discarded – undo
225 225
 			$message .= current_time('mysql', 0) . self::$file_separator;
226 226
 			$message .= get_current_user_id() . self::$file_separator;
227 227
 			$message .= '"' . $name . '"' . self::$file_separator;
228
-			$message .= ( !empty( $array_message['object_id'] ) ? $array_message['object_id'] : 'Not found' ) . self::$file_separator;
228
+			$message .= (!empty($array_message['object_id']) ? $array_message['object_id'] : 'Not found') . self::$file_separator;
229 229
 
230 230
 			// For post type
231
-			if(!empty($array_message['previous_element'])) {
231
+			if (!empty($array_message['previous_element'])) {
232 232
 				$message .= '"' . base64_encode(serialize($array_message['previous_element'])) . '"' . self::$file_separator;
233 233
 				$message .= '"' . base64_encode(serialize($array_message['previous_element_metas'])) . '"' . self::$file_separator;
234 234
 			}
235 235
 
236
-			if(!empty($array_message['message'])) {
236
+			if (!empty($array_message['message'])) {
237 237
 				$message .= '"' . $array_message['message'] . '"' . self::$file_separator;
238 238
 			}
239 239
 			$message .= $criticality . self::$file_separator . $name . self::$file_separator;
240 240
 
241
-			if ( !empty( $backtrace ) ) {
242
-				foreach ( $backtrace as $t ) {
243
-					$message .= ( !empty( $t['file'] ) ? $t['file'] : '' ) . ' line ' . ( !empty( $t['line'] ) ? $t['line'] : '' ) . ' function ' . $t['function'] . '()<br />';
241
+			if (!empty($backtrace)) {
242
+				foreach ($backtrace as $t) {
243
+					$message .= (!empty($t['file']) ? $t['file'] : '') . ' line ' . (!empty($t['line']) ? $t['line'] : '') . ' function ' . $t['function'] . '()<br />';
244 244
 				}
245 245
 			}
246 246
 
247
-			self::check_need_rotate( $service, $name . '-info', $message);
247
+			self::check_need_rotate($service, $name . '-info', $message);
248 248
 
249
-			$fp = fopen( $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '-info.csv', 'a');
249
+			$fp = fopen($upload_dir['basedir'] . '/wpeolog/' . $name . '-info.csv', 'a');
250 250
 			fwrite($fp, $message);
251 251
 			fclose($fp);
252 252
 
253
-			if( 2 <= $criticality ) {
254
-				self::check_need_rotate( $service, $name . '-error', $message);
253
+			if (2 <= $criticality) {
254
+				self::check_need_rotate($service, $name . '-error', $message);
255 255
 
256
-				$fp = fopen( $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '-error.csv', 'a');
256
+				$fp = fopen($upload_dir['basedir'] . '/wpeolog/' . $name . '-error.csv', 'a');
257 257
 				fwrite($fp, $message);
258 258
 				fclose($fp);
259 259
 			}
260
-			else if( 1 == $criticality ) {
261
-				self::check_need_rotate( $service, $name . '-warning', $message);
260
+			else if (1 == $criticality) {
261
+				self::check_need_rotate($service, $name . '-warning', $message);
262 262
 
263
-				$fp = fopen( $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '-warning.csv', 'a');
264
-				fwrite( $fp, $message );
265
-				fclose( $fp );
263
+				$fp = fopen($upload_dir['basedir'] . '/wpeolog/' . $name . '-warning.csv', 'a');
264
+				fwrite($fp, $message);
265
+				fclose($fp);
266 266
 			}
267 267
 		}
268 268
 
@@ -271,23 +271,23 @@  discard block
 block discarded – undo
271 271
 		*
272 272
 		* @param string $file_link The file path to write
273 273
 		*/
274
-		public static function check_need_rotate( $service, $name, $message ) {
274
+		public static function check_need_rotate($service, $name, $message) {
275 275
 			$upload_dir = wp_upload_dir();
276 276
 
277 277
 			$max_size = $service['size'];
278 278
 
279
-			$file_link = $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '.csv';
279
+			$file_link = $upload_dir['basedir'] . '/wpeolog/' . $name . '.csv';
280 280
 
281
-			if( file_exists( $file_link ) ) {
281
+			if (file_exists($file_link)) {
282 282
 				// Get full message
283
-				$message = file_get_contents( $file_link ) . $message;
283
+				$message = file_get_contents($file_link) . $message;
284 284
 
285
-				$file_size = filesize( $file_link );
285
+				$file_size = filesize($file_link);
286 286
 
287
-				if($file_size >= $max_size)
288
-					self::rename_current_file( $service, $name, $file_link );
289
-				else if(strlen($message) >= $max_size)
290
-					self::rename_current_file( $service, $name, $file_link );
287
+				if ($file_size >= $max_size)
288
+					self::rename_current_file($service, $name, $file_link);
289
+				else if (strlen($message) >= $max_size)
290
+					self::rename_current_file($service, $name, $file_link);
291 291
 
292 292
 				return $file_link;
293 293
 			}
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 		 * @param string $service
301 301
 		 * @param string $file_link
302 302
 		 */
303
-		public static function rename_current_file( $service, $name, $file_link ) {
303
+		public static function rename_current_file($service, $name, $file_link) {
304 304
 				$upload_dir = wp_upload_dir();
305 305
 
306 306
 				$number_archive = $service['number'];
307 307
 
308
-				if( file_exists ( $file_link ) ) {
308
+				if (file_exists($file_link)) {
309 309
 					$file_explode = explode('.csv', $file_link);
310 310
 					$get_all_file = glob($file_explode[0] . '*.csv');
311 311
 					array_shift($get_all_file);
312 312
 					arsort($get_all_file);
313 313
 
314
-					foreach($get_all_file as $full_file) {
314
+					foreach ($get_all_file as $full_file) {
315 315
 						$file = explode('/', $full_file);
316 316
 						$file_name = $file[count($file) - 1];
317 317
 						$file_name = explode('.', $file_name);
318 318
 
319 319
 						$file_name[0]++;
320
-						rename($full_file, $upload_dir[ 'basedir' ] . '/wpeolog/' . $file_name[0] . '.csv');
320
+						rename($full_file, $upload_dir['basedir'] . '/wpeolog/' . $file_name[0] . '.csv');
321 321
 
322 322
 						// Check if not execeed the number archive
323 323
 						$count = explode('_', $file_name[0]);
324 324
 
325
-						if($count[1] > $number_archive && file_exists($upload_dir[ 'basedir' ] . '/wpeolog/' . $file_name[0] . '.csv')) {
326
-							unlink($upload_dir[ 'basedir' ] . '/wpeolog/' . $file_name[0] . '.csv');
325
+						if ($count[1] > $number_archive && file_exists($upload_dir['basedir'] . '/wpeolog/' . $file_name[0] . '.csv')) {
326
+							unlink($upload_dir['basedir'] . '/wpeolog/' . $file_name[0] . '.csv');
327 327
 						}
328 328
 					}
329
-					rename( $file_link, $file_explode[0] . '_1.csv' );
329
+					rename($file_link, $file_explode[0] . '_1.csv');
330 330
 				}
331 331
 		}
332 332
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 		 * @param string $name Le nom du service
337 337
 		 * @return array | null
338 338
 		 */
339
-		public static function get_service_by_name( $name ) {
340
-			$array_service = get_option( '_wpeo_log_settings', array() );
339
+		public static function get_service_by_name($name) {
340
+			$array_service = get_option('_wpeo_log_settings', array());
341 341
 
342 342
 			$getted_service = null;
343 343
 
344
-			if ( !empty( $array_service ) ) {
345
-				$array_service = !is_array( $array_service ) ? json_decode( $array_service, true ) : $array_service;
344
+			if (!empty($array_service)) {
345
+				$array_service = !is_array($array_service) ? json_decode($array_service, true) : $array_service;
346 346
 
347
-				foreach ( $array_service as $service ) {
348
-					if( $service['name'] == $name ) {
347
+				foreach ($array_service as $service) {
348
+					if ($service['name'] == $name) {
349 349
 						$getted_service = $service;
350 350
 						break;
351 351
 					}
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 			return $getted_service;
356 356
 		}
357 357
 
358
-		public static function get_service_by_id( $id ) {
359
-			$array_service = get_option( '_wpeo_log_settings', array() );
358
+		public static function get_service_by_id($id) {
359
+			$array_service = get_option('_wpeo_log_settings', array());
360 360
 
361 361
 			$getted_service = null;
362 362
 
363
-			if ( !empty( $array_service ) ) {
364
-				$array_service = json_decode( $array_service, true );
363
+			if (!empty($array_service)) {
364
+				$array_service = json_decode($array_service, true);
365 365
 
366
-				foreach ( $array_service as $key => $service ) {
367
-					if( $key == $id ) {
366
+				foreach ($array_service as $key => $service) {
367
+					if ($key == $id) {
368 368
 						$getted_service = $service;
369 369
 						break;
370 370
 					}
@@ -384,19 +384,19 @@  discard block
 block discarded – undo
384 384
 		 * @return float|number
385 385
 		 */
386 386
 		function convert_to($input, $format, $convert = true) {
387
-			if($format == 'oc')
387
+			if ($format == 'oc')
388 388
 				return $input;
389 389
 
390 390
 			$multiple = 0;
391 391
 
392
-			if($format == 'ko')
392
+			if ($format == 'ko')
393 393
 				$multiple = 1024;
394
-			else if($format == 'mo')
394
+			else if ($format == 'mo')
395 395
 				$multiple = 1048576;
396
-			else if($format == 'go')
396
+			else if ($format == 'go')
397 397
 				$multiple = 1073741824;
398 398
 
399
-			if($convert)
399
+			if ($convert)
400 400
 				return $input * $multiple;
401 401
 			else
402 402
 				return $input / $multiple;
@@ -419,113 +419,113 @@  discard block
 block discarded – undo
419 419
 		 * @param string $name Le nom du service
420 420
 		 * @return void
421 421
 		 */
422
-		public static function add( $name ) {
422
+		public static function add($name) {
423 423
 			$data_service = array(
424 424
 					'active' 		=> true,
425
-					'name'			=> !empty( $name ) ? $name : 'new_log',
425
+					'name'			=> !empty($name) ? $name : 'new_log',
426 426
 					'size' 			=> '1000000',
427 427
 					'format' 		=> 'ko',
428 428
 					'rotate'		=> false,
429 429
 					'number' 		=> 0,
430
-					'created_date'	=> current_time( 'mysql' ),
430
+					'created_date'	=> current_time('mysql'),
431 431
 			);
432 432
 
433
-			$array_current_settings = get_option( '_wpeo_log_settings' );
434
-			if ( !empty( $array_current_settings ) ) {
435
-				$array_current_settings = json_decode( $array_current_settings, true );
433
+			$array_current_settings = get_option('_wpeo_log_settings');
434
+			if (!empty($array_current_settings)) {
435
+				$array_current_settings = json_decode($array_current_settings, true);
436 436
 			}
437 437
 			else {
438 438
 				$array_current_settings = array();
439 439
 			}
440 440
 
441 441
 			$array_current_settings[] = $data_service;
442
-			$success = update_option( '_wpeo_log_settings', json_encode( $array_current_settings ) );
442
+			$success = update_option('_wpeo_log_settings', json_encode($array_current_settings));
443 443
 
444
-			if ( $success ) {
445
-				set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( 'A new service has been created!', 'wpeolog-i18n' ) ) ) );
444
+			if ($success) {
445
+				set_transient('log_message', json_encode(array('type' => 'updated', 'message' => __('A new service has been created!', 'wpeolog-i18n'))));
446 446
 			}
447 447
 
448
-			if ( !empty( $name ) ) {
448
+			if (!empty($name)) {
449 449
 				return $data_service;
450 450
 			}
451 451
 			else {
452
-				wp_safe_redirect( wp_get_referer() );
452
+				wp_safe_redirect(wp_get_referer());
453 453
 				die();
454 454
 			}
455 455
 		}
456 456
 
457 457
 		public function edit_service() {
458
-			if ( empty( $_POST['service'] ) || !is_array( $_POST['service'] ) ) {
459
-				set_transient( 'log_message', json_encode( array( 'type' => 'error', 'message' => __( 'Invalid data to update service' ), 'wpeolog-i18n' ) ) );
460
-				wp_safe_redirect( wp_get_referer() );
458
+			if (empty($_POST['service']) || !is_array($_POST['service'])) {
459
+				set_transient('log_message', json_encode(array('type' => 'error', 'message' => __('Invalid data to update service'), 'wpeolog-i18n')));
460
+				wp_safe_redirect(wp_get_referer());
461 461
 				die();
462 462
 			}
463 463
 
464
-			foreach( $_POST['service'] as &$service ) {
464
+			foreach ($_POST['service'] as &$service) {
465 465
 				// sanitize
466
-				$service['active'] = sanitize_key( $service['active'] );
467
-				$service['name'] = sanitize_key( $service['name'] );
468
-				$service['format'] = sanitize_key( $service['format'] );
469
-				$service['rotate'] = sanitize_key( $service['rotate'] );
470
-				$service['number'] = ( int )$service['number'];
471
-				$service['size'] = ( int )$this->convert_to( $service['size'], $service['format'] );
466
+				$service['active'] = sanitize_key($service['active']);
467
+				$service['name'] = sanitize_key($service['name']);
468
+				$service['format'] = sanitize_key($service['format']);
469
+				$service['rotate'] = sanitize_key($service['rotate']);
470
+				$service['number'] = (int)$service['number'];
471
+				$service['size'] = (int)$this->convert_to($service['size'], $service['format']);
472 472
 			}
473 473
 
474
-			unset( $service );
474
+			unset($service);
475 475
 
476 476
 
477
-			$array_current_setting = get_option( '_wpeo_log_settings' );
478
-			$array_current_setting = json_decode( $array_current_setting, true );
477
+			$array_current_setting = get_option('_wpeo_log_settings');
478
+			$array_current_setting = json_decode($array_current_setting, true);
479 479
 
480
-			$array_current_setting = array_replace( $array_current_setting, $_POST['service'] );
480
+			$array_current_setting = array_replace($array_current_setting, $_POST['service']);
481 481
 
482
-			$success = update_option( '_wpeo_log_settings', json_encode( $array_current_setting ) );
482
+			$success = update_option('_wpeo_log_settings', json_encode($array_current_setting));
483 483
 
484 484
 
485
-			if( $success ) {
486
-				set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( 'The services has been updated!', 'wpeolog-i18n' ) ) ) );
485
+			if ($success) {
486
+				set_transient('log_message', json_encode(array('type' => 'updated', 'message' => __('The services has been updated!', 'wpeolog-i18n'))));
487 487
 			}
488 488
 
489
-			wp_safe_redirect( wp_get_referer() );
489
+			wp_safe_redirect(wp_get_referer());
490 490
 			die();
491 491
 		}
492 492
 
493 493
 		public function to_trash() {
494
-			if( empty( $_GET['_wpnonce'] ) ) {
495
-				wp_safe_redirect( wp_get_referer() );
494
+			if (empty($_GET['_wpnonce'])) {
495
+				wp_safe_redirect(wp_get_referer());
496 496
 				die();
497 497
 			}
498
-			$wpnonce = sanitize_text_field( $_GET['_wpnonce'] );
498
+			$wpnonce = sanitize_text_field($_GET['_wpnonce']);
499 499
 
500
-			if ( 0 === (int) $_GET['service_id'] ) {
501
-				wp_safe_redirect( wp_get_referer() );
500
+			if (0 === (int)$_GET['service_id']) {
501
+				wp_safe_redirect(wp_get_referer());
502 502
 				die();
503 503
 			}
504 504
 			else {
505
-				$service_id = (int) $_GET['service_id'];
505
+				$service_id = (int)$_GET['service_id'];
506 506
 			}
507 507
 
508
-			if ( !isset( $wpnonce ) || !wp_verify_nonce( $wpnonce, 'to_trash_' . $service_id ) ) {
509
-				wp_safe_redirect( wp_get_referer() );
508
+			if (!isset($wpnonce) || !wp_verify_nonce($wpnonce, 'to_trash_' . $service_id)) {
509
+				wp_safe_redirect(wp_get_referer());
510 510
 				die();
511 511
 			}
512 512
 
513
-			$array_current_setting = get_option( '_wpeo_log_settings' );
514
-			$array_current_setting = json_decode( $array_current_setting, true );
513
+			$array_current_setting = get_option('_wpeo_log_settings');
514
+			$array_current_setting = json_decode($array_current_setting, true);
515 515
 
516
-			if ( !empty( $array_current_setting[$service_id] ) ) {
517
-				unset( $array_current_setting[$service_id] );
518
-				$success = update_option( '_wpeo_log_settings', json_encode( $array_current_setting ) );
516
+			if (!empty($array_current_setting[$service_id])) {
517
+				unset($array_current_setting[$service_id]);
518
+				$success = update_option('_wpeo_log_settings', json_encode($array_current_setting));
519 519
 
520
-				if( $success ) {
521
-					set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( sprintf( 'The service %d has been deleted!', $service_id ), 'wpeolog-i18n' ) ) ) );
520
+				if ($success) {
521
+					set_transient('log_message', json_encode(array('type' => 'updated', 'message' => __(sprintf('The service %d has been deleted!', $service_id), 'wpeolog-i18n'))));
522 522
 				}
523 523
 			}
524 524
 			else {
525
-				set_transient( 'log_message', json_encode( array( 'type' => 'error', 'message' => __( sprintf( 'The service %d is invalid!', $service_id ), 'wpeolog-i18n' ) ) ) );
525
+				set_transient('log_message', json_encode(array('type' => 'error', 'message' => __(sprintf('The service %d is invalid!', $service_id), 'wpeolog-i18n'))));
526 526
 			}
527 527
 
528
-			wp_safe_redirect( wp_get_referer() );
528
+			wp_safe_redirect(wp_get_referer());
529 529
 			die();
530 530
 		}
531 531
 
@@ -539,22 +539,22 @@  discard block
 block discarded – undo
539 539
 			$upload_dir = wp_upload_dir();
540 540
 			$dir_file = $upload_dir['basedir'] . '/wpeolog/';
541 541
 
542
-			$file_name = sanitize_file_name( $_GET['file_name'] );
542
+			$file_name = sanitize_file_name($_GET['file_name']);
543 543
 
544
-			$success = unlink( $dir_file . $file_name );
545
-			if ( $success )
546
-				set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( 'The file has been deleted!', 'wpeolog-i18n' ) ) ) );
547
-			wp_safe_redirect( wp_get_referer() );
544
+			$success = unlink($dir_file . $file_name);
545
+			if ($success)
546
+				set_transient('log_message', json_encode(array('type' => 'updated', 'message' => __('The file has been deleted!', 'wpeolog-i18n'))));
547
+			wp_safe_redirect(wp_get_referer());
548 548
 			die();
549 549
 		}
550 550
 
551 551
 		public function transfert() {
552
-			$array_service = get_option( '_wpeo_log_settings' );
552
+			$array_service = get_option('_wpeo_log_settings');
553 553
 
554 554
 			$new_array_service = array();
555 555
 
556
-			if( !empty( $array_service['my_services'] ) && is_array( $array_service['my_services'] ) ) {
557
-			  foreach ( $array_service['my_services'] as $element ) {
556
+			if (!empty($array_service['my_services']) && is_array($array_service['my_services'])) {
557
+			  foreach ($array_service['my_services'] as $element) {
558 558
 					$new_array_service[] = array(
559 559
 						"active" => $element["service_active"] == 1 ? true : false,
560 560
 						"name" => $element["service_name"],
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
 						"format" => $element["service_size_format"],
563 563
 						"rotate" => $element["service_rotate"] == 1 ? true : false,
564 564
 						"number" => $element["service_file"],
565
-						"created_date" => current_time( "mysql" )
565
+						"created_date" => current_time("mysql")
566 566
 					);
567 567
 				}
568 568
 
569
-				update_option( '_wpeo_log_settings', json_encode( $new_array_service ) );
570
-				update_option( '_wpeo_log_old_settings', $array_service );
569
+				update_option('_wpeo_log_settings', json_encode($new_array_service));
570
+				update_option('_wpeo_log_old_settings', $array_service);
571 571
 			}
572 572
 		}
573 573
 	}
Please login to merge, or discard this patch.
Braces   +50 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /**
4 6
  * Main controller file for WP logs module
@@ -114,22 +116,29 @@  discard block
 block discarded – undo
114 116
 		}
115 117
 
116 118
 		private function check_page() {
117
-			if( empty( $_GET['action'] ) || empty( $_GET['type'] ) )
118
-				return false;
119
+			if( empty( $_GET['action'] ) || empty( $_GET['type'] ) ) {
120
+							return false;
121
+			}
119 122
 
120 123
 			$action = sanitize_text_field( $_GET['action'] );
121 124
 			$type = sanitize_text_field( !empty( $_GET['type'] ) ?  $_GET['type'] : '' );
122 125
 
123
-			if ( !isset( $_GET['service_id'] ) ) return false;
124
-			else $service_id = (int) $_GET['service_id'];
126
+			if ( !isset( $_GET['service_id'] ) ) {
127
+				return false;
128
+			} else {
129
+				$service_id = (int) $_GET['service_id'];
130
+			}
125 131
 
126
-			if ( isset( $_GET['key'] ) && 0 !== (int) $_GET['key'] ) $key = (int) $_GET['key'];
132
+			if ( isset( $_GET['key'] ) && 0 !== (int) $_GET['key'] ) {
133
+				$key = (int) $_GET['key'];
134
+			}
127 135
 
128 136
 			if ( 'view' == $action && isset( $service_id ) ) {
129 137
 				$service = self::get_service_by_id( $service_id );
130 138
 
131
-				if( $service == null )
132
-					return false;
139
+				if( $service == null ) {
140
+									return false;
141
+				}
133 142
 
134 143
 				$service_name = $service['name'];
135 144
 
@@ -174,8 +183,7 @@  discard block
 block discarded – undo
174 183
 				}
175 184
 
176 185
 				return array( 'data' => $file, 'count' => count( $file ) );
177
-			}
178
-			else {
186
+			} else {
179 187
 				return array( 'data' => null, 'count' => 0 );
180 188
 			}
181 189
 		}
@@ -217,8 +225,9 @@  discard block
 block discarded – undo
217 225
 
218 226
 			wp_mkdir_p( $upload_dir[ 'basedir' ] . '/wpeolog/' );
219 227
 
220
-			if( $service == null )
221
-				return null;
228
+			if( $service == null ) {
229
+							return null;
230
+			}
222 231
 
223 232
 			$message = "
224 233
 ";
@@ -256,8 +265,7 @@  discard block
 block discarded – undo
256 265
 				$fp = fopen( $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '-error.csv', 'a');
257 266
 				fwrite($fp, $message);
258 267
 				fclose($fp);
259
-			}
260
-			else if( 1 == $criticality ) {
268
+			} else if( 1 == $criticality ) {
261 269
 				self::check_need_rotate( $service, $name . '-warning', $message);
262 270
 
263 271
 				$fp = fopen( $upload_dir[ 'basedir' ] . '/wpeolog/' . $name . '-warning.csv', 'a');
@@ -284,10 +292,11 @@  discard block
 block discarded – undo
284 292
 
285 293
 				$file_size = filesize( $file_link );
286 294
 
287
-				if($file_size >= $max_size)
288
-					self::rename_current_file( $service, $name, $file_link );
289
-				else if(strlen($message) >= $max_size)
290
-					self::rename_current_file( $service, $name, $file_link );
295
+				if($file_size >= $max_size) {
296
+									self::rename_current_file( $service, $name, $file_link );
297
+				} else if(strlen($message) >= $max_size) {
298
+									self::rename_current_file( $service, $name, $file_link );
299
+				}
291 300
 
292 301
 				return $file_link;
293 302
 			}
@@ -384,22 +393,25 @@  discard block
 block discarded – undo
384 393
 		 * @return float|number
385 394
 		 */
386 395
 		function convert_to($input, $format, $convert = true) {
387
-			if($format == 'oc')
388
-				return $input;
396
+			if($format == 'oc') {
397
+							return $input;
398
+			}
389 399
 
390 400
 			$multiple = 0;
391 401
 
392
-			if($format == 'ko')
393
-				$multiple = 1024;
394
-			else if($format == 'mo')
395
-				$multiple = 1048576;
396
-			else if($format == 'go')
397
-				$multiple = 1073741824;
398
-
399
-			if($convert)
400
-				return $input * $multiple;
401
-			else
402
-				return $input / $multiple;
402
+			if($format == 'ko') {
403
+							$multiple = 1024;
404
+			} else if($format == 'mo') {
405
+							$multiple = 1048576;
406
+			} else if($format == 'go') {
407
+							$multiple = 1073741824;
408
+			}
409
+
410
+			if($convert) {
411
+							return $input * $multiple;
412
+			} else {
413
+							return $input / $multiple;
414
+			}
403 415
 		}
404 416
 
405 417
 		/**
@@ -433,8 +445,7 @@  discard block
 block discarded – undo
433 445
 			$array_current_settings = get_option( '_wpeo_log_settings' );
434 446
 			if ( !empty( $array_current_settings ) ) {
435 447
 				$array_current_settings = json_decode( $array_current_settings, true );
436
-			}
437
-			else {
448
+			} else {
438 449
 				$array_current_settings = array();
439 450
 			}
440 451
 
@@ -447,8 +458,7 @@  discard block
 block discarded – undo
447 458
 
448 459
 			if ( !empty( $name ) ) {
449 460
 				return $data_service;
450
-			}
451
-			else {
461
+			} else {
452 462
 				wp_safe_redirect( wp_get_referer() );
453 463
 				die();
454 464
 			}
@@ -500,8 +510,7 @@  discard block
 block discarded – undo
500 510
 			if ( 0 === (int) $_GET['service_id'] ) {
501 511
 				wp_safe_redirect( wp_get_referer() );
502 512
 				die();
503
-			}
504
-			else {
513
+			} else {
505 514
 				$service_id = (int) $_GET['service_id'];
506 515
 			}
507 516
 
@@ -520,8 +529,7 @@  discard block
 block discarded – undo
520 529
 				if( $success ) {
521 530
 					set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( sprintf( 'The service %d has been deleted!', $service_id ), 'wpeolog-i18n' ) ) ) );
522 531
 				}
523
-			}
524
-			else {
532
+			} else {
525 533
 				set_transient( 'log_message', json_encode( array( 'type' => 'error', 'message' => __( sprintf( 'The service %d is invalid!', $service_id ), 'wpeolog-i18n' ) ) ) );
526 534
 			}
527 535
 
@@ -542,8 +550,9 @@  discard block
 block discarded – undo
542 550
 			$file_name = sanitize_file_name( $_GET['file_name'] );
543 551
 
544 552
 			$success = unlink( $dir_file . $file_name );
545
-			if ( $success )
546
-				set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( 'The file has been deleted!', 'wpeolog-i18n' ) ) ) );
553
+			if ( $success ) {
554
+							set_transient( 'log_message', json_encode( array( 'type' => 'updated', 'message' => __( 'The file has been deleted!', 'wpeolog-i18n' ) ) ) );
555
+			}
547 556
 			wp_safe_redirect( wp_get_referer() );
548 557
 			die();
549 558
 		}
Please login to merge, or discard this patch.
core/wpeo_model/controller/term_ctr.01.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,6 @@
 block discarded – undo
156 156
 	/**
157 157
 	 * Retourne une liste de taxinomies selon les paramètres donnés / Return a taxonomy list according to given parameters
158 158
 	 *
159
-	 * @param array $args_where Optionnal Les paramètres du filtre permettant de récupérer les taxinomies / Parameters allowing to retrieve taxonomies
160 159
 	 * @param boolean $cropped Optionnal Permet de choisir si il faut retourner la taxinomie complète ou uniquement les chamsp principaux / Allow to define if the taxonomy must be completly returned or just main fileds must be returned
161 160
 	 *
162 161
 	 * @return array La liste des taxinomies correspondantes aux paramètres / Taxonomies corresping to parameters
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Fichier de gestion du modèle des taxinomies / File for term model management
4 4
  *
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function __construct() {
55 55
 		/**	Ajout des routes personnalisées pour les éléments de type "term" / Add specific routes for "term" elements' type	*/
56
-		add_filter( 'json_endpoints', array( &$this, 'callback_register_route' ) );
56
+		add_filter('json_endpoints', array(&$this, 'callback_register_route'));
57 57
 	}
58 58
 
59 59
 	/**
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return Object L'objet sauvegardé / The saved object
65 65
 	 */
66
-	public function update( $data ) {
66
+	public function update($data) {
67 67
 		$object = $data;
68 68
 
69 69
 		/**	Dans le cas d'un tableau on le lit pour construire l'objet / If passed data is an array read and build an object from it	*/
70
-		if( is_array( $data ) ) {
71
-			$object = new $this->model_name( $data, $this->meta_key );
70
+		if (is_array($data)) {
71
+			$object = new $this->model_name($data, $this->meta_key);
72 72
 		}
73 73
 
74 74
 		/**	Sauvegarde des données dans la base de données / Save data into database	*/
75
-		$wp_category_danger = wp_update_term( $object->id, $this->get_taxonomy(), $object->do_wp_object() );
76
-		if ( !is_wp_error( $wp_category_danger ) ) {
75
+		$wp_category_danger = wp_update_term($object->id, $this->get_taxonomy(), $object->do_wp_object());
76
+		if (!is_wp_error($wp_category_danger)) {
77 77
 			/** Mise à jour des options / Save options */
78
-			if( !empty( $object->option ) ) {
79
-				$object->save_meta_data( $object, 'update_term_meta', $this->meta_key );
78
+			if (!empty($object->option)) {
79
+				$object->save_meta_data($object, 'update_term_meta', $this->meta_key);
80 80
 			}
81 81
 		}
82 82
 
@@ -90,26 +90,26 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return Object L'objet sauvegardé / The saved object
92 92
 	 */
93
-	public function create( $data ) {
93
+	public function create($data) {
94 94
 		$object = $data;
95 95
 
96
-		if( is_array( $data ) ) {
97
-			$object = new $this->model_name( $data, $this->meta_key );
96
+		if (is_array($data)) {
97
+			$object = new $this->model_name($data, $this->meta_key);
98 98
 		}
99 99
 
100
-		$wp_category_danger = wp_insert_term( $object->name, $this->get_taxonomy(), array(
100
+		$wp_category_danger = wp_insert_term($object->name, $this->get_taxonomy(), array(
101 101
 			'description'	=> $object->description,
102 102
 			'slug'	=> $object->slug,
103 103
 			'parent'	=> $object->parent_id,
104
-		) );
104
+		));
105 105
 
106
-		if ( !is_wp_error( $wp_category_danger ) ) {
107
-			$object->id = $wp_category_danger[ 'term_id' ];
108
-			$object->term_taxonomy_id = $wp_category_danger[ 'term_taxonomy_id' ];
106
+		if (!is_wp_error($wp_category_danger)) {
107
+			$object->id = $wp_category_danger['term_id'];
108
+			$object->term_taxonomy_id = $wp_category_danger['term_taxonomy_id'];
109 109
 
110 110
 			/** Mise à jour des options / Save options */
111
-			if( !empty( $object->option ) ) {
112
-				$object->save_meta_data( $object, 'update_term_meta', $this->meta_key );
111
+			if (!empty($object->option)) {
112
+				$object->save_meta_data($object, 'update_term_meta', $this->meta_key);
113 113
 			}
114 114
 
115 115
 			return $object;
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @param integer $id L'identifiant de la taxinomie a supprimer / The taxonomy identifier to delete
129 129
 	 */
130
-	public function delete( $id ) {
131
-		wp_delete_term( $id );
130
+	public function delete($id) {
131
+		wp_delete_term($id);
132 132
 	}
133 133
 
134 134
 	/**
@@ -139,18 +139,18 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @return object la taxinomie construite selon le modèle / The taxonomy builded according to the model
141 141
 	 */
142
-	public function show( $id, $cropped = false ) {
142
+	public function show($id, $cropped = false) {
143 143
 		/**	Récupération de la taxinomie depuis wordpress / Get the taxonomy from wordpress	*/
144
- 		$wp_term = get_term_by( 'id', $id, $this->taxonomy, OBJECT );
144
+ 		$wp_term = get_term_by('id', $id, $this->taxonomy, OBJECT);
145 145
 
146 146
  		/**	Construction de la taxinomie selon le modèle défini / Build the taxonomy according to the model	*/
147
-		$term = new $this->model_name( $wp_term, $this->meta_key, $cropped );
147
+		$term = new $this->model_name($wp_term, $this->meta_key, $cropped);
148 148
 
149 149
 		return $term;
150 150
 	}
151 151
 
152 152
 	public function show_model() {
153
-			return _e( 'Try to get the model definition', 'term_ctr_mdl' );
153
+			return _e('Try to get the model definition', 'term_ctr_mdl');
154 154
 	}
155 155
 
156 156
 	/**
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return array La liste des taxinomies correspondantes aux paramètres / Taxonomies corresping to parameters
163 163
 	 */
164
-	public function index( $args = array(), $cropped = false ) {
164
+	public function index($args = array(), $cropped = false) {
165 165
 		$array_model = array();
166 166
 
167
-		$term_final_args = array_merge( $args, array( 'hide_empty' => false, ) );
168
-		$array_term = get_terms( $this->taxonomy, $term_final_args );
167
+		$term_final_args = array_merge($args, array('hide_empty' => false,));
168
+		$array_term = get_terms($this->taxonomy, $term_final_args);
169 169
 
170
-		if( !empty( $array_term ) ) {
171
-			foreach( $array_term as $key => $term ) {
172
-				$array_model[$key] = new $this->model_name( $term, $this->meta_key, $cropped );
170
+		if (!empty($array_term)) {
171
+			foreach ($array_term as $key => $term) {
172
+				$array_model[$key] = new $this->model_name($term, $this->meta_key, $cropped);
173 173
 			}
174 174
 		}
175 175
 
@@ -183,30 +183,30 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return array La liste des routes personnalisées ajoutées aux routes existantes / The personnalized routes added to existing
185 185
 	 */
186
-	public function callback_register_route( $array_route ) {
186
+	public function callback_register_route($array_route) {
187 187
 		/**	Récupération de la définition du model pour l'élément / Get model structure for element	*/
188
-		$array_route['/' . $this->version . '/show_model/' . $this->base ] = array(
189
-				array( array( $this, 'show_model' ), WP_JSON_Server::READABLE )
188
+		$array_route['/' . $this->version . '/show_model/' . $this->base] = array(
189
+				array(array($this, 'show_model'), WP_JSON_Server::READABLE)
190 190
 		);
191 191
 
192 192
 		/** Récupération de la liste complète des éléments / Get all existing elements */
193
-		$array_route['/' . $this->version . '/get/' . $this->base ] = array(
194
-				array( array( $this, 'index' ), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON )
193
+		$array_route['/' . $this->version . '/get/' . $this->base] = array(
194
+				array(array($this, 'index'), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON)
195 195
 		);
196 196
 
197 197
 		/** Récupération d'un élément donné / Get a given element */
198 198
 		$array_route['/' . $this->version . '/get/' . $this->base . '/(?P<id>\d+)'] = array(
199
-				array( array( $this, 'show' ), WP_JSON_Server::READABLE |  WP_JSON_Server::ACCEPT_JSON )
199
+				array(array($this, 'show'), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON)
200 200
 		);
201 201
 
202 202
 		/** Mise à jour d'un élément / Update an element */
203 203
 		$array_route['/' . $this->version . '/post/' . $this->base . ''] = array(
204
-				array( array( $this, 'update' ), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
204
+				array(array($this, 'update'), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON),
205 205
 		);
206 206
 
207 207
 		/** Suppression d'un élément / Delete an element */
208 208
 		$array_route['/' . $this->version . '/delete/' . $this->base . '/(?P<id>\d+)'] = array(
209
-				array( array( $this, 'delete' ), WP_JSON_Server::DELETABLE | WP_JSON_Server::ACCEPT_JSON ),
209
+				array(array($this, 'delete'), WP_JSON_Server::DELETABLE | WP_JSON_Server::ACCEPT_JSON),
210 210
 		);
211 211
 
212 212
 		return $array_route;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de gestion du modèle des taxinomies / File for term model management
4 6
  *
@@ -113,8 +115,7 @@  discard block
 block discarded – undo
113 115
 			}
114 116
 
115 117
 			return $object;
116
-		}
117
-		else {
118
+		} else {
118 119
 			/**
119 120
 			 * @todo return error when creation does not work
120 121
 			 */
Please login to merge, or discard this patch.
core/wps_utils/wps_utils.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 *	Return a variable with some basic treatment
96 96
 	 *
97 97
 	 *	@param mixed $varToSanitize The variable we want to treat for future use
98
-	 *	@param mixed $varDefaultValue The default value to set to the variable if the different test are not successfull
98
+	 *	@param string $varDefaultValue The default value to set to the variable if the different test are not successfull
99 99
 	 *	@param string $varType optionnal The type of the var for better verification
100 100
 	 *
101 101
 	 *	@return mixed $sanitizedVar The var after treatment
@@ -223,6 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * Return unit sigle
224 224
 	 * @param unknown_type $code
225 225
 	 * @param unknown_type $column_to_return
226
+	 * @return string
226 227
 	 */
227 228
 	public static function wpshop_get_sigle($code, $column_to_return = "unit") {
228 229
 		$tmp_code = (int)$code;
@@ -316,7 +317,7 @@  discard block
 block discarded – undo
316 317
 	 *	Transform a given text with a specific pattern, send by the second parameter
317 318
 	 *
318 319
 	 *	@param string $toSlugify The string we want to "clean" for future use
319
-	 *	@param array|string $slugifyType The type of cleaning we are going to do on the input text
320
+	 *	@param string[] $slugifyType The type of cleaning we are going to do on the input text
320 321
 	 *
321 322
 	 *	@return string $slugified The input string that was slugified with the selected method
322 323
 	 */
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Main controller file for product mass modification module
4 4
  *
@@ -28,56 +28,56 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return string The template file path to use
30 30
 	 */
31
-	public static function get_template_part( $plugin_dir_name, $main_template_dir, $side, $slug, $name=null, $debug = null ) {
31
+	public static function get_template_part($plugin_dir_name, $main_template_dir, $side, $slug, $name = null, $debug = null) {
32 32
 		$path = '';
33 33
 
34 34
 		$templates = array();
35 35
 		$name = (string)$name;
36
-		if ( '' !== $name )
36
+		if ('' !== $name)
37 37
 			$templates[] = "{$side}/{$slug}-{$name}.php";
38 38
 		$templates[] = "{$side}/{$slug}.php";
39 39
 
40 40
 		/**	Check if required template exists into current theme	*/
41 41
 		$check_theme_template = array();
42
-		foreach ( $templates as $template ) {
42
+		foreach ($templates as $template) {
43 43
 			$check_theme_template = $plugin_dir_name . "/" . $template;
44
-			$path = locate_template( $check_theme_template, false );
45
-			if( !empty($path) ) {
44
+			$path = locate_template($check_theme_template, false);
45
+			if (!empty($path)) {
46 46
 				break;
47 47
 			}
48 48
 		}
49 49
 
50 50
 		/**	Allow debugging	*/
51
-		if ( !empty( $debug ) ) {
51
+		if (!empty($debug)) {
52 52
 			echo '--- Debug mode ON - Start ---<br/>';
53 53
 			echo __FILE__ . '<br/>';
54 54
 			echo 'Debug for display method<br/>';
55 55
 			echo 'Asked path ' . $path . '<br/>';
56 56
 		}
57 57
 
58
-		if ( empty( $path ) ) {
59
-			foreach ( (array) $templates as $template_name ) {
60
-				if ( !$template_name )
58
+		if (empty($path)) {
59
+			foreach ((array)$templates as $template_name) {
60
+				if (!$template_name)
61 61
 					continue;
62 62
 
63
-				if ( !empty( $debug ) ) {
63
+				if (!empty($debug)) {
64 64
 					echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>';
65 65
 				}
66 66
 
67
-				$file_exists = file_exists( $main_template_dir . $template_name );
68
-				if ( $file_exists ) {
67
+				$file_exists = file_exists($main_template_dir . $template_name);
68
+				if ($file_exists) {
69 69
 					$path = $main_template_dir . $template_name;
70 70
 					break;
71 71
 				}
72 72
 
73
-				if ( !empty( $debug ) ) {
73
+				if (!empty($debug)) {
74 74
 					echo __LINE__ . ' - ' . (bool)$file_exists . '<hr/>';
75 75
 				}
76 76
 			}
77 77
 		}
78 78
 
79 79
 		/**	Allow debugging	*/
80
-		if ( !empty( $debug ) ) {
80
+		if (!empty($debug)) {
81 81
 			echo '--- Debug mode ON - END ---<br/><br/>';
82 82
 		}
83 83
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *	@return mixed $sanitizedVar The var after treatment
102 102
 	 */
103 103
 	public static function varSanitizer($varToSanitize, $varDefaultValue = '', $varType = '') {
104
-		$sanitizedVar = is_string( $varToSanitize ) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue ;
104
+		$sanitizedVar = is_string($varToSanitize) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue;
105 105
 
106 106
 		return $sanitizedVar;
107 107
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	public static function forceDownload($Fichier_a_telecharger, $delete_after_download = false) {
115 115
 
116 116
 		$nom_fichier = basename($Fichier_a_telecharger);
117
-		switch(strrchr($nom_fichier, ".")) {
117
+		switch (strrchr($nom_fichier, ".")) {
118 118
 			case ".gz": $type = "application/x-gzip"; break;
119 119
 			case ".tgz": $type = "application/x-gzip"; break;
120 120
 			case ".zip": $type = "application/zip"; break;
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 		header("Content-disposition: attachment; filename=$nom_fichier");
132 132
 		header("Content-Type: application/force-download");
133 133
 		header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n
134
-		header("Content-Length: ".filesize($Fichier_a_telecharger));
134
+		header("Content-Length: " . filesize($Fichier_a_telecharger));
135 135
 		header("Pragma: no-cache");
136 136
 		header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
137 137
 		header("Expires: 0");
138 138
 		ob_end_clean();
139 139
 		readfile($Fichier_a_telecharger);
140
-		if ( $delete_after_download ) {
141
-			unlink( $Fichier_a_telecharger );
140
+		if ($delete_after_download) {
141
+			unlink($Fichier_a_telecharger);
142 142
 		}
143 143
 		exit;
144 144
 	}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @return boolean
149 149
 	 */
150 150
 	public static function is_sendsms_actived() {
151
-		if(is_plugin_active('wordpress-send-sms/Send-SMS.php')) {
151
+		if (is_plugin_active('wordpress-send-sms/Send-SMS.php')) {
152 152
 			$configOption = get_option('sendsms_config', '');
153 153
 			$ligne = unserialize($configOption);
154 154
 			$nicOVH = $ligne['nicOVH'];
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param unknown_type $input
166 166
 	 * @return Ambigous <multitype:, multitype:multitype:unknown  >
167 167
 	 */
168
-	public static function search_all_possibilities( $input ) {
168
+	public static function search_all_possibilities($input) {
169 169
 		$result = array();
170 170
 
171 171
 		while (list($key, $values) = each($input)) {
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 			}
175 175
 
176 176
 			if (empty($result)) {
177
-				foreach($values as $value) {
177
+				foreach ($values as $value) {
178 178
 					$result[] = array($key => $value);
179 179
 				}
180 180
 			}
181 181
 			else {
182 182
 				$append = array();
183
-				foreach($result as &$product) {
183
+				foreach ($result as &$product) {
184 184
 					$product[$key] = array_shift($values);
185 185
 					$copy = $product;
186 186
 
187
-					foreach($values as $item) {
187
+					foreach ($values as $item) {
188 188
 						$copy[$key] = $item;
189 189
 						$append[] = $copy;
190 190
 					}
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	 * @param boolean $code : false return sigle, true return code (€ or EUR)
205 205
 	 * @return string currency code or sigle
206 206
 	 */
207
-	public static function wpshop_get_currency($code=false) {
207
+	public static function wpshop_get_currency($code = false) {
208 208
 		// Currency
209 209
 		global $wpdb;
210 210
 		$current_currency = get_option('wpshop_shop_default_currency');
211
-		$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
212
-		$currency_infos = $wpdb->get_row( $query );
213
-		if ( !empty($currency_infos) ) {
214
-			$code = ($code) ?  $currency_infos->name : $currency_infos->unit;
211
+		$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
212
+		$currency_infos = $wpdb->get_row($query);
213
+		if (!empty($currency_infos)) {
214
+			$code = ($code) ? $currency_infos->name : $currency_infos->unit;
215 215
 			return $code;
216 216
 		}
217 217
 		else {
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	public static function wpshop_get_sigle($code, $column_to_return = "unit") {
228 228
 		$tmp_code = (int)$code;
229 229
 		$key_to_get = 'name';
230
-		if ( is_int($tmp_code) && !empty($tmp_code) ) {
230
+		if (is_int($tmp_code) && !empty($tmp_code)) {
231 231
 			$key_to_get = 'id';
232 232
 		}
233 233
 		$old_way_currencies = unserialize(WPSHOP_SHOP_CURRENCIES);
234
-		if ( array_key_exists( $code, $old_way_currencies)) {
234
+		if (array_key_exists($code, $old_way_currencies)) {
235 235
 			$code = $old_way_currencies[$code];
236 236
 			$key_to_get = 'name';
237 237
 		}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * @param string $var : variable to clean
247 247
 	 * @return string
248 248
 	 */
249
-	public static function wpshop_clean( $var ) {
249
+	public static function wpshop_clean($var) {
250 250
 		return trim(strip_tags(stripslashes($var)));
251 251
 	}
252 252
 
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @param   string	phone number
256 256
 	 * @return  boolean
257 257
 	 */
258
-	public static function is_phone( $phone ) {
259
-		if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone)))>0) return false;
258
+	public static function is_phone($phone) {
259
+		if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone))) > 0) return false;
260 260
 		else return true;
261 261
 	}
262 262
 
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 *	@return string $type The form input type to use for the given field
279 279
 	 */
280
-	public static function defineFieldType($dataFieldType, $input_type, $frontend_verification){
280
+	public static function defineFieldType($dataFieldType, $input_type, $frontend_verification) {
281 281
 		$type = 'text';
282 282
 
283
-		if ( $dataFieldType == 'datetime' ) {
283
+		if ($dataFieldType == 'datetime') {
284 284
 			$type = 'text';
285 285
 		}
286 286
 		else {
287
-			switch ( $frontend_verification ) {
287
+			switch ($frontend_verification) {
288 288
 				case 'phone':
289 289
 					$type = 'tel';
290 290
 					break;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @return array The different element send by request method
306 306
 	 */
307
-	public static function getMethode(){
307
+	public static function getMethode() {
308 308
 		if ($_SERVER["REQUEST_METHOD"] == "GET")
309 309
 			return $_GET;
310 310
 		if ($_SERVER["REQUEST_METHOD"] == "POST")
@@ -320,36 +320,36 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 *	@return string $slugified The input string that was slugified with the selected method
322 322
 	 */
323
-	public static function slugify($toSlugify, $slugifyType){
323
+	public static function slugify($toSlugify, $slugifyType) {
324 324
 		$slugified = '';
325 325
 
326
-		if($toSlugify != '')
326
+		if ($toSlugify != '')
327 327
 		{
328 328
 			$slugified = $toSlugify;
329
-			foreach($slugifyType as $type)
329
+			foreach ($slugifyType as $type)
330 330
 			{
331
-				if($type == 'noAccent')
331
+				if ($type == 'noAccent')
332 332
 				{
333
-					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
334
-					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
333
+					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
334
+					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U", "e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
335 335
 				}
336
-				elseif($type == 'noSpaces')
336
+				elseif ($type == 'noSpaces')
337 337
 				{
338 338
 					$pattern = array('/\s/');
339 339
 					$rep_pat = array('_');
340 340
 					$slugified = trim($slugified);
341 341
 				}
342
-				elseif($type == 'lowerCase')
342
+				elseif ($type == 'lowerCase')
343 343
 				{
344 344
 					$slugified = strtolower($slugified);
345 345
 				}
346
-				elseif($type == 'noPunctuation')
346
+				elseif ($type == 'noPunctuation')
347 347
 				{
348 348
 					$pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//");
349 349
 					$rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_");
350 350
 				}
351 351
 
352
-				if(is_array($pattern) && is_array($rep_pat))
352
+				if (is_array($pattern) && is_array($rep_pat))
353 353
 				{
354 354
 					$slugified = preg_replace($pattern, $rep_pat, utf8_decode($slugified));
355 355
 				}
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
 	 *	@return string $string The output string that was trunk if necessary
369 369
 	 */
370 370
 	public static function trunk($string, $maxlength) {
371
-		if(strlen($string)>$maxlength+3)
372
-			return substr($string,0,$maxlength).'...';
371
+		if (strlen($string) > $maxlength + 3)
372
+			return substr($string, 0, $maxlength) . '...';
373 373
 		else return $string;
374 374
 	}
375 375
 
376 376
 	/**
377 377
 	 * Run a safe redirect in javascript
378 378
 	 */
379
-	public static function wpshop_safe_redirect($url='') {
380
-		$url = empty($url) ? admin_url('admin.php?page='.WPSHOP_URL_SLUG_DASHBOARD) : $url;
381
-		echo '<script type="text/javascript">window.top.location.href = "'.$url.'"</script>';
379
+	public static function wpshop_safe_redirect($url = '') {
380
+		$url = empty($url) ? admin_url('admin.php?page=' . WPSHOP_URL_SLUG_DASHBOARD) : $url;
381
+		echo '<script type="text/javascript">window.top.location.href = "' . $url . '"</script>';
382 382
 		exit;
383 383
 	}
384 384
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 * @param array $args : Hook arguments
389 389
 	 * @return string
390 390
 	 */
391
-	public static function create_custom_hook ($hook_name, $args = '') {
391
+	public static function create_custom_hook($hook_name, $args = '') {
392 392
 		ob_start();
393
-		if ( !empty($args) ) {
393
+		if (!empty($args)) {
394 394
 			do_action($hook_name, $args);
395 395
 		}
396 396
 		else {
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
 	 */
410 410
 	public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) {
411 411
 		$code = '';
412
-		if ( !function_exists( 'get_plugin_data') )
413
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
414
-		$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
412
+		if (!function_exists('get_plugin_data'))
413
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
414
+		$plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php');
415 415
 		$code_part = array();
416
-		$code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5);
417
-		$code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5);
418
-		$code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5);
416
+		$code_part[] = substr(hash("sha256", $plugin_name), WPSHOP_ADDONS_KEY_IS, 5);
417
+		$code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5);
418
+		$code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5);
419 419
 		$code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0];
420 420
 		$att = $encrypt_base_attribute;
421
-		$code .= '-' . substr(hash ( "sha256" , $att ),  WPSHOP_ADDONS_KEY_IS, 5);
421
+		$code .= '-' . substr(hash("sha256", $att), WPSHOP_ADDONS_KEY_IS, 5);
422 422
 
423 423
 		return $code;
424 424
 	}
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
 	 * @param string $encrypt_base_attribute
430 430
 	 * @return boolean
431 431
 	 */
432
-	public static function check_plugin_activation_code( $plugin_name, $encrypt_base_attribute, $from = 'file') {
432
+	public static function check_plugin_activation_code($plugin_name, $encrypt_base_attribute, $from = 'file') {
433 433
 		$is_valid = false;
434 434
 		$valid_activation_code = self::get_plugin_validation_code($plugin_name, $encrypt_base_attribute);
435
-		$activation_code_filename = WP_PLUGIN_DIR .'/'. $plugin_name.'/encoder.txt';
436
-		if ( is_file($activation_code_filename) ) {
437
-			$activation_code_file = fopen($activation_code_filename, 'r' );
438
-			if ( $activation_code_file !== false) {
439
-				$activation_code = fread( $activation_code_file, filesize($activation_code_filename));
440
-				if ( $activation_code == $valid_activation_code ) {
435
+		$activation_code_filename = WP_PLUGIN_DIR . '/' . $plugin_name . '/encoder.txt';
436
+		if (is_file($activation_code_filename)) {
437
+			$activation_code_file = fopen($activation_code_filename, 'r');
438
+			if ($activation_code_file !== false) {
439
+				$activation_code = fread($activation_code_file, filesize($activation_code_filename));
440
+				if ($activation_code == $valid_activation_code) {
441 441
 					$is_valid = true;
442 442
 				}
443 443
 			}
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 	 * @param unknown_type $number
451 451
 	 * @return string
452 452
 	 */
453
-	public static function formate_number( $number ) {
454
-		$number = number_format( $number, 2, '.', '' );
455
-		$exploded_number = explode( '.', $number );
453
+	public static function formate_number($number) {
454
+		$number = number_format($number, 2, '.', '');
455
+		$exploded_number = explode('.', $number);
456 456
 		$number = $exploded_number[0];
457
-		if( $exploded_number[1] != '00' ) {
458
-			$number .= '<span class="wps_number_cents">,' . $exploded_number[1]. '</span>';
457
+		if ($exploded_number[1] != '00') {
458
+			$number .= '<span class="wps_number_cents">,' . $exploded_number[1] . '</span>';
459 459
 		}
460 460
 		return $number;
461 461
 	}
@@ -465,12 +465,12 @@  discard block
 block discarded – undo
465 465
 	 * @param int $page_id
466 466
 	 * @return int
467 467
 	 */
468
-	public static function get_page_id( $page_id ) {
469
-		if( !empty($page_id) ) {
470
-			if ( function_exists( 'icl_object_id' ) && defined('ICL_LANGUAGE_CODE') ) {
471
-				$element_post_type = get_post_type( $page_id );
472
-				$translated_element_id = icl_object_id( $page_id, $element_post_type, true, ICL_LANGUAGE_CODE );
473
-				if( !empty($translated_element_id) ) {
468
+	public static function get_page_id($page_id) {
469
+		if (!empty($page_id)) {
470
+			if (function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE')) {
471
+				$element_post_type = get_post_type($page_id);
472
+				$translated_element_id = icl_object_id($page_id, $element_post_type, true, ICL_LANGUAGE_CODE);
473
+				if (!empty($translated_element_id)) {
474 474
 					$page_id = $translated_element_id;
475 475
 				}
476 476
 			}
Please login to merge, or discard this patch.
Braces   +40 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Main controller file for product mass modification module
4 6
  *
@@ -33,8 +35,9 @@  discard block
 block discarded – undo
33 35
 
34 36
 		$templates = array();
35 37
 		$name = (string)$name;
36
-		if ( '' !== $name )
37
-			$templates[] = "{$side}/{$slug}-{$name}.php";
38
+		if ( '' !== $name ) {
39
+					$templates[] = "{$side}/{$slug}-{$name}.php";
40
+		}
38 41
 		$templates[] = "{$side}/{$slug}.php";
39 42
 
40 43
 		/**	Check if required template exists into current theme	*/
@@ -57,8 +60,9 @@  discard block
 block discarded – undo
57 60
 
58 61
 		if ( empty( $path ) ) {
59 62
 			foreach ( (array) $templates as $template_name ) {
60
-				if ( !$template_name )
61
-					continue;
63
+				if ( !$template_name ) {
64
+									continue;
65
+				}
62 66
 
63 67
 				if ( !empty( $debug ) ) {
64 68
 					echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>';
@@ -177,8 +181,7 @@  discard block
 block discarded – undo
177 181
 				foreach($values as $value) {
178 182
 					$result[] = array($key => $value);
179 183
 				}
180
-			}
181
-			else {
184
+			} else {
182 185
 				$append = array();
183 186
 				foreach($result as &$product) {
184 187
 					$product[$key] = array_shift($values);
@@ -213,8 +216,7 @@  discard block
 block discarded – undo
213 216
 		if ( !empty($currency_infos) ) {
214 217
 			$code = ($code) ?  $currency_infos->name : $currency_infos->unit;
215 218
 			return $code;
216
-		}
217
-		else {
219
+		} else {
218 220
 			return '';
219 221
 		}
220 222
 	}
@@ -256,8 +258,11 @@  discard block
 block discarded – undo
256 258
 	 * @return  boolean
257 259
 	 */
258 260
 	public static function is_phone( $phone ) {
259
-		if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone)))>0) return false;
260
-		else return true;
261
+		if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone)))>0) {
262
+			return false;
263
+		} else {
264
+			return true;
265
+		}
261 266
 	}
262 267
 
263 268
 	/**
@@ -266,8 +271,11 @@  discard block
 block discarded – undo
266 271
 	 * @return  boolean
267 272
 	 */
268 273
 	public static function is_postcode($postcode) {
269
-		if (strlen(trim(preg_replace('/[\s\-A-Za-z0-9]/', '', $postcode))) > 0) return false;
270
-		else return true;
274
+		if (strlen(trim(preg_replace('/[\s\-A-Za-z0-9]/', '', $postcode))) > 0) {
275
+			return false;
276
+		} else {
277
+			return true;
278
+		}
271 279
 	}
272 280
 
273 281
 	/**
@@ -282,8 +290,7 @@  discard block
 block discarded – undo
282 290
 
283 291
 		if ( $dataFieldType == 'datetime' ) {
284 292
 			$type = 'text';
285
-		}
286
-		else {
293
+		} else {
287 294
 			switch ( $frontend_verification ) {
288 295
 				case 'phone':
289 296
 					$type = 'tel';
@@ -305,10 +312,12 @@  discard block
 block discarded – undo
305 312
 	 * @return array The different element send by request method
306 313
 	 */
307 314
 	public static function getMethode(){
308
-		if ($_SERVER["REQUEST_METHOD"] == "GET")
309
-			return $_GET;
310
-		if ($_SERVER["REQUEST_METHOD"] == "POST")
311
-			return $_POST;
315
+		if ($_SERVER["REQUEST_METHOD"] == "GET") {
316
+					return $_GET;
317
+		}
318
+		if ($_SERVER["REQUEST_METHOD"] == "POST") {
319
+					return $_POST;
320
+		}
312 321
 		die ('Invalid REQUEST_METHOD (not GET, not POST).');
313 322
 	}
314 323
 
@@ -332,18 +341,15 @@  discard block
 block discarded – undo
332 341
 				{
333 342
 					$pattern = array("/&eacute;/", "/&egrave;/", "/&ecirc;/", "/&ccedil;/", "/&agrave;/", "/&acirc;/", "/&icirc;/", "/&iuml;/", "/&ucirc;/", "/&ocirc;/", "/&Egrave;/", "/&Eacute;/", "/&Ecirc;/", "/&Euml;/", "/&Igrave;/", "/&Iacute;/", "/&Icirc;/", "/&Iuml;/", "/&Ouml;/", "/&Ugrave;/", "/&Ucirc;/", "/&Uuml;/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/");
334 343
 					$rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U");
335
-				}
336
-				elseif($type == 'noSpaces')
344
+				} elseif($type == 'noSpaces')
337 345
 				{
338 346
 					$pattern = array('/\s/');
339 347
 					$rep_pat = array('_');
340 348
 					$slugified = trim($slugified);
341
-				}
342
-				elseif($type == 'lowerCase')
349
+				} elseif($type == 'lowerCase')
343 350
 				{
344 351
 					$slugified = strtolower($slugified);
345
-				}
346
-				elseif($type == 'noPunctuation')
352
+				} elseif($type == 'noPunctuation')
347 353
 				{
348 354
 					$pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//");
349 355
 					$rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_");
@@ -368,9 +374,11 @@  discard block
 block discarded – undo
368 374
 	 *	@return string $string The output string that was trunk if necessary
369 375
 	 */
370 376
 	public static function trunk($string, $maxlength) {
371
-		if(strlen($string)>$maxlength+3)
372
-			return substr($string,0,$maxlength).'...';
373
-		else return $string;
377
+		if(strlen($string)>$maxlength+3) {
378
+					return substr($string,0,$maxlength).'...';
379
+		} else {
380
+			return $string;
381
+		}
374 382
 	}
375 383
 
376 384
 	/**
@@ -392,8 +400,7 @@  discard block
 block discarded – undo
392 400
 		ob_start();
393 401
 		if ( !empty($args) ) {
394 402
 			do_action($hook_name, $args);
395
-		}
396
-		else {
403
+		} else {
397 404
 			do_action($hook_name);
398 405
 		}
399 406
 		$content = ob_get_contents();
@@ -409,8 +416,9 @@  discard block
 block discarded – undo
409 416
 	 */
410 417
 	public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) {
411 418
 		$code = '';
412
-		if ( !function_exists( 'get_plugin_data') )
413
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
419
+		if ( !function_exists( 'get_plugin_data') ) {
420
+					require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
421
+		}
414 422
 		$plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' );
415 423
 		$code_part = array();
416 424
 		$code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5);
Please login to merge, or discard this patch.
includes/librairies/catalog/categories.class.php 4 patches
Doc Comments   +2 added lines, -6 removed lines patch added patch discarded remove patch
@@ -117,10 +117,7 @@  discard block
 block discarded – undo
117 117
 	/**
118 118
 	*	Get the sub categories of a given category
119 119
 	*
120
-	*	@param integer $parent_category The main category we want to have the sub categories for
121
-	*	@param array $instance The current instance of the widget, allows to get the different selected parameters
122
-	*
123
-	* @return mixed $widget_content The widget content build from option
120
+	* @return string
124 121
 	*/
125 122
 	public static function category_tree_output($category_id = 0, $instance) {
126 123
 		global $category_has_sub_category;
@@ -285,7 +282,7 @@  discard block
 block discarded – undo
285 282
 	*	@param object $category The category definition
286 283
 	*	@param string $output_type The output type defined from plugin option
287 284
 	*
288
-	*	@return mixed $content Output the category list
285
+	*	@return string $content Output the category list
289 286
 	*/
290 287
 	public static function category_mini_output($category, $output_type = 'list'){
291 288
 		$content = '';
@@ -420,7 +417,6 @@  discard block
 block discarded – undo
420 417
 	 * @see wp_get_attachment_image_src
421 418
 	 * @param unknown_type $id
422 419
 	 * @param unknown_type $size
423
-	 * @param unknown_type $attr
424 420
 	 * @return (string or array)
425 421
 	 */
426 422
 	public static function get_the_category_thumbnail($id, $size = 'thumbnail', $icon = false) {
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 class wpshop_categories
25 25
 {
26 26
 	/**
27
-	* Retourne une liste de cat�gorie
28
-	* @param boolean $formated : formatage du r�sultat oui/non
29
-	* @param string $product_search : recherche demand�e
30
-	* @return mixed
31
-	**/
27
+	 * Retourne une liste de cat�gorie
28
+	 * @param boolean $formated : formatage du r�sultat oui/non
29
+	 * @param string $product_search : recherche demand�e
30
+	 * @return mixed
31
+	 **/
32 32
 	function product_list_cats($formated=false, $product_search=null) {
33 33
 		$where  = array('hide_empty' => false);
34 34
 		if(!empty($product_search))
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	/**
57
-	*	Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy)
58
-	*/
57
+	 *	Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy)
58
+	 */
59 59
 	public static function create_product_categories(){
60 60
 		$options = get_option('wpshop_catalog_categories_option', null);
61 61
 		$slug = array(
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	/**
91
-	*	Build a complete tree with the categories. Contains the complete tree for a given category and a children list for easy checking
92
-	*
93
-	*	@param integer $category_id The category identifier we want to get the tree element for
94
-	*
95
-	*	@return array $categories_list An array ordered by category with its children
96
-	*/
91
+	 *	Build a complete tree with the categories. Contains the complete tree for a given category and a children list for easy checking
92
+	 *
93
+	 *	@param integer $category_id The category identifier we want to get the tree element for
94
+	 *
95
+	 *	@return array $categories_list An array ordered by category with its children
96
+	 */
97 97
 	public static function category_tree($category_id = 0){
98 98
 		$categories_list = array();
99 99
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 		return $categories_list;
116 116
 	}
117 117
 	/**
118
-	*	Get the sub categories of a given category
119
-	*
120
-	*	@param integer $parent_category The main category we want to have the sub categories for
121
-	*	@param array $instance The current instance of the widget, allows to get the different selected parameters
122
-	*
123
-	* @return mixed $widget_content The widget content build from option
124
-	*/
118
+	 *	Get the sub categories of a given category
119
+	 *
120
+	 *	@param integer $parent_category The main category we want to have the sub categories for
121
+	 *	@param array $instance The current instance of the widget, allows to get the different selected parameters
122
+	 *
123
+	 * @return mixed $widget_content The widget content build from option
124
+	 */
125 125
 	public static function category_tree_output($category_id = 0, $instance) {
126 126
 		global $category_has_sub_category;
127 127
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 
149 149
 
150 150
 	/**
151
-	*	Add additionnal fields to the category edition form
152
-	*/
151
+	 *	Add additionnal fields to the category edition form
152
+	 */
153 153
 	public static function category_edit_fields(){
154 154
 		$category_id = wpshop_tools::varSanitizer($_REQUEST["tag_ID"]);
155 155
 		$category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 	}
211 211
 
212 212
 	/**
213
-	*	Save the different extra fields added for the plugin
214
-	*
215
-	*	@param integer $category_id The category identifier we want to save extra fields for
216
-	*	@param mixed $tt_id
217
-	*
218
-	*	@return void
219
-	*/
213
+	 *	Save the different extra fields added for the plugin
214
+	 *
215
+	 *	@param integer $category_id The category identifier we want to save extra fields for
216
+	 *	@param mixed $tt_id
217
+	 *
218
+	 *	@return void
219
+	 */
220 220
 	public static function category_fields_saver($category_id, $tt_id){
221 221
 		global $wpdb;
222 222
 		$category_meta = array();
@@ -241,28 +241,28 @@  discard block
 block discarded – undo
241 241
 	}
242 242
 
243 243
 	/**
244
-	*	Add extra column to categories listing interface
245
-	*
246
-	*	@param array $columns Actual columns to add extra columns to
247
-	*
248
-	*	@return array $columns The new array with additionnal colu
249
-	*/
244
+	 *	Add extra column to categories listing interface
245
+	 *
246
+	 *	@param array $columns Actual columns to add extra columns to
247
+	 *
248
+	 *	@return array $columns The new array with additionnal colu
249
+	 */
250 250
 	public static function category_manage_columns($columns){
251
-	    unset( $columns["cb"] );
251
+		unset( $columns["cb"] );
252 252
 
253
-	    $custom_array = array(
253
+		$custom_array = array(
254 254
 				'cb' => '<input type="checkbox" />',
255 255
 				'wpshop_category_thumbnail' => __('Thumbnail', 'wpshop')
256
-	    );
256
+		);
257 257
 
258
-	    $columns = array_merge( $custom_array, $columns );
258
+		$columns = array_merge( $custom_array, $columns );
259 259
 
260
-	    return $columns;
260
+		return $columns;
261 261
 	}
262 262
 
263 263
 	/**
264
-	*	Define the content of extra columns to add to categories listing interface
265
-	*/
264
+	 *	Define the content of extra columns to add to categories listing interface
265
+	 */
266 266
 	public static function category_manage_columns_content($string, $column_name, $category_id){
267 267
 		$category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
268 268
 		$category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />';
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
 		$name = $category->name;
276 276
 
277 277
 		$image = $category_thumbnail_preview;
278
-    	return $image;
278
+		return $image;
279 279
 	}
280 280
 
281 281
 
282 282
 	/**
283
-	*	Display a category in a list
284
-	*
285
-	*	@param object $category The category definition
286
-	*	@param string $output_type The output type defined from plugin option
287
-	*
288
-	*	@return mixed $content Output the category list
289
-	*/
283
+	 *	Display a category in a list
284
+	 *
285
+	 *	@param object $category The category definition
286
+	 *	@param string $output_type The output type defined from plugin option
287
+	 *
288
+	 *	@return mixed $content Output the category list
289
+	 */
290 290
 	public static function category_mini_output($category, $output_type = 'list'){
291 291
 		$content = '';
292 292
 		/*	Get the different informations for output	*/
@@ -347,10 +347,10 @@  discard block
 block discarded – undo
347 347
 	}
348 348
 
349 349
 	/**
350
-	* Traduit le shortcode et affiche une cat�gorie
351
-	* @param array $atts : tableau de param�tre du shortcode
352
-	* @return mixed
353
-	**/
350
+	 * Traduit le shortcode et affiche une cat�gorie
351
+	 * @param array $atts : tableau de param�tre du shortcode
352
+	 * @return mixed
353
+	 **/
354 354
 	public static function wpshop_category_func($atts) {
355 355
 		global $wpdb;
356 356
 		$string = '';
Please login to merge, or discard this patch.
Braces   +19 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
 * Products management method file
4 6
 *
@@ -31,8 +33,9 @@  discard block
 block discarded – undo
31 33
 	**/
32 34
 	function product_list_cats($formated=false, $product_search=null) {
33 35
 		$where  = array('hide_empty' => false);
34
-		if(!empty($product_search))
35
-			$where = array_merge($where, array('name__like'=>$product_search));
36
+		if(!empty($product_search)) {
37
+					$where = array_merge($where, array('name__like'=>$product_search));
38
+		}
36 39
 
37 40
 		$data = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, $where);
38 41
 		$cats=array();
@@ -137,8 +140,7 @@  discard block
 block discarded – undo
137 140
 					ob_end_clean();
138 141
 				}
139 142
 				$category_has_sub_category = true;
140
-			}
141
-			else{
143
+			} else{
142 144
 				$category_has_sub_category = false;
143 145
 			}
144 146
 		}
@@ -188,8 +190,7 @@  discard block
 block discarded – undo
188 190
 									$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] =  __($product_attribute->frontend_label, 'wpshop');
189 191
 									if ( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes']) ) {
190 192
 										$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = 'checked="checked"';
191
-									}
192
-									else {
193
+									} else {
193 194
 										$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = '';
194 195
 									}
195 196
 
@@ -201,8 +202,7 @@  discard block
 block discarded – undo
201 202
 					}
202 203
 				}
203 204
 			}
204
-		 }
205
-		 else {
205
+		 } else {
206 206
 		 	$tpl_component['CATEGORY_TAG_ID'] = 1;
207 207
 		 }
208 208
 		 $output = wpshop_display::display_template_element('wpshop_category_edit_interface_admin', $tpl_component, array(), 'admin');
@@ -229,8 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
 		if ( !empty($_POST['filterable_attribute_for_category']) && is_array($_POST['filterable_attribute_for_category']) ) {
231 231
 			$category_option['wpshop_category_filterable_attributes'] = $_POST['filterable_attribute_for_category'];
232
-		}
233
-		else {
232
+		} else {
234 233
 			$category_option['wpshop_category_filterable_attributes'] = array();
235 234
 		}
236 235
 		update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id, $category_option);
@@ -336,8 +335,7 @@  discard block
 block discarded – undo
336 335
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
337 336
 			$content = ob_get_contents();
338 337
 			ob_end_clean();
339
-		}
340
-		else {
338
+		} else {
341 339
 			//echo $template_part.'-'.$tpl_component.'<br>';
342 340
 			$content = wpshop_display::display_template_element($template_part, $tpl_component);
343 341
 		}
@@ -368,8 +366,7 @@  discard block
 block discarded – undo
368 366
 					}
369 367
 				$string .= '
370 368
 					</div>';
371
-			}
372
-			else {
369
+			} else {
373 370
 				$sub_category_def = get_term($atts['cid'], WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
374 371
 
375 372
 				if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){
@@ -385,8 +382,7 @@  discard block
 block discarded – undo
385 382
 					$string .= '</div>';
386 383
 				}
387 384
 			}
388
-		}
389
-		else {
385
+		} else {
390 386
 			$string .= __('No categories found for display', 'wpshop');
391 387
 		}
392 388
 
@@ -428,8 +424,9 @@  discard block
 block discarded – undo
428 424
 		$array_option_category 	= get_option('wpshop_product_category_' . $id);
429 425
 		
430 426
 		/** If not attachment/post ID in the category, return "No thumbnail in the category" */
431
-		if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture']))
432
-			return __('No thumbnail in the category', 'wpshop');
427
+		if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture'])) {
428
+					return __('No thumbnail in the category', 'wpshop');
429
+		}
433 430
 		
434 431
 		/** Set attachment/post ID in $id_picture */
435 432
 		$id_picture = $array_option_category['wpshop_category_picture'];
@@ -440,8 +437,9 @@  discard block
 block discarded – undo
440 437
 		 */
441 438
 		$post_thumbnail = wp_get_attachment_image_src($id_picture, $size, $icon);
442 439
 		
443
-		if(!$post_thumbnail)
444
-			return __('No thumbnail in this post', 'wpshop');
440
+		if(!$post_thumbnail) {
441
+					return __('No thumbnail in this post', 'wpshop');
442
+		}
445 443
 			
446 444
 		return $post_thumbnail;
447 445
 	}
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 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
 * Products management method file
4 4
 *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -29,51 +29,51 @@  discard block
 block discarded – undo
29 29
 	* @param string $product_search : recherche demand�e
30 30
 	* @return mixed
31 31
 	**/
32
-	function product_list_cats($formated=false, $product_search=null) {
32
+	function product_list_cats($formated = false, $product_search = null) {
33 33
 		$where  = array('hide_empty' => false);
34
-		if(!empty($product_search))
34
+		if (!empty($product_search))
35 35
 			$where = array_merge($where, array('name__like'=>$product_search));
36 36
 
37 37
 		$data = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, $where);
38
-		$cats=array();
39
-		foreach($data as $d){
38
+		$cats = array();
39
+		foreach ($data as $d) {
40 40
 			$cats[$d->term_id] = $d->name;
41 41
 		}
42 42
 
43 43
 		// Si le formatage est demand�
44
-		if($formated) {
45
-			if(!empty($cats)):
46
-				$cats_string='';
47
-				foreach($cats as $key=>$value) {
48
-					$cats_string.= '
49
-					<li><input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_categories" value="'.$key.'" id="'.WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES.'-'.$key.'" name="cats[]" /><label for="'.WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES.'-'.$key.'" > '.$value.'</label></li>';
44
+		if ($formated) {
45
+			if (!empty($cats)):
46
+				$cats_string = '';
47
+				foreach ($cats as $key=>$value) {
48
+					$cats_string .= '
49
+					<li><input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_categories" value="'.$key . '" id="' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '-' . $key . '" name="cats[]" /><label for="' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '-' . $key . '" > ' . $value . '</label></li>';
50 50
 				}
51 51
 			endif;
52 52
 		}
53
-		return $formated?$cats_string:$cats;
53
+		return $formated ? $cats_string : $cats;
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	*	Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy)
58 58
 	*/
59
-	public static function create_product_categories(){
59
+	public static function create_product_categories() {
60 60
 		$options = get_option('wpshop_catalog_categories_option', null);
61 61
 		$slug = array(
62 62
 				'slug' => '',
63 63
 				'with_front' => true,
64 64
 				'hierarchical' => true,
65 65
 		);
66
-		( empty($options['wpshop_catalog_categories_slug']) || $options['wpshop_catalog_categories_slug'] == '/' ) ? $slug = false : $slug['slug'] = $options['wpshop_catalog_categories_slug'];
66
+		(empty($options['wpshop_catalog_categories_slug']) || $options['wpshop_catalog_categories_slug'] == '/') ? $slug = false : $slug['slug'] = $options['wpshop_catalog_categories_slug'];
67 67
 		register_taxonomy(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), array(
68 68
 			'labels' => array(
69 69
 				'name' => __('WPshop categories', 'wpshop'),
70 70
 				'singular_name' => __('WPshop category', 'wpshop'),
71 71
 				'add_new_item' => __('Add new wpshop category', 'wpshop'),
72
-				'add_new' => _x( 'Add new', 'admin menu: add new wpshop category', 'wpshop'),
72
+				'add_new' => _x('Add new', 'admin menu: add new wpshop category', 'wpshop'),
73 73
 				'add_new_item' => __('Add new wpshop category', 'wpshop'),
74 74
 				'edit_item' => __('Edit wpshop category', 'wpshop'),
75 75
 				'new_item' => __('New wpshop category', 'wpshop'),
76
-				'view_item' => __('View wpshop category', 'wpshop' ),
76
+				'view_item' => __('View wpshop category', 'wpshop'),
77 77
 				'search_items' => __('Search wpshop categories', 'wpshop'),
78 78
 				'not_found' =>  __('No wpshop categories found', 'wpshop'),
79 79
 				'not_found_in_trash' => __('No wpshop categories found in trash', 'wpshop'),
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
 	*
95 95
 	*	@return array $categories_list An array ordered by category with its children
96 96
 	*/
97
-	public static function category_tree($category_id = 0){
97
+	public static function category_tree($category_id = 0) {
98 98
 		$categories_list = array();
99 99
 
100 100
 		$categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, 'hide_empty=0&parent=' . $category_id);
101
-		if(count($categories) > 0){
102
-			foreach($categories as $category){
101
+		if (count($categories) > 0) {
102
+			foreach ($categories as $category) {
103 103
 				/*	If necessary un-comment this line in order to get the complete tree for the category	*/
104 104
 				// $categories_list[$category->term_id]['children_tree'] = self::category_tree($category->term_id);
105 105
 				$categories_list[$category->term_id]['children_category'] = get_term_children($category->term_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
106 106
 
107 107
 				/*	Get the product list for the category	*/
108 108
 				$products = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES => $category->slug));
109
-				foreach($products as $product){
109
+				foreach ($products as $product) {
110 110
 					$categories_list[$category->term_id]['children_product'][] = $product->ID;
111 111
 				}
112 112
 			}
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$widget_content = '';
129 129
 		$category_tree = wpshop_categories::category_tree($category_id);
130
-		if((!isset($instance['wpshop_widget_categories']) && !isset($instance['show_all_cat'])) || ($instance['show_all_cat'] == 'yes')){
130
+		if ((!isset($instance['wpshop_widget_categories']) && !isset($instance['show_all_cat'])) || ($instance['show_all_cat'] == 'yes')) {
131 131
 			$categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, 'hide_empty=0&parent=' . $category_id);
132
-			if(count($categories) > 0){
133
-				foreach($categories as $category){
132
+			if (count($categories) > 0) {
133
+				foreach ($categories as $category) {
134 134
 					ob_start();
135 135
 					require(wpshop_display::get_template_file('categories-widget.tpl.php'));
136 136
 					$widget_content .= ob_get_contents();
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 				}
139 139
 				$category_has_sub_category = true;
140 140
 			}
141
-			else{
141
+			else {
142 142
 				$category_has_sub_category = false;
143 143
 			}
144 144
 		}
@@ -150,43 +150,43 @@  discard block
 block discarded – undo
150 150
 	/**
151 151
 	*	Add additionnal fields to the category edition form
152 152
 	*/
153
-	public static function category_edit_fields(){
154
-		$category_id = (int) $_REQUEST["tag_ID"];
153
+	public static function category_edit_fields() {
154
+		$category_id = (int)$_REQUEST["tag_ID"];
155 155
 		$category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
156 156
 		$tpl_component = array();
157
-		$category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />';
157
+		$category_thumbnail_preview = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
158 158
 		/*	Check if there is already a picture for the selected category	*/
159 159
 
160
-		if ( !empty($category_meta_information['wpshop_category_picture']) ) {
161
-			$image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview') );
162
-			$category_thumbnail_preview = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />';
160
+		if (!empty($category_meta_information['wpshop_category_picture'])) {
161
+			$image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview'));
162
+			$category_thumbnail_preview = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
163 163
 		}
164 164
 
165 165
 
166 166
 		$tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '';
167
-		if( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_picture']) ) {
168
-			$tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '<a href="#" role="button" id="wps-delete-category-picture" class="wps-bton-second-mini-rounded">' .__( 'Delete the category picture', 'wpshop' ). '</a> ';
167
+		if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_picture'])) {
168
+			$tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '<a href="#" role="button" id="wps-delete-category-picture" class="wps-bton-second-mini-rounded">' . __('Delete the category picture', 'wpshop') . '</a> ';
169 169
 		}
170
-		$tpl_component['CATEGORY_PICTURE_ID'] = ( ( !empty($category_meta_information['wpshop_category_picture']) ) ? $category_meta_information['wpshop_category_picture'] : '' );
170
+		$tpl_component['CATEGORY_PICTURE_ID'] = ((!empty($category_meta_information['wpshop_category_picture'])) ? $category_meta_information['wpshop_category_picture'] : '');
171 171
 
172 172
 		$tpl_component['CATEGORY_THUMBNAIL_PREVIEW'] = $category_thumbnail_preview;
173
-		if(isset($category_id)){
173
+		if (isset($category_id)) {
174 174
 			$tpl_component['CATEGORY_TAG_ID'] = $category_id;
175 175
 			$tpl_component['CATEGORY_FILTERABLE_ATTRIBUTES'] = '';
176
-			$wpshop_category_products = wpshop_categories::get_product_of_category( $category_id );
176
+			$wpshop_category_products = wpshop_categories::get_product_of_category($category_id);
177 177
 			$filterable_attributes_list = array();
178
-			foreach ( $wpshop_category_products as $wpshop_category_product ) {
178
+			foreach ($wpshop_category_products as $wpshop_category_product) {
179 179
 				$elementId = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
180
-				if ( !empty($elementId) ) {
180
+				if (!empty($elementId)) {
181 181
 					$product_attributes = wpshop_attributes::get_attribute_list_for_item($elementId, $wpshop_category_product);
182
-					if ( !empty($product_attributes) ) {
183
-						foreach ( $product_attributes as $key => $product_attribute ) {
184
-							if ( !empty($product_attribute) && !empty($product_attribute->is_filterable) && strtolower(__($product_attribute->is_filterable, 'wpshop')) == strtolower(__('Yes', 'wpshop')) ) {
185
-								if  ( !array_key_exists($product_attribute->attribute_id, $filterable_attributes_list) ) {
182
+					if (!empty($product_attributes)) {
183
+						foreach ($product_attributes as $key => $product_attribute) {
184
+							if (!empty($product_attribute) && !empty($product_attribute->is_filterable) && strtolower(__($product_attribute->is_filterable, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
185
+								if (!array_key_exists($product_attribute->attribute_id, $filterable_attributes_list)) {
186 186
 									$filterable_attributes_list[$product_attribute->attribute_id] = $product_attribute;
187
-									$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_ID'] =  $product_attribute->attribute_id;
188
-									$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] =  __($product_attribute->frontend_label, 'wpshop');
189
-									if ( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes']) ) {
187
+									$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_ID'] = $product_attribute->attribute_id;
188
+									$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] = __($product_attribute->frontend_label, 'wpshop');
189
+									if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes'])) {
190 190
 										$sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = 'checked="checked"';
191 191
 									}
192 192
 									else {
@@ -217,20 +217,20 @@  discard block
 block discarded – undo
217 217
 	*
218 218
 	*	@return void
219 219
 	*/
220
-	public static function category_fields_saver($category_id, $tt_id){
220
+	public static function category_fields_saver($category_id, $tt_id) {
221 221
 		global $wpdb;
222 222
 		$category_meta = array();
223
-		$category_option = get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
223
+		$category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
224 224
 
225
-		$wps_category_picture_id = !empty($_POST['wps_category_picture_id']) ? (int) $_POST['wps_category_picture_id'] : null;
226
-		$filterable_attribute_for_category = ( !empty($_POST['filterable_attribute_for_category']) && is_array($_POST['filterable_attribute_for_category']) ) ? (array) $_POST['filterable_attribute_for_category'] : null;
225
+		$wps_category_picture_id = !empty($_POST['wps_category_picture_id']) ? (int)$_POST['wps_category_picture_id'] : null;
226
+		$filterable_attribute_for_category = (!empty($_POST['filterable_attribute_for_category']) && is_array($_POST['filterable_attribute_for_category'])) ? (array)$_POST['filterable_attribute_for_category'] : null;
227 227
 
228
-		if ( isset( $wps_category_picture_id ) ) {
229
-			$attach_id = intval( $wps_category_picture_id );
228
+		if (isset($wps_category_picture_id)) {
229
+			$attach_id = intval($wps_category_picture_id);
230 230
 			$category_option['wpshop_category_picture'] = $attach_id;
231 231
 		}
232 232
 
233
-		if ( isset( $filterable_attribute_for_category ) ) {
233
+		if (isset($filterable_attribute_for_category)) {
234 234
 			$category_option['wpshop_category_filterable_attributes'] = $filterable_attribute_for_category;
235 235
 		}
236 236
 		else {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 		/** Update filter values **/
242 242
 		$wpshop_filter_search = new wps_filter_search();
243
-		$wpshop_filter_search->stock_values_for_attribute( array($category_id) );
243
+		$wpshop_filter_search->stock_values_for_attribute(array($category_id));
244 244
 	}
245 245
 
246 246
 	/**
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 	*
251 251
 	*	@return array $columns The new array with additionnal colu
252 252
 	*/
253
-	public static function category_manage_columns($columns){
254
-	    unset( $columns["cb"] );
253
+	public static function category_manage_columns($columns) {
254
+	    unset($columns["cb"]);
255 255
 
256 256
 	    $custom_array = array(
257 257
 				'cb' => '<input type="checkbox" />',
258 258
 				'wpshop_category_thumbnail' => __('Thumbnail', 'wpshop')
259 259
 	    );
260 260
 
261
-	    $columns = array_merge( $custom_array, $columns );
261
+	    $columns = array_merge($custom_array, $columns);
262 262
 
263 263
 	    return $columns;
264 264
 	}
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 	/**
267 267
 	*	Define the content of extra columns to add to categories listing interface
268 268
 	*/
269
-	public static function category_manage_columns_content($string, $column_name, $category_id){
269
+	public static function category_manage_columns_content($string, $column_name, $category_id) {
270 270
 		$category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
271
-		$category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />';
271
+		$category_thumbnail_preview = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
272 272
 		/*	Check if there is already a picture for the selected category	*/
273
-		if ( !empty($category_meta_information['wpshop_category_picture']) ) {
274
-			$image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview') );
275
-			$category_thumbnail_preview = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />';
273
+		if (!empty($category_meta_information['wpshop_category_picture'])) {
274
+			$image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview'));
275
+			$category_thumbnail_preview = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />';
276 276
 		}
277 277
 		$category = get_term_by('id', $category_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
278 278
 		$name = $category->name;
@@ -290,21 +290,21 @@  discard block
 block discarded – undo
290 290
 	*
291 291
 	*	@return mixed $content Output the category list
292 292
 	*/
293
-	public static function category_mini_output($category, $output_type = 'list'){
293
+	public static function category_mini_output($category, $output_type = 'list') {
294 294
 		$content = '';
295 295
 		/*	Get the different informations for output	*/
296
-		$category_meta_information = ( !empty($category) && !empty($category->term_id) ) ? get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category->term_id) : '';
297
-		$categoryThumbnail = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="wps-category-thumbnail" />';
296
+		$category_meta_information = (!empty($category) && !empty($category->term_id)) ? get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category->term_id) : '';
297
+		$categoryThumbnail = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="wps-category-thumbnail" />';
298 298
 		/*	Check if there is already a picture for the selected category	*/
299
-		if ( !empty($category_meta_information['wpshop_category_picture']) ) {
300
-			$image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'wps-categorie-display', false, array('class' => 'wps-category-thumbnail') );
301
-			$categoryThumbnail = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="wps-category-thumbnail" />';
299
+		if (!empty($category_meta_information['wpshop_category_picture'])) {
300
+			$image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'wps-categorie-display', false, array('class' => 'wps-category-thumbnail'));
301
+			$categoryThumbnail = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="wps-category-thumbnail" />';
302 302
 		}
303 303
 
304 304
 
305
-		$category_title = ( !empty($category) && !empty($category->name) ) ? $category->name : '';
306
-		$category_more_informations = ( !empty($category) && !empty($category->description) ) ? wp_trim_words( $category->description, 30, ' [...]' ) : '';
307
-		$category_link = ( !empty($category) && !empty($category->term_id) ) ?  get_term_link((int)$category->term_id , WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES) : '';
305
+		$category_title = (!empty($category) && !empty($category->name)) ? $category->name : '';
306
+		$category_more_informations = (!empty($category) && !empty($category->description)) ? wp_trim_words($category->description, 30, ' [...]') : '';
307
+		$category_link = (!empty($category) && !empty($category->term_id)) ? get_term_link((int)$category->term_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES) : '';
308 308
 
309 309
 		// $item_width = null;
310 310
 		// /*	Make some treatment in case we are in grid mode	*/
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 		$tpl_component['CATEGORY_TITLE'] = $category_title;
326 326
 		$tpl_component['CATEGORY_DESCRIPTION'] = $category_more_informations;
327 327
 		//$tpl_component['ITEM_WIDTH'] = $item_width;
328
-		$tpl_component['CATEGORY_ID'] = ( !empty($category) && !empty($category->term_id) ) ? $category->term_id : '';
328
+		$tpl_component['CATEGORY_ID'] = (!empty($category) && !empty($category->term_id)) ? $category->term_id : '';
329 329
 		$tpl_component['CATEGORY_DISPLAY_TYPE'] = $output_type;
330 330
 
331 331
 		/*
332 332
 		 * Build template
333 333
 		 */
334 334
 		$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
335
-		if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
335
+		if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
336 336
 			/*	Include the old way template part	*/
337 337
 
338 338
 			ob_start();
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
 	public static function wpshop_category_func($atts) {
358 358
 		global $wpdb;
359 359
 		$string = '';
360
-		if ( !empty($atts['cid']) ) {
361
-			$atts['type'] = (!empty($atts['type']) && in_array($atts['type'],array('grid','list'))) ? $atts['type'] : 'grid';
360
+		if (!empty($atts['cid'])) {
361
+			$atts['type'] = (!empty($atts['type']) && in_array($atts['type'], array('grid', 'list'))) ? $atts['type'] : 'grid';
362 362
 
363 363
 			$cat_list = explode(',', $atts['cid']);
364 364
 
365
-			if ( (count($cat_list) > 1) || ( !empty($atts['display']) && ($atts['display'] == 'only_cat') ) ) {
365
+			if ((count($cat_list) > 1) || (!empty($atts['display']) && ($atts['display'] == 'only_cat'))) {
366 366
 				$string .= '
367 367
 					<div class="wpshop_categories_' . $atts['type'] . '" >';
368
-					foreach( $cat_list as $cat_id ){
368
+					foreach ($cat_list as $cat_id) {
369 369
 						$sub_category_def = get_term($cat_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
370 370
 						$string .= wpshop_categories::category_mini_output($sub_category_def, $atts['type']);
371 371
 					}
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
 			else {
376 376
 				$sub_category_def = get_term($atts['cid'], WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
377 377
 
378
-				if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){
378
+				if (empty($atts['display']) || ($atts['display'] != 'only_products')) {
379 379
 					$string .= wpshop_categories::category_mini_output($sub_category_def, $atts['type']);
380 380
 					$string .= '
381 381
 					<div class="category_product_' . $atts['type'] . '" >
382
-						<h2 class="category_content_part_title" >'.__('Category\'s product list', 'wpshop').'</h2>';
382
+						<h2 class="category_content_part_title" >'.__('Category\'s product list', 'wpshop') . '</h2>';
383 383
 				}
384 384
 
385 385
 				$string .= wpshop_products::wpshop_products_func($atts);
386 386
 
387
-				if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){
387
+				if (empty($atts['display']) || ($atts['display'] != 'only_products')) {
388 388
 					$string .= '</div>';
389 389
 				}
390 390
 			}
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 		return do_shortcode($string);
397 397
 	}
398 398
 
399
-	public static function get_product_of_category( $category_id ) {
399
+	public static function get_product_of_category($category_id) {
400 400
 		$product_id_list = array();
401
-		if ( !empty($category_id) ) {
401
+		if (!empty($category_id)) {
402 402
 			global $wpdb;
403 403
 			$query = $wpdb->prepare("SELECT T.* FROM " . $wpdb->term_relationships . " AS T INNER JOIN " . $wpdb->posts . " AS P ON ((P.ID = T.object_id) AND (P.post_status = %s)) WHERE T.term_taxonomy_id = %d ", 'publish', $category_id);
404 404
 			$relationships = $wpdb->get_results($query);
405
-			if ( !empty($relationships) ) {
406
-				foreach ( $relationships as $relationship ) {
405
+			if (!empty($relationships)) {
406
+				foreach ($relationships as $relationship) {
407 407
 					$product_id_list[] = $relationship->object_id;
408 408
 				}
409 409
 			}
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	public static function get_the_category_thumbnail($id, $size = 'thumbnail', $icon = false) {
430 430
 		/** Get the attachment/post ID */
431
-		$array_option_category 	= get_option('wpshop_product_category_' . $id);
431
+		$array_option_category = get_option('wpshop_product_category_' . $id);
432 432
 		
433 433
 		/** If not attachment/post ID in the category, return "No thumbnail in the category" */
434
-		if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture']))
434
+		if (is_array($array_option_category) && empty($array_option_category['wpshop_category_picture']))
435 435
 			return __('No thumbnail in the category', 'wpshop');
436 436
 		
437 437
 		/** Set attachment/post ID in $id_picture */
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 		 */
444 444
 		$post_thumbnail = wp_get_attachment_image_src($id_picture, $size, $icon);
445 445
 		
446
-		if(!$post_thumbnail)
446
+		if (!$post_thumbnail)
447 447
 			return __('No thumbnail in this post', 'wpshop');
448 448
 			
449 449
 		return $post_thumbnail;
Please login to merge, or discard this patch.
includes/librairies/catalog/products.class.php 4 patches
Doc Comments   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -773,6 +773,9 @@  discard block
 block discarded – undo
773 773
 		return do_shortcode($string);
774 774
 	}
775 775
 
776
+	/**
777
+	 * @param integer $page_number
778
+	 */
776 779
 	public static function wpshop_get_product_by_criteria( $criteria = null, $cid=0, $pid=0, $display_type, $order='ASC', $page_number, $products_per_page=0, $nb_of_product_limit=0, $grid_element_nb_per_line=WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE, $display_pagination = true ) {
777 780
 		global $wpdb;
778 781
 
@@ -1131,7 +1134,7 @@  discard block
 block discarded – undo
1131 1134
 	/**
1132 1135
 	 * Add a product into the db. This function is used for the EDI
1133 1136
 	 * @param $name Name of the product
1134
-	 * @param $description Description of the product
1137
+	 * @param string $description Description of the product
1135 1138
 	 * @param $attrs List of the attributes and values of the product
1136 1139
 	 * @return boolean
1137 1140
 	*/
@@ -1450,10 +1453,10 @@  discard block
 block discarded – undo
1450 1453
 	/**
1451 1454
 	*	Define output for product
1452 1455
 	*
1453
-	*	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1456
+	*	@param string $initialContent The initial product content defined into wordpress basic admin interface
1454 1457
 	*	@param integer $product_id The product identifier we want to get and output attribute for
1455 1458
 	*
1456
-	*	@return mixed $content The content to add or to modify the product output in frontend
1459
+	*	@return string $content The content to add or to modify the product output in frontend
1457 1460
 	*/
1458 1461
 	public static function product_complete_sheet_output($initialContent, $product_id) {
1459 1462
 		$content = $attributeContentOutput = '';
@@ -2508,7 +2511,7 @@  discard block
 block discarded – undo
2508 2511
 
2509 2512
 	/**
2510 2513
 	 * Retrieve and display the variation for a given product
2511
-	 * @param integer $product_id The product identifier to get variation for
2514
+	 * @param integer $post_id The product identifier to get variation for
2512 2515
 	 */
2513 2516
 	public static function wpshop_variation( $post_id = '', $from_admin = false, $order_id = '', $qty = 1 ) {
2514 2517
 		global $wp_query;
@@ -3300,6 +3303,9 @@  discard block
 block discarded – undo
3300 3303
 	}
3301 3304
 
3302 3305
 
3306
+	/**
3307
+	 * @param boolean $has_variation
3308
+	 */
3303 3309
 	function wps_get_summary_variations_product( $product_id, $the_product, $has_variation ) {
3304 3310
 		global $wpdb, $wpshop_payment;
3305 3311
 		$output = '';
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class wpshop_products {
25 25
 	/**
26
-	*	Définition du code de la classe courante
27
-	*/
26
+	 *	Définition du code de la classe courante
27
+	 */
28 28
 	const currentPageCode = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
29 29
 	const current_page_variation_code = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION;
30 30
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 	/**
64
-	*	Déclaration des produits et variations en tant que "post" de wordpress
65
-	*
66
-	*	@see register_post_type()
67
-	*/
64
+	 *	Déclaration des produits et variations en tant que "post" de wordpress
65
+	 *
66
+	 *	@see register_post_type()
67
+	 */
68 68
 	public static function create_wpshop_products_type() {
69 69
 
70 70
 		$options = get_option('wpshop_catalog_product_option', array());
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 	/**
179
-	*	Create the different bow for the product management page looking for the attribute set to create the different boxes
180
-	*/
179
+	 *	Create the different bow for the product management page looking for the attribute set to create the different boxes
180
+	 */
181 181
 	public static function add_meta_boxes() {
182 182
 		global $post, $currentTabContent;
183 183
 
@@ -607,21 +607,21 @@  discard block
 block discarded – undo
607 607
 	}
608 608
 
609 609
 	/**
610
-	* Display a list of product from a shortcode
611
-	*
612
-	* @param array $atts {
613
-	*	limit : The number of element to display
614
-	*	order : The information to order list by
615
-	*	sorting : List order (ASC | DESC)
616
-	*	display : Display size (normal | mini)
617
-	*	type : Display tyep (grid | list) only work with display=normal
618
-	*	pagination : The number of element per page
619
-	* display_pagination : Display the pagination or not
620
-	* }
621
-	*
622
-	* @return string
623
-	*
624
-	**/
610
+	 * Display a list of product from a shortcode
611
+	 *
612
+	 * @param array $atts {
613
+	 *	limit : The number of element to display
614
+	 *	order : The information to order list by
615
+	 *	sorting : List order (ASC | DESC)
616
+	 *	display : Display size (normal | mini)
617
+	 *	type : Display tyep (grid | list) only work with display=normal
618
+	 *	pagination : The number of element per page
619
+	 * display_pagination : Display the pagination or not
620
+	 * }
621
+	 *
622
+	 * @return string
623
+	 *
624
+	 **/
625 625
 	public static function wpshop_products_func($atts) {
626 626
 		global $wpdb, $wp_query;
627 627
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 	 * @param $description Description of the product
1135 1135
 	 * @param $attrs List of the attributes and values of the product
1136 1136
 	 * @return boolean
1137
-	*/
1137
+	 */
1138 1138
 	function addProduct($name, $description, $attrs=array()) {
1139 1139
 		$new_product = wpshop_entities::create_new_entity(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $name, $description, $attrs);
1140 1140
 		return $new_product[0];
@@ -1448,13 +1448,13 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
 
1450 1450
 	/**
1451
-	*	Define output for product
1452
-	*
1453
-	*	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1454
-	*	@param integer $product_id The product identifier we want to get and output attribute for
1455
-	*
1456
-	*	@return mixed $content The content to add or to modify the product output in frontend
1457
-	*/
1451
+	 *	Define output for product
1452
+	 *
1453
+	 *	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1454
+	 *	@param integer $product_id The product identifier we want to get and output attribute for
1455
+	 *
1456
+	 *	@return mixed $content The content to add or to modify the product output in frontend
1457
+	 */
1458 1458
 	public static function product_complete_sheet_output($initialContent, $product_id) {
1459 1459
 		$content = $attributeContentOutput = '';
1460 1460
 		$wps_product_ctr = new wps_product_ctr();
@@ -1754,12 +1754,12 @@  discard block
 block discarded – undo
1754 1754
 
1755 1755
 
1756 1756
 	/**
1757
-	*	Get the products (post) of a given category
1758
-	*
1759
-	*	@param string $category_slug The category slug we want to get the product list for
1760
-	*
1761
-	*	@return mixed $widget_content The output for the product list
1762
-	*/
1757
+	 *	Get the products (post) of a given category
1758
+	 *
1759
+	 *	@param string $category_slug The category slug we want to get the product list for
1760
+	 *
1761
+	 *	@return mixed $widget_content The output for the product list
1762
+	 */
1763 1763
 	public static function get_product_of_category($category_slug, $category_id){
1764 1764
 		global $top_categories;
1765 1765
 		$widget_content = '';
Please login to merge, or discard this patch.
Braces   +89 added lines, -131 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
 * Products management method file
4 6
 *
@@ -200,8 +202,7 @@  discard block
 block discarded – undo
200 202
 			if(((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))){
201 203
 				if((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))){
202 204
 					$post_attribute_set_id = $attributeEntitySetList[0]->id;
203
-				}
204
-				elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
205
+				} elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
205 206
 					$post_attribute_set_id = $attribute_set_id->value;
206 207
 				}
207 208
 
@@ -213,8 +214,9 @@  discard block
 block discarded – undo
213 214
 					foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
214 215
 						if(!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type'] == 'movable-tab')){
215 216
 							add_meta_box('wpshop_product_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_products', 'meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default', array('boxIdentifier' => $boxIdentifier));
217
+						} else {
218
+							$fixed_box_exist = true;
216 219
 						}
217
-						else $fixed_box_exist = true;
218 220
 					}
219 221
 				}
220 222
 				if ( $fixed_box_exist ) {
@@ -228,8 +230,7 @@  discard block
 block discarded – undo
228 230
 
229 231
 				/**	Product option	*/
230 232
 				add_meta_box('wpshop_product_options', __('Options', 'wpshop'), array('wpshop_products', 'product_options_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'side', 'default');
231
-			}
232
-			else if ( count($attributeEntitySetList) > 1 ) {
233
+			} else if ( count($attributeEntitySetList) > 1 ) {
233 234
 				$input_def['id'] = 'product_attribute_set_id';
234 235
 				$input_def['name'] = 'product_attribute_set_id';
235 236
 				$input_def['value'] = '';
@@ -477,8 +478,9 @@  discard block
 block discarded – undo
477 478
 			$tpl_component = array();
478 479
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] = '';
479 480
 			for ( $i=1; $i<=$column_count; $i++ ) {
480
-				if (!empty($sub_content[$i]))
481
-					$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
481
+				if (!empty($sub_content[$i])) {
482
+									$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
483
+				}
482 484
 			}
483 485
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT_CLASS'] = empty($product_attribute_frontend_display_config) ? ' class="wpshopHide" ' : '';
484 486
 			$tpl_component['ADMIN_PRODUCT_ATTRIBUTE_FRONTEND_DISPLAY_MAIN_CHOICE_CHECK'] = empty($product_attribute_frontend_display_config) ? ' checked="checked"' : '';
@@ -501,7 +503,9 @@  discard block
 block discarded – undo
501 503
 
502 504
 		$query = $wpdb->prepare("SELECT code, frontend_label FROM ".WPSHOP_DBT_ATTRIBUTE." WHERE is_used_for_sort_by = %s",  'yes');
503 505
 		$results = $wpdb->get_results($query, ARRAY_A);
504
-		if(!empty($results))$data = array_merge($data, $results);
506
+		if(!empty($results)) {
507
+			$data = array_merge($data, $results);
508
+		}
505 509
 
506 510
 		return $data;
507 511
 	}
@@ -516,12 +520,7 @@  discard block
 block discarded – undo
516 520
 		if(!empty($data)) {
517 521
 			if ($data['data_type_to_use'] == 'custom' ) {
518 522
 				// Find which table to take
519
-				if($data['data_type']=='datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
-				elseif($data['data_type']=='decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
-				elseif($data['data_type']=='integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
-				elseif($data['data_type']=='options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
-				elseif($data['data_type']=='text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
-				elseif($data['data_type']=='varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
523
+				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; }
525 524
 
526 525
 				if(isset($table_name)) {
527 526
 					// If the value is an id of a select, radio or checkbox
@@ -535,8 +534,7 @@  discard block
 block discarded – undo
535 534
 							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower( __( $attr_value, 'wpshop' ) ), $attr_value
536 535
 						);
537 536
 						$data = $wpdb->get_results($query);
538
-					}
539
-					else {
537
+					} else {
540 538
 
541 539
 						$query = $wpdb->prepare("
542 540
 							SELECT ".$table_name.".entity_id FROM ".$table_name."
@@ -548,10 +546,10 @@  discard block
 block discarded – undo
548 546
 						$data = $wpdb->get_results($query);
549 547
 
550 548
 					}
549
+				} else {
550
+					return __('Incorrect shortcode','wpshop');
551 551
 				}
552
-				else return __('Incorrect shortcode','wpshop');
553
-			}
554
-			elseif( $data['data_type_to_use'] == 'internal' )  {
552
+			} elseif( $data['data_type_to_use'] == 'internal' )  {
555 553
 				/** Check the ID of manufacturer **/
556 554
 				$default_value = unserialize( $data['default_value'] );
557 555
 				if( !empty($default_value) && !empty($default_value['default_value']) ) {
@@ -562,9 +560,13 @@  discard block
 block discarded – undo
562 560
 						$data = $wpdb->get_results( $query );
563 561
 					}
564 562
 				}
565
-			}else return __('Incorrect shortcode','wpshop');
563
+			} else {
564
+				return __('Incorrect shortcode','wpshop');
565
+			}
566 566
 
567
-		} else return __('Incorrect shortcode','wpshop');
567
+		} else {
568
+			return __('Incorrect shortcode','wpshop');
569
+		}
568 570
 
569 571
 		if(!empty($data)) {
570 572
 			foreach($data as $p) {
@@ -591,7 +593,9 @@  discard block
 block discarded – undo
591 593
 		global $wp_query;
592 594
 
593 595
 		$atts['product_type'] = 'related';
594
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
596
+		if(empty($atts['pid'])) {
597
+			$atts['pid'] = $wp_query->posts[0]->ID;
598
+		}
595 599
 
596 600
 		$related_product_output = self::wpshop_products_func($atts);
597 601
 
@@ -651,9 +655,12 @@  discard block
 block discarded – undo
651 655
 			// Foreach on the found products
652 656
 			if ( !empty($products) ) {
653 657
 				$pid = implode(',',$products);
654
-				if(empty($pid))$output_results = false;
658
+				if(empty($pid)) {
659
+					$output_results = false;
660
+				}
661
+			} else {
662
+				$output_results = false;
655 663
 			}
656
-			else $output_results = false;
657 664
 		}
658 665
 
659 666
 		/** Get related products	*/
@@ -712,8 +719,7 @@  discard block
 block discarded – undo
712 719
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
713 720
 				$sorting = ob_get_contents();
714 721
 				ob_end_clean();
715
-			}
716
-			else {
722
+			} else {
717 723
 				/*
718 724
 				 * Display hidden field every times
719 725
 				 */
@@ -745,8 +751,7 @@  discard block
 block discarded – undo
745 751
 					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ?' active' : null;
746 752
 					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ?' active' : null;
747 753
 					$sorting = wpshop_display::display_template_element($template_part, $tpl_component);
748
-				}
749
-				else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
754
+				} else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
750 755
 					$sub_template_part = 'product_listing_sorting_criteria_hidden';
751 756
 					$sub_tpl_component = array();
752 757
 					$sub_tpl_component['CRITERIA_DEFAULT'] = !empty($sorting_criteria[0]['code']) ? $sorting_criteria[0]['code'] : 'title';
@@ -761,12 +766,10 @@  discard block
 block discarded – undo
761 766
 
762 767
 			if ( !empty( $atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763 768
 				$string = $sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div>';
764
-			}
765
-			else {
769
+			} else {
766 770
 				$string = '<div class="wpshop_products_block">'.$sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div></div>';
767 771
 			}
768
-		}
769
-		else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
772
+		} else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
770 773
 			$string = __('There is nothing to output here', 'wpshop');
771 774
 		}
772 775
 
@@ -831,24 +834,21 @@  discard block
 block discarded – undo
831 834
 				default:
832 835
 					if(!empty($pid)) {
833 836
 						$post_meta = get_post_meta($pid, '_'.$criteria, true);
834
-					}
835
-					else{
837
+					} else{
836 838
 						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_'.$criteria);
837 839
 						$post_meta = $wpdb->get_var($check_meta);
838 840
 					}
839 841
 					if(!empty($post_meta)){
840 842
 						if ( in_array( $criteria, array( 'wpshop_displayed_price', 'product_price' ) ) ) {
841 843
 							$query['orderby'] = 'meta_value_num';
842
-						}
843
-						else {
844
+						} else {
844 845
 							$query['orderby'] = 'meta_value';
845 846
 						}
846 847
 						$query['meta_key'] = '_'.$criteria;
847 848
 					}
848 849
 					break;
849 850
 			}
850
-		}
851
-		else {
851
+		} else {
852 852
 			$query['orderby'] = 'menu_order ID';
853 853
 		}
854 854
 		$post_per_page = $query['posts_per_page'];
@@ -860,8 +860,7 @@  discard block
 block discarded – undo
860 860
 				for( $i = 0; $i < $query['posts_per_page']; $i++ ) {
861 861
 					$tmp_array[] = $query['post__in'][$i];
862 862
 				}
863
-			}
864
-			else {
863
+			} else {
865 864
 				$begin_number = ( ($page_number - 1) * $query['posts_per_page'] ) ;
866 865
 				for( $i = $begin_number ; $i < $query['posts_per_page'] + $begin_number ; $i++ ) {
867 866
 					if ( !empty($query['post__in'][$i]) ) {
@@ -1091,8 +1090,7 @@  discard block
 block discarded – undo
1091 1090
 						$product_meta['attribute_visible_listing'][$attribute->attribute_code] = $value;
1092 1091
 					}
1093 1092
 				}
1094
-			}
1095
-			else {
1093
+			} else {
1096 1094
 
1097 1095
 			}
1098 1096
 
@@ -1194,8 +1192,7 @@  discard block
 block discarded – undo
1194 1192
 					$query = "SELECT MAX(ID) AS PDCT_ID FROM {$wpdb->posts}";
1195 1193
 					$last_ref = $wpdb->get_var($query);
1196 1194
 					$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
1197
-				}
1198
-				else {
1195
+				} else {
1199 1196
 					/* Check if the product reference existing in the database */
1200 1197
 					$ref = $data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'];
1201 1198
 					$query = $wpdb->prepare(
@@ -1250,8 +1247,7 @@  discard block
 block discarded – undo
1250 1247
 
1251 1248
 			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config']) ) {
1252 1249
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, $data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']);
1253
-			}
1254
-			else if ( $data_to_save['action'] != 'autosave') {
1250
+			} else if ( $data_to_save['action'] != 'autosave') {
1255 1251
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF);
1256 1252
 			}
1257 1253
 
@@ -1325,23 +1321,20 @@  discard block
 block discarded – undo
1325 1321
 			/*	Update the related products list*/
1326 1322
 			if ( !empty($data_to_save['related_products_list']) ) {
1327 1323
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS, $data_to_save['related_products_list']);
1328
-			}
1329
-			else if ( $data_to_save['action'] != 'autosave') {
1324
+			} else if ( $data_to_save['action'] != 'autosave') {
1330 1325
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS);
1331 1326
 			}
1332 1327
 			/*	Update the provider list*/
1333 1328
 			if ( !empty($data_to_save['provider_list']) ) {
1334 1329
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER, $data_to_save['provider_list']);
1335
-			}
1336
-			else if ( $data_to_save['action'] != 'autosave') {
1330
+			} else if ( $data_to_save['action'] != 'autosave') {
1337 1331
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER);
1338 1332
 			}
1339 1333
 
1340 1334
 			/*	Update product options	*/
1341 1335
 			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']) ) {
1342 1336
 				update_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']);
1343
-			}
1344
-			else if ( $data_to_save['action'] != 'autosave') {
1337
+			} else if ( $data_to_save['action'] != 'autosave') {
1345 1338
 				delete_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
1346 1339
 			}
1347 1340
 
@@ -1372,8 +1365,7 @@  discard block
 block discarded – undo
1372 1365
 				foreach( $variations as $variation_id => $variation_data ) {
1373 1366
 					if( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1 ) {
1374 1367
 						return 'single';
1375
-					}
1376
-					elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1368
+					} elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1377 1369
 						$variation_type = 'combined';
1378 1370
 					}
1379 1371
 				}
@@ -1529,8 +1521,7 @@  discard block
 block discarded – undo
1529 1521
 		$display_price_state_when_price_is_empty = true;
1530 1522
 		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1531 1523
 			$display_price_state_when_price_is_empty = false;
1532
-		}
1533
-		else if ( !empty( $productPrice ) ) {
1524
+		} else if ( !empty( $productPrice ) ) {
1534 1525
 			$display_price_state_when_price_is_empty = true;
1535 1526
 		}
1536 1527
 		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'complete' ) : '';
@@ -1590,8 +1581,7 @@  discard block
 block discarded – undo
1590 1581
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1591 1582
 			$content = ob_get_contents();
1592 1583
 			ob_end_clean();
1593
-		}
1594
-		else {
1584
+		} else {
1595 1585
 			$content = wpshop_display::display_template_element($template_part, $tpl_component);
1596 1586
 		}
1597 1587
 		unset($tpl_component);
@@ -1625,8 +1615,7 @@  discard block
 block discarded – undo
1625 1615
 				$product_more_informations = $post_content[0];
1626 1616
 			}
1627 1617
 
1628
-		}
1629
-		else {
1618
+		} else {
1630 1619
 			$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1631 1620
 			$product_title = '<i>'.__('This product does not exist', 'wpshop').'</i>';
1632 1621
 			$product_link = '';
@@ -1655,8 +1644,7 @@  discard block
 block discarded – undo
1655 1644
 	 			$tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY'];
1656 1645
 	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT' ) ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657 1646
 	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price );
1658
-	 		}
1659
-			else {
1647
+	 		} else {
1660 1648
 				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type) );
1661 1649
 	 		}
1662 1650
 		}
@@ -1671,8 +1659,7 @@  discard block
 block discarded – undo
1671 1659
 		$display_price_state_when_price_is_empty = false;
1672 1660
 		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1673 1661
 			$display_price_state_when_price_is_empty = false;
1674
-		}
1675
-		else if ( !empty( $productPrice ) ) {
1662
+		} else if ( !empty( $productPrice ) ) {
1676 1663
 			$display_price_state_when_price_is_empty = true;
1677 1664
 		}
1678 1665
 		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'mini' ) : '';
@@ -1739,8 +1726,7 @@  discard block
 block discarded – undo
1739 1726
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1740 1727
 				$content = ob_get_contents();
1741 1728
 				ob_end_clean();
1742
-			}
1743
-			else {
1729
+			} else {
1744 1730
 				$content = wpshop_display::display_template_element($template_part, $tpl_component);
1745 1731
 			}
1746 1732
 			unset($tpl_component);
@@ -1862,8 +1848,7 @@  discard block
 block discarded – undo
1862 1848
 					$option_value = $wpdb->get_var($query);
1863 1849
 					$parent_post = $parent_product['parent_post'];
1864 1850
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title. ' <br/>('. $option_name . ' : ' . $option_value. ')');
1865
-				}
1866
-				else {
1851
+				} else {
1867 1852
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1868 1853
 				}
1869 1854
 
@@ -1958,8 +1943,7 @@  discard block
 block discarded – undo
1958 1943
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1959 1944
 				$product_special_state['output'] = ob_get_contents();
1960 1945
 				ob_end_clean();
1961
-			}
1962
-			else {
1946
+			} else {
1963 1947
 				$product_special_state['output'] = wpshop_display::display_template_element($template_part, $tpl_component);
1964 1948
 			}
1965 1949
 			unset($tpl_component);
@@ -1995,8 +1979,7 @@  discard block
 block discarded – undo
1995 1979
 		/** Si aucun prix trouvé on stop la méthode / If not found price, stop the method */
1996 1980
 		if( empty( $prices_attribute ) ) {
1997 1981
 			return false;
1998
-		}
1999
-		else {
1982
+		} else {
2000 1983
 			/**
2001 1984
 			 * Récupère le prix de base selon le pilotage de prix de la boutique / Get
2002 1985
 			 * the base amount according on the shop price control
@@ -2024,8 +2007,7 @@  discard block
 block discarded – undo
2024 2007
 			if ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) {
2025 2008
 				$price_with_vat = ($base_price * $divider_price_ttc );
2026 2009
 				$price_no_vat 	= $base_price;
2027
-			}
2028
-			else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2010
+			} else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2029 2011
 				$price_with_vat = $base_price;
2030 2012
 				$price_no_vat	= ($price_with_vat / $divider_price_ttc );
2031 2013
 			}
@@ -2118,8 +2100,7 @@  discard block
 block discarded – undo
2118 2100
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2119 2101
 				$button = ob_get_contents();
2120 2102
 				ob_end_clean();
2121
-			}
2122
-			else {
2103
+			} else {
2123 2104
 				$button = wpshop_display::display_template_element($template_part, $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $product_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . 'output_type' => $output_type));
2124 2105
 			}
2125 2106
 			unset($tpl_component);
@@ -2161,8 +2142,7 @@  discard block
 block discarded – undo
2161 2142
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2162 2143
 				$quotation_button = ob_get_contents();
2163 2144
 				ob_end_clean();
2164
-			}
2165
-			else {
2145
+			} else {
2166 2146
 				$quotation_button = wpshop_display::display_template_element($template_part, $tpl_component);
2167 2147
 			}
2168 2148
 			unset($tpl_component);
@@ -2213,8 +2193,7 @@  discard block
 block discarded – undo
2213 2193
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2214 2194
 			$galery_output = ob_get_contents();
2215 2195
 			ob_end_clean();
2216
-		}
2217
-		else {
2196
+		} else {
2218 2197
 			$galery_output = wpshop_display::display_template_element($template_part, $tpl_component);
2219 2198
 		}
2220 2199
 		unset($tpl_component);
@@ -2363,8 +2342,7 @@  discard block
 block discarded – undo
2363 2342
 					if ( !empty($content->$attribute_value) ) {
2364 2343
 						if ( !empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes']) ) {
2365 2344
 							$variations_output[$post_def->ID]['variation_def'][$content->code] = $content->$attribute_value;
2366
-						}
2367
-						else {
2345
+						} else {
2368 2346
 							$variations_output[$post_def->ID]['variation_dif'][$content->code] = $content->$attribute_value;
2369 2347
 						}
2370 2348
 					}
@@ -2404,8 +2382,7 @@  discard block
 block discarded – undo
2404 2382
 				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format( $p, 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2405 2383
 				if ( !empty($price_piloting) && $price_piloting == 'HT' ) {
2406 2384
 
2407
-				}
2408
-				else {
2385
+				} else {
2409 2386
 
2410 2387
 				}
2411 2388
 				$post_obj = $variation['post'];
@@ -2417,17 +2394,14 @@  discard block
 block discarded – undo
2417 2394
 					if ( !empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418 2395
 						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2419 2396
 							$product_price = ( ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0 ) + $parent_product_infos['parent_post_meta']['price_ht'];
2420
-						}
2421
-						else {
2397
+						} else {
2422 2398
 							$product_price = ( ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) + $parent_product_infos['parent_post_meta']['product_price'];
2423 2399
 						}
2424 2400
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Variation price combined with the parent product price', 'wpshop');
2425
-					}
2426
-					else {
2401
+					} else {
2427 2402
 						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2428 2403
 							$product_price = ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0;
2429
-						}
2430
-						else {
2404
+						} else {
2431 2405
 							$product_price = ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0;
2432 2406
 						}
2433 2407
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Only variation\'s price is used', 'wpshop');
@@ -2498,8 +2472,7 @@  discard block
 block discarded – undo
2498 2472
 			$output .= wpshop_display::display_template_element('wpshop_admin_existing_variation_list', array('ADMIN_EXISTING_VARIATIONS_CONTAINER_CLASS' => '', 'ADMIN_EXISTING_VARIATIONS_CONTAINER' => $existing_variation_list), array(), 'admin');
2499 2473
 			/*	Reset de la liste des résultats pour éviter les comportements indésirables	*/
2500 2474
 			wp_reset_query();
2501
-		}
2502
-		else {
2475
+		} else {
2503 2476
 			$output = __('No variation found for this product. Please use button above for create one', 'wpshop');
2504 2477
 		}
2505 2478
 
@@ -2525,8 +2498,9 @@  discard block
 block discarded – undo
2525 2498
 			if (!empty($product_attribute_order_detail) ) {
2526 2499
 				foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527 2500
 					foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
-						if ( !empty($attribute_def->code) )
2529
-							$output_order[$attribute_def->code] = $position;
2501
+						if ( !empty($attribute_def->code) ) {
2502
+													$output_order[$attribute_def->code] = $position;
2503
+						}
2530 2504
 					}
2531 2505
 				}
2532 2506
 			}
@@ -2564,8 +2538,7 @@  discard block
 block discarded – undo
2564 2538
 							if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2565 2539
 								$tpl_component['VARIATION_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', 'custom'));
2566 2540
 								$position = wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'position', 'custom');
2567
-							}
2568
-							else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2541
+							} else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2569 2542
 								$post_def = get_post($attribute_value);
2570 2543
 								$tpl_component['VARIATION_VALUE'] = stripslashes($post_def->post_title);
2571 2544
 								$position = $post_def->menu_order;
@@ -2899,8 +2872,7 @@  discard block
 block discarded – undo
2899 2872
 				//Get Summary cart
2900 2873
 				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product( $product_id, $the_product, ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ? true : false )  );
2901 2874
 				$response_status = true;
2902
-			}
2903
-			else {
2875
+			} else {
2904 2876
 				//Product without variations
2905 2877
 				$product_data = wpshop_products::get_product_data($product_id);
2906 2878
 				$response['product_price_output'] = wpshop_prices::get_product_price($product_data, 'price_display', 'complete_sheet');
@@ -2971,8 +2943,7 @@  discard block
 block discarded – undo
2971 2943
 						}
2972 2944
 					}
2973 2945
 				}
2974
-			}
2975
-			else {
2946
+			} else {
2976 2947
 				// Get combined variations
2977 2948
 				$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_key = '_wpshop_variations_attribute_def' AND P_META.meta_value = '" . serialize($query_variation) . "'", $product_id);
2978 2949
 				$combined_variation_id = $wpdb->get_var($query);
@@ -2995,12 +2966,10 @@  discard block
 block discarded – undo
2995 2966
 						}
2996 2967
 					}
2997 2968
 					$product_to_add_to_cart['display_lower_price'] = true;
2998
-				}
2999
-				else {
2969
+				} else {
3000 2970
 					$product_to_add_to_cart[$product_id]['variations'] = array();
3001 2971
 				}
3002
-			}
3003
-			else {
2972
+			} else {
3004 2973
 				$product_to_add_to_cart['text_from'] = '';
3005 2974
 				$product_to_add_to_cart[$product_id]['variations'] = ( !empty($product_variation_type) && $product_variation_type == 'single' ) ? $single_variations : $combined_variations;
3006 2975
 			}
@@ -3051,11 +3020,9 @@  discard block
 block discarded – undo
3051 3020
 
3052 3021
 						if( !empty($discount_config['type']) && $discount_config['type'] == 'discount_amount' ) {
3053 3022
 							$product_into_cart['discount_amount'] = $discount_amount + $product_into_cart['discount_amount'];
3054
-						}
3055
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3023
+						} elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3056 3024
 							$product_into_cart['discount_rate'] = $discount_rate + $discount_config['value'];
3057
-						}
3058
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3025
+						} elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3059 3026
 							$product_into_cart['special_price'] = $special_price + $discount_config['value'];
3060 3027
 						}
3061 3028
 					}
@@ -3076,14 +3043,12 @@  discard block
 block discarded – undo
3076 3043
 					$product_into_cart['product_price'] = $variations_discount_total_price['price_ati'];
3077 3044
 					$product_into_cart['price_ht'] = $variations_discount_total_price['price_et'];
3078 3045
 					$product_into_cart['tva'] = $variations_discount_total_price['vat_amount'];
3079
-				}
3080
-				else {
3046
+				} else {
3081 3047
 					$product_into_cart['product_price'] = $variations_total_price['price_ati'];
3082 3048
 					$product_into_cart['price_ht'] = $variations_total_price['price_et'];
3083 3049
 					$product_into_cart['tva'] = $variations_total_price['vat_amount'];
3084 3050
 				}
3085
-			}
3086
-			else {
3051
+			} else {
3087 3052
 				// Add variations price to product price
3088 3053
 				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3089 3054
 					$product_into_cart['price_ttc_before_discount'] = ( $product_into_cart['product_price'] + $variations_total_price['price_ati'] );
@@ -3092,8 +3057,7 @@  discard block
 block discarded – undo
3092 3057
 					$product_into_cart['product_price'] += $variations_discount_total_price['price_ati'];
3093 3058
 					$product_into_cart['price_ht'] += $variations_discount_total_price['price_et'];
3094 3059
 					$product_into_cart['tva'] += $variations_discount_total_price['vat_amount'];
3095
-				}
3096
-				else {
3060
+				} else {
3097 3061
 					$product_into_cart['product_price'] += $variations_total_price['price_ati'];
3098 3062
 					$product_into_cart['price_ht'] += $variations_total_price['price_et'];
3099 3063
 					$product_into_cart['tva'] += $variations_total_price['vat_amount'];
@@ -3107,17 +3071,14 @@  discard block
 block discarded – undo
3107 3071
 
3108 3072
 					if( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount' ) {
3109 3073
 						$product_into_cart['discount_amount'] = $discount_amount +  $parent_discount_config['value'];
3110
-					}
3111
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3074
+					} elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3112 3075
 						$product_into_cart['discount_rate'] = $discount_rate + $parent_discount_config['value'];
3113
-					}
3114
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3076
+					} elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3115 3077
 						$product_into_cart['special_price'] = $special_price + $parent_discount_config['value'];
3116 3078
 					}
3117 3079
 				}
3118 3080
 			}
3119
-		}
3120
-		else {
3081
+		} else {
3121 3082
 			// If product have just Free variations
3122 3083
 			$discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3123 3084
 			if( !empty($discount_config) ) {
@@ -3161,8 +3122,7 @@  discard block
 block discarded – undo
3161 3122
 					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3162 3123
 						$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = $display_data;
3163 3124
 					}
3164
-				}
3165
-				else {
3125
+				} else {
3166 3126
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3167 3127
 					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3168 3128
 						$variation_attribute_ordered['attribute_list'][] = $display_data;
@@ -3202,8 +3162,7 @@  discard block
 block discarded – undo
3202 3162
 					$variation_definition = explode('-_variation_val_-', $build_variation);
3203 3163
 					$attribute_code = $variation_definition[0];
3204 3164
 					$attribute_selected_value = $variation_definition[1];
3205
-				}
3206
-				else {
3165
+				} else {
3207 3166
 					$attribute_code = $build_variation_key;
3208 3167
 					$attribute_selected_value = $build_variation;
3209 3168
 				}
@@ -3291,8 +3250,7 @@  discard block
 block discarded – undo
3291 3250
 				$output .= '<li>' .sprintf( __( 'Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key'] ). '</li>';
3292 3251
 			}
3293 3252
 			$output .= '</ul>';
3294
-		}
3295
-		else {
3253
+		} else {
3296 3254
 			$output .= __( 'This product has never been ordered', 'wpshop');
3297 3255
 		}
3298 3256
 
@@ -3310,8 +3268,9 @@  discard block
 block discarded – undo
3310 3268
 		if ( count($product_attribute_order_detail) > 0 ) {
3311 3269
 			foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312 3270
 				foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
-					if ( !empty($attribute_def->code) )
3314
-						$output_order[$attribute_def->code] = $position;
3271
+					if ( !empty($attribute_def->code) ) {
3272
+											$output_order[$attribute_def->code] = $position;
3273
+					}
3315 3274
 				}
3316 3275
 			}
3317 3276
 		}
@@ -3331,8 +3290,7 @@  discard block
 block discarded – undo
3331 3290
 				if ( !empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
3332 3291
 					$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3333 3292
 				}
3334
-			}
3335
-			else {
3293
+			} else {
3336 3294
 				$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $product_definition_value, $output_order, 'selection_summary' );
3337 3295
 			}
3338 3296
 		}
Please login to merge, or discard this patch.
Spacing   +802 added lines, -802 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
 * Products management method file
4 4
 *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 		die();
38 38
 	}
39 39
 
40
-	function products_list_js () {
40
+	function products_list_js() {
41 41
 		global $wpdb;
42 42
 		/** Create a JS Array of products **/
43 43
 // 		$query = $wpdb->prepare('SELECT ID, post_title FROM ' .$wpdb->posts. '  WHERE post_type = %s AND post_status = %s', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
44 44
 // 		$products_post = $wpdb->get_results( $query );
45 45
 
46
-		$products_post = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'post_status' => 'publish', 'posts_per_page' => -1 ) );
46
+		$products_post = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'post_status' => 'publish', 'posts_per_page' => -1));
47 47
 
48
-		if ( !empty( $products_post ) ) {
49
-			$products_js_array  = 'var products = [';
50
-			foreach ( $products_post as $product ) {
51
-				$barcode = get_post_meta( $product->ID, '_barcode', true);
52
-				$products_js_array .= '{label:"#' .$product->ID. ' ' .str_replace('"', '', $product->post_title). ' - ' .( (!empty($barcode) ) ? $barcode : '' ). '", ';
53
-				$products_js_array .= 'value:"' .$product->ID. '", ';
54
-				$products_js_array .= ( !empty($barcode) ) ? 'desc:"' .$barcode. '"},' : '},';
48
+		if (!empty($products_post)) {
49
+			$products_js_array = 'var products = [';
50
+			foreach ($products_post as $product) {
51
+				$barcode = get_post_meta($product->ID, '_barcode', true);
52
+				$products_js_array .= '{label:"#' . $product->ID . ' ' . str_replace('"', '', $product->post_title) . ' - ' . ((!empty($barcode)) ? $barcode : '') . '", ';
53
+				$products_js_array .= 'value:"' . $product->ID . '", ';
54
+				$products_js_array .= (!empty($barcode)) ? 'desc:"' . $barcode . '"},' : '},';
55 55
 			}
56 56
 			$products_js_array .= '];';
57 57
 		}
58
-		$output = wpshop_display::display_template_element('wps_orders_products_list_js', array('PRODUCTS_JS_ARRAY' => $products_js_array) , array(), 'admin');
58
+		$output = wpshop_display::display_template_element('wps_orders_products_list_js', array('PRODUCTS_JS_ARRAY' => $products_js_array), array(), 'admin');
59 59
 		return $output;
60 60
 	}
61 61
 
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 				'with_front'		=> false,
78 78
 		);
79 79
 
80
-		if ( empty( $options['wpshop_catalog_product_slug'] ) || $options['wpshop_catalog_product_slug'] == '/' ) {
80
+		if (empty($options['wpshop_catalog_product_slug']) || $options['wpshop_catalog_product_slug'] == '/') {
81 81
 			$slug = false;
82 82
 		} else {
83 83
 			$slug['slug'] = $options['wpshop_catalog_product_slug'];
84
-			if( !empty( $options['wpshop_catalog_product_slug_with_category'] ) ) {
84
+			if (!empty($options['wpshop_catalog_product_slug_with_category'])) {
85 85
 				$slug['slug'] .= '/%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%';
86 86
 			}
87 87
 		}
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
 		/*	Définition des produits 	*/
91 91
 		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, array(
92 92
 			'labels' => array(
93
-				'name'					=> __( 'Products', 'wpshop' ),
94
-				'singular_name' 		=> __( 'Catalog', 'wpshop' ),
95
-				'add_new_item' 			=> __( 'Add new product', 'wpshop' ),
96
-				'add_new' 				=> __( 'Add new product', 'wpshop' ),
97
-				'add_new_item' 			=> __( 'Add new product', 'wpshop' ),
98
-				'edit_item' 			=> __( 'Edit product', 'wpshop' ),
99
-				'new_item' 				=> __( 'New product', 'wpshop' ),
100
-				'view_item' 			=> __( 'View product', 'wpshop' ),
101
-				'search_items' 			=> __( 'Search products', 'wpshop' ),
102
-				'not_found' 			=> __( 'No products found', 'wpshop' ),
103
-				'not_found_in_trash' 	=> __( 'No products found in Trash', 'wpshop' ),
93
+				'name'					=> __('Products', 'wpshop'),
94
+				'singular_name' 		=> __('Catalog', 'wpshop'),
95
+				'add_new_item' 			=> __('Add new product', 'wpshop'),
96
+				'add_new' 				=> __('Add new product', 'wpshop'),
97
+				'add_new_item' 			=> __('Add new product', 'wpshop'),
98
+				'edit_item' 			=> __('Edit product', 'wpshop'),
99
+				'new_item' 				=> __('New product', 'wpshop'),
100
+				'view_item' 			=> __('View product', 'wpshop'),
101
+				'search_items' 			=> __('Search products', 'wpshop'),
102
+				'not_found' 			=> __('No products found', 'wpshop'),
103
+				'not_found_in_trash' 	=> __('No products found in Trash', 'wpshop'),
104 104
 				'parent_item_colon' 	=> ''
105 105
 			),
106 106
 			'supports' 				=> unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT),
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
 			'has_archive'			=> false,
109 109
 			'show_in_nav_menus' 	=> true,
110 110
 			//'rewrite' 				=> false,	//	For information see below
111
-			'taxonomies' 			=> array( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES ),
111
+			'taxonomies' 			=> array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES),
112 112
 			'menu_icon' 			=> 'dashicons-archive',
113 113
 			'rewrite' 				=> $slug,
114 114
 		));
115 115
 
116 116
 		/*	Définition des variations de produit (Déclinaisons)	*/
117
-		register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, array(
117
+		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, array(
118 118
 			'labels'				=> array(
119
-				'name' 					=> __( 'Variations', 'wpshop' ),
120
-				'singular_name' 		=> __( 'Variation', 'wpshop' ),
121
-				'add_new' 				=> __( 'Add Variation', 'wpshop' ),
122
-				'add_new_item' 			=> __( 'Add New Variation', 'wpshop' ),
123
-				'edit' 					=> __( 'Edit', 'wpshop' ),
124
-				'edit_item' 			=> __( 'Edit Variation', 'wpshop' ),
125
-				'new_item' 				=> __( 'New Variation', 'wpshop' ),
126
-				'view' 					=> __( 'View Variation', 'wpshop' ),
127
-				'view_item' 			=> __( 'View Variation', 'wpshop' ),
128
-				'search_items' 			=> __( 'Search Variations', 'wpshop' ),
129
-				'not_found' 			=> __( 'No Variations found', 'wpshop' ),
130
-				'not_found_in_trash' 	=> __( 'No Variations found in trash', 'wpshop' ),
119
+				'name' 					=> __('Variations', 'wpshop'),
120
+				'singular_name' 		=> __('Variation', 'wpshop'),
121
+				'add_new' 				=> __('Add Variation', 'wpshop'),
122
+				'add_new_item' 			=> __('Add New Variation', 'wpshop'),
123
+				'edit' 					=> __('Edit', 'wpshop'),
124
+				'edit_item' 			=> __('Edit Variation', 'wpshop'),
125
+				'new_item' 				=> __('New Variation', 'wpshop'),
126
+				'view' 					=> __('View Variation', 'wpshop'),
127
+				'view_item' 			=> __('View Variation', 'wpshop'),
128
+				'search_items' 			=> __('Search Variations', 'wpshop'),
129
+				'not_found' 			=> __('No Variations found', 'wpshop'),
130
+				'not_found_in_trash' 	=> __('No Variations found in trash', 'wpshop'),
131 131
 				'parent_item_colon' 	=> ''
132 132
 			),
133 133
 			'supports' 				=> unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT),
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 	
164 164
 	public static function hidden_meta_boxes($hidden, $screen, $use_defaults) {
165 165
 		global $wpdb;
166
-		if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT === $screen->post_type ) {
167
-			$user_meta_for_wpshop = array('metaboxhidden_'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
168
-			foreach($user_meta_for_wpshop as $meta_to_check){
169
-				$metas_hidden = get_user_meta( get_current_user_id(), $meta_to_check, true );
170
-				if( empty( $metas_hidden ) && !is_array( $metas_hidden ) ) {
171
-					$hidden = unserialize( WPSHOP_PRODUCT_HIDDEN_METABOX );
166
+		if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT === $screen->post_type) {
167
+			$user_meta_for_wpshop = array('metaboxhidden_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
168
+			foreach ($user_meta_for_wpshop as $meta_to_check) {
169
+				$metas_hidden = get_user_meta(get_current_user_id(), $meta_to_check, true);
170
+				if (empty($metas_hidden) && !is_array($metas_hidden)) {
171
+					$hidden = unserialize(WPSHOP_PRODUCT_HIDDEN_METABOX);
172 172
 				}
173 173
 			}
174 174
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	public static function add_meta_boxes() {
182 182
 		global $post, $currentTabContent;
183 183
 
184
-		if(!empty($post->post_type) && ( ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ) ) {
184
+		if (!empty($post->post_type) && (($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION))) {
185 185
 			/*	Get the attribute set list for the current entity	*/
186 186
 			$attributeEntitySetList = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode));
187 187
 			/*	Check if the meta information of the current product already exists 	*/
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
 			/*	Check if the product has been saved without meta information set	*/
190 190
 			$attribute_set_id = wpshop_attributes::get_attribute_value_content('product_attribute_set_id', $post->ID, self::currentPageCode);
191 191
 			/*	Unset 'free_product' from list of attributes set	*/
192
-			foreach( $attributeEntitySetList as $key_attribute_set => $attribute_set ) {
193
-				if( $attribute_set->slug == 'free_product' ) {
192
+			foreach ($attributeEntitySetList as $key_attribute_set => $attribute_set) {
193
+				if ($attribute_set->slug == 'free_product') {
194 194
 					unset($attributeEntitySetList[$key_attribute_set]);
195 195
 					break;
196 196
 				}
197 197
 			}
198 198
 
199 199
 			/*	Check if an attribute has already been choosen for the curernt entity or if the user has to choose a entity set before continuing	*/
200
-			if(((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))){
201
-				if((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))){
200
+			if (((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))) {
201
+				if ((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))) {
202 202
 					$post_attribute_set_id = $attributeEntitySetList[0]->id;
203 203
 				}
204
-				elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
204
+				elseif (($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)) {
205 205
 					$post_attribute_set_id = $attribute_set_id->value;
206 206
 				}
207 207
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 
210 210
 				$fixed_box_exist = false;
211 211
 				/*	Get all the other attribute set for hte current entity	*/
212
-				if(isset($currentTabContent['box']) && count($currentTabContent['box']) > 0){
213
-					foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
214
-						if(!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type'] == 'movable-tab')){
212
+				if (isset($currentTabContent['box']) && count($currentTabContent['box']) > 0) {
213
+					foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
214
+						if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab')) {
215 215
 							add_meta_box('wpshop_product_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_products', 'meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default', array('boxIdentifier' => $boxIdentifier));
216 216
 						}
217 217
 						else $fixed_box_exist = true;
218 218
 					}
219 219
 				}
220
-				if ( $fixed_box_exist ) {
220
+				if ($fixed_box_exist) {
221 221
 					add_meta_box('wpshop_product_fixed_tab', __('Product data', 'wpshop'), array('wpshop_products', 'product_data_meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'high', array('currentTabContent' => $currentTabContent));
222 222
 					add_meta_box('wpshop_product_fixed_tab', __('Product data', 'wpshop'), array('wpshop_products', 'product_data_meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'normal', 'high', array('currentTabContent' => $currentTabContent));
223 223
 				}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 				/**	Product option	*/
230 230
 				add_meta_box('wpshop_product_options', __('Options', 'wpshop'), array('wpshop_products', 'product_options_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'side', 'default');
231 231
 			}
232
-			else if ( count($attributeEntitySetList) > 1 ) {
232
+			else if (count($attributeEntitySetList) > 1) {
233 233
 				$input_def['id'] = 'product_attribute_set_id';
234 234
 				$input_def['name'] = 'product_attribute_set_id';
235 235
 				$input_def['value'] = '';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 				$input_def['value'] = '';
240 240
 				foreach ($attributeEntitySetList as $set) {
241
-					if( $set->default_set == 'yes' ) {
241
+					if ($set->default_set == 'yes') {
242 242
 						$input_def['value'] = $set->id;
243 243
 					}
244 244
 				}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				$currentTabContent['boxContent']['attribute_set_selector'] = '
247 247
 	<ul class="attribute_set_selector" >
248 248
 		<li class="attribute_set_selector_title_select" ><label for="title" >' . __('Choose a title for your product', 'wpshop') . '</label></li>
249
-		<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . __('Choose an attribute group for this product', 'wpshop') . '</label>&nbsp;'.wpshop_form::check_input_type($input_def, self::currentPageCode.'_attribute[integer]').'</li>
249
+		<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . __('Choose an attribute group for this product', 'wpshop') . '</label>&nbsp;' . wpshop_form::check_input_type($input_def, self::currentPageCode . '_attribute[integer]') . '</li>
250 250
 		<li class="attribute_set_selector_save_instruction" >' . __('Save the product with the "Save draft" button on the right side', 'wpshop') . '</li>
251 251
 		<li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li>
252 252
 	</ul>';
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @param object $post
264 264
 	 */
265
-	public static function product_options_meta_box_content( $post ) {
265
+	public static function product_options_meta_box_content($post) {
266 266
 		$output = '';
267 267
 
268
-		$product_current_options = get_post_meta( $post->ID, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true);
268
+		$product_current_options = get_post_meta($post->ID, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true);
269 269
 
270 270
 		$tpl_component = array();
271 271
 		$tpl_component['ADMIN_PRODUCT_OPTION_FOR_CART_AUTOADD_CHECKBOX_STATE'] = (!empty($product_current_options['cart']) && !empty($product_current_options['cart']['auto_add'])) ? ' checked="checked"' : '';
@@ -284,25 +284,25 @@  discard block
 block discarded – undo
284 284
 
285 285
 		echo '<div id="fixed-tabs" class="wpshop_tabs wpshop_detail_tabs wpshop_product_attribute_tabs" >
286 286
 				<ul>';
287
-		if(!empty($currentTabContent['box'])){
288
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
289
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
290
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
291
-						echo '<li><a href="#tabs-'.sanitize_title($boxIdentifier).'">'.__($boxTitle, 'wpshop').'</a></li>';
287
+		if (!empty($currentTabContent['box'])) {
288
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
289
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
290
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
291
+						echo '<li><a href="#tabs-' . sanitize_title($boxIdentifier) . '">' . __($boxTitle, 'wpshop') . '</a></li>';
292 292
 					}
293 293
 				}
294 294
 			}
295 295
 		}
296
-		echo '<li><a href="#tabs-product-related">'.__('Related products', 'wpshop').'</a></li>';
297
-		echo '<li><a href="#tabs-product-provider">'.__('Providers', 'wpshop').'</a></li>';
298
-		echo '<li class="wpshop_product_data_display_tab" ><a href="#tabs-product-display">'.__('Product display', 'wpshop').'</a></li>';
296
+		echo '<li><a href="#tabs-product-related">' . __('Related products', 'wpshop') . '</a></li>';
297
+		echo '<li><a href="#tabs-product-provider">' . __('Providers', 'wpshop') . '</a></li>';
298
+		echo '<li class="wpshop_product_data_display_tab" ><a href="#tabs-product-display">' . __('Product display', 'wpshop') . '</a></li>';
299 299
 		echo '</ul>';
300 300
 
301
-		if(!empty($currentTabContent['box'])){
302
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
303
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
304
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
305
-						echo '<div id="tabs-'.sanitize_title($boxIdentifier).'">'.$currentTabContent['boxContent'][$boxIdentifier].'</div>';
301
+		if (!empty($currentTabContent['box'])) {
302
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
303
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
304
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
305
+						echo '<div id="tabs-' . sanitize_title($boxIdentifier) . '">' . $currentTabContent['boxContent'][$boxIdentifier] . '</div>';
306 306
 					}
307 307
 				}
308 308
 			}
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 	 * @param object $post The current edited post
325 325
 	 * @return string
326 326
 	 */
327
-	public static function related_products_meta_box_content( $post ) {
327
+	public static function related_products_meta_box_content($post) {
328 328
 		$content = $existing_selection = '';
329 329
 
330
-		if( !empty($post->ID) ) {
330
+		if (!empty($post->ID)) {
331 331
 			$related_products_id = get_post_meta($post->ID, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
332
-			if( !empty($related_products_id) && !empty($related_products_id[0]) ) {
332
+			if (!empty($related_products_id) && !empty($related_products_id[0])) {
333 333
 				foreach ($related_products_id as $related_product_id) {
334 334
 					$existing_selection .= '<option selected value="' . $related_product_id . '" >' . get_the_title($related_product_id) . '</option>';
335 335
 				}
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 	 * @param object $post The current edited post
350 350
 	 * @return string
351 351
 	 */
352
-	public static function provider_products_meta_box_content( $post ) {
352
+	public static function provider_products_meta_box_content($post) {
353 353
 		$content = $existing_selection = '';
354 354
 
355
-		if( !empty($post->ID) ) {
355
+		if (!empty($post->ID)) {
356 356
 			$providers_id = get_post_meta($post->ID, WPSHOP_PRODUCT_PROVIDER, true);
357
-			if( !empty($providers_id) && !empty($providers_id[0]) ) {
357
+			if (!empty($providers_id) && !empty($providers_id[0])) {
358 358
 				foreach ($providers_id as $provider_id) {
359
-					$existing_selection .= '<option selected value="' . $provider_id . '" >' . get_the_title( $provider_id ) . '</option>';
359
+					$existing_selection .= '<option selected value="' . $provider_id . '" >' . get_the_title($provider_id) . '</option>';
360 360
 				}
361 361
 			}
362 362
 		}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * Define the metabox content for the action box
374 374
 	 * @param obejct $post The current element being edited
375 375
 	 */
376
-	public static function product_actions_meta_box_content( $post ) {
376
+	public static function product_actions_meta_box_content($post) {
377 377
 		$output = '';
378 378
 		/*
379 379
 		 * Template parameters
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		$template_part = 'wpshop_duplicate_product';
382 382
 		$tpl_component = array();
383 383
 		$tpl_component['PRODUCT_ID'] = $post->ID;
384
-		$tpl_component['PRINT_PRODUCT_SHEET_LINK'] = WPSHOP_TEMPLATES_URL.'product_sheet.php?pid='.$post->ID;
384
+		$tpl_component['PRINT_PRODUCT_SHEET_LINK'] = WPSHOP_TEMPLATES_URL . 'product_sheet.php?pid=' . $post->ID;
385 385
 		/*
386 386
 		 * Build template
387 387
 		*/
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	/**
395 395
 	 *	Define the content of the product main information box
396 396
 	 */
397
-	public static function meta_box_content($post, $metaboxArgs){
397
+	public static function meta_box_content($post, $metaboxArgs) {
398 398
 		global $currentTabContent;
399 399
 
400 400
 		/*	Add the extra fields defined by the default attribute group in the general section	*/
@@ -407,19 +407,19 @@  discard block
 block discarded – undo
407 407
 	 * @param object $post The current element being edited
408 408
 	 * @return string The metabox content
409 409
 	 */
410
-	public static function product_frontend_display_config_meta_box( $post ) {
410
+	public static function product_frontend_display_config_meta_box($post) {
411 411
 		$content = '';
412 412
 
413 413
 		$product_attribute_frontend_display_config = null;
414
-		if( !empty($post->ID) ) {
414
+		if (!empty($post->ID)) {
415 415
 			$product_attribute_frontend_display_config = get_post_meta($post->ID, WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
416 416
 
417 417
 			$extra_options = get_option('wpshop_extra_options', array());
418
-			$column_count = (!empty($extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY'])?$extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY']:3);
419
-			$attribute_list = wpshop_attributes::getElementWithAttributeAndValue(wpshop_entities::get_entity_identifier_from_code( self::currentPageCode ), $post->ID, WPSHOP_CURRENT_LOCALE);
418
+			$column_count = (!empty($extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY']) ? $extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY'] : 3);
419
+			$attribute_list = wpshop_attributes::getElementWithAttributeAndValue(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post->ID, WPSHOP_CURRENT_LOCALE);
420 420
 			$column = 1;
421 421
 
422
-			if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
422
+			if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
423 423
 				$sub_tpl_component = array();
424 424
 				$sub_tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_NAME'] = __('Action on product', 'wpshop');
425 425
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 				$tpl_component['ADMIN_ATTRIBUTE_FD_ID'] = $post->ID . '_product_action_button_add_to_cart';
430 430
 				$button_is_set_to_be_displayed = (WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no';
431 431
 
432
-				$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display( $button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'complete_sheet') ? ' checked="checked"' : '';
433
-				$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display( $button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'mini_output') ? ' checked="checked"' : '';
432
+				$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display($button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'complete_sheet') ? ' checked="checked"' : '';
433
+				$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display($button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'mini_output') ? ' checked="checked"' : '';
434 434
 				$sub_tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_CONTENT'] = wpshop_display::display_template_element('wpshop_admin_attr_config_for_front_display', $tpl_component, array(), 'admin');
435 435
 				unset($tpl_component);
436 436
 
@@ -440,21 +440,21 @@  discard block
 block discarded – undo
440 440
 				$sub_content[1] = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display', $sub_tpl_component, array(), 'admin');
441 441
 			}
442 442
 
443
-			if ( !empty($attribute_list[$post->ID]) && is_array($attribute_list[$post->ID]) ) {
444
-				foreach ( $attribute_list[$post->ID] as $attribute_set_section_name => $attribute_set_section_content ) {
445
-					if ( !isset($sub_content[$column]) ) {
443
+			if (!empty($attribute_list[$post->ID]) && is_array($attribute_list[$post->ID])) {
444
+				foreach ($attribute_list[$post->ID] as $attribute_set_section_name => $attribute_set_section_content) {
445
+					if (!isset($sub_content[$column])) {
446 446
 						$sub_content[$column] = '';
447 447
 					}
448 448
 
449 449
 					$attribute_sub_output = '';
450
-					foreach ( $attribute_set_section_content['attributes'] as $attribute_id => $attribute_def ) {
451
-						if ( $attribute_def['attribute_code'] != 'product_attribute_set_id' ) {
450
+					foreach ($attribute_set_section_content['attributes'] as $attribute_id => $attribute_def) {
451
+						if ($attribute_def['attribute_code'] != 'product_attribute_set_id') {
452 452
 							$tpl_component = array();
453 453
 							$tpl_component['ADMIN_ATTRIBUTE_LABEL'] = $attribute_def['frontend_label'];
454 454
 							$tpl_component['ADMIN_ATTRIBUTE_FD_NAME'] = self::currentPageCode . '_attr_frontend_display[attribute][' . $attribute_def['attribute_code'] . ']';
455 455
 							$tpl_component['ADMIN_ATTRIBUTE_FD_ID'] = $post->ID . '_' . $attribute_def['attribute_code'];
456
-							$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display( $attribute_def['is_visible_in_front'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'complete_sheet') ? ' checked="checked"' : '';
457
-							$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display( $attribute_def['is_visible_in_front_listing'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'mini_output') ? ' checked="checked"' : '';
456
+							$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display($attribute_def['is_visible_in_front'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'complete_sheet') ? ' checked="checked"' : '';
457
+							$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display($attribute_def['is_visible_in_front_listing'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'mini_output') ? ' checked="checked"' : '';
458 458
 							$attribute_sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_config_for_front_display', $tpl_component, array(), 'admin');
459 459
 							unset($tpl_component);
460 460
 						}
@@ -465,18 +465,18 @@  discard block
 block discarded – undo
465 465
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_CONTENT'] = $attribute_sub_output;
466 466
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_FD_NAME'] = self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . ']';
467 467
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_FD_ID'] = $attribute_set_section_content['code'];
468
-					$ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK = wpshop_attributes::check_attribute_display( $attribute_set_section_content['display_on_frontend'], $product_attribute_frontend_display_config, 'attribute_set_section', $attribute_set_section_content['code'], 'complete_sheet') ? ' checked="checked"' : '';
469
-					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_INPUT_CHECKBOX'] = '<input type="checkbox" name="' .  self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . '][complete_sheet]" id="' .  $attribute_set_section_content['code'] . '_complete_sheet" value="yes"' . $ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK . ' /><label for="' .  $attribute_set_section_content['code'] . '_complete_sheet" >' . __('Display in product page', 'wpshop') . '</label>';
468
+					$ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK = wpshop_attributes::check_attribute_display($attribute_set_section_content['display_on_frontend'], $product_attribute_frontend_display_config, 'attribute_set_section', $attribute_set_section_content['code'], 'complete_sheet') ? ' checked="checked"' : '';
469
+					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_INPUT_CHECKBOX'] = '<input type="checkbox" name="' . self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . '][complete_sheet]" id="' . $attribute_set_section_content['code'] . '_complete_sheet" value="yes"' . $ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK . ' /><label for="' . $attribute_set_section_content['code'] . '_complete_sheet" >' . __('Display in product page', 'wpshop') . '</label>';
470 470
 					$sub_content[$column] .= wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display', $tpl_component, array(), 'admin');
471 471
 					$column++;
472
-					if ( $column > $column_count ){
472
+					if ($column > $column_count) {
473 473
 						$column = 1;
474 474
 					}
475 475
 				}
476 476
 			}
477 477
 			$tpl_component = array();
478 478
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] = '';
479
-			for ( $i=1; $i<=$column_count; $i++ ) {
479
+			for ($i = 1; $i <= $column_count; $i++) {
480 480
 				if (!empty($sub_content[$i]))
481 481
 					$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
482 482
 			}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$tpl_component['ADMIN_PRODUCT_ATTRIBUTE_FRONTEND_DISPLAY_MAIN_CHOICE_CHECK'] = empty($product_attribute_frontend_display_config) ? ' checked="checked"' : '';
485 485
 			$tpl_component['ADMIN_ATTRIBUTE_FD_NAME'] = self::currentPageCode . '_attr_frontend_display';
486 486
 
487
-			$content = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display_default_choice',$tpl_component, array(), 'admin') . '<div class="wpshop_cls"></div>';
487
+			$content = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display_default_choice', $tpl_component, array(), 'admin') . '<div class="wpshop_cls"></div>';
488 488
 		}
489 489
 
490 490
 		return $content;
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 
500 500
 		$data = array(array('code' => 'title', 'frontend_label' => __('Product name', 'wpshop')), array('code' => 'date', 'frontend_label' => __('Date added', 'wpshop')), array('code' => 'modified', 'frontend_label' => __('Date modified', 'wpshop')));
501 501
 
502
-		$query = $wpdb->prepare("SELECT code, frontend_label FROM ".WPSHOP_DBT_ATTRIBUTE." WHERE is_used_for_sort_by = %s",  'yes');
502
+		$query = $wpdb->prepare("SELECT code, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE is_used_for_sort_by = %s", 'yes');
503 503
 		$results = $wpdb->get_results($query, ARRAY_A);
504
-		if(!empty($results))$data = array_merge($data, $results);
504
+		if (!empty($results))$data = array_merge($data, $results);
505 505
 
506 506
 		return $data;
507 507
 	}
@@ -513,62 +513,62 @@  discard block
 block discarded – undo
513 513
 		$query = "SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code=%s";
514 514
 		$data = (array)$wpdb->get_row($wpdb->prepare($query, $attr_name));
515 515
 
516
-		if(!empty($data)) {
517
-			if ($data['data_type_to_use'] == 'custom' ) {
516
+		if (!empty($data)) {
517
+			if ($data['data_type_to_use'] == 'custom') {
518 518
 				// Find which table to take
519
-				if($data['data_type']=='datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
-				elseif($data['data_type']=='decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
-				elseif($data['data_type']=='integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
-				elseif($data['data_type']=='options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
-				elseif($data['data_type']=='text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
-				elseif($data['data_type']=='varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
525
-
526
-				if(isset($table_name)) {
519
+				if ($data['data_type'] == 'datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
+				elseif ($data['data_type'] == 'decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
+				elseif ($data['data_type'] == 'integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
+				elseif ($data['data_type'] == 'options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
+				elseif ($data['data_type'] == 'text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
+				elseif ($data['data_type'] == 'varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
525
+
526
+				if (isset($table_name)) {
527 527
 					// If the value is an id of a select, radio or checkbox
528
-					if(in_array($data['backend_input'], array('select','multiple-select', 'radio','checkbox'))) {
528
+					if (in_array($data['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox'))) {
529 529
 
530 530
 						$query = $wpdb->prepare("
531
-							SELECT ".$table_name.".entity_id FROM ".$table_name."
532
-							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
533
-							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE." AS ATT ON ATT.id = ".$table_name.".attribute_id
534
-							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." AS ATT_OPT ON ".$table_name.".value = ATT_OPT.id
535
-							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower( __( $attr_value, 'wpshop' ) ), $attr_value
531
+							SELECT ".$table_name . ".entity_id FROM " . $table_name . "
532
+							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
533
+							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE . " AS ATT ON ATT.id = " . $table_name . ".attribute_id
534
+							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATT_OPT ON " . $table_name . ".value = ATT_OPT.id
535
+							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower(__($attr_value, 'wpshop')), $attr_value
536 536
 						);
537 537
 						$data = $wpdb->get_results($query);
538 538
 					}
539 539
 					else {
540 540
 
541 541
 						$query = $wpdb->prepare("
542
-							SELECT ".$table_name.".entity_id FROM ".$table_name."
543
-							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
544
-							INNER JOIN ".WPSHOP_DBT_ATTRIBUTE." AS ATT ON ATT.id = ".$table_name.".attribute_id
545
-								INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
546
-							WHERE ATT.code=%s AND ".$table_name.".value=%s", $attr_name, sprintf('%.5f', $attr_value) // force useless zero like 48.58000
542
+							SELECT ".$table_name . ".entity_id FROM " . $table_name . "
543
+							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
544
+							INNER JOIN ".WPSHOP_DBT_ATTRIBUTE . " AS ATT ON ATT.id = " . $table_name . ".attribute_id
545
+								INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
546
+							WHERE ATT.code=%s AND ".$table_name . ".value=%s", $attr_name, sprintf('%.5f', $attr_value) // force useless zero like 48.58000
547 547
 						);
548 548
 						$data = $wpdb->get_results($query);
549 549
 
550 550
 					}
551 551
 				}
552
-				else return __('Incorrect shortcode','wpshop');
552
+				else return __('Incorrect shortcode', 'wpshop');
553 553
 			}
554
-			elseif( $data['data_type_to_use'] == 'internal' )  {
554
+			elseif ($data['data_type_to_use'] == 'internal') {
555 555
 				/** Check the ID of manufacturer **/
556
-				$default_value = unserialize( $data['default_value'] );
557
-				if( !empty($default_value) && !empty($default_value['default_value']) ) {
558
-					$query = get_post( $attr_value );
559
-					$pid = ( !empty($query) && !empty($query->ID) ) ? $query->ID : '';
560
-					if ( !empty($pid) ) {
561
-						$query = $wpdb->prepare( 'SELECT post_id AS entity_id FROM '.$wpdb->postmeta.' WHERE post_id = ID AND post_status = %s AND meta_key = %s AND meta_value = %s', 'publish', '_'.$data['code'], $pid);
562
-						$data = $wpdb->get_results( $query );
556
+				$default_value = unserialize($data['default_value']);
557
+				if (!empty($default_value) && !empty($default_value['default_value'])) {
558
+					$query = get_post($attr_value);
559
+					$pid = (!empty($query) && !empty($query->ID)) ? $query->ID : '';
560
+					if (!empty($pid)) {
561
+						$query = $wpdb->prepare('SELECT post_id AS entity_id FROM ' . $wpdb->postmeta . ' WHERE post_id = ID AND post_status = %s AND meta_key = %s AND meta_value = %s', 'publish', '_' . $data['code'], $pid);
562
+						$data = $wpdb->get_results($query);
563 563
 					}
564 564
 				}
565
-			}else return __('Incorrect shortcode','wpshop');
565
+			} else return __('Incorrect shortcode', 'wpshop');
566 566
 
567
-		} else return __('Incorrect shortcode','wpshop');
567
+		} else return __('Incorrect shortcode', 'wpshop');
568 568
 
569
-		if(!empty($data)) {
570
-			foreach($data as $p) {
571
-				if ( !empty($p) && is_object($p) && !empty($p->entity_id) ) {
569
+		if (!empty($data)) {
570
+			foreach ($data as $p) {
571
+				if (!empty($p) && is_object($p) && !empty($p->entity_id)) {
572 572
 					$products[] = $p->entity_id;
573 573
 				}
574 574
 			}
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 		global $wp_query;
592 592
 
593 593
 		$atts['product_type'] = 'related';
594
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
594
+		if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
595 595
 
596 596
 		$related_product_output = self::wpshop_products_func($atts);
597 597
 
598 598
 		$output = '';
599
-		if ( !empty( $related_product_output ) ) {
599
+		if (!empty($related_product_output)) {
600 600
 			ob_start();
601
-			require( wpshop_tools::get_template_part( WPS_PRODUCT_DIR, WPS_PRODUCT_TEMPLATES_MAIN_DIR, 'frontend', 'related_product') );
601
+			require(wpshop_tools::get_template_part(WPS_PRODUCT_DIR, WPS_PRODUCT_TEMPLATES_MAIN_DIR, 'frontend', 'related_product'));
602 602
 			$output = ob_get_contents();
603 603
 			ob_end_clean();
604 604
 		}
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 		$string = '';
630 630
 		$have_results = false;
631 631
 		$output_results = true;
632
-		$type = ( empty($atts['type']) OR !in_array($atts['type'], array('grid','list')) ) ? WPSHOP_DISPLAY_LIST_TYPE : $atts['type'];
632
+		$type = (empty($atts['type']) OR !in_array($atts['type'], array('grid', 'list'))) ? WPSHOP_DISPLAY_LIST_TYPE : $atts['type'];
633 633
 		$pagination = isset($atts['pagination']) ? intval($atts['pagination']) : WPSHOP_ELEMENT_NB_PER_PAGE;
634 634
 		$cid = !empty($atts['cid']) ? $atts['cid'] : 0;
635 635
 		$pid = !empty($atts['pid']) ? $atts['pid'] : 0;
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 
645 645
 		/** Get products which have att_name equal to att_value	*/
646 646
 		if (!empty($atts['att_name']) && !empty($atts['att_value'])) {
647
-			$attr = $atts['att_name'].':'.$atts['att_value'];
647
+			$attr = $atts['att_name'] . ':' . $atts['att_value'];
648 648
 
649 649
 			$products = self::get_products_matching_attribute($atts['att_name'], $atts['att_value']);
650 650
 
651 651
 			// Foreach on the found products
652
-			if ( !empty($products) ) {
653
-				$pid = implode(',',$products);
654
-				if(empty($pid))$output_results = false;
652
+			if (!empty($products)) {
653
+				$pid = implode(',', $products);
654
+				if (empty($pid))$output_results = false;
655 655
 			}
656 656
 			else $output_results = false;
657 657
 		}
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 			switch ($atts['product_type']) {
662 662
 				case 'related':
663 663
 					$product_id = !empty($atts['pid']) ? (int)$atts['pid'] : get_the_ID();
664
-					$type = !empty($atts['display_mode']) && in_array($atts['display_mode'],array('list','grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE;
664
+					$type = !empty($atts['display_mode']) && in_array($atts['display_mode'], array('list', 'grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE;
665 665
 					$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;
666 666
 
667 667
 					$pids = get_post_meta((int)$product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
668
-					if ( !empty($pids) && !empty($pids[0]) ) {
668
+					if (!empty($pids) && !empty($pids[0])) {
669 669
 						$pid = implode(',', $pids);
670 670
 					}
671
-					if(empty($pid) || $pid == $product_id) {
671
+					if (empty($pid) || $pid == $product_id) {
672 672
 						$output_results = false;
673 673
 					}
674 674
 
@@ -677,21 +677,21 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 
679 679
 		/** Output all the products	*/
680
-		if ( $output_results ) {
680
+		if ($output_results) {
681 681
 			$data = self::wpshop_get_product_by_criteria((!empty($atts['order']) ? $atts['order'] : (!empty($atts['creator']) ? ($atts['creator'] == 'current') : '')), $cid, $pid, $type, $order_by_sorting, 1, $pagination, $limit, $grid_element_nb_per_line, $display_pagination);
682 682
 
683
-			if ( $data[0] ) {
683
+			if ($data[0]) {
684 684
 				$have_results = true;
685 685
 				$string = $data[1];
686 686
 			}
687 687
 		}
688 688
 
689 689
 		/** If there are result to display	*/
690
-		if ( $have_results ) {
690
+		if ($have_results) {
691 691
 			$sorting = '';
692
-			if ( !empty($pid) ) {
692
+			if (!empty($pid)) {
693 693
 				$product_list = explode(',', $pid);
694
-				if ( count($product_list) == 1 ) {
694
+				if (count($product_list) == 1) {
695 695
 					$atts['sorting'] = 'no';
696 696
 				}
697 697
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 			 * Build template
707 707
 			*/
708 708
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
709
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
709
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
710 710
 				/*	Include the old way template part	*/
711 711
 				ob_start();
712 712
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -729,24 +729,24 @@  discard block
 block discarded – undo
729 729
 				$tpl_component['SORTING_HIDDEN_FIELDS'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component, array(), 'admin');
730 730
 				unset($sub_tpl_component);
731 731
 
732
-				if ( (!empty($sorting_criteria) && is_array($sorting_criteria)) ) {
732
+				if ((!empty($sorting_criteria) && is_array($sorting_criteria))) {
733 733
 					$sub_template_part = 'product_listing_sorting_criteria';
734 734
 					$sub_tpl_component = array();
735 735
 					$criteria = '';
736
-					foreach($sorting_criteria as $c):
737
-						$criteria .= '<option value="' . $c['code'] . '">' . __($c['frontend_label'],'wpshop') . '</option>';
736
+					foreach ($sorting_criteria as $c):
737
+						$criteria .= '<option value="' . $c['code'] . '">' . __($c['frontend_label'], 'wpshop') . '</option>';
738 738
 					endforeach;
739 739
 					$sub_tpl_component['SORTING_CRITERIA_LIST'] = $criteria;
740 740
 					$tpl_component['SORTING_CRITERIA'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component);
741 741
 					unset($sub_tpl_component);
742 742
 				}
743 743
 
744
-				if ( empty($atts['sorting']) || ( !empty($atts['sorting']) && ($atts['sorting'] != 'no') ) ) {
745
-					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ?' active' : null;
746
-					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ?' active' : null;
744
+				if (empty($atts['sorting']) || (!empty($atts['sorting']) && ($atts['sorting'] != 'no'))) {
745
+					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ? ' active' : null;
746
+					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ? ' active' : null;
747 747
 					$sorting = wpshop_display::display_template_element($template_part, $tpl_component);
748 748
 				}
749
-				else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
749
+				else if (!empty($atts['sorting']) && ($atts['sorting'] == 'no')) {
750 750
 					$sub_template_part = 'product_listing_sorting_criteria_hidden';
751 751
 					$sub_tpl_component = array();
752 752
 					$sub_tpl_component['CRITERIA_DEFAULT'] = !empty($sorting_criteria[0]['code']) ? $sorting_criteria[0]['code'] : 'title';
@@ -759,31 +759,31 @@  discard block
 block discarded – undo
759 759
 			}
760 760
 			unset($tpl_component);
761 761
 
762
-			if ( !empty( $atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763
-				$string = $sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div>';
762
+			if (!empty($atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763
+				$string = $sorting . '<div class="wps-catalog-container wps-bloc-loader">' . $string . '</div>';
764 764
 			}
765 765
 			else {
766
-				$string = '<div class="wpshop_products_block">'.$sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div></div>';
766
+				$string = '<div class="wpshop_products_block">' . $sorting . '<div class="wps-catalog-container wps-bloc-loader">' . $string . '</div></div>';
767 767
 			}
768 768
 		}
769
-		else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
769
+		else if (empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no')) {
770 770
 			$string = __('There is nothing to output here', 'wpshop');
771 771
 		}
772 772
 
773 773
 		return do_shortcode($string);
774 774
 	}
775 775
 
776
-	public static function wpshop_get_product_by_criteria( $criteria = null, $cid=0, $pid=0, $display_type, $order='ASC', $page_number, $products_per_page=0, $nb_of_product_limit=0, $grid_element_nb_per_line=WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE, $display_pagination = true ) {
776
+	public static function wpshop_get_product_by_criteria($criteria = null, $cid = 0, $pid = 0, $display_type, $order = 'ASC', $page_number, $products_per_page = 0, $nb_of_product_limit = 0, $grid_element_nb_per_line = WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE, $display_pagination = true) {
777 777
 		global $wpdb;
778 778
 
779 779
 		$string = '<span id="wpshop_loading">&nbsp;</span>';
780 780
 		$have_results = false;
781
-		$display_type = (!empty($display_type) && in_array($display_type,array('grid','list'))) ? $display_type : 'grid';
781
+		$display_type = (!empty($display_type) && in_array($display_type, array('grid', 'list'))) ? $display_type : 'grid';
782 782
 
783 783
 		/** Check if Discount are activated */
784
-		$discount_option = get_option( 'wpshop_catalog_product_option' );
784
+		$discount_option = get_option('wpshop_catalog_product_option');
785 785
 
786
-		if ( $criteria == 'product_price' && !empty($discount_option) && !empty($discount_option['discount']) && $discount_option['discount'] == 'on') {
786
+		if ($criteria == 'product_price' && !empty($discount_option) && !empty($discount_option['discount']) && $discount_option['discount'] == 'on') {
787 787
 			$criteria = 'wpshop_displayed_price';
788 788
 		}
789 789
 
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 		);
797 797
 
798 798
 		// If the limit is greater than zero, hide pagination and change posts_per_page var
799
-		if ( $nb_of_product_limit > 0 ) {
799
+		if ($nb_of_product_limit > 0) {
800 800
 			$query['posts_per_page'] = $nb_of_product_limit;
801 801
 			unset($query['paged']);
802 802
 		}
803
-		if( !empty($pid) ) {
804
-			if(!is_array($pid)){
803
+		if (!empty($pid)) {
804
+			if (!is_array($pid)) {
805 805
 				$pid = explode(',', $pid);
806 806
 			}
807 807
 
808 808
 			$query['post__in'] = $pid;
809 809
 		}
810
-		if ( !empty($cid) ) {
810
+		if (!empty($cid)) {
811 811
 			$cid = explode(',', $cid);
812 812
 			$query['tax_query'] = array(array(
813 813
 				'taxonomy' => WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES,
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 				'operator' => 'IN'
817 817
 			));
818 818
 		}
819
-		if($criteria != null) {
820
-			switch($criteria){
819
+		if ($criteria != null) {
820
+			switch ($criteria) {
821 821
 				case 'creator':
822 822
 				case 'author':
823 823
 					$query['author'] = get_current_user_id();
@@ -829,21 +829,21 @@  discard block
 block discarded – undo
829 829
 					$query['orderby'] = $criteria;
830 830
 					break;
831 831
 				default:
832
-					if(!empty($pid)) {
833
-						$post_meta = get_post_meta($pid, '_'.$criteria, true);
832
+					if (!empty($pid)) {
833
+						$post_meta = get_post_meta($pid, '_' . $criteria, true);
834 834
 					}
835
-					else{
836
-						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_'.$criteria);
835
+					else {
836
+						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_' . $criteria);
837 837
 						$post_meta = $wpdb->get_var($check_meta);
838 838
 					}
839
-					if(!empty($post_meta)){
840
-						if ( in_array( $criteria, array( 'wpshop_displayed_price', 'product_price' ) ) ) {
839
+					if (!empty($post_meta)) {
840
+						if (in_array($criteria, array('wpshop_displayed_price', 'product_price'))) {
841 841
 							$query['orderby'] = 'meta_value_num';
842 842
 						}
843 843
 						else {
844 844
 							$query['orderby'] = 'meta_value';
845 845
 						}
846
-						$query['meta_key'] = '_'.$criteria;
846
+						$query['meta_key'] = '_' . $criteria;
847 847
 					}
848 848
 					break;
849 849
 			}
@@ -852,33 +852,33 @@  discard block
 block discarded – undo
852 852
 			$query['orderby'] = 'menu_order ID';
853 853
 		}
854 854
 		$post_per_page = $query['posts_per_page'];
855
-		$total_products = ( !empty($query['post__in']) ) ? $query['post__in'] : 0;
856
-		if ( !empty($pid) && !empty($query['post__in']) && count($query['post__in']) > $query['posts_per_page'] ) {
855
+		$total_products = (!empty($query['post__in'])) ? $query['post__in'] : 0;
856
+		if (!empty($pid) && !empty($query['post__in']) && count($query['post__in']) > $query['posts_per_page']) {
857 857
 			$tmp_array = array();
858 858
 
859
-			if ( empty($page_number) || $page_number == 1 ) {
860
-				for( $i = 0; $i < $query['posts_per_page']; $i++ ) {
859
+			if (empty($page_number) || $page_number == 1) {
860
+				for ($i = 0; $i < $query['posts_per_page']; $i++) {
861 861
 					$tmp_array[] = $query['post__in'][$i];
862 862
 				}
863 863
 			}
864 864
 			else {
865
-				$begin_number = ( ($page_number - 1) * $query['posts_per_page'] ) ;
866
-				for( $i = $begin_number ; $i < $query['posts_per_page'] + $begin_number ; $i++ ) {
867
-					if ( !empty($query['post__in'][$i]) ) {
865
+				$begin_number = (($page_number - 1) * $query['posts_per_page']);
866
+				for ($i = $begin_number; $i < $query['posts_per_page'] + $begin_number; $i++) {
867
+					if (!empty($query['post__in'][$i])) {
868 868
 						$tmp_array[] = $query['post__in'][$i];
869 869
 					}
870 870
 				}
871 871
 			}
872
-			unset( $query['post__in'] );
872
+			unset($query['post__in']);
873 873
 			$query['post__in'] = $tmp_array;
874 874
 			$query['posts_per_page'] = -1;
875 875
 		}
876 876
 
877 877
 		$query['post_status'] = 'publish';
878 878
 
879
-		$custom_query = new WP_Query( $query );
879
+		$custom_query = new WP_Query($query);
880 880
 
881
-		if ( $custom_query->have_posts() ) {
881
+		if ($custom_query->have_posts()) {
882 882
 			$have_results = true;
883 883
 
884 884
 			// ---------------- //
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 				$current_position++;
895 895
 			endwhile;
896 896
 			$tpl_component = array();
897
-			$tpl_component['PRODUCT_CONTAINER_TYPE_CLASS'] = ($display_type == 'grid' ? ' ' . $display_type . '_' . $grid_element_nb_per_line : '') . ' '. $display_type .'_mode';
897
+			$tpl_component['PRODUCT_CONTAINER_TYPE_CLASS'] = ($display_type == 'grid' ? ' ' . $display_type . '_' . $grid_element_nb_per_line : '') . ' ' . $display_type . '_mode';
898 898
 			$tpl_component['PRODUCT_LIST_DISPLAY_TYPE'] = $display_type;
899 899
 			$tpl_component['PRODUCT_LIST_PER_LINE'] = $grid_element_nb_per_line;
900 900
 			$tpl_component['PRODUCT_LIST'] = $product_list;
@@ -905,39 +905,39 @@  discard block
 block discarded – undo
905 905
 			// --------------------- //
906 906
 			// Pagination management //
907 907
 			// --------------------- //
908
-			if($display_pagination) {
909
-				if($nb_of_product_limit==0) {
908
+			if ($display_pagination) {
909
+				if ($nb_of_product_limit == 0) {
910 910
 
911 911
 					$paginate = paginate_links(array(
912 912
 						'base' => '%_%',
913 913
 						'format' => '/?page_product=%#%',
914
-						'current' => $page_number ,
914
+						'current' => $page_number,
915 915
 						'total' => $custom_query->max_num_pages,
916 916
 						'type' => 'array',
917 917
 						'prev_next' => false
918 918
 					));
919
-					if(!empty($paginate)) {
919
+					if (!empty($paginate)) {
920 920
 						$string .= '<ul class="pagination wps-pagination">';
921
-						foreach($paginate as $p) {
922
-							$string .= '<li>'.$p.'</li>';
921
+						foreach ($paginate as $p) {
922
+							$string .= '<li>' . $p . '</li>';
923 923
 						}
924 924
 						$string .= '</ul>';
925 925
 					}
926 926
 				}
927 927
 
928
-				if ( !empty($pid) && !empty($query['post__in']) && count($total_products) > $post_per_page ) {
928
+				if (!empty($pid) && !empty($query['post__in']) && count($total_products) > $post_per_page) {
929 929
 					$paginate = paginate_links(array(
930 930
 							'base' => '%_%',
931 931
 							'format' => '/?page_product=%#%',
932 932
 							'current' => $page_number,
933
-							'total' => ceil( count($total_products) / $post_per_page ) ,
933
+							'total' => ceil(count($total_products) / $post_per_page),
934 934
 							'type' => 'array',
935 935
 							'prev_next' => false
936 936
 					));
937
-					if(!empty($paginate)) {
937
+					if (!empty($paginate)) {
938 938
 						$string .= '<ul class="pagination wps-pagination">';
939
-						foreach($paginate as $p) {
940
-							$string .= '<li>'.$p.'</li>';
939
+						foreach ($paginate as $p) {
940
+							$string .= '<li>' . $p . '</li>';
941 941
 						}
942 942
 						$string .= '</ul>';
943 943
 					}
@@ -955,21 +955,21 @@  discard block
 block discarded – undo
955 955
 	 * @param integer $product_id The product we want to update quantity for
956 956
 	 * @param decimal $qty The new quantity
957 957
 	 */
958
-	public static function reduce_product_stock_qty($product_id, $qty, $variation_id = '' ) {
958
+	public static function reduce_product_stock_qty($product_id, $qty, $variation_id = '') {
959 959
 		global $wpdb;
960 960
 
961 961
 		$product = self::get_product_data($product_id);
962 962
 		/** Check if there is variation ***/
963
-		if ( !empty($variation_id) && $variation_id != $product_id ) {
964
-			$variation_post_type = get_post_type( $variation_id );
965
-			if ( $variation_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
963
+		if (!empty($variation_id) && $variation_id != $product_id) {
964
+			$variation_post_type = get_post_type($variation_id);
965
+			if ($variation_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
966 966
 				/** Check if variation def is combined **/
967
-				$variations = get_post_meta( $product_id, '_wpshop_variation_defining', true );
968
-				if ( !empty($variations) && !empty($variations['options']) && !empty($variations['options']['priority']) && in_array( 'combined', $variations['options']['priority']) ) {
967
+				$variations = get_post_meta($product_id, '_wpshop_variation_defining', true);
968
+				if (!empty($variations) && !empty($variations['options']) && !empty($variations['options']['priority']) && in_array('combined', $variations['options']['priority'])) {
969 969
 					/** Get post meta of variation */
970
-					$variation_metadata = get_post_meta( $variation_id, '_wpshop_product_metadata', true );
971
-					if ( !empty($variation_metadata) && isset($variation_metadata['product_stock']) ) {
972
-						$product = self::get_product_data( $variation_id );
970
+					$variation_metadata = get_post_meta($variation_id, '_wpshop_product_metadata', true);
971
+					if (!empty($variation_metadata) && isset($variation_metadata['product_stock'])) {
972
+						$product = self::get_product_data($variation_id);
973 973
 						$product_id = $variation_id;
974 974
 					}
975 975
 				}
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 		if (!empty($product)) {
980 980
 			$newQty = $product['product_stock'] - $qty;
981 981
 			$value_id = 0;
982
-			if ( $newQty >= 0 ) {
982
+			if ($newQty >= 0) {
983 983
 				$query = '
984 984
 					SELECT wp_wpshop__attribute_value_decimal.value_id
985 985
 					FROM wp_wpshop__attribute_value_decimal
986 986
 					LEFT JOIN wp_wpshop__attribute ON wp_wpshop__attribute_value_decimal.attribute_id = wp_wpshop__attribute.id
987
-					WHERE wp_wpshop__attribute_value_decimal.entity_id='.$product_id.' AND wp_wpshop__attribute.code="product_stock"
987
+					WHERE wp_wpshop__attribute_value_decimal.entity_id='.$product_id . ' AND wp_wpshop__attribute.code="product_stock"
988 988
 					LIMIT 1
989 989
 				';
990 990
 				$value_id = $wpdb->get_var($query);
@@ -994,10 +994,10 @@  discard block
 block discarded – undo
994 994
 			$attribute_histo_content = array();
995 995
 			$attribute_histo_content['status'] = 'valid';
996 996
 			$attribute_histo_content['creation_date'] = current_time('mysql', 0);
997
-			$attribute_histo_content['creation_date_value'] = ( !empty( $attribute_histo[0]->creation_date_value ) ) ? $attribute_histo[0]->creation_date_value : current_time('mysql', 0);
997
+			$attribute_histo_content['creation_date_value'] = (!empty($attribute_histo[0]->creation_date_value)) ? $attribute_histo[0]->creation_date_value : current_time('mysql', 0);
998 998
 			$attribute_histo_content['original_value_id'] = $value_id;
999
-			$attribute_histo_content['entity_type_id'] = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
1000
-			$stock_atribute = wpshop_attributes::getElement( 'product_stock', "'valid'", 'code' );
999
+			$attribute_histo_content['entity_type_id'] = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1000
+			$stock_atribute = wpshop_attributes::getElement('product_stock', "'valid'", 'code');
1001 1001
 			$attribute_histo_content['attribute_id'] = $stock_atribute->id;
1002 1002
 			$attribute_histo_content['entity_id'] = $product_id;
1003 1003
 			$attribute_histo_content['value'] = $product['product_stock'];
@@ -1017,15 +1017,15 @@  discard block
 block discarded – undo
1017 1017
 	 * @param boolean $for_cart_storage
1018 1018
 	 * @return array Information about the product defined by first parameter
1019 1019
 	 */
1020
-	public static function get_product_data( $product_id, $for_cart_storage = false, $post_status = '"publish"') {
1020
+	public static function get_product_data($product_id, $for_cart_storage = false, $post_status = '"publish"') {
1021 1021
 		global $wpdb;
1022 1022
 			$query = $wpdb->prepare('
1023 1023
 			SELECT P.*, PM.meta_value AS attribute_set_id
1024
-			FROM '.$wpdb->posts.' AS P
1025
-				INNER JOIN '.$wpdb->postmeta.' AS PM ON (PM.post_id=P.ID)
1024
+			FROM '.$wpdb->posts . ' AS P
1025
+				INNER JOIN '.$wpdb->postmeta . ' AS PM ON (PM.post_id=P.ID)
1026 1026
 			WHERE
1027 1027
 				P.ID = %d
1028
-				AND ( (P.post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'") OR (P.post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '") OR (P.post_type = "free_product") )
1028
+				AND ( (P.post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '") OR (P.post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '") OR (P.post_type = "free_product") )
1029 1029
 				AND P.post_status IN (' . $post_status . ')
1030 1030
 				AND	PM.meta_key = "_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id"
1031 1031
 			LIMIT 1
@@ -1037,35 +1037,35 @@  discard block
 block discarded – undo
1037 1037
 		$product_meta = array();
1038 1038
 
1039 1039
 		if (!empty($product)) {
1040
-			$product_data['product_id'] = ( !empty($product->ID) ) ?  $product->ID : '';
1041
-			$product_data['post_name'] = ( !empty($product->post_name) ) ? $product->post_name : '';
1042
-			$product_data['product_name'] = ( !empty($product->post_title) ) ? $product->post_title : '';
1043
-			$product_data['post_title'] = ( !empty($product->post_title) ) ? $product->post_title : '';
1040
+			$product_data['product_id'] = (!empty($product->ID)) ? $product->ID : '';
1041
+			$product_data['post_name'] = (!empty($product->post_name)) ? $product->post_name : '';
1042
+			$product_data['product_name'] = (!empty($product->post_title)) ? $product->post_title : '';
1043
+			$product_data['post_title'] = (!empty($product->post_title)) ? $product->post_title : '';
1044 1044
 
1045
-			$product_data['product_author_id'] = ( !empty($product->post_author) ) ? $product->post_author : '';
1046
-			$product_data['product_date'] = ( !empty($product->post_date) ) ? $product->post_date : '';
1047
-			$product_data['product_content'] = ( !empty($product->post_content) ) ? $product->post_content : '';
1048
-			$product_data['product_excerpt'] = ( !empty($product->post_excerpt) ) ? $product->post_excerpt : wp_trim_words( $product_data['product_content'], apply_filters( 'excerpt_length', 50 ), '...' );
1045
+			$product_data['product_author_id'] = (!empty($product->post_author)) ? $product->post_author : '';
1046
+			$product_data['product_date'] = (!empty($product->post_date)) ? $product->post_date : '';
1047
+			$product_data['product_content'] = (!empty($product->post_content)) ? $product->post_content : '';
1048
+			$product_data['product_excerpt'] = (!empty($product->post_excerpt)) ? $product->post_excerpt : wp_trim_words($product_data['product_content'], apply_filters('excerpt_length', 50), '...');
1049 1049
 
1050
-			$product_data['product_meta_attribute_set_id'] = ( !empty($product->attribute_set_id) ) ? $product->attribute_set_id : '';
1050
+			$product_data['product_meta_attribute_set_id'] = (!empty($product->attribute_set_id)) ? $product->attribute_set_id : '';
1051 1051
 
1052 1052
 			$data = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $product->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1053
-			if ( !empty($data) ) {
1053
+			if (!empty($data)) {
1054 1054
 				foreach ($data as $attribute) {
1055
-					$data_type = 'attribute_value_'.$attribute->data_type;
1055
+					$data_type = 'attribute_value_' . $attribute->data_type;
1056 1056
 					$value = $attribute->$data_type;
1057
-					if (in_array($attribute->backend_input, array('select','multiple-select', 'radio','checkbox'))) {
1057
+					if (in_array($attribute->backend_input, array('select', 'multiple-select', 'radio', 'checkbox'))) {
1058 1058
 						$value = wpshop_attributes::get_attribute_type_select_option_info($value, 'value');
1059 1059
 					}
1060 1060
 
1061 1061
 					/** Special traitment regarding attribute_code	*/
1062
-					switch($attribute->attribute_code) {
1062
+					switch ($attribute->attribute_code) {
1063 1063
 						case 'product_weight':
1064 1064
 							$default_weight_unity = get_option('wpshop_shop_default_weight_unity');
1065
-							if ( !empty($default_weight_unity) ) {
1066
-								$query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = %d', $default_weight_unity);
1065
+							if (!empty($default_weight_unity)) {
1066
+								$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d', $default_weight_unity);
1067 1067
 								$unity = $wpdb->get_var($query);
1068
-								if ( $unity == 'kg') {
1068
+								if ($unity == 'kg') {
1069 1069
 									$value *= 1000;
1070 1070
 								}
1071 1071
 
@@ -1077,17 +1077,17 @@  discard block
 block discarded – undo
1077 1077
 					}
1078 1078
 					$product_data[$attribute->attribute_code] = $value;
1079 1079
 
1080
-					if(!$for_cart_storage OR $for_cart_storage && $attribute->is_recordable_in_cart_meta == 'yes') {
1081
-						$meta = get_post_meta($product->ID, 'attribute_option_'.$attribute->attribute_code, true);
1082
-						if(!empty($meta)) {
1080
+					if (!$for_cart_storage OR $for_cart_storage && $attribute->is_recordable_in_cart_meta == 'yes') {
1081
+						$meta = get_post_meta($product->ID, 'attribute_option_' . $attribute->attribute_code, true);
1082
+						if (!empty($meta)) {
1083 1083
 							$product_meta[$attribute->attribute_code] = $meta;
1084 1084
 						}
1085 1085
 					}
1086 1086
 
1087
-					if ( ($attribute->is_visible_in_front == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) ) {
1087
+					if (($attribute->is_visible_in_front == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES)))) {
1088 1088
 						$product_meta['attribute_visible'][$attribute->attribute_code] = $value;
1089 1089
 					}
1090
-					if ( ($attribute->is_visible_in_front_listing == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) ) {
1090
+					if (($attribute->is_visible_in_front_listing == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES)))) {
1091 1091
 						$product_meta['attribute_visible_listing'][$attribute->attribute_code] = $value;
1092 1092
 					}
1093 1093
 				}
@@ -1097,16 +1097,16 @@  discard block
 block discarded – undo
1097 1097
 			}
1098 1098
 
1099 1099
 			/**	Get datas about product options	*/
1100
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
1100
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
1101 1101
 				$variation_details = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true);
1102 1102
 
1103
-				foreach ( $variation_details as $attribute_code => $attribute_value) {
1103
+				foreach ($variation_details as $attribute_code => $attribute_value) {
1104 1104
 					$variation_id = $attribute_value;
1105 1105
 					$attribute_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
1106 1106
 
1107 1107
 					$product_meta['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', $attribute_definition->data_type_to_use, true));
1108 1108
 					$product_meta['variation_definition'][$attribute_code]['NAME'] = $attribute_definition->frontend_label;
1109
-					switch( $attribute_definition->backend_input ) {
1109
+					switch ($attribute_definition->backend_input) {
1110 1110
 						case 'select':
1111 1111
 						case 'multiple-select':
1112 1112
 						case 'radio':
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 	 * @param $attrs List of the attributes and values of the product
1136 1136
 	 * @return boolean
1137 1137
 	*/
1138
-	function addProduct($name, $description, $attrs=array()) {
1138
+	function addProduct($name, $description, $attrs = array()) {
1139 1139
 		$new_product = wpshop_entities::create_new_entity(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $name, $description, $attrs);
1140 1140
 		return $new_product[0];
1141 1141
 	}
@@ -1146,13 +1146,13 @@  discard block
 block discarded – undo
1146 1146
 	 * @param string $product_search Optionnal Define a search term for request
1147 1147
 	 * @return object|string If $formated is set to true will display an html output with all product. Else return a wordpress database object with the product list
1148 1148
 	 */
1149
-	function product_list($formated=false, $product_search=null) {
1149
+	function product_list($formated = false, $product_search = null) {
1150 1150
 		global $wpdb;
1151 1151
 
1152 1152
 		$query_extra_params = $query_extra_params_value = '';
1153
-		if( !empty($product_search) ) {
1154
-			$query_extra_params = " AND post_title LIKE '%%".$product_search."%%'";
1155
-			if ( is_array($product_search) ) {
1153
+		if (!empty($product_search)) {
1154
+			$query_extra_params = " AND post_title LIKE '%%" . $product_search . "%%'";
1155
+			if (is_array($product_search)) {
1156 1156
 				$query_extra_params = " AND ID IN (%s)";
1157 1157
 				$query_extra_params_value = implode(",", $product_search);
1158 1158
 			}
@@ -1164,12 +1164,12 @@  discard block
 block discarded – undo
1164 1164
 		/*
1165 1165
 		 * Make some arangement on output if parameter is given
1166 1166
 		 */
1167
-		if ( $formated ) {
1168
-			$product_string='';
1167
+		if ($formated) {
1168
+			$product_string = '';
1169 1169
 			foreach ($data as $d) {
1170 1170
 				$product_string .= '
1171 1171
 					<li class="wpshop_shortcode_element_container wpshop_shortcode_element_container_product" >
1172
-						<input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_product" value="'.$d->ID.'" id="'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'-'.$d->ID.'" name="products[]" /><label for="'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'-'.$d->ID.'" > '.$d->post_title.'</label>
1172
+						<input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_product" value="'.$d->ID . '" id="' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '-' . $d->ID . '" name="products[]" /><label for="' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '-' . $d->ID . '" > ' . $d->post_title . '</label>
1173 1173
 					</li>';
1174 1174
 			}
1175 1175
 		}
@@ -1180,17 +1180,17 @@  discard block
 block discarded – undo
1180 1180
 	/**
1181 1181
 	 * Enregistrement des données pour le produit
1182 1182
 	 */
1183
-	function save_product_custom_informations( $post_id , $data_to_save = array() ) {
1183
+	function save_product_custom_informations($post_id, $data_to_save = array()) {
1184 1184
 		global $wpdb;
1185 1185
 
1186
-		$data_to_save = ( !empty($data_to_save) ) ? $data_to_save : (array) $_REQUEST;
1186
+		$data_to_save = (!empty($data_to_save)) ? $data_to_save : (array)$_REQUEST;
1187 1187
 		// Apply a filter to extra actions
1188
-		$data_to_save = apply_filters( 'wps_save_product_extra_filter', $data_to_save );
1188
+		$data_to_save = apply_filters('wps_save_product_extra_filter', $data_to_save);
1189 1189
 
1190
-		if ( !empty($data_to_save['post_ID']) && ( (get_post_type($data_to_save['post_ID']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || (get_post_type($data_to_save['post_ID']) == "free_product") ) ) {
1191
-			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attribute']) ) {
1190
+		if (!empty($data_to_save['post_ID']) && ((get_post_type($data_to_save['post_ID']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || (get_post_type($data_to_save['post_ID']) == "free_product"))) {
1191
+			if (!empty($data_to_save[wpshop_products::currentPageCode . '_attribute'])) {
1192 1192
 				/*	Fill the product reference automatically if nothing is sent	*/
1193
-				if ( empty($data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference']) ) {
1193
+				if (empty($data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'])) {
1194 1194
 					$query = "SELECT MAX(ID) AS PDCT_ID FROM {$wpdb->posts}";
1195 1195
 					$last_ref = $wpdb->get_var($query);
1196 1196
 					$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
@@ -1200,16 +1200,16 @@  discard block
 block discarded – undo
1200 1200
 					$ref = $data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'];
1201 1201
 					$query = $wpdb->prepare(
1202 1202
 						"SELECT value_id
1203
-						FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR."
1203
+						FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . "
1204 1204
 							INNER JOIN {$wpdb->posts} ON ( ID = entity_id )
1205 1205
 						WHERE value = %s
1206 1206
 							AND entity_id != %d
1207 1207
 							AND entity_type_id = %d"
1208 1208
 						, $ref, $data_to_save['post_ID'], wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
1209
-					$existing_reference = $wpdb->get_var( $query );
1209
+					$existing_reference = $wpdb->get_var($query);
1210 1210
 
1211 1211
 					/* If this product reference exist -> Create a new product reference */
1212
-					if ( $wpdb->num_rows > 0 ) {
1212
+					if ($wpdb->num_rows > 0) {
1213 1213
 						$query = "SELECT MAX(ID) AS PDCT_ID FROM " . $wpdb->posts;
1214 1214
 						$last_ref = $wpdb->get_var($query);
1215 1215
 						$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
@@ -1219,27 +1219,27 @@  discard block
 block discarded – undo
1219 1219
 				/*	Save the attributes values into wpshop eav database	*/
1220 1220
 				$update_from = !empty($data_to_save[wpshop_products::currentPageCode . '_provenance']) ? $data_to_save[wpshop_products::currentPageCode . '_provenance'] : '';
1221 1221
 				$lang = WPSHOP_CURRENT_LOCALE;
1222
-				if ( !empty($data_to_save['icl_post_language']) ) {
1222
+				if (!empty($data_to_save['icl_post_language'])) {
1223 1223
 					$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", $data_to_save['icl_post_language']);
1224 1224
 					$lang = $wpdb->get_var($query);
1225 1225
 				}
1226 1226
 				wpshop_attributes::saveAttributeForEntity($data_to_save[wpshop_products::currentPageCode . '_attribute'], wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $data_to_save['post_ID'], $lang, $update_from);
1227 1227
 
1228 1228
 				/*	Update product price looking for shop parameters	*/
1229
-				wpshop_products::calculate_price( $data_to_save['post_ID'] );
1229
+				wpshop_products::calculate_price($data_to_save['post_ID']);
1230 1230
 
1231 1231
 				/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
1232 1232
 				$productMetaDatas = array();
1233
-				foreach ( $data_to_save[wpshop_products::currentPageCode . '_attribute'] as $attributeType => $attributeValues ) {
1234
-					foreach ( $attributeValues as $attributeCode => $attributeValue ) {
1235
-						if ( $attributeCode == 'product_attribute_set_id' ) {
1233
+				foreach ($data_to_save[wpshop_products::currentPageCode . '_attribute'] as $attributeType => $attributeValues) {
1234
+					foreach ($attributeValues as $attributeCode => $attributeValue) {
1235
+						if ($attributeCode == 'product_attribute_set_id') {
1236 1236
 							/*	Update the attribute set id for the current product	*/
1237 1237
 							update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue);
1238 1238
 						}
1239
-						if ( $attributeType == 'decimal' ) {
1239
+						if ($attributeType == 'decimal') {
1240 1240
 							$attributeValue = str_replace(',', '.', $attributeValue);
1241 1241
 						}
1242
-						if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1242
+						if (($attributeType == 'integer') && !is_array($attributeValue)) {
1243 1243
 							$attributeValue = (int)$attributeValue;
1244 1244
 						}
1245 1245
 						$productMetaDatas[$attributeCode] = $attributeValue;
@@ -1248,51 +1248,51 @@  discard block
 block discarded – undo
1248 1248
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $productMetaDatas);
1249 1249
 			}
1250 1250
 
1251
-			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config']) ) {
1251
+			if (!empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config'])) {
1252 1252
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, $data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']);
1253 1253
 			}
1254
-			else if ( $data_to_save['action'] != 'autosave') {
1254
+			else if ($data_to_save['action'] != 'autosave') {
1255 1255
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF);
1256 1256
 			}
1257 1257
 
1258 1258
 
1259
-			$product = wpshop_products::get_product_data( $data_to_save['post_ID'], false, '"publish"' );
1260
-			if( empty($product['product_id']) ) {
1259
+			$product = wpshop_products::get_product_data($data_to_save['post_ID'], false, '"publish"');
1260
+			if (empty($product['product_id'])) {
1261 1261
 				$product['product_id'] = $data_to_save['post_ID'];
1262 1262
 			}
1263
-			$price = wpshop_prices::get_product_price( $product, 'just_price_infos', array('mini_output', 'grid') );
1264
-			update_post_meta( $data_to_save['post_ID'], '_wps_price_infos', $price );
1263
+			$price = wpshop_prices::get_product_price($product, 'just_price_infos', array('mini_output', 'grid'));
1264
+			update_post_meta($data_to_save['post_ID'], '_wps_price_infos', $price);
1265 1265
 
1266 1266
 
1267 1267
 			/**	Save product variation	*/
1268
-			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]) ) {
1269
-				foreach ( $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION] as $variation_id => $variation_definition ) {
1268
+			if (!empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION])) {
1269
+				foreach ($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION] as $variation_id => $variation_definition) {
1270 1270
 
1271
-					foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
1271
+					foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
1272 1272
 						$price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code');
1273
-						if ( !empty($variation_definition) && !empty($variation_definition['attribute']) && is_object($price_attr_def) && !empty($variation_definition['attribute'][$price_attr_def->data_type]) && is_array($variation_definition['attribute'][$price_attr_def->data_type]) && !array_key_exists($price_attribute_code, $variation_definition['attribute'][$price_attr_def->data_type]) ) {
1273
+						if (!empty($variation_definition) && !empty($variation_definition['attribute']) && is_object($price_attr_def) && !empty($variation_definition['attribute'][$price_attr_def->data_type]) && is_array($variation_definition['attribute'][$price_attr_def->data_type]) && !array_key_exists($price_attribute_code, $variation_definition['attribute'][$price_attr_def->data_type])) {
1274 1274
 							$variation_definition['attribute'][$price_attr_def->data_type][$price_attribute_code] = !empty($data_to_save[wpshop_products::currentPageCode . '_attribute'][$price_attr_def->data_type][$price_attribute_code]) ? $data_to_save[wpshop_products::currentPageCode . '_attribute'][$price_attr_def->data_type][$price_attribute_code] : 0;
1275 1275
 						}
1276 1276
 					}
1277 1277
 					$lang = WPSHOP_CURRENT_LOCALE;
1278
-					if ( !empty($data_to_save['icl_post_language']) ) {
1278
+					if (!empty($data_to_save['icl_post_language'])) {
1279 1279
 						$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", $data_to_save['icl_post_language']);
1280 1280
 						$lang = $wpdb->get_var($query);
1281 1281
 					}
1282 1282
 					wpshop_attributes::saveAttributeForEntity($variation_definition['attribute'], wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $variation_id, $lang);
1283 1283
 
1284 1284
 					/**	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
1285
-					$variation_metadata = get_post_meta( $variation_id, '_wpshop_product_metadata', true);
1286
-					if ( !empty($variation_metadata) ) {
1287
-						$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION),  $variation_id);
1288
-						if ( !empty($attributes_list)) {
1285
+					$variation_metadata = get_post_meta($variation_id, '_wpshop_product_metadata', true);
1286
+					if (!empty($variation_metadata)) {
1287
+						$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION), $variation_id);
1288
+						if (!empty($attributes_list)) {
1289 1289
 							foreach ($attributes_list as $attribute) {
1290
-								$value_key = 'attribute_value_'.$attribute->data_type;
1290
+								$value_key = 'attribute_value_' . $attribute->data_type;
1291 1291
 								$attributeValue = $attribute->$value_key;
1292
-								if ( $attribute->data_type == 'decimal' ) {
1292
+								if ($attribute->data_type == 'decimal') {
1293 1293
 									$attributeValue = str_replace(',', '.', $attribute->$value_key);
1294 1294
 								}
1295
-								if ( ($attribute->data_type == 'integer') && !is_array($attributeValue) ) {
1295
+								if (($attribute->data_type == 'integer') && !is_array($attributeValue)) {
1296 1296
 									$attributeValue = (int)$attribute->$value_key;
1297 1297
 								}
1298 1298
 								$variation_metadata[$attribute->code] = $attribute->$value_key;
@@ -1300,12 +1300,12 @@  discard block
 block discarded – undo
1300 1300
 						}
1301 1301
 					}
1302 1302
 
1303
-					foreach ( $variation_definition['attribute'] as $attributeType => $attributeValues ) {
1304
-						foreach ( $attributeValues as $attributeCode => $attributeValue ) {
1305
-							if ( $attributeType == 'decimal' ) {
1303
+					foreach ($variation_definition['attribute'] as $attributeType => $attributeValues) {
1304
+						foreach ($attributeValues as $attributeCode => $attributeValue) {
1305
+							if ($attributeType == 'decimal') {
1306 1306
 								$attributeValue = str_replace(',', '.', $attributeValue);
1307 1307
 							}
1308
-							if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1308
+							if (($attributeType == 'integer') && !is_array($attributeValue)) {
1309 1309
 								$attributeValue = (int)$attributeValue;
1310 1310
 							}
1311 1311
 							$variation_metadata[$attributeCode] = $attributeValue;
@@ -1314,46 +1314,46 @@  discard block
 block discarded – undo
1314 1314
 					update_post_meta($variation_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $variation_metadata);
1315 1315
 
1316 1316
 					/** Save attached picture id **/
1317
-					$attached_picture_id = ( !empty($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id']) ) ? intval( $data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id'] ) : '';
1318
-					$selected_picture = update_post_meta( $variation_id, '_wps_variation_attached_picture', $attached_picture_id );
1317
+					$attached_picture_id = (!empty($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id'])) ? intval($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id']) : '';
1318
+					$selected_picture = update_post_meta($variation_id, '_wps_variation_attached_picture', $attached_picture_id);
1319 1319
 
1320 1320
 					/*	Update product price looking for shop parameters	*/
1321
-					wpshop_products::calculate_price( $variation_id );
1321
+					wpshop_products::calculate_price($variation_id);
1322 1322
 				}
1323 1323
 			}
1324 1324
 
1325 1325
 			/*	Update the related products list*/
1326
-			if ( !empty($data_to_save['related_products_list']) ) {
1326
+			if (!empty($data_to_save['related_products_list'])) {
1327 1327
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS, $data_to_save['related_products_list']);
1328 1328
 			}
1329
-			else if ( $data_to_save['action'] != 'autosave') {
1329
+			else if ($data_to_save['action'] != 'autosave') {
1330 1330
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS);
1331 1331
 			}
1332 1332
 			/*	Update the provider list*/
1333
-			if ( !empty($data_to_save['provider_list']) ) {
1333
+			if (!empty($data_to_save['provider_list'])) {
1334 1334
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER, $data_to_save['provider_list']);
1335 1335
 			}
1336
-			else if ( $data_to_save['action'] != 'autosave') {
1336
+			else if ($data_to_save['action'] != 'autosave') {
1337 1337
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER);
1338 1338
 			}
1339 1339
 
1340 1340
 			/*	Update product options	*/
1341
-			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']) ) {
1341
+			if (!empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options'])) {
1342 1342
 				update_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']);
1343 1343
 			}
1344
-			else if ( $data_to_save['action'] != 'autosave') {
1344
+			else if ($data_to_save['action'] != 'autosave') {
1345 1345
 				delete_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
1346 1346
 			}
1347 1347
 
1348 1348
 			/** Add flag on variations to check which type of variation **/
1349
-			$check_product_have_variations = self::get_variation( $post_id );
1350
-			if( !empty($check_product_have_variations) ) {
1351
-				$variation_flag = self::check_variation_type( $post_id );
1352
-				$variation_defining = get_post_meta( $post_id, '_wpshop_variation_defining', true );
1349
+			$check_product_have_variations = self::get_variation($post_id);
1350
+			if (!empty($check_product_have_variations)) {
1351
+				$variation_flag = self::check_variation_type($post_id);
1352
+				$variation_defining = get_post_meta($post_id, '_wpshop_variation_defining', true);
1353 1353
 				$variation_defining['variation_type'] = $variation_flag;
1354
-				update_post_meta( $post_id, '_wpshop_variation_defining', $variation_defining );
1354
+				update_post_meta($post_id, '_wpshop_variation_defining', $variation_defining);
1355 1355
 			}
1356
-			add_post_meta( $post_id, '_wpshop_variation_defining', array( 'follow_general_config' => true, 'options' => array( 'priority' => array( 'combined' ), 'price_behaviour' => array( 'replacement' ), 'price_display' => ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) ) ? $catalog_product_option['price_display'] : array( 'text_from' => 'on', 'lower_price' => 'on' ) ) ), true );
1356
+			add_post_meta($post_id, '_wpshop_variation_defining', array('follow_general_config' => true, 'options' => array('priority' => array('combined'), 'price_behaviour' => array('replacement'), 'price_display' => (!empty($catalog_product_option) && !empty($catalog_product_option['price_display'])) ? $catalog_product_option['price_display'] : array('text_from' => 'on', 'lower_price' => 'on'))), true);
1357 1357
 		}
1358 1358
 
1359 1359
 		flush_rewrite_rules();
@@ -1364,16 +1364,16 @@  discard block
 block discarded – undo
1364 1364
 	 * @param integer $post_id
1365 1365
 	 * @return string
1366 1366
 	 */
1367
-	public function check_variation_type( $post_id ) {
1367
+	public function check_variation_type($post_id) {
1368 1368
 		$variation_type = 'single';
1369
-		if( !empty($variation_type) ) {
1370
-			$variations = self::get_variation( $post_id );
1371
-			if( !empty($variations) ) {
1372
-				foreach( $variations as $variation_id => $variation_data ) {
1373
-					if( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1 ) {
1369
+		if (!empty($variation_type)) {
1370
+			$variations = self::get_variation($post_id);
1371
+			if (!empty($variations)) {
1372
+				foreach ($variations as $variation_id => $variation_data) {
1373
+					if (!empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1) {
1374 1374
 						return 'single';
1375 1375
 					}
1376
-					elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1376
+					elseif (!empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1) {
1377 1377
 						$variation_type = 'combined';
1378 1378
 					}
1379 1379
 				}
@@ -1391,21 +1391,21 @@  discard block
 block discarded – undo
1391 1391
 	 *
1392 1392
 	 * @return mixed The new permalink for the current element
1393 1393
 	 */
1394
-	public static function set_product_permalink($permalink, $post, $unknown){
1394
+	public static function set_product_permalink($permalink, $post, $unknown) {
1395 1395
 		$options = get_option('wpshop_catalog_product_option', array());
1396 1396
 
1397
-		if( $post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT /* && 'publish' == $post->post_status */ ) {
1398
-			if( !isset( $options['wpshop_catalog_product_slug_with_category'] ) || $options['wpshop_catalog_product_slug_with_category'] != 'yes' ) {
1397
+		if ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT /* && 'publish' == $post->post_status */) {
1398
+			if (!isset($options['wpshop_catalog_product_slug_with_category']) || $options['wpshop_catalog_product_slug_with_category'] != 'yes') {
1399 1399
 				return $permalink;
1400 1400
 			} else {
1401
-				$options_cats = get_option( 'wpshop_catalog_categories_option', array() );
1402
-				$product_categories = wp_get_object_terms( $post->ID, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES );
1403
-				if( empty( $product_categories ) ) {
1401
+				$options_cats = get_option('wpshop_catalog_categories_option', array());
1402
+				$product_categories = wp_get_object_terms($post->ID, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1403
+				if (empty($product_categories)) {
1404 1404
 					$product_category_slug = $options_cats['wpshop_catalog_no_category_slug'];
1405 1405
 				} else {
1406 1406
 					$product_category_slug = $product_categories[0]->slug;
1407 1407
 				}
1408
-				$permalink = str_replace( '%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%', $product_category_slug, $permalink );
1408
+				$permalink = str_replace('%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%', $product_category_slug, $permalink);
1409 1409
 			}
1410 1410
 		}
1411 1411
 
@@ -1439,10 +1439,10 @@  discard block
 block discarded – undo
1439 1439
 		}*/
1440 1440
 	}
1441 1441
 
1442
-	public static function set_product_request_by_name( $query ) {
1442
+	public static function set_product_request_by_name($query) {
1443 1443
 		$options = get_option('wpshop_catalog_product_option', array());
1444 1444
 
1445
-		if ( $query->is_main_query() && ( 2 == count( $query->query ) || isset( $query->query['page'] ) ) && ! empty( $query->query['name'] ) && empty( $options['wpshop_catalog_product_slug'] ) );
1445
+		if ($query->is_main_query() && (2 == count($query->query) || isset($query->query['page'])) && !empty($query->query['name']) && empty($options['wpshop_catalog_product_slug']));
1446 1446
 		//	$query->set( 'post_type', array( 'post', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'page' ) );
1447 1447
 	}
1448 1448
 
@@ -1466,57 +1466,57 @@  discard block
 block discarded – undo
1466 1466
 		/** Get product definition	*/
1467 1467
 
1468 1468
 		$product = self::get_product_data($product_id);
1469
-		wp_cache_set( 'wpshop_product_data_'.$product_id, $product );
1469
+		wp_cache_set('wpshop_product_data_' . $product_id, $product);
1470 1470
 
1471 1471
 		/** Get the product thumbnail	*/
1472 1472
 		$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1473
-		if ( has_post_thumbnail($product_id) ) {
1474
-			$thumbnail_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
1473
+		if (has_post_thumbnail($product_id)) {
1474
+			$thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
1475 1475
 			$tpl_component = array();
1476 1476
 			$tpl_component['PRODUCT_THUMBNAIL_URL'] = $thumbnail_url[0];
1477
-			$tpl_component['PRODUCT_THUMBNAIL'] = get_the_post_thumbnail( $product_id, 'wpshop-product-galery' );
1478
-			$tpl_component['PRODUCT_THUMBNAIL_FULL'] = get_the_post_thumbnail( $product_id, 'full' );
1479
-			$image_attributes = wp_get_attachment_metadata( get_post_thumbnail_id() );
1480
-			if ( !empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes']) ) {
1481
-				foreach ( $image_attributes['sizes'] as $size_name => $size_def) {
1477
+			$tpl_component['PRODUCT_THUMBNAIL'] = get_the_post_thumbnail($product_id, 'wpshop-product-galery');
1478
+			$tpl_component['PRODUCT_THUMBNAIL_FULL'] = get_the_post_thumbnail($product_id, 'full');
1479
+			$image_attributes = wp_get_attachment_metadata(get_post_thumbnail_id());
1480
+			if (!empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes'])) {
1481
+				foreach ($image_attributes['sizes'] as $size_name => $size_def) {
1482 1482
 					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = wp_get_attachment_image(get_post_thumbnail_id(), $size_name);
1483
-					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1483
+					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = (!empty($tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)])) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1484 1484
 				}
1485 1485
 			}
1486
-			$tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1487
-			$productThumbnail = wpshop_display::display_template_element( 'product_thumbnail', $tpl_component );
1486
+			$tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] = (!empty($tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'])) ? $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1487
+			$productThumbnail = wpshop_display::display_template_element('product_thumbnail', $tpl_component);
1488 1488
 			unset($tpl_component);
1489 1489
 		}
1490 1490
 
1491
-		$product_document_galery = wps_media_manager_frontend_ctr::get_product_complete_sheet_attachments( $product_id );
1491
+		$product_document_galery = wps_media_manager_frontend_ctr::get_product_complete_sheet_attachments($product_id);
1492 1492
 
1493 1493
 		/**	Retrieve product attributes for output	*/
1494
-		$attributeContentOutput = wpshop_attributes::attribute_of_entity_to_tab( wpshop_entities::get_entity_identifier_from_code( self::currentPageCode ), $product_id, $product);
1494
+		$attributeContentOutput = wpshop_attributes::attribute_of_entity_to_tab(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $product_id, $product);
1495 1495
 
1496 1496
 		/** Retrieve product price */
1497
-		$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
1498
-		$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
1499
-		$catalog_options = get_option( 'wpshop_catalog_main_option' , array() );
1497
+		$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
1498
+		$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
1499
+		$catalog_options = get_option('wpshop_catalog_main_option', array());
1500 1500
 		$productPrice = '';
1501 1501
 		$wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting');
1502 1502
 		$check_product_price = wpshop_prices::check_product_price($product);
1503
-		$result_price_piloting = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1504
-		if ( $price_display && !( !empty( $catalog_options ) && ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) && $result_price_piloting == 0 ) ) {
1503
+		$result_price_piloting = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1504
+		if ($price_display && !(!empty($catalog_options) && (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes') && $result_price_piloting == 0)) {
1505 1505
 			$productPrice = wpshop_prices::get_product_price($product, 'price_display', 'complete_sheet');
1506 1506
 		}
1507 1507
 
1508 1508
 		/** Check if there is at less 1 product in stock	*/
1509 1509
 		$productStock = $wps_product_ctr->check_stock($product_id, 1);
1510
-		$productStock = ( $productStock === true ) ? 1 : null;
1510
+		$productStock = ($productStock === true) ? 1 : null;
1511 1511
 
1512 1512
 		/** if !product stock check product have variation with stock **/
1513 1513
 // 		if ( empty($productStock) ) {
1514
-			$product_variation_meta = get_post_meta( $product_id, '_wpshop_variation_defining', true );
1515
-			if ( !empty($product_variation_meta) && !empty($product_variation_meta['options']) && !empty($product_variation_meta['options']['priority']) && in_array('combined', $product_variation_meta['options']['priority']) ) {
1516
-				$variations = wpshop_products::get_variation( $product_id );
1517
-				if ( !empty($variations) ) {
1518
-					foreach( $variations as $variation ) {
1519
-						if ( !empty($variation) && !empty($variation['variation_dif']) && array_key_exists('product_stock', $variation['variation_dif']) && round( $variation['variation_dif']['product_stock'] ) > 0 ) {
1514
+			$product_variation_meta = get_post_meta($product_id, '_wpshop_variation_defining', true);
1515
+			if (!empty($product_variation_meta) && !empty($product_variation_meta['options']) && !empty($product_variation_meta['options']['priority']) && in_array('combined', $product_variation_meta['options']['priority'])) {
1516
+				$variations = wpshop_products::get_variation($product_id);
1517
+				if (!empty($variations)) {
1518
+					foreach ($variations as $variation) {
1519
+						if (!empty($variation) && !empty($variation['variation_dif']) && array_key_exists('product_stock', $variation['variation_dif']) && round($variation['variation_dif']['product_stock']) > 0) {
1520 1520
 							$productStock = 1;
1521 1521
 						}
1522 1522
 					}
@@ -1525,16 +1525,16 @@  discard block
 block discarded – undo
1525 1525
 // 		}
1526 1526
 
1527 1527
 		/** Define "Add to cart" button	 */
1528
-		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display( ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'complete_sheet');
1528
+		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display(((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'complete_sheet');
1529 1529
 		$display_price_state_when_price_is_empty = true;
1530
-		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1530
+		if (empty($productPrice) && (!empty($catalog_options) || (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes'))) {
1531 1531
 			$display_price_state_when_price_is_empty = false;
1532 1532
 		}
1533
-		else if ( !empty( $productPrice ) ) {
1533
+		else if (!empty($productPrice)) {
1534 1534
 			$display_price_state_when_price_is_empty = true;
1535 1535
 		}
1536
-		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'complete' ) : '';
1537
-		$product_quantity_chooser_input = ( true === $add_to_cart_button_display_state ) ? wpshop_display::display_template_element( 'product_complete_sheet_quantity_chooser', array( 'PRODUCT_ID' => $product_id, ) ) : '';
1536
+		$add_to_cart_button = (true === $add_to_cart_button_display_state) && (true === $display_price_state_when_price_is_empty) ? self::display_add_to_cart_button($product_id, $productStock, 'complete') : '';
1537
+		$product_quantity_chooser_input = (true === $add_to_cart_button_display_state) ? wpshop_display::display_template_element('product_complete_sheet_quantity_chooser', array('PRODUCT_ID' => $product_id,)) : '';
1538 1538
 
1539 1539
 		/** Define "Ask a quotation" button	*/
1540 1540
 		$quotation_button = self::display_quotation_button($product_id, (!empty($product['quotation_allowed']) ? $product['quotation_allowed'] : null), 'complete');
@@ -1551,14 +1551,14 @@  discard block
 block discarded – undo
1551 1551
 		$tpl_component['PRODUCT_PRICE'] = $productPrice;
1552 1552
 		$modules_option = get_option('wpshop_modules');
1553 1553
 		$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = '';
1554
-		if ( !empty($modules_option) && !empty($modules_option['wpshop_low_stock_alert']) && $modules_option['wpshop_low_stock_alert']['activated'] == 'on' ) {
1554
+		if (!empty($modules_option) && !empty($modules_option['wpshop_low_stock_alert']) && $modules_option['wpshop_low_stock_alert']['activated'] == 'on') {
1555 1555
 			$wps_marketing_tools = new wps_marketing_tools_ctr();
1556
-			$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = $wps_marketing_tools->display_alert_stock_message( array( 'id' => $product_id ) );
1556
+			$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = $wps_marketing_tools->display_alert_stock_message(array('id' => $product_id));
1557 1557
 		}
1558 1558
 
1559 1559
 
1560 1560
 		/** Gallery **/
1561
-		$tpl_component['PRODUCT_COMPLETE_SHEET_GALLERY'] = wps_media_manager_frontend_ctr::get_product_complete_sheet_galery( $product_id );
1561
+		$tpl_component['PRODUCT_COMPLETE_SHEET_GALLERY'] = wps_media_manager_frontend_ctr::get_product_complete_sheet_galery($product_id);
1562 1562
 
1563 1563
 		$product_new_def = self::display_product_special_state('declare_new', 'complete', (!empty($product['declare_new']) ? $product['declare_new'] : 'no'), (!empty($product['set_new_from']) ? $product['set_new_from'] : ''), (!empty($product['set_new_to']) ? $product['set_new_to'] : ''));
1564 1564
 
@@ -1577,14 +1577,14 @@  discard block
 block discarded – undo
1577 1577
 		$tpl_component['PRODUCT_BUTTON_ADD_TO_CART'] = $add_to_cart_button;
1578 1578
 		$tpl_component['PRODUCT_BUTTON_QUOTATION'] = $quotation_button;
1579 1579
 		$tpl_component['PRODUCT_QUANTITY_CHOOSER'] = $product_quantity_chooser_input;
1580
-		$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_QUOTATION'].$tpl_component['PRODUCT_BUTTON_ADD_TO_CART'];
1580
+		$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_QUOTATION'] . $tpl_component['PRODUCT_BUTTON_ADD_TO_CART'];
1581 1581
 		$tpl_component['PRODUCT_GALERY_DOCS'] = $product_document_galery;
1582 1582
 		$tpl_component['PRODUCT_FEATURES'] = $attributeContentOutput;
1583
-		$tpl_component = apply_filters( 'wps-filter-product-complete-sheet-output', $tpl_component, $product_id );
1583
+		$tpl_component = apply_filters('wps-filter-product-complete-sheet-output', $tpl_component, $product_id);
1584 1584
 
1585 1585
 		/** Build template	*/
1586 1586
 		$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1587
-		if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1587
+		if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1588 1588
 			/*	Include the old way template part	*/
1589 1589
 			ob_start();
1590 1590
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1605,14 +1605,14 @@  discard block
 block discarded – undo
1605 1605
 
1606 1606
 		/** Get the product thumbnail	*/
1607 1607
 		$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1608
-		if(has_post_thumbnail($product_id)){
1608
+		if (has_post_thumbnail($product_id)) {
1609 1609
 			$productThumbnail = get_the_post_thumbnail($product_id, 'thumbnail');
1610 1610
 		}
1611 1611
 
1612 1612
 		$product = self::get_product_data($product_id);
1613 1613
 
1614 1614
 		/**	Get the product information for output	*/
1615
-		if ( !empty($product) ) {
1615
+		if (!empty($product)) {
1616 1616
 
1617 1617
 			$product_title = $product['post_title'];
1618 1618
 			$product_name = $product['post_name'];
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 			$product_more_informations = $product['product_content'];
1621 1621
 			$product_excerpt = $product['product_excerpt'];
1622 1622
 
1623
-			if ( strpos($product['product_content'], '<!--more-->') ) {
1623
+			if (strpos($product['product_content'], '<!--more-->')) {
1624 1624
 				$post_content = explode('<!--more-->', $product['product_content']);
1625 1625
 				$product_more_informations = $post_content[0];
1626 1626
 			}
@@ -1628,55 +1628,55 @@  discard block
 block discarded – undo
1628 1628
 		}
1629 1629
 		else {
1630 1630
 			$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1631
-			$product_title = '<i>'.__('This product does not exist', 'wpshop').'</i>';
1631
+			$product_title = '<i>' . __('This product does not exist', 'wpshop') . '</i>';
1632 1632
 			$product_link = '';
1633 1633
 			$product_more_informations = '';
1634 1634
 			$product_excerpt = '';
1635 1635
 		}
1636 1636
 
1637 1637
 		/** Retrieve product price	*/
1638
-		$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
1639
-		$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front_listing, $product['custom_display'], 'attribute', 'product_price', 'mini_output');
1640
-		$catalog_options = get_option( 'wpshop_catalog_main_option' , array() );
1638
+		$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
1639
+		$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front_listing, $product['custom_display'], 'attribute', 'product_price', 'mini_output');
1640
+		$catalog_options = get_option('wpshop_catalog_main_option', array());
1641 1641
 		$productPrice = '';
1642 1642
 		$wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting');
1643 1643
 		$check_product_price = wpshop_prices::check_product_price($product);
1644
-		$result_price_piloting = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1645
-		if ( $price_display && !( !empty( $catalog_options ) && ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) && $result_price_piloting == 0 ) ) {
1646
-			$product_price_infos = wpshop_prices::get_product_price( $product, 'just_price_infos', 'mini_output' );
1644
+		$result_price_piloting = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1645
+		if ($price_display && !(!empty($catalog_options) && (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes') && $result_price_piloting == 0)) {
1646
+			$product_price_infos = wpshop_prices::get_product_price($product, 'just_price_infos', 'mini_output');
1647 1647
 			
1648
-	 		if ( !empty($product_price_infos) ) {
1648
+	 		if (!empty($product_price_infos)) {
1649 1649
 	 			$tpl_component_price = array();
1650 1650
 	 			/** Price piloting **/
1651
-	 			$price_ploting = get_option( 'wpshop_shop_price_piloting' );
1652
-	 			$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'])) : '';
1653
-	 			$variations = wpshop_products::get_variation( $product_id );
1654
-				$tpl_component_price['PRODUCT_PRICE'] = ( empty($product_price_infos['CROSSED_OUT_PRICE']) && ( !empty( $variations ) && !empty($product_price_infos['PRICE_FROM'] ) ) ) ? __('Price from', 'wpshop') . ' ' . $product_price_infos['PRODUCT_PRICE'] : $product_price_infos['PRODUCT_PRICE'];
1651
+	 			$price_ploting = get_option('wpshop_shop_price_piloting');
1652
+	 			$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'])) : '';
1653
+	 			$variations = wpshop_products::get_variation($product_id);
1654
+				$tpl_component_price['PRODUCT_PRICE'] = (empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && !empty($product_price_infos['PRICE_FROM']))) ? __('Price from', 'wpshop') . ' ' . $product_price_infos['PRODUCT_PRICE'] : $product_price_infos['PRODUCT_PRICE'];
1655 1655
 	 			$tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY'];
1656
-	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT' ) ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657
-	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price );
1656
+	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT') ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657
+	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price);
1658 1658
 	 		}
1659 1659
 			else {
1660
-				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type) );
1660
+				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type));
1661 1661
 	 		}
1662 1662
 		}
1663 1663
 
1664 1664
 		/** Check if there is at less 1 product in stock	*/
1665 1665
 		$wps_product_ctr = new wps_product_ctr();
1666 1666
 		$productStock = $wps_product_ctr->check_stock($product_id, 1);
1667
-		$productStock = $productStock===true ? 1 : null;
1667
+		$productStock = $productStock === true ? 1 : null;
1668 1668
 
1669 1669
 		/** Define "Add to cart" button	*/
1670
-		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display( ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'mini_output');
1670
+		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display(((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'mini_output');
1671 1671
 		$display_price_state_when_price_is_empty = false;
1672
-		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1672
+		if (empty($productPrice) && (!empty($catalog_options) || (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes'))) {
1673 1673
 			$display_price_state_when_price_is_empty = false;
1674 1674
 		}
1675
-		else if ( !empty( $productPrice ) ) {
1675
+		else if (!empty($productPrice)) {
1676 1676
 			$display_price_state_when_price_is_empty = true;
1677 1677
 		}
1678
-		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'mini' ) : '';
1679
-		$product_quantity_chooser_input = ( true === $add_to_cart_button_display_state ) ? wpshop_display::display_template_element( 'product_complete_sheet_quantity_chooser', array( 'PRODUCT_ID' => $product_id, ) ) : '';
1678
+		$add_to_cart_button = (true === $add_to_cart_button_display_state) && (true === $display_price_state_when_price_is_empty) ? self::display_add_to_cart_button($product_id, $productStock, 'mini') : '';
1679
+		$product_quantity_chooser_input = (true === $add_to_cart_button_display_state) ? wpshop_display::display_template_element('product_complete_sheet_quantity_chooser', array('PRODUCT_ID' => $product_id,)) : '';
1680 1680
 
1681 1681
 		/** Define "Ask a quotation" button	*/
1682 1682
 		$quotation_button = self::display_quotation_button($product_id, (!empty($product['quotation_allowed']) ? $product['quotation_allowed'] : null));
@@ -1690,11 +1690,11 @@  discard block
 block discarded – undo
1690 1690
 		$product_featured = $product_featured_def['output'];
1691 1691
 		$product_class .= $product_featured_def['class'];
1692 1692
 
1693
-		if ( !($current_item_position%$grid_element_nb_per_line) ) {
1693
+		if (!($current_item_position % $grid_element_nb_per_line)) {
1694 1694
 			$product_class .= ' wpshop_last_product_of_line';
1695 1695
 		}
1696 1696
 
1697
-		if ( !empty($product['product_id']) ) {
1697
+		if (!empty($product['product_id'])) {
1698 1698
 			/** Template parameters	*/
1699 1699
 			$template_part = 'product_mini_' . $output_type;
1700 1700
 			$tpl_component = array();
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 			$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_ADD_TO_CART'] . $tpl_component['PRODUCT_BUTTON_QUOTATION'];
1709 1709
 			$tpl_component['PRODUCT_PRICE'] = $productPrice;
1710 1710
 			$tpl_component['PRODUCT_PERMALINK'] = $product_link;
1711
-			$tpl_component['PRODUCT_TITLE'] = ( !empty($product_title) ) ? $product_title  : '';
1711
+			$tpl_component['PRODUCT_TITLE'] = (!empty($product_title)) ? $product_title : '';
1712 1712
 			$tpl_component['PRODUCT_NAME'] = $product_name;
1713 1713
 			$tpl_component['PRODUCT_DESCRIPTION'] = $product_more_informations;
1714 1714
 			$tpl_component['PRODUCT_IS_NEW'] = $product_new;
@@ -1716,24 +1716,24 @@  discard block
 block discarded – undo
1716 1716
 			$tpl_component['PRODUCT_EXTRA_STATE'] = $tpl_component['PRODUCT_IS_NEW'] . $tpl_component['PRODUCT_IS_FEATURED'];
1717 1717
 			$tpl_component['PRODUCT_THUMBNAIL'] = $productThumbnail;
1718 1718
 
1719
-			if ( has_post_thumbnail($product_id) ) {
1720
-				$image_attributes = wp_get_attachment_metadata( get_post_thumbnail_id($product_id)  );
1721
-				if ( !empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes']) ) {
1719
+			if (has_post_thumbnail($product_id)) {
1720
+				$image_attributes = wp_get_attachment_metadata(get_post_thumbnail_id($product_id));
1721
+				if (!empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes'])) {
1722 1722
 					$existing_image_sizes = get_intermediate_image_sizes();
1723
-					foreach ( $existing_image_sizes as $size_name) {
1723
+					foreach ($existing_image_sizes as $size_name) {
1724 1724
 						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = wp_get_attachment_image(get_post_thumbnail_id($product_id), $size_name);
1725
-						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1725
+						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = (!empty($tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)])) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1726 1726
 					}
1727 1727
 				}
1728 1728
 			}
1729 1729
 
1730 1730
 			$tpl_component['PRODUCT_EXCERPT'] = $product_excerpt;
1731 1731
 			$tpl_component['PRODUCT_OUTPUT_TYPE'] = $output_type;
1732
-			$tpl_component = apply_filters( 'wps-filter-product-mini-output', $tpl_component, $product_id );
1732
+			$tpl_component = apply_filters('wps-filter-product-mini-output', $tpl_component, $product_id);
1733 1733
 
1734 1734
 			/** Build template	*/
1735 1735
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1736
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1736
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1737 1737
 				/**	Include the old way template part	*/
1738 1738
 				ob_start();
1739 1739
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1760,18 +1760,18 @@  discard block
 block discarded – undo
1760 1760
 	*
1761 1761
 	*	@return mixed $widget_content The output for the product list
1762 1762
 	*/
1763
-	public static function get_product_of_category($category_slug, $category_id){
1763
+	public static function get_product_of_category($category_slug, $category_id) {
1764 1764
 		global $top_categories;
1765 1765
 		$widget_content = '';
1766
-		$products = wp_cache_get( 'wpshop_products_category_'.$category_id );
1767
-		if( false == $products ) {
1766
+		$products = wp_cache_get('wpshop_products_category_' . $category_id);
1767
+		if (false == $products) {
1768 1768
 			$args = array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES => $category_slug);
1769 1769
 			$products = get_posts($args);
1770
-			wp_cache_set( 'wpshop_products_category_'.$category_id, $products );
1770
+			wp_cache_set('wpshop_products_category_' . $category_id, $products);
1771 1771
 		}
1772
-		if(is_array($products) && (count($products) > 0)){
1773
-			foreach($products as $product){
1774
-				if ( $product->post_status == "publish" ) {
1772
+		if (is_array($products) && (count($products) > 0)) {
1773
+			foreach ($products as $product) {
1774
+				if ($product->post_status == "publish") {
1775 1775
 					ob_start();
1776 1776
 					require(wpshop_display::get_template_file('categories_products-widget.tpl.php'));
1777 1777
 					$widget_content .= ob_get_contents();
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 	 * @param unknown_type $selected_product
1789 1789
 	 * @return string
1790 1790
 	 */
1791
-	function custom_product_list($selected_product = array()){
1791
+	function custom_product_list($selected_product = array()) {
1792 1792
 		global $wpdb;
1793 1793
 
1794 1794
 		/*	Start the table definition	*/
@@ -1816,9 +1816,9 @@  discard block
 block discarded – undo
1816 1816
 		$posts = query_posts(array(
1817 1817
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'posts_per_page' => -1
1818 1818
 		));
1819
-		if(!empty($posts)){
1819
+		if (!empty($posts)) {
1820 1820
 			$has_result = true;
1821
-			foreach($posts as $post){
1821
+			foreach ($posts as $post) {
1822 1822
 				$tableRowsId[$current_line_index] = 'product_' . $post->ID;
1823 1823
 
1824 1824
 				$post_info = get_post_meta($post->ID, '_wpshop_product_metadata', true);
@@ -1826,12 +1826,12 @@  discard block
 block discarded – undo
1826 1826
 				unset($tableRowValue);
1827 1827
 				$tableRowValue[] = array('class' => 'wpshop_product_selector_cell', 'value' => '<input type="checkbox" name="wp_list_product[]" value="' . $post->ID . '" class="wpshop_product_cb_dialog" id="wpshop_product_cb_dialog_' . $post->ID . '" />');
1828 1828
 				$tableRowValue[] = array('class' => 'wpshop_product_identifier_cell', 'value' => '<label for="wpshop_product_cb_dialog_' . $post->ID . '" >' . WPSHOP_IDENTIFIER_PRODUCT . $post->ID . '</label>');
1829
-				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID  . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1830
-				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => ( !empty($post_info['product_reference']) ) ? $post_info['product_reference'] : '');
1829
+				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1830
+				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => (!empty($post_info['product_reference'])) ? $post_info['product_reference'] : '');
1831 1831
 				$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1832 1832
 				$tableRowValue[] = array('class' => 'wpshop_product_link_cell', 'value' => '<a href="' . $post->guid . '" target="wpshop_product_view_product" target="wpshop_view_product" >' . __('View product', 'wpshop') . '</a><br/>
1833
-				<a href="' . admin_url('post.php?post=' . $post->ID  . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1834
-				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty( $post_info[WPSHOP_PRODUCT_PRICE_HT]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty($post_info[WPSHOP_PRODUCT_PRICE_TTC]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1833
+				<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1834
+				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_HT])) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_TTC])) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1835 1835
 				$tableRows[] = $tableRowValue;
1836 1836
 
1837 1837
 				$current_line_index++;
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 		$posts = query_posts(array(
1842 1842
 				'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'posts_per_page' => -1
1843 1843
 		));
1844
-		if(!empty($posts)){
1844
+		if (!empty($posts)) {
1845 1845
 			$has_result = true;
1846
-			foreach($posts as $post){
1846
+			foreach ($posts as $post) {
1847 1847
 				$tableRowsId[$current_line_index] = 'product_' . $post->ID;
1848 1848
 
1849 1849
 				$post_info = get_post_meta($post->ID, '_wpshop_product_metadata', true);
@@ -1851,25 +1851,25 @@  discard block
 block discarded – undo
1851 1851
 				unset($tableRowValue);
1852 1852
 				$tableRowValue[] = array('class' => 'wpshop_product_selector_cell', 'value' => '<input type="checkbox" name="wp_list_product[]" value="' . $post->ID . '" class="wpshop_product_cb_dialog" id="wpshop_product_cb_dialog_' . $post->ID . '" />');
1853 1853
 				$tableRowValue[] = array('class' => 'wpshop_product_identifier_cell', 'value' => '<label for="wpshop_product_cb_dialog_' . $post->ID . '" >' . WPSHOP_IDENTIFIER_PRODUCT . $post->ID . '</label>');
1854
-				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID  . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1855
-				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => ( !empty($post_info['product_reference']) ) ? $post_info['product_reference'] : '');
1854
+				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1855
+				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => (!empty($post_info['product_reference'])) ? $post_info['product_reference'] : '');
1856 1856
 				$parent_product = wpshop_products::get_parent_variation($post->ID);
1857
-				if ( !empty($parent_product) && !empty($parent_product['parent_post']) ) {
1858
-					$product_variations_postmeta = get_post_meta($post->ID,'_wpshop_variations_attribute_def', true);
1859
-					$query = $wpdb->prepare('SELECT frontend_label FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', key($product_variations_postmeta) );
1857
+				if (!empty($parent_product) && !empty($parent_product['parent_post'])) {
1858
+					$product_variations_postmeta = get_post_meta($post->ID, '_wpshop_variations_attribute_def', true);
1859
+					$query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', key($product_variations_postmeta));
1860 1860
 					$option_name = $wpdb->get_var($query);
1861
-					$query = $wpdb->prepare('SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $product_variations_postmeta[key($product_variations_postmeta)]);
1861
+					$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $product_variations_postmeta[key($product_variations_postmeta)]);
1862 1862
 					$option_value = $wpdb->get_var($query);
1863 1863
 					$parent_post = $parent_product['parent_post'];
1864
-					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title. ' <br/>('. $option_name . ' : ' . $option_value. ')');
1864
+					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title . ' <br/>(' . $option_name . ' : ' . $option_value . ')');
1865 1865
 				}
1866 1866
 				else {
1867 1867
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1868 1868
 				}
1869 1869
 
1870 1870
 				$tableRowValue[] = array('class' => 'wpshop_product_link_cell', 'value' => '<a href="' . $post->guid . '" target="wpshop_product_view_product" target="wpshop_view_product" >' . __('View product', 'wpshop') . '</a><br/>
1871
-				<a href="' . admin_url('post.php?post=' . $post->ID  . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1872
-				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty( $post_info[WPSHOP_PRODUCT_PRICE_HT]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty($post_info[WPSHOP_PRODUCT_PRICE_TTC]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1871
+				<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1872
+				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_HT])) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_TTC])) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1873 1873
 				$tableRows[] = $tableRowValue;
1874 1874
 
1875 1875
 				$current_line_index++;
@@ -1927,15 +1927,15 @@  discard block
 block discarded – undo
1927 1927
 
1928 1928
 		/** PRODUCT MARK AS NEW */
1929 1929
 		$show_product_special_state = false;
1930
-		if ( (strtolower(__($special_state_def, 'wpshop')) === strtolower(__('Yes', 'wpshop')) ) &&
1930
+		if ((strtolower(__($special_state_def, 'wpshop')) === strtolower(__('Yes', 'wpshop'))) &&
1931 1931
 				(empty($special_state_start) || ($special_state_start == '0000-00-00') || ($special_state_start >= $current_time)) &&
1932
-				(empty($special_state_end) || ($special_state_end == '0000-00-00') || ($special_state_end <= $current_time)) ) {
1932
+				(empty($special_state_end) || ($special_state_end == '0000-00-00') || ($special_state_end <= $current_time))) {
1933 1933
 			$show_product_special_state = true;
1934 1934
 		}
1935 1935
 
1936
-		if ( $show_product_special_state ) {
1936
+		if ($show_product_special_state) {
1937 1937
 			/** Check the type of special output needed	*/
1938
-			switch ( $special ) {
1938
+			switch ($special) {
1939 1939
 				case 'declare_new':
1940 1940
 					$product_special_state['class'] = ' wpshop_product_is_new_' . $output_type;
1941 1941
 					$template_part = 'product_is_new_sticker';
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 			/** Build template		*/
1954 1954
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1955
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1955
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1956 1956
 				/**	Include the old way template part	*/
1957 1957
 				ob_start();
1958 1958
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 	 *
1976 1976
 	 * @param integer $element_id Identifier of current product
1977 1977
 	 */
1978
-	public static function calculate_price( $element_id ) {
1978
+	public static function calculate_price($element_id) {
1979 1979
 		global $wpdb;
1980 1980
 
1981 1981
 		/**
@@ -1987,13 +1987,13 @@  discard block
 block discarded – undo
1987 1987
 			"SELECT ATTR.code, ATTR_VAL.value_id AS id, ATTR_VAL.value, ATTR.id AS attribute_id
1988 1988
 			FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR
1989 1989
 				RIGHT JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . " AS ATTR_VAL ON ((ATTR_VAL.attribute_id = ATTR.id) AND (ATTR_VAL.entity_id = %d))
1990
-			WHERE ATTR.code IN ('" . implode( "', '",  unserialize( WPSHOP_ATTRIBUTE_PRICES ) ) . "')",
1990
+			WHERE ATTR.code IN ('" . implode("', '", unserialize(WPSHOP_ATTRIBUTE_PRICES)) . "')",
1991 1991
 			$element_id
1992 1992
 		);
1993
-		$prices_attribute = $wpdb->get_results( $query, OBJECT_K );
1993
+		$prices_attribute = $wpdb->get_results($query, OBJECT_K);
1994 1994
 
1995 1995
 		/** Si aucun prix trouvé on stop la méthode / If not found price, stop the method */
1996
-		if( empty( $prices_attribute ) ) {
1996
+		if (empty($prices_attribute)) {
1997 1997
 			return false;
1998 1998
 		}
1999 1999
 		else {
@@ -2001,18 +2001,18 @@  discard block
 block discarded – undo
2001 2001
 			 * Récupère le prix de base selon le pilotage de prix de la boutique / Get
2002 2002
 			 * the base amount according on the shop price control
2003 2003
 			 */
2004
-			$base_price 		= $prices_attribute[constant( 'WPSHOP_PRODUCT_PRICE_' . WPSHOP_PRODUCT_PRICE_PILOT )]->value;
2005
-			$rate_vat			= wpshop_prices::get_rate_vat( $element_id );
2006
-			$divider_price_ttc 	= 1 + ( $rate_vat->value / 100 );
2004
+			$base_price = $prices_attribute[constant('WPSHOP_PRODUCT_PRICE_' . WPSHOP_PRODUCT_PRICE_PILOT)]->value;
2005
+			$rate_vat = wpshop_prices::get_rate_vat($element_id);
2006
+			$divider_price_ttc = 1 + ($rate_vat->value / 100);
2007 2007
 
2008 2008
 			/**
2009 2009
 			 * Informations nécessaire pour crée un attribut / Information needed to
2010 2010
 			 * create an attribute
2011 2011
 			 */
2012
-			$entity_type_id	= wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2013
-			$language 		= WPSHOP_CURRENT_LOCALE;
2012
+			$entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2013
+			$language = WPSHOP_CURRENT_LOCALE;
2014 2014
 
2015
-			if ( !empty($_REQUEST['icl_post_language']) ) {
2015
+			if (!empty($_REQUEST['icl_post_language'])) {
2016 2016
 				$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", sanitize_text_field($_REQUEST['icl_post_language']));
2017 2017
 				$language = $wpdb->get_var($query);
2018 2018
 			}
@@ -2021,13 +2021,13 @@  discard block
 block discarded – undo
2021 2021
 			 * Vérifie la configuration pour savoir comment calculer les prix pour le produit /
2022 2022
 			 * Check configuration to know how to make the calcul for the product
2023 2023
 			 */
2024
-			if ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) {
2025
-				$price_with_vat = ($base_price * $divider_price_ttc );
2026
-				$price_no_vat 	= $base_price;
2024
+			if (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') {
2025
+				$price_with_vat = ($base_price * $divider_price_ttc);
2026
+				$price_no_vat = $base_price;
2027 2027
 			}
2028
-			else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2028
+			else if (WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') {
2029 2029
 				$price_with_vat = $base_price;
2030
-				$price_no_vat	= ($price_with_vat / $divider_price_ttc );
2030
+				$price_no_vat = ($price_with_vat / $divider_price_ttc);
2031 2031
 			}
2032 2032
 
2033 2033
 			/**
@@ -2035,29 +2035,29 @@  discard block
 block discarded – undo
2035 2035
 			 * type que celui-ci / The last parameter allows not to delete the
2036 2036
 			 * attributes of the same type as this one
2037 2037
 			 */
2038
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'product_price' => $price_with_vat )), $entity_type_id, $element_id, $language, 'wpshop_products' );
2039
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'price_ht' => $price_no_vat )), $entity_type_id, $element_id, $language, 'wpshop_product' );
2038
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('product_price' => $price_with_vat)), $entity_type_id, $element_id, $language, 'wpshop_products');
2039
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('price_ht' => $price_no_vat)), $entity_type_id, $element_id, $language, 'wpshop_product');
2040 2040
 
2041 2041
 			/** Ajout ou met à jour de l'attribut tva / Add or update the attribute vat */
2042 2042
 			$vat_amount = $price_with_vat - $price_no_vat;
2043
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'tva' => $vat_amount )), $entity_type_id, $element_id, $language, 'wpshop_product' );
2043
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('tva' => $vat_amount)), $entity_type_id, $element_id, $language, 'wpshop_product');
2044 2044
 
2045 2045
 			/**	Update the product meta information with the calculated prices	*/
2046
-			$product_postmeta 									= get_post_meta( $element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true );
2047
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_TTC] 		= number_format( round( $price_with_vat, 5 ), 5, '.', '' );
2048
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_HT] 			= number_format( round( $price_no_vat, 5 ), 5, '.', '' );
2049
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX_AMOUNT] 	= number_format( round( $vat_amount, 5 ), 5, '.', '' );
2046
+			$product_postmeta = get_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
2047
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_TTC] 		= number_format(round($price_with_vat, 5), 5, '.', '');
2048
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_HT] 			= number_format(round($price_no_vat, 5), 5, '.', '');
2049
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX_AMOUNT] = number_format(round($vat_amount, 5), 5, '.', '');
2050 2050
 			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX] 		= $rate_vat->id;
2051 2051
 
2052
-			update_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $product_postmeta );
2052
+			update_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $product_postmeta);
2053 2053
 
2054 2054
 			/** Met à jour la meta _wps_price_infos */
2055
-			$p 		= wpshop_products::get_product_data( $element_id );
2056
-			$price 	= wpshop_prices::get_product_price( $p, 'just_price_infos', array( 'mini_output', 'grid' ) );
2057
-			update_post_meta( $element_id, '_wps_price_infos', $price );
2055
+			$p = wpshop_products::get_product_data($element_id);
2056
+			$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', 'grid'));
2057
+			update_post_meta($element_id, '_wps_price_infos', $price);
2058 2058
 
2059 2059
 			/** Met à jour la meta _wpshop_displayed_price */
2060
-			wps_filter_search::save_displayed_price_meta( $element_id );
2060
+			wps_filter_search::save_displayed_price_meta($element_id);
2061 2061
 		}
2062 2062
 
2063 2063
 		return true;
@@ -2077,24 +2077,24 @@  discard block
 block discarded – undo
2077 2077
 		$button = '';
2078 2078
 // 		$attributes_frontend_display = get_post_meta( $product_id, '_wpshop_product_attributes_frontend_display', true );
2079 2079
 
2080
-		if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' /*&& ( empty($attributes_frontend_display) || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['mini_output']) && $output_type == 'mini') || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['complete_sheet']) && $output_type == 'complete') ) */) {
2080
+		if (WPSHOP_DEFINED_SHOP_TYPE == 'sale' /*&& ( empty($attributes_frontend_display) || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['mini_output']) && $output_type == 'mini') || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['complete_sheet']) && $output_type == 'complete') ) */) {
2081 2081
 			/*
2082 2082
 			 * Check if current product has variation for button display
2083 2083
 			 */
2084
-			$variations_exists = get_posts( array( 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $product_id) );
2085
-			$variations_list = ( !empty($variations_exists) && is_array( wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode)) ) ) ? true : false;
2084
+			$variations_exists = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $product_id));
2085
+			$variations_list = (!empty($variations_exists) && is_array(wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode)))) ? true : false;
2086 2086
 
2087 2087
 			/*
2088 2088
 			 * Template parameters
2089 2089
 			 */
2090 2090
 
2091 2091
 
2092
-			if( get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2092
+			if (get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2093 2093
 				/** Check variation stock **/
2094
-				$variations = self::get_variation( $product_id );
2095
-				if ( !empty($variations) ) {
2096
-					foreach($variations as $variation ) {
2097
-						if( !empty($variation) && !empty($variation['variation_dif']) && !empty($variation['variation_dif']['product_stock']) ) {
2094
+				$variations = self::get_variation($product_id);
2095
+				if (!empty($variations)) {
2096
+					foreach ($variations as $variation) {
2097
+						if (!empty($variation) && !empty($variation['variation_dif']) && !empty($variation['variation_dif']['product_stock'])) {
2098 2098
 							$productStock += $variation['variation_dif']['product_stock'];
2099 2099
 						}
2100 2100
 					}
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 			 * Build template
2113 2113
 			 */
2114 2114
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2115
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2115
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2116 2116
 				/*	Include the old way template part	*/
2117 2117
 				ob_start();
2118 2118
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2137,11 +2137,11 @@  discard block
 block discarded – undo
2137 2137
 	 *
2138 2138
 	 * @return string $button The html output for the button
2139 2139
 	 */
2140
-	public static function display_quotation_button($product_id, $product_quotation_state,  $output_type = 'mini') {
2140
+	public static function display_quotation_button($product_id, $product_quotation_state, $output_type = 'mini') {
2141 2141
 		$quotation_button = '';
2142 2142
 
2143
-		if ( WPSHOP_ADDONS_QUOTATION && (!empty($product_quotation_state) && strtolower(__($product_quotation_state, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) && (empty($_SESSION['cart']['cart_type']) || ($_SESSION['cart']['cart_type'] == 'quotation')) ) {
2144
-			$variations_list = ( is_array( wpshop_products::get_variation( $product_id ) ) && is_array( wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode)) ) ) ? array_merge( wpshop_products::get_variation( $product_id ), wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode) ) ) : array();
2143
+		if (WPSHOP_ADDONS_QUOTATION && (!empty($product_quotation_state) && strtolower(__($product_quotation_state, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) && (empty($_SESSION['cart']['cart_type']) || ($_SESSION['cart']['cart_type'] == 'quotation'))) {
2144
+			$variations_list = (is_array(wpshop_products::get_variation($product_id)) && is_array(wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode)))) ? array_merge(wpshop_products::get_variation($product_id), wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode))) : array();
2145 2145
 			/**
2146 2146
 			 * Template parameters
2147 2147
 			 */
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 			 * Build template
2156 2156
 			 */
2157 2157
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2158
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2158
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2159 2159
 				/*	Include the old way template part	*/
2160 2160
 				ob_start();
2161 2161
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2181,13 +2181,13 @@  discard block
 block discarded – undo
2181 2181
 	 *
2182 2182
 	 * @return string The attachement gallery output
2183 2183
 	 */
2184
-	public static function display_attachment_gallery( $attachement_type, $content ) {
2184
+	public static function display_attachment_gallery($attachement_type, $content) {
2185 2185
 		$galery_output = '';
2186 2186
 
2187 2187
 		/*
2188 2188
 		 * Get the template part for given galery type
2189 2189
 		 */
2190
-		switch ( $attachement_type ) {
2190
+		switch ($attachement_type) {
2191 2191
 			case 'picture':
2192 2192
 					$template_part = 'product_attachment_picture_galery';
2193 2193
 				break;
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 		 * Build template
2208 2208
 		 */
2209 2209
 		$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2210
-		if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2210
+		if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2211 2211
 			/*	Include the old way template part	*/
2212 2212
 			ob_start();
2213 2213
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2227,11 +2227,11 @@  discard block
 block discarded – undo
2227 2227
 	 * Define the metabox to display in product edition page in backend
2228 2228
 	 * @param object $post The current element displayed for edition
2229 2229
 	 */
2230
-	public static function meta_box_variations( $post ) {
2230
+	public static function meta_box_variations($post) {
2231 2231
 		$output = '';
2232 2232
 		/*	Variations container	*/
2233 2233
 		$tpl_component = array();
2234
-		$tpl_component['ADMIN_VARIATION_CONTAINER'] = self::display_variation_admin( $post->ID );
2234
+		$tpl_component['ADMIN_VARIATION_CONTAINER'] = self::display_variation_admin($post->ID);
2235 2235
 		$output .= wpshop_display::display_template_element('wpshop_admin_variation_metabox', $tpl_component, array(), 'admin');
2236 2236
 		echo '<span class="wpshop_loading_ wpshopHide" ><img src="' . admin_url('images/loading.gif') . '" alt="loading picture" /></span>' . $output . '<div class="wpshop_cls" ></div>';
2237 2237
 	}
@@ -2246,12 +2246,12 @@  discard block
 block discarded – undo
2246 2246
 	 *
2247 2247
 	 * @return mixed The last created variation identifier
2248 2248
 	 */
2249
-	public static function creation_variation_callback( $possible_variations, $element_id ) {
2249
+	public static function creation_variation_callback($possible_variations, $element_id) {
2250 2250
 		/** Get existing variation	*/
2251
-		$existing_variations_in_db = wpshop_products::get_variation( $element_id );
2251
+		$existing_variations_in_db = wpshop_products::get_variation($element_id);
2252 2252
 		$existing_variations = array();
2253
-		if ( !empty($existing_variations_in_db) ) {
2254
-			foreach ( $existing_variations_in_db as $variations_def) {
2253
+		if (!empty($existing_variations_in_db)) {
2254
+			foreach ($existing_variations_in_db as $variations_def) {
2255 2255
 				$existing_variations[] = $variations_def['variation_def'];
2256 2256
 			}
2257 2257
 		}
@@ -2259,22 +2259,22 @@  discard block
 block discarded – undo
2259 2259
 		$attribute_defining_variation = get_post_meta($element_id, '_wpshop_variation_defining', true);
2260 2260
 
2261 2261
 		/**	Read possible values	*/
2262
-		foreach ( $possible_variations as $variation_definition) {
2263
-			if ( in_array($variation_definition, $existing_variations) ) {
2262
+		foreach ($possible_variations as $variation_definition) {
2263
+			if (in_array($variation_definition, $existing_variations)) {
2264 2264
 				continue;
2265 2265
 			}
2266 2266
 
2267 2267
 			$attribute_to_set = array();
2268
-			foreach ( $variation_definition as $attribute_code => $attribute_selected_value ) {
2268
+			foreach ($variation_definition as $attribute_code => $attribute_selected_value) {
2269 2269
 				$attribute = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2270 2270
 				$attribute_to_set[$attribute->data_type][$attribute_code] = $attribute_selected_value;
2271
-				if ( empty($attribute_defining_variation['attributes']) || (!in_array($attribute_code, $attribute_defining_variation['attributes'])) ) {
2271
+				if (empty($attribute_defining_variation['attributes']) || (!in_array($attribute_code, $attribute_defining_variation['attributes']))) {
2272 2272
 					$attribute_defining_variation['attributes'][] = $attribute_code;
2273 2273
 				}
2274 2274
 			}
2275 2275
 			$variation_id = wpshop_products::create_variation($element_id, $attribute_to_set);
2276 2276
 		}
2277
-		update_post_meta($element_id, '_wpshop_variation_defining', $attribute_defining_variation );
2277
+		update_post_meta($element_id, '_wpshop_variation_defining', $attribute_defining_variation);
2278 2278
 
2279 2279
 		return !empty($variation_id) ? $variation_id : 0;
2280 2280
 	}
@@ -2288,13 +2288,13 @@  discard block
 block discarded – undo
2288 2288
 	 *
2289 2289
 	 * @return mixed <number, WP_Error> The variation identifier or an error in case the creation was not succesfull
2290 2290
 	 */
2291
-	public static function create_variation( $head_product, $variation_attributes ) {
2291
+	public static function create_variation($head_product, $variation_attributes) {
2292 2292
 		/** Create custom title */
2293 2293
 		$title_variation = "";
2294
-		if(!empty($variation_attributes)) {
2295
-			foreach($variation_attributes as $type => $array) {
2296
-				if(!empty($array)) {
2297
-					foreach($array as $code => $value) {
2294
+		if (!empty($variation_attributes)) {
2295
+			foreach ($variation_attributes as $type => $array) {
2296
+				if (!empty($array)) {
2297
+					foreach ($array as $code => $value) {
2298 2298
 						$title_variation .= " " . $code . " " . $value;
2299 2299
 					}
2300 2300
 				}
@@ -2302,25 +2302,25 @@  discard block
 block discarded – undo
2302 2302
 		}
2303 2303
 
2304 2304
 		$variation = array(
2305
-			'post_title' => sprintf(__('Product %s variation %s', 'wpshop'), $head_product, get_the_title( $head_product )) . $title_variation,
2305
+			'post_title' => sprintf(__('Product %s variation %s', 'wpshop'), $head_product, get_the_title($head_product)) . $title_variation,
2306 2306
 			'post_content' => '',
2307 2307
 			'post_status' => 'publish',
2308 2308
 			'post_author' => get_current_user_id(),
2309 2309
 			'post_parent' => $head_product,
2310 2310
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION
2311 2311
 		);
2312
-		$variation_id = wp_insert_post( $variation );
2312
+		$variation_id = wp_insert_post($variation);
2313 2313
 
2314 2314
 		wpshop_attributes::saveAttributeForEntity($variation_attributes, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $variation_id, WPSHOP_CURRENT_LOCALE, '');
2315 2315
 
2316 2316
 		/*	Update product price looking for shop parameters	*/
2317
-		wpshop_products::calculate_price( $variation_id );
2317
+		wpshop_products::calculate_price($variation_id);
2318 2318
 
2319 2319
 		/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
2320 2320
 		$productMetaDatas = array();
2321
-		foreach ( $variation_attributes as $attributeType => $attributeValues ) {
2322
-			foreach ( $attributeValues as $attributeCode => $attributeValue ) {
2323
-				if ( !empty($attributeValue) ) {
2321
+		foreach ($variation_attributes as $attributeType => $attributeValues) {
2322
+			foreach ($attributeValues as $attributeCode => $attributeValue) {
2323
+				if (!empty($attributeValue)) {
2324 2324
 					$productMetaDatas[$attributeCode] = $attributeValue;
2325 2325
 				}
2326 2326
 			}
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 	 * @param integer $head_product The product identifier to get the variation for
2340 2340
 	 * @return object The variation list
2341 2341
 	 */
2342
-	public static function get_variation( $head_product ) {
2342
+	public static function get_variation($head_product) {
2343 2343
 		global $wpdb;
2344 2344
 		$variations_output = null;
2345 2345
 // 		$variations = query_posts(array(
@@ -2350,18 +2350,18 @@  discard block
 block discarded – undo
2350 2350
 // 			'posts_per_page'=> -1
2351 2351
 // 		));
2352 2352
 
2353
-		$query = $wpdb->prepare( 'SELECT * FROM ' .$wpdb->posts.' WHERE post_type = %s AND post_parent = %d AND post_status = %s ORDER BY ID ASC', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, $head_product, 'publish' );
2354
-		$variations = $wpdb->get_results( $query );
2353
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_parent = %d AND post_status = %s ORDER BY ID ASC', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, $head_product, 'publish');
2354
+		$variations = $wpdb->get_results($query);
2355 2355
 
2356
-		if ( !empty( $variations ) ) {
2357
-			$head_wpshop_variation_definition = get_post_meta( $head_product, '_wpshop_variation_defining', true );
2356
+		if (!empty($variations)) {
2357
+			$head_wpshop_variation_definition = get_post_meta($head_product, '_wpshop_variation_defining', true);
2358 2358
 
2359
-			foreach ( $variations as $post_def ) {
2360
-				$data = wpshop_attributes::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post_def->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
2361
-				foreach ( $data as $content ) {
2359
+			foreach ($variations as $post_def) {
2360
+				$data = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post_def->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2361
+				foreach ($data as $content) {
2362 2362
 					$attribute_value = 'attribute_value_' . $content->data_type;
2363
-					if ( !empty($content->$attribute_value) ) {
2364
-						if ( !empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes']) ) {
2363
+					if (!empty($content->$attribute_value)) {
2364
+						if (!empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes'])) {
2365 2365
 							$variations_output[$post_def->ID]['variation_def'][$content->code] = $content->$attribute_value;
2366 2366
 						}
2367 2367
 						else {
@@ -2383,26 +2383,26 @@  discard block
 block discarded – undo
2383 2383
 	 * @param integer $head_product L'identifiant du produit dont on veut afficher les variations
2384 2384
 	 * @return string Le code html permettant l'affichage des variations dans l'interface d'édition du produit
2385 2385
 	 */
2386
-	public static function display_variation_admin( $head_product ) {
2386
+	public static function display_variation_admin($head_product) {
2387 2387
 		$output = '';
2388 2388
 		$productCurrency = wpshop_tools::wpshop_get_currency();
2389 2389
 		/*	Récupération de la liste des variations pour le produit en cours d'édition	*/
2390
-		$variations = self::get_variation( $head_product );
2391
-		$price_piloting = get_option( 'wpshop_shop_price_piloting' );
2390
+		$variations = self::get_variation($head_product);
2391
+		$price_piloting = get_option('wpshop_shop_price_piloting');
2392 2392
 
2393 2393
 		/*	Affichage de la liste des variations pour le produit en cours d'édition	*/
2394
-		if ( !empty($variations) && is_array($variations) ) {
2394
+		if (!empty($variations) && is_array($variations)) {
2395 2395
 			$existing_variation_list = wpshop_display::display_template_element('wpshop_admin_existing_variation_controller', array(), array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product), 'admin');
2396 2396
 
2397
-			foreach ( $variations as $variation ) {
2397
+			foreach ($variations as $variation) {
2398 2398
 				$tpl_component = array();
2399 2399
 
2400 2400
 				$tpl_component['ADMIN_EXISTING_VARIATIONS_CLASS'] = ' wpshop_variation_' . self::currentPageCode;
2401 2401
 				$tpl_component['VARIATION_IDENTIFIER'] = $variation['post']->ID;
2402 2402
 				$tpl_component['VARIATION_DETAIL'] = '  ';
2403
-				$p = ( !empty($variation['variation_dif']['product_price']) || !empty($variation['variation_dif']['price_ht']) ) ? ( ( !empty($price_piloting) && $price_piloting == 'HT' && !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) : 0;
2404
-				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format( $p, 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2405
-				if ( !empty($price_piloting) && $price_piloting == 'HT' ) {
2403
+				$p = (!empty($variation['variation_dif']['product_price']) || !empty($variation['variation_dif']['price_ht'])) ? ((!empty($price_piloting) && $price_piloting == 'HT' && !empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : (!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0) : 0;
2404
+				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format($p, 2, '.', '') . ' ' . $productCurrency . ' ' . ((!empty($price_piloting) && $price_piloting == 'HT') ? __('ET', 'wpshop') : __('ATI', 'wpshop'));
2405
+				if (!empty($price_piloting) && $price_piloting == 'HT') {
2406 2406
 
2407 2407
 				}
2408 2408
 				else {
@@ -2410,66 +2410,66 @@  discard block
 block discarded – undo
2410 2410
 				}
2411 2411
 				$post_obj = $variation['post'];
2412 2412
 
2413
-				$parent_product_infos = wpshop_products::get_parent_variation( $post_obj->ID );
2414
-				if ( !empty($parent_product_infos) ) {
2413
+				$parent_product_infos = wpshop_products::get_parent_variation($post_obj->ID);
2414
+				if (!empty($parent_product_infos)) {
2415 2415
 					$parent_post = $parent_product_infos['parent_post'];
2416 2416
 					$product_option_postmeta = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true);
2417
-					if ( !empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418
-						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2419
-							$product_price = ( ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0 ) + $parent_product_infos['parent_post_meta']['price_ht'];
2417
+					if (!empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418
+						if (!empty($price_piloting) && $price_piloting == 'HT') {
2419
+							$product_price = ((!empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : 0) + $parent_product_infos['parent_post_meta']['price_ht'];
2420 2420
 						}
2421 2421
 						else {
2422
-							$product_price = ( ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) + $parent_product_infos['parent_post_meta']['product_price'];
2422
+							$product_price = ((!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0) + $parent_product_infos['parent_post_meta']['product_price'];
2423 2423
 						}
2424 2424
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Variation price combined with the parent product price', 'wpshop');
2425 2425
 					}
2426 2426
 					else {
2427
-						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2428
-							$product_price = ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0;
2427
+						if (!empty($price_piloting) && $price_piloting == 'HT') {
2428
+							$product_price = (!empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : 0;
2429 2429
 						}
2430 2430
 						else {
2431
-							$product_price = ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0;
2431
+							$product_price = (!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0;
2432 2432
 						}
2433 2433
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Only variation\'s price is used', 'wpshop');
2434 2434
 					}
2435
-					$product_price = number_format(str_replace(',', '.',$product_price), 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2435
+					$product_price = number_format(str_replace(',', '.', $product_price), 2, '.', '') . ' ' . $productCurrency . ' ' . ((!empty($price_piloting) && $price_piloting == 'HT') ? __('ET', 'wpshop') : __('ATI', 'wpshop'));
2436 2436
 					$tpl_component['VARIATION_DETAIL_SALE_PRICE'] = $product_price;
2437 2437
 				}
2438 2438
 
2439
-				if ( !empty($variation['variation_def']) ) {
2440
-					foreach ( $variation['variation_def'] as $variation_key => $variation_value ) {
2441
-						if ( !empty($variation_value) ) {
2439
+				if (!empty($variation['variation_def'])) {
2440
+					foreach ($variation['variation_def'] as $variation_key => $variation_value) {
2441
+						if (!empty($variation_value)) {
2442 2442
 							$attribute_def_for_variation = wpshop_attributes::getElement($variation_key, "'valid'", 'code');
2443 2443
 							$tpl_component['VARIATION_DETAIL'] .= '<input type="hidden" name="' . self::current_page_variation_code . '[' . $variation['post']->ID . '][attribute][' . $attribute_def_for_variation->data_type . '][' . $variation_key . ']" value="' . $variation_value . '" />' . wpshop_display::display_template_element('wpshop_admin_variation_item_def_header', array('VARIATION_ATTRIBUTE_CODE' => $attribute_def_for_variation->frontend_label, 'VARIATION_ATTRIBUTE_CODE_VALUE' => stripslashes(wpshop_attributes::get_attribute_type_select_option_info($variation_value, 'label', $attribute_def_for_variation->data_type_to_use, true))), array(), 'admin');
2444 2444
 							$tpl_component['VARIATION_IMAGE_CHOICE'] = '';
2445 2445
 
2446 2446
 							/** Define Link image to variation interface **/
2447
-							if( !empty($product_option_postmeta) && !empty($product_option_postmeta['attributes']) && !empty($product_option_postmeta['variation_type']) && ( ( count( $product_option_postmeta['attributes'] ) == 1 && $product_option_postmeta['variation_type'] == 'single' ) || ($product_option_postmeta['variation_type'] == 'combined' ) ) ) {
2448
-								$pictures = get_posts( array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => $head_product) );
2447
+							if (!empty($product_option_postmeta) && !empty($product_option_postmeta['attributes']) && !empty($product_option_postmeta['variation_type']) && ((count($product_option_postmeta['attributes']) == 1 && $product_option_postmeta['variation_type'] == 'single') || ($product_option_postmeta['variation_type'] == 'combined'))) {
2448
+								$pictures = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => $head_product));
2449 2449
 
2450
-								$media_id_data = get_post_meta( $head_product, '_wps_product_media', true );
2451
-								if( !empty($media_id_data) ) {
2452
-									$medias_ids = explode( ',', $media_id_data );
2450
+								$media_id_data = get_post_meta($head_product, '_wps_product_media', true);
2451
+								if (!empty($media_id_data)) {
2452
+									$medias_ids = explode(',', $media_id_data);
2453 2453
 
2454
-									if ( !empty( $medias_ids ) ) {
2455
-										foreach ( $medias_ids as $media_id ) {
2456
-											if ( !empty( $media_id ) ) {
2457
-												$pictures[] = get_post( $media_id );
2454
+									if (!empty($medias_ids)) {
2455
+										foreach ($medias_ids as $media_id) {
2456
+											if (!empty($media_id)) {
2457
+												$pictures[] = get_post($media_id);
2458 2458
 											}
2459 2459
 										}
2460 2460
 									}
2461 2461
 								}
2462 2462
 
2463 2463
 								$pictures_data = '';
2464
-								if( !empty($pictures) ) {
2465
-									$selected_picture = get_post_meta($variation['post']->ID, '_wps_variation_attached_picture', true );
2464
+								if (!empty($pictures)) {
2465
+									$selected_picture = get_post_meta($variation['post']->ID, '_wps_variation_attached_picture', true);
2466 2466
 
2467 2467
 									$done_picture = array();
2468
-									foreach( $pictures as $picture ) {
2469
-										if ( !in_array( $picture->ID, $done_picture ) ) {
2470
-											if( wp_attachment_is_image( $picture->ID ) ) {
2471
-												$checked = ( ( !empty($selected_picture) && $selected_picture == $picture->ID ) ? 'checked="checked"' : '' );
2472
-												$pictures_data .= wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_element', array( 'PICTURE_CHOICE_VARIATION_ID' => $picture->ID, 'PRODUCT_VARIATION_ID' =>$variation['post']->ID, 'PICTURE_CHOICE_SELECTED' => $checked, 'PICTURE_CHOICE_VARIATION_IMG' => wp_get_attachment_image( $picture->ID, 'thumbnail' ) ), array(), 'admin');
2468
+									foreach ($pictures as $picture) {
2469
+										if (!in_array($picture->ID, $done_picture)) {
2470
+											if (wp_attachment_is_image($picture->ID)) {
2471
+												$checked = ((!empty($selected_picture) && $selected_picture == $picture->ID) ? 'checked="checked"' : '');
2472
+												$pictures_data .= wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_element', array('PICTURE_CHOICE_VARIATION_ID' => $picture->ID, 'PRODUCT_VARIATION_ID' =>$variation['post']->ID, 'PICTURE_CHOICE_SELECTED' => $checked, 'PICTURE_CHOICE_VARIATION_IMG' => wp_get_attachment_image($picture->ID, 'thumbnail')), array(), 'admin');
2473 2473
 
2474 2474
 												$done_picture[] = $picture->ID;
2475 2475
 											}
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 									}
2478 2478
 								}
2479 2479
 
2480
-								$tpl_component['VARIATION_IMAGE_CHOICE'] = wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_container',  array( 'PICTURE_CHOICE_CONTAINER_CONTENT' => $pictures_data ), array(), 'admin');
2480
+								$tpl_component['VARIATION_IMAGE_CHOICE'] = wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_container', array('PICTURE_CHOICE_CONTAINER_CONTENT' => $pictures_data), array(), 'admin');
2481 2481
 							}
2482 2482
 
2483 2483
 						}
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 				$tpl_component['VARIATION_DETAIL'] = substr($tpl_component['VARIATION_DETAIL'], 0, -2);
2489 2489
 
2490 2490
 				$tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = ' wpshopHide';
2491
-				$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' ', 'field_name' => wpshop_products::current_page_variation_code . '[' . $variation['post']->ID . ']','page_code' => self::current_page_variation_code, 'field_id' => self::current_page_variation_code . '_' . $variation['post']->ID, 'variation_dif_values' => (!empty($variation['variation_dif']) ? $variation['variation_dif'] : array())) );
2491
+				$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' ', 'field_name' => wpshop_products::current_page_variation_code . '[' . $variation['post']->ID . ']', 'page_code' => self::current_page_variation_code, 'field_id' => self::current_page_variation_code . '_' . $variation['post']->ID, 'variation_dif_values' => (!empty($variation['variation_dif']) ? $variation['variation_dif'] : array())));
2492 2492
 				$tpl_component['VARIATION_DEFINITION_CONTENT'] = wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $variation['post']->ID), 'admin');
2493 2493
 
2494 2494
 				/*	Add the variation definition to output	*/
@@ -2510,22 +2510,22 @@  discard block
 block discarded – undo
2510 2510
 	 * Retrieve and display the variation for a given product
2511 2511
 	 * @param integer $product_id The product identifier to get variation for
2512 2512
 	 */
2513
-	public static function wpshop_variation( $post_id = '', $from_admin = false, $order_id = '', $qty = 1 ) {
2513
+	public static function wpshop_variation($post_id = '', $from_admin = false, $order_id = '', $qty = 1) {
2514 2514
 		global $wp_query;
2515 2515
 		$output = '';
2516 2516
 
2517
-		$product_id = empty($post_id) ? $wp_query->post->ID : $post_id ;
2518
-		$wpshop_product_attributes_frontend_display = get_post_meta( $product_id, '_wpshop_product_attributes_frontend_display', true );
2519
-		$head_wpshop_variation_definition = get_post_meta( $product_id, '_wpshop_variation_defining', true );
2517
+		$product_id = empty($post_id) ? $wp_query->post->ID : $post_id;
2518
+		$wpshop_product_attributes_frontend_display = get_post_meta($product_id, '_wpshop_product_attributes_frontend_display', true);
2519
+		$head_wpshop_variation_definition = get_post_meta($product_id, '_wpshop_variation_defining', true);
2520 2520
 
2521 2521
 		/**	Get attribute order for current product	*/
2522
-		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
2522
+		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
2523 2523
 		$output_order = array();
2524
-		if ( count($product_attribute_order_detail) > 0 ) {
2525
-			if (!empty($product_attribute_order_detail) ) {
2526
-				foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527
-					foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
-						if ( !empty($attribute_def->code) )
2524
+		if (count($product_attribute_order_detail) > 0) {
2525
+			if (!empty($product_attribute_order_detail)) {
2526
+				foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527
+					foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
+						if (!empty($attribute_def->code))
2529 2529
 							$output_order[$attribute_def->code] = $position;
2530 2530
 					}
2531 2531
 				}
@@ -2539,49 +2539,49 @@  discard block
 block discarded – undo
2539 2539
 		$possible_values_for_selection_calculation = array();
2540 2540
 
2541 2541
 		/*	Vérification de l'existence de déclinaison pour le produit	*/
2542
-		$wpshop_variation_list = self::get_variation( $product_id );
2543
-		if ( !empty($wpshop_variation_list) ) {
2542
+		$wpshop_variation_list = self::get_variation($product_id);
2543
+		if (!empty($wpshop_variation_list)) {
2544 2544
 			foreach ($wpshop_variation_list as $variation) {
2545
-				if (!empty($variation['variation_def']) ) {
2546
-					$display_option = get_post_meta( $post_id, '_wpshop_product_attributes_frontend_display', true );
2547
-					foreach ( $variation['variation_def'] as $attribute_code => $attribute_value ) {
2548
-						if ( empty($display_option) || ( !empty($display_option['attribute']) && !empty($display_option['attribute'][$attribute_code]) && !empty($display_option['attribute'][$attribute_code]['complete_sheet']) ) ) {
2545
+				if (!empty($variation['variation_def'])) {
2546
+					$display_option = get_post_meta($post_id, '_wpshop_product_attributes_frontend_display', true);
2547
+					foreach ($variation['variation_def'] as $attribute_code => $attribute_value) {
2548
+						if (empty($display_option) || (!empty($display_option['attribute']) && !empty($display_option['attribute'][$attribute_code]) && !empty($display_option['attribute'][$attribute_code]['complete_sheet']))) {
2549 2549
 							$tpl_component = array();
2550 2550
 
2551 2551
 							$attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2552 2552
 							$default_value_is_serial = false;
2553 2553
 							$attribute_list_first_element = $attribute_db_definition->default_value;
2554
-							if ( !empty($attribute_db_definition->default_value) && ($attribute_db_definition->default_value == serialize(false) || @unserialize($attribute_db_definition->default_value) !== false) ) {
2554
+							if (!empty($attribute_db_definition->default_value) && ($attribute_db_definition->default_value == serialize(false) || @unserialize($attribute_db_definition->default_value) !== false)) {
2555 2555
 								$default_value_is_serial = true;
2556 2556
 								$tmp_default_value = unserialize($attribute_db_definition->default_value);
2557 2557
 								$attribute_list_first_element = !empty($tmp_default_value['field_options']['label_for_first_item']) ? $tmp_default_value['field_options']['label_for_first_item'] : null;
2558 2558
 							}
2559 2559
 
2560
-							if ( $default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none') ) {
2561
-								$possible_values[$attribute_code][0][0] = ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) ? stripslashes( sprintf( $attribute_list_first_element, strtolower($attribute_db_definition->frontend_label)) ) : __('Choose a value', 'wpshop');
2560
+							if ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) {
2561
+								$possible_values[$attribute_code][0][0] = ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) ? stripslashes(sprintf($attribute_list_first_element, strtolower($attribute_db_definition->frontend_label))) : __('Choose a value', 'wpshop');
2562 2562
 							}
2563 2563
 
2564
-							if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2564
+							if (!empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2565 2565
 								$tpl_component['VARIATION_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', 'custom'));
2566 2566
 								$position = wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'position', 'custom');
2567 2567
 							}
2568
-							else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2568
+							else if (!empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2569 2569
 								$post_def = get_post($attribute_value);
2570 2570
 								$tpl_component['VARIATION_VALUE'] = stripslashes($post_def->post_title);
2571 2571
 								$position = $post_def->menu_order;
2572 2572
 							}
2573 2573
 
2574
-							if ( !empty($variation['variation_dif']) ) {
2575
-								foreach ( $variation['variation_dif'] as $attribute_dif_code => $attribute_dif_value) {
2574
+							if (!empty($variation['variation_dif'])) {
2575
+								foreach ($variation['variation_dif'] as $attribute_dif_code => $attribute_dif_value) {
2576 2576
 									$wpshop_prices_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2577 2577
 									$the_value = $attribute_dif_value;
2578
-									if ( in_array($attribute_dif_code, $wpshop_prices_attributes) ) {
2578
+									if (in_array($attribute_dif_code, $wpshop_prices_attributes)) {
2579 2579
 										$the_value = wpshop_display::format_field_output('wpshop_product_price', $attribute_dif_value);
2580 2580
 									}
2581 2581
 									$tpl_component['VARIATION_DIF_' . strtoupper($attribute_dif_code)] = stripslashes($the_value);
2582 2582
 								}
2583 2583
 							}
2584
-							if ( !empty($attribute_value) ) {
2584
+							if (!empty($attribute_value)) {
2585 2585
 								$possible_values[$attribute_code][$position][$attribute_value] = wpshop_display::display_template_element('product_variation_item_possible_values', $tpl_component, array('type' => 'attribute_for_variation', 'id' => $attribute_code));
2586 2586
 								$possible_values_for_selection_calculation[$attribute_code][$attribute_value] = $tpl_component['VARIATION_VALUE'];
2587 2587
 							}
@@ -2592,33 +2592,33 @@  discard block
 block discarded – undo
2592 2592
 			}
2593 2593
 
2594 2594
 			$variation_tpl = array();
2595
-			if ( !empty($head_wpshop_variation_definition['attributes']) ) {
2596
-				foreach ( $head_wpshop_variation_definition['attributes'] as $attribute_code ) {
2595
+			if (!empty($head_wpshop_variation_definition['attributes'])) {
2596
+				foreach ($head_wpshop_variation_definition['attributes'] as $attribute_code) {
2597 2597
 					$attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2598
-					if ( !empty( $attribute_db_definition ) ) {
2599
-						$attribute_display_state = wpshop_attributes::check_attribute_display( $attribute_db_definition->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_code, 'complete_sheet');
2598
+					if (!empty($attribute_db_definition)) {
2599
+						$attribute_display_state = wpshop_attributes::check_attribute_display($attribute_db_definition->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_code, 'complete_sheet');
2600 2600
 
2601 2601
 
2602 2602
 
2603
-						$is_required = ( (!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']) )) ) ? true : false;
2604
-						if ( !$is_required && $attribute_db_definition->is_required == 'yes' ) {
2603
+						$is_required = ((!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'])))) ? true : false;
2604
+						if (!$is_required && $attribute_db_definition->is_required == 'yes') {
2605 2605
 							$is_required = true;
2606 2606
 						}
2607 2607
 
2608 2608
 						$input_def = array();
2609 2609
 						$input_def['type'] = $attribute_db_definition->frontend_input;
2610 2610
 						$value = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : (!empty($attribute_db_definition->default_value) ? $attribute_db_definition->default_value : null);
2611
-						if ( in_array($attribute_db_definition->frontend_input, array('radio', 'checkbox')) ) {
2611
+						if (in_array($attribute_db_definition->frontend_input, array('radio', 'checkbox'))) {
2612 2612
 							unset($possible_values[$attribute_code][0]);
2613 2613
 							$value = array($value);
2614 2614
 						}
2615 2615
 						$input_def['id'] = 'wpshop_variation_attr_' . $attribute_code;
2616 2616
 						$input_def['name'] = $attribute_code;
2617 2617
 						$real_possible_values = array();
2618
-						if ( !empty($possible_values[$attribute_code]) ) {
2618
+						if (!empty($possible_values[$attribute_code])) {
2619 2619
 							ksort($possible_values[$attribute_code]);
2620
-							foreach ( $possible_values[$attribute_code] as $position => $def ) {
2621
-								foreach ( $def as $attribute_value => $attribute_value_output ) {
2620
+							foreach ($possible_values[$attribute_code] as $position => $def) {
2621
+								foreach ($def as $attribute_value => $attribute_value_output) {
2622 2622
 									$real_possible_values[$attribute_value] = $attribute_value_output;
2623 2623
 								}
2624 2624
 							}
@@ -2628,19 +2628,19 @@  discard block
 block discarded – undo
2628 2628
 						$input_def['value'] = $value;
2629 2629
 
2630 2630
 						$input_def['options']['more_input'] = '';
2631
-						if ( !empty($possible_values_for_selection_calculation[$attribute_code]) ) {
2632
-							foreach ( $possible_values_for_selection_calculation[$attribute_code] as $value_id => $value ) {
2631
+						if (!empty($possible_values_for_selection_calculation[$attribute_code])) {
2632
+							foreach ($possible_values_for_selection_calculation[$attribute_code] as $value_id => $value) {
2633 2633
 								$input_def['options']['more_input'] .= '<input type="hidden" disabled="disabled" value="' . str_replace("\\", "", $value) . '" name="' . $input_def['id'] . '_current_value" id="' . $input_def['id'] . '_current_value_' . $value_id . '" />';
2634 2634
 							}
2635 2635
 						}
2636 2636
 
2637 2637
 						$input_def['options_label']['original'] = true;
2638
-						$input_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_code . ' ' : '') . ( $attribute_db_definition->_display_informations_about_value == 'yes' ? ' wpshop_display_information_about_value' : '' ) . ' ' . (( is_admin() ) ? $attribute_db_definition->backend_css_class : $attribute_db_definition->frontend_css_class) . '" ';
2639
-						if ( !empty(  $real_possible_values ) ) {
2638
+						$input_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_code . ' ' : '') . ($attribute_db_definition->_display_informations_about_value == 'yes' ? ' wpshop_display_information_about_value' : '') . ' ' . ((is_admin()) ? $attribute_db_definition->backend_css_class : $attribute_db_definition->frontend_css_class) . '" ';
2639
+						if (!empty($real_possible_values)) {
2640 2640
 							$tpl_component = array();
2641 2641
 							$attribute_output_def['value'] = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : $input_def['value'];
2642 2642
 							$tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($input_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) . $input_def['options']['more_input'];
2643
-							$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_code . '" >' . stripslashes($attribute_db_definition->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_db_definition->frontend_label) );
2643
+							$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_code . '" >' . stripslashes($attribute_db_definition->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_db_definition->frontend_label));
2644 2644
 							$tpl_component['VARIATION_CODE'] = $attribute_code;
2645 2645
 							$tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_db_definition->frontend_help_message) ? ' title="' . $attribute_db_definition->frontend_help_message . '" ' : '';
2646 2646
 						 	$tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_db_definition->frontend_help_message) ? ' wpshop_att_variation_helper' : '';
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 							$tpl_component['VARIATION_PARENT_ID'] = $product_id;
2649 2649
 							$tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
2650 2650
 							$tpl_component['VARIATION_CONTAINER_CLASS'] = ($is_required ? ' attribute_is_required_container attribute_is_required_container_' . $attribute_code : '') . ' wpshop_variation_' . $attribute_code . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product_id;
2651
-							$tpl_component['VARIATION_REQUIRED_INDICATION'] = ( $is_required ) ? __('Required variation', 'wpshop') : '';
2651
+							$tpl_component['VARIATION_REQUIRED_INDICATION'] = ($is_required) ? __('Required variation', 'wpshop') : '';
2652 2652
 							$variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)] = wpshop_display::display_template_element('product_variation_item', $tpl_component);
2653 2653
 							$variation_attribute_ordered[$output_order[$attribute_code]] = $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)];
2654 2654
 						}
@@ -2662,23 +2662,23 @@  discard block
 block discarded – undo
2662 2662
 		$variation_tpl['VARIATION_FORM_ELEMENT_ID'] = $product_id;
2663 2663
 		wp_reset_query();
2664 2664
 
2665
-		$attribute_defined_to_be_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode) );
2666
-		if ( !empty($attribute_defined_to_be_user_defined) ) {
2667
-			foreach ( $attribute_defined_to_be_user_defined as $attribute_not_in_variation_but_user_defined ) {
2668
-				$is_required = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_not_in_variation_but_user_defined->code, $head_wpshop_variation_definition['options']['required_attributes']) )) || $attribute_not_in_variation_but_user_defined->is_required == 'yes' ) ? true : false;
2665
+		$attribute_defined_to_be_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode));
2666
+		if (!empty($attribute_defined_to_be_user_defined)) {
2667
+			foreach ($attribute_defined_to_be_user_defined as $attribute_not_in_variation_but_user_defined) {
2668
+				$is_required = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_not_in_variation_but_user_defined->code, $head_wpshop_variation_definition['options']['required_attributes']))) || $attribute_not_in_variation_but_user_defined->is_required == 'yes') ? true : false;
2669 2669
 
2670
-				$attribute_display_state = wpshop_attributes::check_attribute_display( $attribute_not_in_variation_but_user_defined->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_not_in_variation_but_user_defined->code, 'complete_sheet');
2671
-				if ( $attribute_display_state &&  array_key_exists($attribute_not_in_variation_but_user_defined->code, $output_order) && !in_array($attribute_not_in_variation_but_user_defined->code, $variation_attribute) && ($attribute_not_in_variation_but_user_defined->is_used_for_variation == 'no') ) {
2672
-					$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_not_in_variation_but_user_defined, (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code] : 'Salut' ));
2670
+				$attribute_display_state = wpshop_attributes::check_attribute_display($attribute_not_in_variation_but_user_defined->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_not_in_variation_but_user_defined->code, 'complete_sheet');
2671
+				if ($attribute_display_state && array_key_exists($attribute_not_in_variation_but_user_defined->code, $output_order) && !in_array($attribute_not_in_variation_but_user_defined->code, $variation_attribute) && ($attribute_not_in_variation_but_user_defined->is_used_for_variation == 'no')) {
2672
+					$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_not_in_variation_but_user_defined, (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code] : 'Salut'));
2673 2673
 
2674 2674
 					$tpl_component = array();
2675
-					$attribute_output_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_not_in_variation_but_user_defined->code : '') . ' ' . ( str_replace('"', '', str_replace('class="', '', $attribute_output_def['option'])) ) . ' ' . (( is_admin() ) ? $attribute_not_in_variation_but_user_defined->backend_css_class : $attribute_not_in_variation_but_user_defined->frontend_css_class) . '" ';
2675
+					$attribute_output_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_not_in_variation_but_user_defined->code : '') . ' ' . (str_replace('"', '', str_replace('class="', '', $attribute_output_def['option']))) . ' ' . ((is_admin()) ? $attribute_not_in_variation_but_user_defined->backend_css_class : $attribute_not_in_variation_but_user_defined->frontend_css_class) . '" ';
2676 2676
 					$tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($attribute_output_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '[free]') . $attribute_output_def['options'];
2677
-					$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_not_in_variation_but_user_defined->code . '" >' . stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) );
2677
+					$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_not_in_variation_but_user_defined->code . '" >' . stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_not_in_variation_but_user_defined->frontend_label));
2678 2678
 					$tpl_component['VARIATION_CODE'] = $attribute_not_in_variation_but_user_defined->code;
2679 2679
 					$tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' title="' . $attribute_not_in_variation_but_user_defined->frontend_help_message . '" ' : '';
2680 2680
 					$tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' wpshop_att_variation_helper' : '';
2681
-					$tpl_component['VARIATION_REQUIRED_INDICATION'] = ( $is_required ) ? __('Required variation', 'wpshop') : '';
2681
+					$tpl_component['VARIATION_REQUIRED_INDICATION'] = ($is_required) ? __('Required variation', 'wpshop') : '';
2682 2682
 					$tpl_component['VARIATION_IDENTIFIER'] = $attribute_output_def['id'];
2683 2683
 					$tpl_component['VARIATION_PARENT_ID'] = $product_id;
2684 2684
 					$tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
@@ -2690,17 +2690,17 @@  discard block
 block discarded – undo
2690 2690
 		}
2691 2691
 
2692 2692
 		$variation_tpl['VARIATION_FORM_VARIATION_LIST'] = '';
2693
-		if ( !empty($variation_attribute_ordered) && is_array($variation_attribute_ordered) ) {
2693
+		if (!empty($variation_attribute_ordered) && is_array($variation_attribute_ordered)) {
2694 2694
 			ksort($variation_attribute_ordered);
2695
-			foreach ( $variation_attribute_ordered as $attribute_variation_to_output ) {
2695
+			foreach ($variation_attribute_ordered as $attribute_variation_to_output) {
2696 2696
 				$variation_tpl['VARIATION_FORM_VARIATION_LIST'] .= $attribute_variation_to_output;
2697 2697
 			}
2698 2698
 		}
2699 2699
 		$variation_tpl['FROM_ADMIN_INDICATOR'] = $variation_tpl['ORDER_ID_INDICATOR'] = '';
2700
-		$variation_tpl['PRODUCT_ADDED_TO_CART_QTY'] = ( !empty( $qty ) ) ? $qty : 1;
2701
-		if ( $from_admin && !empty($order_id) ) {
2700
+		$variation_tpl['PRODUCT_ADDED_TO_CART_QTY'] = (!empty($qty)) ? $qty : 1;
2701
+		if ($from_admin && !empty($order_id)) {
2702 2702
 			$variation_tpl['FROM_ADMIN_INDICATOR'] = '<input type="hidden" name="wps_orders_from_admin" value="1" />';
2703
-			$variation_tpl['ORDER_ID_INDICATOR'] = '<input type="hidden" name="wps_orders_order_id" value="' .$order_id. '" />';
2703
+			$variation_tpl['ORDER_ID_INDICATOR'] = '<input type="hidden" name="wps_orders_order_id" value="' . $order_id . '" />';
2704 2704
 
2705 2705
 		}
2706 2706
 		$output = !empty($variation_tpl['VARIATION_FORM_VARIATION_LIST']) ? wpshop_display::display_template_element('product_variation_form', $variation_tpl) : '';
@@ -2708,11 +2708,11 @@  discard block
 block discarded – undo
2708 2708
 		return $output;
2709 2709
 	}
2710 2710
 
2711
-	public static function get_parent_variation ( $variation_id ) {
2711
+	public static function get_parent_variation($variation_id) {
2712 2712
 		$result = array();
2713
-		if ( !empty($variation_id) ) {
2714
-			$variation_post = get_post( $variation_id);
2715
-			if ( !empty($variation_post) && !empty($variation_post->post_parent) ) {
2713
+		if (!empty($variation_id)) {
2714
+			$variation_post = get_post($variation_id);
2715
+			if (!empty($variation_post) && !empty($variation_post->post_parent)) {
2716 2716
 				$result['parent_post'] = get_post($variation_post->post_parent);
2717 2717
 				$result['parent_post_meta'] = get_post_meta($variation_post->post_parent, '_wpshop_product_metadata', true);
2718 2718
 			}
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
 	 * Display the current configuration for a given product
2725 2725
 	 * @param array $shortcode_attribute Some parameters given by the shortcode for display
2726 2726
 	 */
2727
-	function wpshop_product_variations_summary( $shortcode_attribute ) {
2727
+	function wpshop_product_variations_summary($shortcode_attribute) {
2728 2728
 		$output = '';
2729 2729
 
2730 2730
 		$product_variations_selection_args = array(
@@ -2734,36 +2734,36 @@  discard block
 block discarded – undo
2734 2734
 
2735 2735
 		$current_user_id = get_current_user_id();
2736 2736
 
2737
-		if ( !empty( $_SESSION ) && !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) ) {
2738
-			foreach ( $_SESSION[ 'cart' ][ 'order_items' ] as $item_id => $item ) {
2739
-				if ( !empty( $item ) && !empty( $item[ 'item_id' ] ) ) {
2737
+		if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) {
2738
+			foreach ($_SESSION['cart']['order_items'] as $item_id => $item) {
2739
+				if (!empty($item) && !empty($item['item_id'])) {
2740 2740
 
2741 2741
 					$free_variations = array();
2742
-					if ( !empty( $item['item_meta'] ) && !empty( $item['item_meta']['free_variation'] ) ) {
2743
-						foreach ( $item['item_meta']['free_variation'] as $attribute_code => $attribute_value ) {
2742
+					if (!empty($item['item_meta']) && !empty($item['item_meta']['free_variation'])) {
2743
+						foreach ($item['item_meta']['free_variation'] as $attribute_code => $attribute_value) {
2744 2744
 							$free_variations[] = $attribute_code . '-_variation_val_-' . $attribute_value;
2745 2745
 						}
2746 2746
 					}
2747 2747
 
2748 2748
 					$variations = array();
2749
-					if ( !empty( $item['item_meta'] ) && !empty( $item['item_meta']['variations'] ) ) {
2750
-						foreach ( $item['item_meta']['variations'] as $variation_id => $variation_def ) {
2749
+					if (!empty($item['item_meta']) && !empty($item['item_meta']['variations'])) {
2750
+						foreach ($item['item_meta']['variations'] as $variation_id => $variation_def) {
2751 2751
 
2752
-							if ( !empty( $variation_def[ 'item_meta' ] ) && !empty( $variation_def[ 'item_meta' ][ 'variation_definition' ] ) ) {
2753
-								foreach ( $variation_def[ 'item_meta' ][ 'variation_definition' ] as $attribute_code => $attribute_selected_data ) {
2754
-									$variations[] = $attribute_code . '-_variation_val_-' . $attribute_selected_data[ 'ID' ];
2752
+							if (!empty($variation_def['item_meta']) && !empty($variation_def['item_meta']['variation_definition'])) {
2753
+								foreach ($variation_def['item_meta']['variation_definition'] as $attribute_code => $attribute_selected_data) {
2754
+									$variations[] = $attribute_code . '-_variation_val_-' . $attribute_selected_data['ID'];
2755 2755
 								}
2756 2756
 							}
2757 2757
 						}
2758 2758
 					}
2759
-					$product_variation_summary = self::wpshop_ajax_wpshop_variation_selection( $item[ 'item_id' ], $variations, $free_variations, null, $item[ 'item_qty' ] );
2759
+					$product_variation_summary = self::wpshop_ajax_wpshop_variation_selection($item['item_id'], $variations, $free_variations, null, $item['item_qty']);
2760 2760
 
2761
-					$product_variations_selection_args['PRODUCT_VARIATION_SELECTION_DISPLAY'] .= $product_variation_summary[ 1 ][ 'product_output' ];
2761
+					$product_variations_selection_args['PRODUCT_VARIATION_SELECTION_DISPLAY'] .= $product_variation_summary[1]['product_output'];
2762 2762
 				}
2763 2763
 			}
2764 2764
 		}
2765 2765
 
2766
-		$output .= wpshop_display::display_template_element( 'wpshop_product_configuration_summary', $product_variations_selection_args );
2766
+		$output .= wpshop_display::display_template_element('wpshop_product_configuration_summary', $product_variations_selection_args);
2767 2767
 
2768 2768
 		echo $output;
2769 2769
 	}
@@ -2779,53 +2779,53 @@  discard block
 block discarded – undo
2779 2779
 	 *
2780 2780
 	 * @return array Le résultat du calcul pour l'affichage / Output result
2781 2781
 	 */
2782
-	public static function wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty = 1 ) {
2782
+	public static function wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty = 1) {
2783 2783
 		global $wpdb;
2784 2784
 
2785 2785
 		$wpshop_cart = new wps_cart();
2786 2786
 		$wpshop_products = new wpshop_products();
2787 2787
 
2788 2788
 		$response = '';
2789
-		$response_status = $has_variation = false ;
2789
+		$response_status = $has_variation = false;
2790 2790
 		$tpl_component = array();
2791 2791
 
2792 2792
 		// Check if variations exists
2793
-		if ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ) {
2793
+		if (!empty($wpshop_variation_selected) || !empty($wpshop_free_variation)) {
2794 2794
 
2795 2795
 			//Recover all selected variations
2796 2796
 			$variations_selected = array();
2797
-			if ( !empty($wpshop_variation_selected) ) {
2798
-				foreach ( $wpshop_variation_selected as $selected_variation ) {
2797
+			if (!empty($wpshop_variation_selected)) {
2798
+				foreach ($wpshop_variation_selected as $selected_variation) {
2799 2799
 					$variation_definition = explode('-_variation_val_-', $selected_variation);
2800 2800
 					$variations_selected[$variation_definition[0]] = $variation_definition[1];
2801 2801
 				}
2802 2802
 			}
2803 2803
 
2804 2804
 			// Check variations priority
2805
-			$product_with_variation = wpshop_products::get_variation_by_priority( $variations_selected, $product_id );
2805
+			$product_with_variation = wpshop_products::get_variation_by_priority($variations_selected, $product_id);
2806 2806
 
2807 2807
 			// Check if $product_with_variation have variations
2808
-			if ( !empty($product_with_variation[$product_id]['variations']) || !empty( $wpshop_free_variation )  ) {
2808
+			if (!empty($product_with_variation[$product_id]['variations']) || !empty($wpshop_free_variation)) {
2809 2809
 
2810
-				$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $variations_selected );
2810
+				$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $variations_selected);
2811 2811
 				$product_to_add_to_cart = $formatted_product[0];
2812
-				foreach ( $formatted_product[0] as $pid => $product_more_content) {
2812
+				foreach ($formatted_product[0] as $pid => $product_more_content) {
2813 2813
 					$order_items[$pid]['product_id'] = $product_more_content['id'];
2814 2814
 
2815 2815
 					/** For product with variation	*/
2816
-					$order_items[$pid]['product_variation_type'] = !empty( $product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
2816
+					$order_items[$pid]['product_variation_type'] = !empty($product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
2817 2817
 					$order_items[$pid]['free_variation'] = !empty($product_more_content['free_variation']) ? $product_more_content['free_variation'] : '';
2818 2818
 					$order_items[$pid]['product_variation'] = '';
2819
-					if ( !empty($product_more_content['variations']) ) {
2820
-						foreach ( $product_more_content['variations'] as $variation_id) {
2819
+					if (!empty($product_more_content['variations'])) {
2820
+						foreach ($product_more_content['variations'] as $variation_id) {
2821 2821
 							$order_items[$pid]['product_variation'][] = $variation_id;
2822 2822
 						}
2823 2823
 					}
2824 2824
 				}
2825 2825
 
2826 2826
 				// If Product list is not empty, add products to order
2827
-				if( !empty($order_items) ) {
2828
-					foreach ( $order_items as $product_id => $d ) {
2827
+				if (!empty($order_items)) {
2828
+					foreach ($order_items as $product_id => $d) {
2829 2829
 						$product_key = $product_id;
2830 2830
 
2831 2831
 						// Formate datas
@@ -2833,71 +2833,71 @@  discard block
 block discarded – undo
2833 2833
 						$product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
2834 2834
 
2835 2835
 						// If product is a single variation product
2836
-						if ( !empty($product_variation) && ( count($product_variation) == 1 ) ) {
2836
+						if (!empty($product_variation) && (count($product_variation) == 1)) {
2837 2837
 							$product_id = $product_variation[0];
2838 2838
 						}
2839 2839
 
2840 2840
 						// Construct final product
2841 2841
 						$product = wpshop_products::get_product_data($d['product_id'], true);
2842
-						$the_product = array_merge( array('product_id'	=> $d['product_id'], 'product_qty' 	=> 1 ), $product);
2842
+						$the_product = array_merge(array('product_id'	=> $d['product_id'], 'product_qty' 	=> 1), $product);
2843 2843
 
2844 2844
 						//	Add variation to product into cart for storage
2845
-						if ( !empty($product_variation) ) {
2846
-							$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']) );
2845
+						if (!empty($product_variation)) {
2846
+							$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
2847 2847
 						}
2848 2848
 
2849 2849
 						// Free Variations Checking
2850
-						if ( !empty( $d['free_variation'] ) ) {
2850
+						if (!empty($d['free_variation'])) {
2851 2851
 							$the_product['item_meta']['free_variation'] = $d['free_variation'];
2852 2852
 							$head_product_id = $the_product['product_id'];
2853 2853
 						}
2854 2854
 
2855 2855
 						// If product is a variation, we check parent product general
2856
-						if( get_post_type( $the_product['product_id'] )  == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2857
-							$parent_def = wpshop_products::get_parent_variation ( $the_product['product_id'] );
2858
-							if( !empty($parent_def) && !empty($parent_def['parent_post']) ) {
2859
-								$variation_def = get_post_meta( $parent_def['parent_post']->ID, '_wpshop_variation_defining', true );
2856
+						if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2857
+							$parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
2858
+							if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
2859
+								$variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
2860 2860
 								$parent_meta = $parent_def['parent_post_meta'];
2861
-								if( !empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority'] ) && !empty($variation_def['options']['price_behaviour']) && in_array( 'addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1 ) {
2862
-									$the_product['product_price'] += number_format( str_replace( ',', '.', $parent_meta['product_price'] ), 2, '.', '' );
2863
-									$the_product['price_ht'] += number_format( str_replace( ',', '.',$parent_meta['price_ht']) , 2, '.', '' );
2864
-									$the_product['tva'] += number_format( str_replace( ',', '.', $parent_meta['tva']) , 2, '.', '' );
2861
+								if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
2862
+									$the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
2863
+									$the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
2864
+									$the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
2865 2865
 								}
2866 2866
 							}
2867 2867
 						}
2868 2868
 					}
2869 2869
 				}
2870 2870
 
2871
-				if( !empty($the_product) && empty($the_product['price_ttc_before_discount']) && empty($the_product['price_ht_before_discount']) ) {
2872
-					$price_infos = wpshop_prices::check_product_price( $the_product, true );
2873
-					if ( !empty($price_infos['discount']['discount_exist']) ) {
2871
+				if (!empty($the_product) && empty($the_product['price_ttc_before_discount']) && empty($the_product['price_ht_before_discount'])) {
2872
+					$price_infos = wpshop_prices::check_product_price($the_product, true);
2873
+					if (!empty($price_infos['discount']['discount_exist'])) {
2874 2874
 						$the_product['price_ttc_before_discount'] = $the_product['product_price'];
2875 2875
 						$the_product['price_ht_before_discount'] = $the_product['price_ht'];
2876 2876
 					}
2877
-					$the_product['price_ht'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ?  $price_infos['discount']['discount_et_price'] : $price_infos['et'];
2878
-					$the_product['product_price'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati'];
2879
-					$the_product['tva'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva'];
2877
+					$the_product['price_ht'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et'];
2878
+					$the_product['product_price'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati'];
2879
+					$the_product['tva'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva'];
2880 2880
 				}
2881 2881
 
2882
-				$product = wpshop_products::get_product_data( $product_id, true );
2882
+				$product = wpshop_products::get_product_data($product_id, true);
2883 2883
 				// Add free variations to product
2884
-				if (  !empty( $wpshop_free_variation )  ) {
2884
+				if (!empty($wpshop_free_variation)) {
2885 2885
 					$the_product['item_meta']['free_variation'] = $wpshop_free_variation;
2886 2886
 				}
2887 2887
 				// Change picture if have a selected variation
2888
-				$the_selected_variation = !empty( $product_with_variation ) && !empty( $product_with_variation[$head_product_id] ) && !empty( $product_with_variation[$head_product_id]['variations'] ) ? $product_with_variation[$head_product_id]['variations'] : null;
2889
-				$response['wps_product_image'] = $wpshop_products->wps_selected_variation_picture( $head_product_id, $the_selected_variation );
2888
+				$the_selected_variation = !empty($product_with_variation) && !empty($product_with_variation[$head_product_id]) && !empty($product_with_variation[$head_product_id]['variations']) ? $product_with_variation[$head_product_id]['variations'] : null;
2889
+				$response['wps_product_image'] = $wpshop_products->wps_selected_variation_picture($head_product_id, $the_selected_variation);
2890 2890
 
2891 2891
 				// Price Display
2892
-				$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
2893
-				$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
2892
+				$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
2893
+				$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
2894 2894
 				$productPrice = '';
2895
-				if ( $price_display ) {
2895
+				if ($price_display) {
2896 2896
 					$response['product_price_output'] = wpshop_prices::get_product_price($the_product, 'price_display', 'complete_sheet', false, true);
2897 2897
 				}
2898 2898
 
2899 2899
 				//Get Summary cart
2900
-				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product( $product_id, $the_product, ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ? true : false )  );
2900
+				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product($product_id, $the_product, (!empty($wpshop_variation_selected) || !empty($wpshop_free_variation) ? true : false));
2901 2901
 				$response_status = true;
2902 2902
 			}
2903 2903
 			else {
@@ -2907,7 +2907,7 @@  discard block
 block discarded – undo
2907 2907
 			}
2908 2908
 		}
2909 2909
 
2910
-		return array( $response_status, $response );
2910
+		return array($response_status, $response);
2911 2911
 	}
2912 2912
 
2913 2913
 	/**
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
 	 *
2916 2916
 	 * @param array $shortcode_attribute Some parameters given by the shortcode for display
2917 2917
 	 */
2918
-	function wpshop_product_variation_value_detail( $shortcode_attribute ) {
2918
+	function wpshop_product_variation_value_detail($shortcode_attribute) {
2919 2919
 		echo wpshop_display::display_template_element('wpshop_product_variation_value_detail_container', array());
2920 2920
 	}
2921 2921
 
@@ -2927,47 +2927,47 @@  discard block
 block discarded – undo
2927 2927
 	 *
2928 2928
 	 * @return array The product list for adding to the cart build by variation priority
2929 2929
 	 */
2930
-	public static function get_variation_by_priority( $selected_variation, $product_id, $add_to_cart_action = false ) {
2930
+	public static function get_variation_by_priority($selected_variation, $product_id, $add_to_cart_action = false) {
2931 2931
 		global $wpdb;
2932 2932
 		$all_required_variations_selected = $no_selected_variation = true;
2933 2933
 		$single_variations = $combined_variations = $product_to_add_to_cart = array();
2934 2934
 
2935 2935
 		// Check if all required variations are selected
2936
-		$required_attributes_list = wpshop_prices::check_required_attributes( $product_id );
2937
-		foreach( $selected_variation as $k => $value ) {
2938
-			if( $value == 0 && in_array($k, $required_attributes_list) ) {
2936
+		$required_attributes_list = wpshop_prices::check_required_attributes($product_id);
2937
+		foreach ($selected_variation as $k => $value) {
2938
+			if ($value == 0 && in_array($k, $required_attributes_list)) {
2939 2939
 				$all_required_variations_selected = false;
2940 2940
 			}
2941
-			if( $value != 0 ) {
2941
+			if ($value != 0) {
2942 2942
 				$no_selected_variation = false;
2943 2943
 			}
2944 2944
 		}
2945
-		if( !empty($selected_variation) ) {
2945
+		if (!empty($selected_variation)) {
2946 2946
 			//Check variations configuration
2947 2947
 			$product_variation_configuration = get_post_meta($product_id, '_wpshop_variation_defining', true);
2948 2948
 			// Check variations type
2949
-			$product_variation_type = ( !empty($product_variation_configuration) && !empty($product_variation_configuration['variation_type']) ) ? $product_variation_configuration['variation_type'] : 'single';
2949
+			$product_variation_type = (!empty($product_variation_configuration) && !empty($product_variation_configuration['variation_type'])) ? $product_variation_configuration['variation_type'] : 'single';
2950 2950
 			$product_to_add_to_cart[$product_id]['variation_priority'] = $product_variation_type;
2951 2951
 
2952 2952
 			//Check defined variation priority
2953
-			$priority = (!empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['priority'][0]) ) ?  $product_variation_configuration['options']['priority'][0] : 'combined';
2953
+			$priority = (!empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['priority'][0])) ? $product_variation_configuration['options']['priority'][0] : 'combined';
2954 2954
 			$product_to_add_to_cart[$product_id]['defined_variation_priority'] = $priority;
2955 2955
 
2956 2956
 			// Recover all product variations
2957 2957
 			$query_variation = $selected_variation;
2958 2958
 			// Delete free variations
2959
-			unset( $query_variation['free'] );
2959
+			unset($query_variation['free']);
2960 2960
 
2961
-			if( $product_variation_type == 'single' ) {
2961
+			if ($product_variation_type == 'single') {
2962 2962
 				// Get single variations
2963 2963
 				$single_variations = array();
2964
-				foreach ( $selected_variation as $attribute_code => $attribute_value ) {
2965
-					if ( isset($attribute_value) && $attribute_code != 'free' ) {
2964
+				foreach ($selected_variation as $attribute_code => $attribute_value) {
2965
+					if (isset($attribute_value) && $attribute_code != 'free') {
2966 2966
 						$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)) . "'", $product_id);
2967 2967
 						$single_variation_id = $wpdb->get_var($query);
2968
-						if ( !empty($single_variation_id) ) {
2968
+						if (!empty($single_variation_id)) {
2969 2969
 							$single_variations[] = $single_variation_id;
2970
-							unset( $query_variation[$attribute_code] );
2970
+							unset($query_variation[$attribute_code]);
2971 2971
 						}
2972 2972
 					}
2973 2973
 				}
@@ -2976,21 +2976,21 @@  discard block
 block discarded – undo
2976 2976
 				// Get combined variations
2977 2977
 				$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_key = '_wpshop_variations_attribute_def' AND P_META.meta_value = '" . serialize($query_variation) . "'", $product_id);
2978 2978
 				$combined_variation_id = $wpdb->get_var($query);
2979
-				if ( !empty($combined_variation_id) ) {
2979
+				if (!empty($combined_variation_id)) {
2980 2980
 					$combined_variations[] = $combined_variation_id;
2981 2981
 				}
2982 2982
 
2983 2983
 			}
2984 2984
 
2985 2985
 			//If all required variations are not selected
2986
-			if ( !$all_required_variations_selected || $no_selected_variation ) {
2986
+			if (!$all_required_variations_selected || $no_selected_variation) {
2987 2987
 				$product_to_add_to_cart['text_from'] = 'on';
2988 2988
 				// If we choose to display lower price variation combinaison
2989
-				if( empty($product_variation_configuration) || ( !empty($product_variation_configuration) && empty($product_variation_configuration['options']) ) || ( !empty($product_variation_configuration) && !empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['price_display']) && !empty($product_variation_configuration['options']['price_display']['lower_price']) ) ) {
2989
+				if (empty($product_variation_configuration) || (!empty($product_variation_configuration) && empty($product_variation_configuration['options'])) || (!empty($product_variation_configuration) && !empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['price_display']) && !empty($product_variation_configuration['options']['price_display']['lower_price']))) {
2990 2990
 					//Get lower price variation combinaison
2991
-					$lower_price_variations = wpshop_prices::check_product_lower_price( $product_id );
2992
-					if ( !empty($lower_price_variations['variations']) && is_array($lower_price_variations['variations']) ) {
2993
-						foreach( $lower_price_variations['variations'] as $lower_price_variation ) {
2991
+					$lower_price_variations = wpshop_prices::check_product_lower_price($product_id);
2992
+					if (!empty($lower_price_variations['variations']) && is_array($lower_price_variations['variations'])) {
2993
+						foreach ($lower_price_variations['variations'] as $lower_price_variation) {
2994 2994
 							$product_to_add_to_cart[$product_id]['variations'][] = $lower_price_variation;
2995 2995
 						}
2996 2996
 					}
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 			}
3003 3003
 			else {
3004 3004
 				$product_to_add_to_cart['text_from'] = '';
3005
-				$product_to_add_to_cart[$product_id]['variations'] = ( !empty($product_variation_type) && $product_variation_type == 'single' ) ? $single_variations : $combined_variations;
3005
+				$product_to_add_to_cart[$product_id]['variations'] = (!empty($product_variation_type) && $product_variation_type == 'single') ? $single_variations : $combined_variations;
3006 3006
 			}
3007 3007
 		}
3008 3008
 
@@ -3010,30 +3010,30 @@  discard block
 block discarded – undo
3010 3010
 	}
3011 3011
 
3012 3012
 
3013
-	public static function get_variation_price_behaviour( $product_into_cart, $product_variations, $head_product_id, $variations_options ) {
3013
+	public static function get_variation_price_behaviour($product_into_cart, $product_variations, $head_product_id, $variations_options) {
3014 3014
 		global $wpdb;
3015 3015
 
3016
-		if( !empty($product_variations) ) {
3016
+		if (!empty($product_variations)) {
3017 3017
 			// Initialize variations total price datas
3018
-			$variations_total_price = array( 'price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3019
-			$variations_discount_total_price = array( 'price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0 );
3018
+			$variations_total_price = array('price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3019
+			$variations_discount_total_price = array('price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3020 3020
 			$vat_rate = 0;
3021 3021
 			$discount_amount = $discount_rate = $special_price = 0;
3022 3022
 			// Recover Head product metadata
3023
-			$head_product_metadata = get_post_meta( $head_product_id, '_wpshop_product_metadata', true );
3024
-			$tva_rate_id = ( !empty($head_product_metadata['tx_tva']) ) ? $head_product_metadata['tx_tva'] : 0;
3025
-			if( !empty($tva_rate_id) ) {
3023
+			$head_product_metadata = get_post_meta($head_product_id, '_wpshop_product_metadata', true);
3024
+			$tva_rate_id = (!empty($head_product_metadata['tx_tva'])) ? $head_product_metadata['tx_tva'] : 0;
3025
+			if (!empty($tva_rate_id)) {
3026 3026
 				// Recover VAT Rate of product
3027
-				$query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $tva_rate_id );
3028
-				$vat_rate = $wpdb->get_var( $query );
3027
+				$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $tva_rate_id);
3028
+				$vat_rate = $wpdb->get_var($query);
3029 3029
 			}
3030
-			$price_piloting = get_option( 'wpshop_shop_price_piloting');
3031
-			foreach( $product_variations as $product_variation ) {
3030
+			$price_piloting = get_option('wpshop_shop_price_piloting');
3031
+			foreach ($product_variations as $product_variation) {
3032 3032
 				$variation_metadata['product_price'] = 0;
3033
-				$variation_metadata = get_post_meta( $product_variation, '_wpshop_product_metadata', true );
3034
-				if( !empty($variation_metadata) ) {
3035
-					$p_et = ( ( empty($price_piloting) || $price_piloting == 'TTC' ) ? ( ( !empty( $variation_metadata['product_price'] ) ? $variation_metadata['product_price'] : 0 ) / ( 1 + ( $vat_rate / 100) ) )  : $variation_metadata['price_ht'] );
3036
-					$p_ati = ( ( empty($price_piloting) || $price_piloting == 'TTC' ) ? ( !empty( $variation_metadata['product_price'] ) ? $variation_metadata['product_price'] : 0 ) : ( $variation_metadata['price_ht'] * ( 1 + ( $vat_rate / 100) ) ) );
3033
+				$variation_metadata = get_post_meta($product_variation, '_wpshop_product_metadata', true);
3034
+				if (!empty($variation_metadata)) {
3035
+					$p_et = ((empty($price_piloting) || $price_piloting == 'TTC') ? ((!empty($variation_metadata['product_price']) ? $variation_metadata['product_price'] : 0) / (1 + ($vat_rate / 100))) : $variation_metadata['price_ht']);
3036
+					$p_ati = ((empty($price_piloting) || $price_piloting == 'TTC') ? (!empty($variation_metadata['product_price']) ? $variation_metadata['product_price'] : 0) : ($variation_metadata['price_ht'] * (1 + ($vat_rate / 100))));
3037 3037
 
3038 3038
 					$variations_total_price['price_et'] += $p_et;
3039 3039
 					$variations_total_price['price_ati'] += $p_ati;
@@ -3042,20 +3042,20 @@  discard block
 block discarded – undo
3042 3042
 					$variation_metadata['tx_tva'] = $product_into_cart['tx_tva'] = $vat_rate;
3043 3043
 
3044 3044
 					// Check discount
3045
-					$discount_config = wpshop_prices::check_discount_for_product( $product_variation );
3046
-					if ( !empty($discount_config) && !empty($discount_config['value']) ) {
3047
-						$variation_discount_prices = wpshop_prices::calcul_discounted_price( $variation_metadata, $discount_config );
3045
+					$discount_config = wpshop_prices::check_discount_for_product($product_variation);
3046
+					if (!empty($discount_config) && !empty($discount_config['value'])) {
3047
+						$variation_discount_prices = wpshop_prices::calcul_discounted_price($variation_metadata, $discount_config);
3048 3048
 						$variations_discount_total_price['price_et'] += $variation_discount_prices['price_ht'];
3049 3049
 						$variations_discount_total_price['price_ati'] += $variation_discount_prices['product_price'];
3050 3050
 						$variations_discount_total_price['vat_amount'] += $variation_discount_prices['tva'];
3051 3051
 
3052
-						if( !empty($discount_config['type']) && $discount_config['type'] == 'discount_amount' ) {
3052
+						if (!empty($discount_config['type']) && $discount_config['type'] == 'discount_amount') {
3053 3053
 							$product_into_cart['discount_amount'] = $discount_amount + $product_into_cart['discount_amount'];
3054 3054
 						}
3055
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3055
+						elseif (!empty($discount_config['type']) && $discount_config['type'] == 'discount_rate') {
3056 3056
 							$product_into_cart['discount_rate'] = $discount_rate + $discount_config['value'];
3057 3057
 						}
3058
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3058
+						elseif (!empty($discount_config['type']) && $discount_config['type'] == 'special_price') {
3059 3059
 							$product_into_cart['special_price'] = $special_price + $discount_config['value'];
3060 3060
 						}
3061 3061
 					}
@@ -3066,10 +3066,10 @@  discard block
 block discarded – undo
3066 3066
 			}
3067 3067
 
3068 3068
 			// Check if add or replace variation price to head product
3069
-			$product_variation_defining = get_post_meta( $head_product_id, '_wpshop_variation_defining', true );
3070
-			if( empty($product_variation_defining) || ( !empty($product_variation_defining) && empty($product_variation_defining['options']) ) || ( ( !empty($product_variation_defining) ) && !empty($product_variation_defining['options']) && !empty($product_variation_defining['options']['price_behaviour']) && !empty($product_variation_defining['options']['price_behaviour'][0]) && $product_variation_defining['options']['price_behaviour'][0] == 'replacement' ) ){
3069
+			$product_variation_defining = get_post_meta($head_product_id, '_wpshop_variation_defining', true);
3070
+			if (empty($product_variation_defining) || (!empty($product_variation_defining) && empty($product_variation_defining['options'])) || ((!empty($product_variation_defining)) && !empty($product_variation_defining['options']) && !empty($product_variation_defining['options']['price_behaviour']) && !empty($product_variation_defining['options']['price_behaviour'][0]) && $product_variation_defining['options']['price_behaviour'][0] == 'replacement')) {
3071 3071
 				//Replace the product price
3072
-				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3072
+				if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) {
3073 3073
 					$product_into_cart['price_ttc_before_discount'] = $variations_total_price['price_ati'];
3074 3074
 					$product_into_cart['price_ht_before_discount'] = $variations_total_price['price_et'];
3075 3075
 
@@ -3085,9 +3085,9 @@  discard block
 block discarded – undo
3085 3085
 			}
3086 3086
 			else {
3087 3087
 				// Add variations price to product price
3088
-				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3089
-					$product_into_cart['price_ttc_before_discount'] = ( $product_into_cart['product_price'] + $variations_total_price['price_ati'] );
3090
-					$product_into_cart['price_ht_before_discount'] = ( $product_into_cart['price_ht'] + $variations_total_price['price_et'] );
3088
+				if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) {
3089
+					$product_into_cart['price_ttc_before_discount'] = ($product_into_cart['product_price'] + $variations_total_price['price_ati']);
3090
+					$product_into_cart['price_ht_before_discount'] = ($product_into_cart['price_ht'] + $variations_total_price['price_et']);
3091 3091
 
3092 3092
 					$product_into_cart['product_price'] += $variations_discount_total_price['price_ati'];
3093 3093
 					$product_into_cart['price_ht'] += $variations_discount_total_price['price_et'];
@@ -3099,19 +3099,19 @@  discard block
 block discarded – undo
3099 3099
 					$product_into_cart['tva'] += $variations_total_price['vat_amount'];
3100 3100
 				}
3101 3101
 				// Check parent discount
3102
-				$parent_discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3103
-				if( !empty($parent_discount_config) ) {
3104
-					$product_into_cart['price_ttc_before_discount'] = ( !empty( $product_into_cart['price_ttc_before_discount'] ) ) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3105
-					$product_into_cart['price_ht_before_discount'] = ( !empty($product_into_cart['price_ht_before_discount']) ) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3106
-					$product_into_cart = wpshop_prices::calcul_discounted_price( $product_into_cart, $parent_discount_config );
3107
-
3108
-					if( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount' ) {
3109
-						$product_into_cart['discount_amount'] = $discount_amount +  $parent_discount_config['value'];
3102
+				$parent_discount_config = wpshop_prices::check_discount_for_product($head_product_id);
3103
+				if (!empty($parent_discount_config)) {
3104
+					$product_into_cart['price_ttc_before_discount'] = (!empty($product_into_cart['price_ttc_before_discount'])) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3105
+					$product_into_cart['price_ht_before_discount'] = (!empty($product_into_cart['price_ht_before_discount'])) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3106
+					$product_into_cart = wpshop_prices::calcul_discounted_price($product_into_cart, $parent_discount_config);
3107
+
3108
+					if (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount') {
3109
+						$product_into_cart['discount_amount'] = $discount_amount + $parent_discount_config['value'];
3110 3110
 					}
3111
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3111
+					elseif (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate') {
3112 3112
 						$product_into_cart['discount_rate'] = $discount_rate + $parent_discount_config['value'];
3113 3113
 					}
3114
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3114
+					elseif (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price') {
3115 3115
 						$product_into_cart['special_price'] = $special_price + $parent_discount_config['value'];
3116 3116
 					}
3117 3117
 				}
@@ -3119,16 +3119,16 @@  discard block
 block discarded – undo
3119 3119
 		}
3120 3120
 		else {
3121 3121
 			// If product have just Free variations
3122
-			$discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3123
-			if( !empty($discount_config) ) {
3124
-				$product_into_cart['price_ttc_before_discount'] = ( !empty( $product_into_cart['price_ttc_before_discount'] ) ) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3125
-				$product_into_cart['price_ht_before_discount'] = ( !empty($product_into_cart['price_ht_before_discount']) ) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3126
-				$product_into_cart = wpshop_prices::calcul_discounted_price( $product_into_cart, $discount_config );
3122
+			$discount_config = wpshop_prices::check_discount_for_product($head_product_id);
3123
+			if (!empty($discount_config)) {
3124
+				$product_into_cart['price_ttc_before_discount'] = (!empty($product_into_cart['price_ttc_before_discount'])) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3125
+				$product_into_cart['price_ht_before_discount'] = (!empty($product_into_cart['price_ht_before_discount'])) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3126
+				$product_into_cart = wpshop_prices::calcul_discounted_price($product_into_cart, $discount_config);
3127 3127
 			}
3128 3128
 		}
3129 3129
 
3130 3130
 		// Text From indicator
3131
-		if( !empty($variations_options) && !empty($variations_options['text_from']) ) {
3131
+		if (!empty($variations_options) && !empty($variations_options['text_from'])) {
3132 3132
 			$product_into_cart['text_from'] = $variations_options['text_from'];
3133 3133
 		}
3134 3134
 		return $product_into_cart;
@@ -3143,28 +3143,28 @@  discard block
 block discarded – undo
3143 3143
 	 *
3144 3144
 	 * @return array The array containing all product options ordered as the admin configure it
3145 3145
 	 */
3146
-	public static function get_selected_variation_display( $product_definition_value, $output_order, $from_page = null, $template_part = 'wpshop', $output_type = null ) {
3146
+	public static function get_selected_variation_display($product_definition_value, $output_order, $from_page = null, $template_part = 'wpshop', $output_type = null) {
3147 3147
 		$variation_attribute_ordered = array();
3148 3148
 		$variation_attribute_ordered['prices'] = array();
3149 3149
 		$variation_attribute_ordered['attribute_list'] = array();
3150 3150
 
3151
-		if ( !empty( $product_definition_value['variation_definition'] ) && is_array( $product_definition_value['variation_definition'] ) ) {
3152
-			foreach ( $product_definition_value['variation_definition'] as $variation_attribute_code => $variation_attribute_detail ) {
3151
+		if (!empty($product_definition_value['variation_definition']) && is_array($product_definition_value['variation_definition'])) {
3152
+			foreach ($product_definition_value['variation_definition'] as $variation_attribute_code => $variation_attribute_detail) {
3153 3153
 				$variation_tpl_component = array();
3154
-				foreach ( $variation_attribute_detail as $info_name => $info_value) {
3155
-					$variation_tpl_component['VARIATION_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value)  : stripslashes($info_value);
3154
+				foreach ($variation_attribute_detail as $info_name => $info_value) {
3155
+					$variation_tpl_component['VARIATION_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value) : stripslashes($info_value);
3156 3156
 				}
3157 3157
 				$variation_tpl_component['VARIATION_ID'] = $variation_attribute_code;
3158 3158
 				$variation_tpl_component['VARIATION_ATT_CODE'] = $variation_attribute_code;
3159
-				if( !empty($output_order[$variation_attribute_code]) ){
3159
+				if (!empty($output_order[$variation_attribute_code])) {
3160 3160
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3161
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3161
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3162 3162
 						$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = $display_data;
3163 3163
 					}
3164 3164
 				}
3165 3165
 				else {
3166 3166
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3167
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3167
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3168 3168
 						$variation_attribute_ordered['attribute_list'][] = $display_data;
3169 3169
 					}
3170 3170
 				}
@@ -3172,15 +3172,15 @@  discard block
 block discarded – undo
3172 3172
 			}
3173 3173
 		}
3174 3174
 
3175
-		if ( !empty( $product_definition_value['variations'] ) && is_array( $product_definition_value['variations'] ) ) {
3176
-			foreach ( $product_definition_value['variations'] as $variation_id => $variation_details ) {
3175
+		if (!empty($product_definition_value['variations']) && is_array($product_definition_value['variations'])) {
3176
+			foreach ($product_definition_value['variations'] as $variation_id => $variation_details) {
3177 3177
 				$variation_tpl_component = array();
3178
-				foreach ( $variation_details as $info_name => $info_value) {
3179
-					if ( $info_name != 'item_meta' ) {
3180
-						$variation_tpl_component['VARIATION_DETAIL_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value)  : stripslashes($info_value);
3178
+				foreach ($variation_details as $info_name => $info_value) {
3179
+					if ($info_name != 'item_meta') {
3180
+						$variation_tpl_component['VARIATION_DETAIL_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value) : stripslashes($info_value);
3181 3181
 					}
3182 3182
 				}
3183
-				foreach ( $variation_details['item_meta']['variation_definition'] as $variation_attribute_code => $variation_attribute_def ) {
3183
+				foreach ($variation_details['item_meta']['variation_definition'] as $variation_attribute_code => $variation_attribute_def) {
3184 3184
 					$variation_tpl_component['VARIATION_NAME'] = stripslashes($variation_attribute_def['NAME']);
3185 3185
 					$variation_tpl_component['VARIATION_VALUE'] = stripslashes($variation_attribute_def['VALUE']);
3186 3186
 					$variation_tpl_component['VARIATION_ID'] = $variation_id;
@@ -3188,7 +3188,7 @@  discard block
 block discarded – undo
3188 3188
 
3189 3189
 					$variation_attribute_ordered['prices'][$variation_attribute_code] = $variation_tpl_component['VARIATION_DETAIL_PRODUCT_PRICE'];
3190 3190
 				}
3191
-				if( !empty($output_order[$variation_attribute_code]) ) {
3191
+				if (!empty($output_order[$variation_attribute_code])) {
3192 3192
 					$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3193 3193
 				}
3194 3194
 				unset($variation_tpl_component);
@@ -3196,9 +3196,9 @@  discard block
 block discarded – undo
3196 3196
 		}
3197 3197
 
3198 3198
 		/**	Free Variation part	*/
3199
-		if ( !empty( $product_definition_value['free_variation'] ) && is_array( $product_definition_value['free_variation'] ) ) {
3200
-			foreach ( $product_definition_value['free_variation'] as $build_variation_key => $build_variation ) {
3201
-				if ( strpos($build_variation, '-_variation_val_-')) {
3199
+		if (!empty($product_definition_value['free_variation']) && is_array($product_definition_value['free_variation'])) {
3200
+			foreach ($product_definition_value['free_variation'] as $build_variation_key => $build_variation) {
3201
+				if (strpos($build_variation, '-_variation_val_-')) {
3202 3202
 					$variation_definition = explode('-_variation_val_-', $build_variation);
3203 3203
 					$attribute_code = $variation_definition[0];
3204 3204
 					$attribute_selected_value = $variation_definition[1];
@@ -3211,17 +3211,17 @@  discard block
 block discarded – undo
3211 3211
 				$free_variation_attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
3212 3212
 				$variation_tpl_component['VARIATION_NAME'] = stripslashes($free_variation_attribute_def->frontend_label);
3213 3213
 				$value_to_outut = $attribute_selected_value;
3214
-				switch ( $free_variation_attribute_def->data_type ) {
3214
+				switch ($free_variation_attribute_def->data_type) {
3215 3215
 					case 'datetime':
3216
-						$value_to_outut = mysql2date( get_option( 'date_format' ), $attribute_selected_value, true );
3216
+						$value_to_outut = mysql2date(get_option('date_format'), $attribute_selected_value, true);
3217 3217
 					break;
3218 3218
 				}
3219 3219
 				$variation_tpl_component['VARIATION_VALUE'] = stripslashes($value_to_outut);
3220 3220
 				$variation_tpl_component['VARIATION_ID'] = $attribute_code;
3221 3221
 				$variation_tpl_component['VARIATION_ATT_CODE'] = $attribute_code;
3222
-				if ( !empty($value_to_outut) && !empty($output_order[$free_variation_attribute_def->code]) ) {
3222
+				if (!empty($value_to_outut) && !empty($output_order[$free_variation_attribute_def->code])) {
3223 3223
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_code), $template_part);
3224
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3224
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3225 3225
 						$variation_attribute_ordered['attribute_list'][$output_order[$free_variation_attribute_def->code]] = $display_data;
3226 3226
 					}
3227 3227
 				}
@@ -3232,23 +3232,23 @@  discard block
 block discarded – undo
3232 3232
 	}
3233 3233
 
3234 3234
 
3235
-	function wps_selected_variation_picture( $head_product_id, $variations ) {
3235
+	function wps_selected_variation_picture($head_product_id, $variations) {
3236 3236
 		$response = array();
3237 3237
 		/** Selected Product image **/
3238
-		$post_thumbnail_id = get_post_thumbnail_id( $head_product_id );
3239
-		if( !empty($post_thumbnail_id) ) {
3238
+		$post_thumbnail_id = get_post_thumbnail_id($head_product_id);
3239
+		if (!empty($post_thumbnail_id)) {
3240 3240
 			$response['img_id'] = $post_thumbnail_id;
3241
-			$response['img'] = wp_get_attachment_image( $post_thumbnail_id,  'wpshop-product-galery' );
3242
-			$response['img_url'] = wp_get_attachment_url( $post_thumbnail_id );
3241
+			$response['img'] = wp_get_attachment_image($post_thumbnail_id, 'wpshop-product-galery');
3242
+			$response['img_url'] = wp_get_attachment_url($post_thumbnail_id);
3243 3243
 		}
3244 3244
 
3245 3245
 		/** check if have one variation **/
3246
-		if ( !empty($variations) && count($variations) == 1 ) {
3247
-			$variation_attached_image_id = get_post_meta( $variations[0], '_wps_variation_attached_picture', true );
3248
-			if( !empty($variation_attached_image_id) ) {
3246
+		if (!empty($variations) && count($variations) == 1) {
3247
+			$variation_attached_image_id = get_post_meta($variations[0], '_wps_variation_attached_picture', true);
3248
+			if (!empty($variation_attached_image_id)) {
3249 3249
 				$response['img_id'] = $variation_attached_image_id;
3250
-				$response['img'] = wp_get_attachment_image( $variation_attached_image_id,  'wpshop-product-galery' );
3251
-				$response['img_url'] = wp_get_attachment_url( $variation_attached_image_id);
3250
+				$response['img'] = wp_get_attachment_image($variation_attached_image_id, 'wpshop-product-galery');
3251
+				$response['img_url'] = wp_get_attachment_url($variation_attached_image_id);
3252 3252
 			}
3253 3253
 		}
3254 3254
 		return $response;
@@ -3260,23 +3260,23 @@  discard block
 block discarded – undo
3260 3260
 		global $post;
3261 3261
 		$product_id = $post->ID;
3262 3262
 
3263
-		$variations = self::get_variation( $product_id );
3263
+		$variations = self::get_variation($product_id);
3264 3264
 
3265 3265
 		$sales_informations = array();
3266 3266
 		/** Query **/
3267
-		$data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";';
3268
-		$query_args = array( 'posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) );
3269
-		$orders = new WP_Query( $query_args );
3270
-		if ( !empty($orders) && !empty($orders->posts) ) {
3271
-			foreach( $orders->posts as $order ) {
3272
-				$order_meta = get_post_meta( $order->ID, '_order_postmeta', true );
3273
-				$order_info = get_post_meta( $order->ID, '_order_info', true );
3267
+		$data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";';
3268
+		$query_args = array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE')));
3269
+		$orders = new WP_Query($query_args);
3270
+		if (!empty($orders) && !empty($orders->posts)) {
3271
+			foreach ($orders->posts as $order) {
3272
+				$order_meta = get_post_meta($order->ID, '_order_postmeta', true);
3273
+				$order_info = get_post_meta($order->ID, '_order_info', true);
3274 3274
 				$sales_informations[] = array(
3275
-											'order_key' => ( !empty($order_meta) && !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '',
3276
-											'order_date' => ( !empty($order_meta) && !empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '',
3277
-											'customer_firstname' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '',
3278
-											'customer_name' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '',
3279
-											'customer_email' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : ''
3275
+											'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '',
3276
+											'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '',
3277
+											'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '',
3278
+											'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '',
3279
+											'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : ''
3280 3280
 										);
3281 3281
 			}
3282 3282
 		}
@@ -3284,33 +3284,33 @@  discard block
 block discarded – undo
3284 3284
 
3285 3285
 		/** If product has been ordered **/
3286 3286
 		$output = '';
3287
-		if( !empty($sales_informations) ) {
3288
-			$output .= '<p>'.__( 'This product has been ordered', 'wpshop').' :</p>';
3287
+		if (!empty($sales_informations)) {
3288
+			$output .= '<p>' . __('This product has been ordered', 'wpshop') . ' :</p>';
3289 3289
 			$output .= '<ul>';
3290
-			foreach( $sales_informations as $sales_information ) {
3291
-				$output .= '<li>' .sprintf( __( 'Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key'] ). '</li>';
3290
+			foreach ($sales_informations as $sales_information) {
3291
+				$output .= '<li>' . sprintf(__('Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key']) . '</li>';
3292 3292
 			}
3293 3293
 			$output .= '</ul>';
3294 3294
 		}
3295 3295
 		else {
3296
-			$output .= __( 'This product has never been ordered', 'wpshop');
3296
+			$output .= __('This product has never been ordered', 'wpshop');
3297 3297
 		}
3298 3298
 
3299 3299
 		echo $output;
3300 3300
 	}
3301 3301
 
3302 3302
 
3303
-	function wps_get_summary_variations_product( $product_id, $the_product, $has_variation ) {
3303
+	function wps_get_summary_variations_product($product_id, $the_product, $has_variation) {
3304 3304
 		global $wpdb, $wpshop_payment;
3305 3305
 		$output = '';
3306 3306
 		$tpl_component = array();
3307 3307
 		/**	Get attribute order for current product	*/
3308
-		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
3308
+		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
3309 3309
 		$output_order = array();
3310
-		if ( count($product_attribute_order_detail) > 0 ) {
3311
-			foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312
-				foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
-					if ( !empty($attribute_def->code) )
3310
+		if (count($product_attribute_order_detail) > 0) {
3311
+			foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312
+				foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
+					if (!empty($attribute_def->code))
3314 3314
 						$output_order[$attribute_def->code] = $position;
3315 3315
 				}
3316 3316
 			}
@@ -3318,22 +3318,22 @@  discard block
 block discarded – undo
3318 3318
 		$variation_attribute_ordered = array();
3319 3319
 
3320 3320
 		/** Check if product is a variation and change his name **/
3321
-		$product_post_type = get_post_type( $the_product['product_id'] );
3322
-		if ( !empty($product_post_type) && $product_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
3323
-			$parent_infos = wpshop_products::get_parent_variation( $the_product['product_id'] );
3324
-			$parent_post = ( !empty($parent_infos) && !empty($parent_infos['parent_post']) ) ? $parent_infos['parent_post'] : array();
3321
+		$product_post_type = get_post_type($the_product['product_id']);
3322
+		if (!empty($product_post_type) && $product_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
3323
+			$parent_infos = wpshop_products::get_parent_variation($the_product['product_id']);
3324
+			$parent_post = (!empty($parent_infos) && !empty($parent_infos['parent_post'])) ? $parent_infos['parent_post'] : array();
3325 3325
 			$the_product['product_name'] = $the_product['post_title'] = $parent_post->post_title;
3326 3326
 		}
3327 3327
 
3328
-		foreach ( $the_product as $product_definition_key => $product_definition_value ) {
3329
-			if ( $product_definition_key != 'item_meta' ) {
3328
+		foreach ($the_product as $product_definition_key => $product_definition_value) {
3329
+			if ($product_definition_key != 'item_meta') {
3330 3330
 				$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3331
-				if ( !empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
3331
+				if (!empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES))) {
3332 3332
 					$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3333 3333
 				}
3334 3334
 			}
3335 3335
 			else {
3336
-				$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $product_definition_value, $output_order, 'selection_summary' );
3336
+				$variation_attribute_ordered = wpshop_products::get_selected_variation_display($product_definition_value, $output_order, 'selection_summary');
3337 3337
 			}
3338 3338
 		}
3339 3339
 
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
 
3342 3342
 		ksort($variation_attribute_ordered['attribute_list']);
3343 3343
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] = '';
3344
-		foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) {
3344
+		foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) {
3345 3345
 			$tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] .= $attribute_variation_to_output;
3346 3346
 		}
3347 3347
 
@@ -3349,36 +3349,36 @@  discard block
 block discarded – undo
3349 3349
 
3350 3350
 		/**	For security get all attributes defined as user defined or used in variation in order to set default value to empty	*/
3351 3351
 		$attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_for_variation", true);
3352
-		if ( !empty($attribute_list) ) {
3353
-			foreach ( $attribute_list as $attribute_def ) {
3352
+		if (!empty($attribute_list)) {
3353
+			foreach ($attribute_list as $attribute_def) {
3354 3354
 				$tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute_def->code)] = '-';
3355 3355
 			}
3356 3356
 		}
3357 3357
 
3358 3358
 		/**	Fill the array with all prices for different variations	*/
3359
-		foreach ( $variation_attribute_ordered['prices'] as $attribute => $prices ) {
3359
+		foreach ($variation_attribute_ordered['prices'] as $attribute => $prices) {
3360 3360
 			$tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute)] = $prices;
3361 3361
 		}
3362 3362
 
3363 3363
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = '';
3364 3364
 		$query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
3365 3365
 		$post_list_with_options = $wpdb->get_results($query);
3366
-		if ( !empty($post_list_with_options) ) {
3366
+		if (!empty($post_list_with_options)) {
3367 3367
 			$additionnal_price = 0;
3368
-			foreach ( $post_list_with_options as $product_info) {
3368
+			foreach ($post_list_with_options as $product_info) {
3369 3369
 				$product_meta = unserialize($product_info->meta_value);
3370
-				if ( !empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') ) {
3370
+				if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes')) {
3371 3371
 					$product = wpshop_products::get_product_data($product_info->post_id, true, '"publish", "draft"');
3372 3372
 
3373
-					$the_product = array_merge( array(
3373
+					$the_product = array_merge(array(
3374 3374
 							'product_id'	=> $product_info->post_id,
3375 3375
 							'product_qty' 	=> 1
3376 3376
 					), $product);
3377 3377
 
3378
-					$additionnal_price += ( !$different_currency || ($change_rate == 1) ) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate);
3378
+					$additionnal_price += (!$different_currency || ($change_rate == 1)) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate);
3379 3379
 					$tpl_component['AUTO_PRODUCT_NAME'] = $the_product['product_name'];
3380 3380
 
3381
-					$tpl_component['AUTO_PRODUCT_PRODUCT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', ( !$different_currency || ($change_rate == 1) ) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate));
3381
+					$tpl_component['AUTO_PRODUCT_PRODUCT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', (!$different_currency || ($change_rate == 1)) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate));
3382 3382
 					$tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_auto_product', $tpl_component);
3383 3383
 				}
3384 3384
 			}
@@ -3386,14 +3386,14 @@  discard block
 block discarded – undo
3386 3386
 
3387 3387
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = '';
3388 3388
 		$tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = '';
3389
-		if ( !empty($additionnal_price) ) {
3389
+		if (!empty($additionnal_price)) {
3390 3390
 			$tpl_component['SUMMARY_FINAL_RESULT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', $tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price);
3391 3391
 			$tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = ($tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price);
3392 3392
 			$tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_final_result', $tpl_component);
3393 3393
 		}
3394 3394
 
3395 3395
 		/**	Call informtion for partial payment	*/
3396
-		$partial_payment = $wpshop_payment->partial_payment_calcul( $tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] );
3396
+		$partial_payment = $wpshop_payment->partial_payment_calcul($tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT']);
3397 3397
 		$tpl_component['PARTIAL_PAYMENT_INFO'] = !empty($partial_payment['amount_to_pay']) ? $partial_payment['display'] : '';
3398 3398
 
3399 3399
 
@@ -3420,13 +3420,13 @@  discard block
 block discarded – undo
3420 3420
 	 * @param array $old_value
3421 3421
 	 * @return array $new_value
3422 3422
 	 */
3423
-	public static function update_wpshop_catalog_product_option( $new_value, $old_value ) {
3423
+	public static function update_wpshop_catalog_product_option($new_value, $old_value) {
3424 3424
 		global $wpdb;
3425
-		$query = $wpdb->prepare('SELECT post_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND meta_value LIKE %s', '_wpshop_variation_defining', '%' . serialize( 'follow_general_config' ) . '%' );
3426
-		foreach( $wpdb->get_results( $query ) as $wpshop_variation_defining ) {
3427
-			$wpshop_variation_defining_value = unserialize( $wpshop_variation_defining->meta_value );
3425
+		$query = $wpdb->prepare('SELECT post_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND meta_value LIKE %s', '_wpshop_variation_defining', '%' . serialize('follow_general_config') . '%');
3426
+		foreach ($wpdb->get_results($query) as $wpshop_variation_defining) {
3427
+			$wpshop_variation_defining_value = unserialize($wpshop_variation_defining->meta_value);
3428 3428
 			$wpshop_variation_defining_value['options']['price_display'] = $new_value['price_display'];
3429
-			update_post_meta( $wpshop_variation_defining->post_id, '_wpshop_variation_defining', $wpshop_variation_defining_value );
3429
+			update_post_meta($wpshop_variation_defining->post_id, '_wpshop_variation_defining', $wpshop_variation_defining_value);
3430 3430
 		}
3431 3431
 		return $new_value;
3432 3432
 	}
Please login to merge, or discard this patch.
includes/librairies/db/database.class.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -120,6 +120,7 @@  discard block
 block discarded – undo
120 120
 	*	Save a new attribute in database
121 121
 	*
122 122
 	*	@param array $informationsToSet An array with the different information we want to set
123
+	* @param string $dataBaseTable
123 124
 	*
124 125
 	*	@return string $requestResponse A message that allows to know if the creation has been done correctly or not
125 126
 	*/
@@ -141,6 +142,7 @@  discard block
 block discarded – undo
141 142
 	*	Update an existing attribute in database
142 143
 	*
143 144
 	*	@param array $informationsToSet An array with the different information we want to set
145
+	* @param string $dataBaseTable
144 146
 	*
145 147
 	*	@return string $requestResponse A message that allows to know if the update has been done correctly or not
146 148
 	*/
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
 {
25 25
 
26 26
 	/**
27
-	*	Get the field list into a database table
28
-	*
29
-	*	@param string $table_name The name of the table we want to retrieve field list for
30
-	*
31
-	*	@return object $field_list A wordpress database object containing the different field of the table
32
-	*/
27
+	 *	Get the field list into a database table
28
+	 *
29
+	 *	@param string $table_name The name of the table we want to retrieve field list for
30
+	 *
31
+	 *	@return object $field_list A wordpress database object containing the different field of the table
32
+	 */
33 33
 	public static function get_field_list($table_name){
34 34
 		global $wpdb;
35 35
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 		return $field_list;
40 40
 	}
41 41
 	/**
42
-	*	Get a field defintion into a database table
43
-	*
44
-	*	@param string $table_name The name of the table we want to retrieve field list for
45
-	*
46
-	*	@return object $field A wordpress database object containing the field definition into the database table
47
-	*/
42
+	 *	Get a field defintion into a database table
43
+	 *
44
+	 *	@param string $table_name The name of the table we want to retrieve field list for
45
+	 *
46
+	 *	@return object $field A wordpress database object containing the field definition into the database table
47
+	 */
48 48
 	function get_field_definition($table_name, $field){
49 49
 		global $wpdb;
50 50
 
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	*	Make a translation of the different database field type into a form input type
59
-	*
60
-	*	@param string $table_name The name of the table we want to retrieve field input type for
61
-	*
62
-	*	@return array $field_to_form An array with the list of field with its type, name and value
63
-	*/
58
+	 *	Make a translation of the different database field type into a form input type
59
+	 *
60
+	 *	@param string $table_name The name of the table we want to retrieve field input type for
61
+	 *
62
+	 *	@return array $field_to_form An array with the list of field with its type, name and value
63
+	 */
64 64
 	public static function fields_to_input($table_name){
65 65
 		$list_of_field_to_convert = wpshop_database::get_field_list($table_name);
66 66
 
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	*	Transform the database table definition into an array for building a input for users
74
-	*
75
-	*	@param array $list_of_field_to_convert The list of field we want to have the types for
76
-	*
77
-	*	@return array $field_to_form The field stored into an array
78
-	*/
73
+	 *	Transform the database table definition into an array for building a input for users
74
+	 *
75
+	 *	@param array $list_of_field_to_convert The list of field we want to have the types for
76
+	 *
77
+	 *	@return array $field_to_form The field stored into an array
78
+	 */
79 79
 	public static function fields_type($list_of_field_to_convert){
80 80
 		$field_to_form = array();
81 81
 		$i = 0;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 
118 118
 
119 119
 	/**
120
-	*	Save a new attribute in database
121
-	*
122
-	*	@param array $informationsToSet An array with the different information we want to set
123
-	*
124
-	*	@return string $requestResponse A message that allows to know if the creation has been done correctly or not
125
-	*/
120
+	 *	Save a new attribute in database
121
+	 *
122
+	 *	@param array $informationsToSet An array with the different information we want to set
123
+	 *
124
+	 *	@return string $requestResponse A message that allows to know if the creation has been done correctly or not
125
+	 */
126 126
 	public static function save($informationsToSet, $dataBaseTable){
127 127
 		global $wpdb;
128 128
 		$requestResponse = '';
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 		return $requestResponse;
139 139
 	}
140 140
 	/**
141
-	*	Update an existing attribute in database
142
-	*
143
-	*	@param array $informationsToSet An array with the different information we want to set
144
-	*
145
-	*	@return string $requestResponse A message that allows to know if the update has been done correctly or not
146
-	*/
141
+	 *	Update an existing attribute in database
142
+	 *
143
+	 *	@param array $informationsToSet An array with the different information we want to set
144
+	 *
145
+	 *	@return string $requestResponse A message that allows to know if the update has been done correctly or not
146
+	 */
147 147
 	public static function update($informationsToSet, $id, $dataBaseTable){
148 148
 		global $wpdb;
149 149
 		$requestResponse = '';
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	*
31 31
 	*	@return object $field_list A wordpress database object containing the different field of the table
32 32
 	*/
33
-	public static function get_field_list($table_name){
33
+	public static function get_field_list($table_name) {
34 34
 		global $wpdb;
35 35
 
36 36
 		$query = "SHOW COLUMNS FROM " . $table_name;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	*
46 46
 	*	@return object $field A wordpress database object containing the field definition into the database table
47 47
 	*/
48
-	function get_field_definition($table_name, $field){
48
+	function get_field_definition($table_name, $field) {
49 49
 		global $wpdb;
50 50
 
51 51
 		$query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	*
62 62
 	*	@return array $field_to_form An array with the list of field with its type, name and value
63 63
 	*/
64
-	public static function fields_to_input($table_name){
64
+	public static function fields_to_input($table_name) {
65 65
 		$list_of_field_to_convert = wpshop_database::get_field_list($table_name);
66 66
 
67 67
 		$field_to_form = self::fields_type($list_of_field_to_convert);
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
 	*
77 77
 	*	@return array $field_to_form The field stored into an array
78 78
 	*/
79
-	public static function fields_type($list_of_field_to_convert){
79
+	public static function fields_type($list_of_field_to_convert) {
80 80
 		$field_to_form = array();
81 81
 		$i = 0;
82
-		foreach ($list_of_field_to_convert as $Key => $field_definition){
82
+		foreach ($list_of_field_to_convert as $Key => $field_definition) {
83 83
 			$field_to_form[$i]['name'] = $field_definition->Field;
84 84
 			$field_to_form[$i]['value'] = $field_definition->Default;
85 85
 
86 86
 			$type = 'text';
87
-			if(($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')){
88
-				$type =  'hidden';
87
+			if (($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')) {
88
+				$type = 'hidden';
89 89
 			}
90
-			else{
91
-				$fieldtype = explode('(',$field_definition->Type);
92
-				if(!empty($fieldtype[1]))$fieldtype[1] = str_replace(')','',$fieldtype[1]);
90
+			else {
91
+				$fieldtype = explode('(', $field_definition->Type);
92
+				if (!empty($fieldtype[1]))$fieldtype[1] = str_replace(')', '', $fieldtype[1]);
93 93
 
94
-				if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int'))
94
+				if (($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int'))
95 95
 					$type = 'text';
96
-				elseif($fieldtype[0] == 'text')
96
+				elseif ($fieldtype[0] == 'text')
97 97
 					$type = 'textarea';
98
-				elseif($fieldtype[0] == 'enum')
98
+				elseif ($fieldtype[0] == 'enum')
99 99
 				{
100
-					$fieldtype[1] = str_replace("'","",$fieldtype[1]);
101
-					$possible_value = explode(",",$fieldtype[1]);
100
+					$fieldtype[1] = str_replace("'", "", $fieldtype[1]);
101
+					$possible_value = explode(",", $fieldtype[1]);
102 102
 
103 103
 					$type = 'radio';
104
-					if(count($possible_value) > 1)
104
+					if (count($possible_value) > 1)
105 105
 						$type = 'select';
106 106
 
107 107
 					$field_to_form[$i]['possible_value'] = $possible_value;
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 	*
124 124
 	*	@return string $requestResponse A message that allows to know if the creation has been done correctly or not
125 125
 	*/
126
-	public static function save($informationsToSet, $dataBaseTable){
126
+	public static function save($informationsToSet, $dataBaseTable) {
127 127
 		global $wpdb;
128 128
 		$requestResponse = '';
129 129
 
130 130
 		$updateResult = $wpdb->insert($dataBaseTable, $informationsToSet, '%s');
131
-		if( $updateResult != false ){
131
+		if ($updateResult != false) {
132 132
 			$requestResponse = 'done';
133 133
 		}
134
-		else{
134
+		else {
135 135
 			$requestResponse = 'error';
136 136
 		}
137 137
 
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
 	*
145 145
 	*	@return string $requestResponse A message that allows to know if the update has been done correctly or not
146 146
 	*/
147
-	public static function update($informationsToSet, $id, $dataBaseTable){
147
+	public static function update($informationsToSet, $id, $dataBaseTable) {
148 148
 		global $wpdb;
149 149
 		$requestResponse = '';
150 150
 
151
-		$updateResult = $wpdb->update($dataBaseTable, $informationsToSet , array( 'id' => $id ), '%s', array('%d') );
151
+		$updateResult = $wpdb->update($dataBaseTable, $informationsToSet, array('id' => $id), '%s', array('%d'));
152 152
 
153
-		if( $updateResult == 1 ){
153
+		if ($updateResult == 1) {
154 154
 			$requestResponse = 'done';
155 155
 		}
156
-		elseif( $updateResult == 0 ){
156
+		elseif ($updateResult == 0) {
157 157
 			$requestResponse = 'nothingToUpdate';
158 158
 		}
159
-		elseif( $updateResult == false ){
159
+		elseif ($updateResult == false) {
160 160
 			$requestResponse = 'error';
161 161
 		}
162 162
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -86,23 +88,25 @@  discard block
 block discarded – undo
86 88
 			$type = 'text';
87 89
 			if(($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')){
88 90
 				$type =  'hidden';
89
-			}
90
-			else{
91
+			} else{
91 92
 				$fieldtype = explode('(',$field_definition->Type);
92
-				if(!empty($fieldtype[1]))$fieldtype[1] = str_replace(')','',$fieldtype[1]);
93
+				if(!empty($fieldtype[1])) {
94
+					$fieldtype[1] = str_replace(')','',$fieldtype[1]);
95
+				}
93 96
 
94
-				if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int'))
95
-					$type = 'text';
96
-				elseif($fieldtype[0] == 'text')
97
-					$type = 'textarea';
98
-				elseif($fieldtype[0] == 'enum')
97
+				if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int')) {
98
+									$type = 'text';
99
+				} elseif($fieldtype[0] == 'text') {
100
+									$type = 'textarea';
101
+				} elseif($fieldtype[0] == 'enum')
99 102
 				{
100 103
 					$fieldtype[1] = str_replace("'","",$fieldtype[1]);
101 104
 					$possible_value = explode(",",$fieldtype[1]);
102 105
 
103 106
 					$type = 'radio';
104
-					if(count($possible_value) > 1)
105
-						$type = 'select';
107
+					if(count($possible_value) > 1) {
108
+											$type = 'select';
109
+					}
106 110
 
107 111
 					$field_to_form[$i]['possible_value'] = $possible_value;
108 112
 				}
@@ -130,8 +134,7 @@  discard block
 block discarded – undo
130 134
 		$updateResult = $wpdb->insert($dataBaseTable, $informationsToSet, '%s');
131 135
 		if( $updateResult != false ){
132 136
 			$requestResponse = 'done';
133
-		}
134
-		else{
137
+		} else{
135 138
 			$requestResponse = 'error';
136 139
 		}
137 140
 
@@ -152,11 +155,9 @@  discard block
 block discarded – undo
152 155
 
153 156
 		if( $updateResult == 1 ){
154 157
 			$requestResponse = 'done';
155
-		}
156
-		elseif( $updateResult == 0 ){
158
+		} elseif( $updateResult == 0 ){
157 159
 			$requestResponse = 'nothingToUpdate';
158
-		}
159
-		elseif( $updateResult == false ){
160
+		} elseif( $updateResult == false ){
160 161
 			$requestResponse = 'error';
161 162
 		}
162 163
 
Please login to merge, or discard this patch.
includes/librairies/display/display.class.php 4 patches
Doc Comments   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * Return a complete html table with header, body and content
192 192
 	 *
193 193
 	 *	@param string $tableId The unique identifier of the table in the document
194
-	 *	@param array $tableTitles An array with the different element to put into the table's header and footer
194
+	 *	@param string[] $tableTitles An array with the different element to put into the table's header and footer
195 195
 	 *	@param array $tableRows An array with the different value to put into the table's body
196
-	 *	@param array $tableClasses An array with the different class to affect to table rows and cols
197
-	 *	@param array $tableRowsId An array with the different identifier for table lines
196
+	 *	@param string[] $tableClasses An array with the different class to affect to table rows and cols
197
+	 *	@param string[] $tableRowsId An array with the different identifier for table lines
198 198
 	 *	@param string $tableSummary A summary for the table
199 199
 	 *	@param boolean $withFooter Allow to define if the table must be create with a footer or not
200 200
 	 *
@@ -274,6 +274,7 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param string $file_name The file name to check if exists in current theme
276 276
 	 * @param string $dir_name Optionnal The directory name of the file to check Default : wpshop
277
+	 * @param string $default_dir
277 278
 	 *
278 279
 	 * @return string $file_path The good filepath to include
279 280
 	 */
@@ -299,7 +300,7 @@  discard block
 block discarded – undo
299 300
 	 * Check if the current shop use the first method for templates. One file per element to display
300 301
 	 *
301 302
 	 * @param string $template_part The part to take display for, will be usefull to check what file take in care if there were a file in old method
302
-	 * @param string $default_template_dirThe part of website to check template for. Possible values : wpshop / admin
303
+	 * @param string $default_template_dir part of website to check template for. Possible values : wpshop / admin
303 304
 	 *
304 305
 	 * @return array First index represent if there is a file for old version support, Second index represent the file to get for support old version
305 306
 	 */
@@ -546,6 +547,7 @@  discard block
 block discarded – undo
546 547
 	 * @param string $part The part of shop where to display the given template element
547 548
 	 * @param string $template_part The template element we want to display
548 549
 	 * @param array $extras_args Allows to define some parameters to spot a specific template for example
550
+	 * @param string $default_template_dir
549 551
 	 *
550 552
 	 * @return string The good template to take in care, regarding on the given parameters
551 553
 	 */
@@ -742,7 +744,7 @@  discard block
 block discarded – undo
742 744
 	 * Change output for product page
743 745
 	 *
744 746
 	 * @param string $content The content of a post
745
-	 * @return Ambigous <mixed, string>|unknown
747
+	 * @return string <mixed, string>|unknown
746 748
 	 */
747 749
 	public static function products_page( $content = '' ) {
748 750
 		global $wp_query;
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,39 +17,39 @@
 block discarded – undo
17 17
 class wpshop_display {
18 18
 
19 19
 	/**
20
-	*	Returns the header display of a classical HTML page.
21
-	*
22
-	*	@see afficherFinPage
23
-	*
24
-	*	@param string $pageTitle Title of the page.
25
-	*	@param string $pageIcon Path of the icon.
26
-	*	@param string $iconTitle Title attribute of the icon.
27
-	*	@param string $iconAlt Alt attribute of the icon.
28
-	*	@param boolean $hasAddButton Define if there must be a "add" button for this page
29
-	*	@param string $actionInformationMessage A message to display in case of action is send
30
-	*
31
-	*	@return string Html code composing the page header
32
-	*/
20
+	 *	Returns the header display of a classical HTML page.
21
+	 *
22
+	 *	@see afficherFinPage
23
+	 *
24
+	 *	@param string $pageTitle Title of the page.
25
+	 *	@param string $pageIcon Path of the icon.
26
+	 *	@param string $iconTitle Title attribute of the icon.
27
+	 *	@param string $iconAlt Alt attribute of the icon.
28
+	 *	@param boolean $hasAddButton Define if there must be a "add" button for this page
29
+	 *	@param string $actionInformationMessage A message to display in case of action is send
30
+	 *
31
+	 *	@return string Html code composing the page header
32
+	 */
33 33
 	public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){
34 34
 		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php');
35 35
 	}
36 36
 
37 37
 	/**
38
-	*	Returns the end of a classical page
39
-	*
40
-	*	@see displayPageHeader
41
-	*
42
-	*	@return string Html code composing the page footer
43
-	*/
38
+	 *	Returns the end of a classical page
39
+	 *
40
+	 *	@see displayPageHeader
41
+	 *
42
+	 *	@return string Html code composing the page footer
43
+	 */
44 44
 	public static function displayPageFooter($formActionButton){
45 45
 		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php');
46 46
 	}
47 47
 
48 48
 	/**
49
-	*	Return The complete output page code
50
-	*
51
-	*	@return string The complete html page output
52
-	*/
49
+	 *	Return The complete output page code
50
+	 *
51
+	 *	@return string The complete html page output
52
+	 */
53 53
 	public static function display_page(){
54 54
 
55 55
 		$pageAddButton = false;
Please login to merge, or discard this patch.
Braces   +29 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -111,8 +113,7 @@  discard block
 block discarded – undo
111 113
 
112 114
 			if($outputType == 'listing'){
113 115
 				$pageContent = $objectType->elementList();
114
-			}
115
-			elseif($outputType == 'adding'){
116
+			} elseif($outputType == 'adding'){
116 117
 				$pageAddButton = false;
117 118
 
118 119
 				$pageFormButton = $objectType->getPageFormButton($objectToEdit);
@@ -124,8 +125,7 @@  discard block
 block discarded – undo
124 125
 			$pageMessage = $objectType->pageMessage;
125 126
 			if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) {
126 127
 				$addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&amp;action=add');
127
-			}
128
-			else {
128
+			} else {
129 129
 				$addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
130 130
 			}
131 131
 		}
@@ -287,8 +287,7 @@  discard block
 block discarded – undo
287 287
 				$default_dir = get_stylesheet_directory();
288 288
 			}
289 289
 			$file_path = $default_dir . '/' . $the_file;
290
-		}
291
-		else if ( !$check_only_custom ) {
290
+		} else if ( !$check_only_custom ) {
292 291
 			$file_path = $default_dir . $the_file;
293 292
 		}
294 293
 
@@ -480,13 +479,17 @@  discard block
 block discarded – undo
480 479
 		/*	Get custom admin template	*/
481 480
 		if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) {
482 481
 			require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php');
483
-			if (!empty($tpl_element))
484
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
482
+			if (!empty($tpl_element)) {
483
+							$wpshop_template['admin']['custom'] = ($tpl_element);
484
+			}
485
+			unset($tpl_element);
485 486
 		}
486 487
 		if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) {
487 488
 			require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php');
488
-			if (!empty($tpl_element))
489
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
489
+			if (!empty($tpl_element)) {
490
+							$wpshop_template['admin']['custom'] = ($tpl_element);
491
+			}
492
+			unset($tpl_element);
490 493
 		}
491 494
 		/*	Get default frontend template	*/
492 495
 		require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php');
@@ -494,13 +497,17 @@  discard block
 block discarded – undo
494 497
 		/*	Get custom frontend template	*/
495 498
 		if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) {
496 499
 			require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php');
497
-			if (!empty($tpl_element))
498
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
500
+			if (!empty($tpl_element)) {
501
+							$wpshop_template['wpshop']['custom'] = ($tpl_element);
502
+			}
503
+			unset($tpl_element);
499 504
 		}
500 505
 		if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) {
501 506
 			require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php');
502
-			if (!empty($tpl_element))
503
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
507
+			if (!empty($tpl_element)) {
508
+							$wpshop_template['wpshop']['custom'] = ($tpl_element);
509
+			}
510
+			unset($tpl_element);
504 511
 		}
505 512
 		foreach ( $wpshop_template as $site_side => $types ) {
506 513
 			foreach ( $types as $type => $tpl_component ) {
@@ -557,8 +564,7 @@  discard block
 block discarded – undo
557 564
 
558 565
 		if ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty( $template[$default_template_dir][$part][$extras_args['page']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
559 566
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part];
560
-		}
561
-		elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
567
+		} elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
562 568
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part];
563 569
 		}
564 570
 		/**	Check if the file have been duplicated into theme directory for customization	*/
@@ -591,7 +597,9 @@  discard block
 block discarded – undo
591 597
 				$template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill);
592 598
 			}
593 599
 		}
594
-		if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill;
600
+		if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) {
601
+			$template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill;
602
+		}
595 603
 
596 604
 		return $template_to_fill;
597 605
 	}
@@ -655,8 +663,7 @@  discard block
 block discarded – undo
655 663
 		/*	Enable shortcodes in category, taxonomy, tag descriptions */
656 664
 		if(function_exists('term_description')) {
657 665
 			add_filter('term_description', 'do_shortcode');
658
-		}
659
-		else {
666
+		} else {
660 667
 			add_filter('category_description', 'do_shortcode');
661 668
 		}
662 669
 	}
@@ -686,8 +693,7 @@  discard block
 block discarded – undo
686 693
 		if( in_array($pagenow, array('edit-tags.php')) ) {
687 694
 			$editor_id = 'tag_description';
688 695
 			$editor_selector = 'description';
689
-		}
690
-		else {
696
+		} else {
691 697
 			$editor_id = $editor_selector = 'category_description';
692 698
 		}
693 699
 
@@ -749,8 +755,7 @@  discard block
 block discarded – undo
749 755
 
750 756
 		if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) {
751 757
 			return wpshop_products::product_complete_sheet_output($content, $wp_query->post->ID);
752
-		}
753
-		else {
758
+		} else {
754 759
 			return $content;
755 760
 		}
756 761
 	}
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	*
31 31
 	*	@return string Html code composing the page header
32 32
 	*/
33
-	public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){
34
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php');
33
+	public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = '') {
34
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_header.tpl.php');
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	*
42 42
 	*	@return string Html code composing the page footer
43 43
 	*/
44
-	public static function displayPageFooter($formActionButton){
45
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php');
44
+	public static function displayPageFooter($formActionButton) {
45
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_footer.tpl.php');
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	*
51 51
 	*	@return string The complete html page output
52 52
 	*/
53
-	public static function display_page(){
53
+	public static function display_page() {
54 54
 
55 55
 		$pageAddButton = false;
56 56
 		$pageMessage = $addButtonLink = $pageFormButton = $pageIcon = $pageIconTitle = $pageIconAlt = $objectType = '';
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : '';
61 61
 
62 62
 		/*	Select the content to add to the page looking for the parameter	*/
63
-		switch($pageSlug){
63
+		switch ($pageSlug) {
64 64
 			case WPSHOP_URL_SLUG_ATTRIBUTE_LISTING:
65 65
 				$objectType = new wpshop_attributes();
66 66
 				$current_user_can_edit = current_user_can('wpshop_edit_attributes');
67 67
 				$current_user_can_add = current_user_can('wpshop_add_attributes');
68 68
 				$current_user_can_delete = current_user_can('wpshop_delete_attributes');
69
-				if(current_user_can('wpshop_add_attributes')){
69
+				if (current_user_can('wpshop_add_attributes')) {
70 70
 					$pageAddButton = true;
71 71
 				}
72 72
 			break;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 				$current_user_can_edit = current_user_can('wpshop_edit_attribute_set');
76 76
 				$current_user_can_add = current_user_can('wpshop_add_attribute_set');
77 77
 				$current_user_can_delete = current_user_can('wpshop_delete_attribute_set');
78
-				if(current_user_can('wpshop_add_attribute_set')){
78
+				if (current_user_can('wpshop_add_attribute_set')) {
79 79
 					$pageAddButton = true;
80 80
 				}
81 81
 			break;
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 				$pageAddButton = false;
89 89
 				$objectType = new wpshop_messages();
90 90
 				$current_user_can_edit = true;
91
-				if(!empty($_GET['mid'])){
91
+				if (!empty($_GET['mid'])) {
92 92
 					$action = 'edit';
93 93
 				}
94 94
 			break;
95 95
 			default:{
96
-				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ - 4));
96
+				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ -4));
97 97
 				$pageAddButton = false;
98 98
 			}
99 99
 			break;
100 100
 		}
101 101
 
102
-		if($objectType != ''){
103
-			if(($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))){
102
+		if ($objectType != '') {
103
+			if (($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))) {
104 104
 				$outputType = 'adding';
105 105
 			}
106 106
 			$objectType->elementAction();
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 			$pageIconTitle = self::getPageIconInformation('title', $objectType);
110 110
 			$pageIconAlt = self::getPageIconInformation('alt', $objectType);
111 111
 
112
-			if($outputType == 'listing'){
112
+			if ($outputType == 'listing') {
113 113
 				$pageContent = $objectType->elementList();
114 114
 			}
115
-			elseif($outputType == 'adding'){
115
+			elseif ($outputType == 'adding') {
116 116
 				$pageAddButton = false;
117 117
 
118 118
 				$pageFormButton = $objectType->getPageFormButton($objectToEdit);
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 
123 123
 			$pageTitle = $objectType->pageTitle();
124 124
 			$pageMessage = $objectType->pageMessage;
125
-			if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) {
125
+			if (in_array($objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING))) {
126 126
 				$addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&amp;action=add');
127 127
 			}
128 128
 			else {
129
-				$addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
129
+				$addButtonLink = admin_url('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
130 130
 			}
131 131
 		}
132 132
 
@@ -148,37 +148,37 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return string The output builded from selected type
150 150
 	 */
151
-	public static function custom_page_output_builder($content, $output_type='tab') {
151
+	public static function custom_page_output_builder($content, $output_type = 'tab') {
152 152
 		$output_custom_layout = '';
153 153
 
154
-		switch ( $output_type ) {
154
+		switch ($output_type) {
155 155
 			case 'separated_bloc':
156
-				foreach ( $content as $element_type => $element_type_details ) {
157
-					$output_custom_layout.='
158
-	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type.'" >';
159
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
160
-						$output_custom_layout.='
161
-		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >
156
+				foreach ($content as $element_type => $element_type_details) {
157
+					$output_custom_layout .= '
158
+	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type . '" >';
159
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
160
+						$output_custom_layout .= '
161
+		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >
162 162
 			<h3>' . $element_type_content['title'] . '</h3>' . $element_type_content['content'] . '
163 163
 		</div>';
164 164
 					}
165
-					$output_custom_layout.='
165
+					$output_custom_layout .= '
166 166
 	</div>';
167 167
 				}
168 168
 			break;
169 169
 			case 'tab':
170
-				$tab_list=$tab_content_list='';
171
-				foreach ( $content as $element_type => $element_type_details ) {
172
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
173
-						$tab_list.='
174
-		<li><a href="#wpshop_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['title'].'</a></li>';
175
-						$tab_content_list.='
176
-		<div id="wpshop_'.$element_type.'_'.$element_type_key.'" class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['content'].'
170
+				$tab_list = $tab_content_list = '';
171
+				foreach ($content as $element_type => $element_type_details) {
172
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
173
+						$tab_list .= '
174
+		<li><a href="#wpshop_'.$element_type . '_' . $element_type_key . '" >' . $element_type_content['title'] . '</a></li>';
175
+						$tab_content_list .= '
176
+		<div id="wpshop_'.$element_type . '_' . $element_type_key . '" class="wpshop_admin_box wpshop_admin_box_' . $element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >' . $element_type_content['content'] . '
177 177
 		</div>';
178 178
 					}
179 179
 				}
180
-				$output_custom_layout.='
181
-	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type.'_tabs" >
180
+				$output_custom_layout .= '
181
+	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type . '_tabs" >
182 182
 		<ul>' . $tab_list . '</ul>' . $tab_content_list . '
183 183
 	</div>';
184 184
 					break;
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 *	@return string $table The html code of the table to output
202 202
 	 */
203
-	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true){
203
+	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true) {
204 204
 		$tableTitleBar = $tableBody = '';
205 205
 
206 206
 		/*	Create the header and footer row	*/
207
-		for($i=0; $i<count($tableTitles); $i++){
207
+		for ($i = 0; $i < count($tableTitles); $i++) {
208 208
 			$tableTitleBar .= '
209 209
 				<th class="' . $tableClasses[$i] . '" scope="col" >' . $tableTitles[$i] . '</th>';
210 210
 		}
211 211
 
212 212
 		/*	Create each table row	*/
213
-		for($lineNumber=0; $lineNumber<count($tableRows); $lineNumber++){
213
+		for ($lineNumber = 0; $lineNumber < count($tableRows); $lineNumber++) {
214 214
 			$tableRow = $tableRows[$lineNumber];
215 215
 			$tableBody .= '
216 216
 		<tr id="' . $tableRowsId[$lineNumber] . '" class="tableRow" >';
217
-			for($i=0; $i<count($tableRow); $i++){
217
+			for ($i = 0; $i < count($tableRow); $i++) {
218 218
 				$tableBody .= '
219 219
 			<td class="' . $tableClasses[$i] . ' ' . $tableRow[$i]['class'] . '" >' . $tableRow[$i]['value'] . '</td>';
220 220
 			}
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 		/*	Create the table output	*/
226 226
 		$table = '
227 227
 <table id="' . $tableId . '" cellspacing="0" cellpadding="0" class="widefat post fixed" >';
228
-		if($tableTitleBar != ''){
228
+		if ($tableTitleBar != '') {
229 229
 			$table .= '
230 230
 	<thead>
231 231
 			<tr class="tableTitleHeader" >' . $tableTitleBar . '
232 232
 			</tr>
233 233
 	</thead>';
234
-			if($withFooter){
234
+			if ($withFooter) {
235 235
 				$table .= '
236 236
 	<tfoot>
237 237
 			<tr class="tableTitleFooter" >' . $tableTitleBar . '
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return string $pageIconInformation The information to output in the page
256 256
 	 */
257
-	public static function getPageIconInformation($infoType, $object){
258
-		switch($infoType){
257
+	public static function getPageIconInformation($infoType, $object) {
258
+		switch ($infoType) {
259 259
 			case 'path':
260 260
 				$pageIconInformation = $object->pageIcon;
261 261
 			break;
@@ -277,18 +277,18 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @return string $file_path The good filepath to include
279 279
 	 */
280
-	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false){
280
+	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false) {
281 281
 		$file_path = '';
282 282
 		$the_file = $dir_name . '/' . $file_name;
283 283
 
284 284
 		if (is_file(get_stylesheet_directory() . '/' . $the_file)) {
285 285
 			$default_dir = str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, get_stylesheet_directory());
286
-			if($usage_type == 'include'){
286
+			if ($usage_type == 'include') {
287 287
 				$default_dir = get_stylesheet_directory();
288 288
 			}
289 289
 			$file_path = $default_dir . '/' . $the_file;
290 290
 		}
291
-		else if ( !$check_only_custom ) {
291
+		else if (!$check_only_custom) {
292 292
 			$file_path = $default_dir . $the_file;
293 293
 		}
294 294
 
@@ -311,124 +311,124 @@  discard block
 block discarded – undo
311 311
 		$custom_template_part = get_stylesheet_directory() . '/' . $default_template_dir . '/';
312 312
 
313 313
 		/** Let support the old way of template managing	*/
314
-		switch ( $template_part ) {
314
+		switch ($template_part) {
315 315
 			case 'category_mini_list':
316 316
 					$old_file_to_take_care_url = 'category-mini-list.tpl.php';
317
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
317
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
318 318
 						$old_file_to_take_care = true;
319 319
 					endif;
320 320
 				break;
321 321
 			case 'category_mini_grid':
322 322
 					$old_file_to_take_care_url = 'category-mini-grid.tpl.php';
323
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
323
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
324 324
 						$old_file_to_take_care = true;
325 325
 					endif;
326 326
 				break;
327 327
 			case 'product_complete_tpl':
328 328
 					$old_file_to_take_care_url = 'product.tpl.php';
329
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
329
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
330 330
 						$old_file_to_take_care = true;
331 331
 					endif;
332 332
 				break;
333 333
 			case 'product_mini_list':
334 334
 					$old_file_to_take_care_url = 'product-mini-list.tpl.php';
335
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
335
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
336 336
 						$old_file_to_take_care = true;
337 337
 					endif;
338 338
 				break;
339 339
 			case 'product_mini_grid':
340 340
 					$old_file_to_take_care_url = 'product-mini-grid.tpl.php';
341
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
341
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
342 342
 						$old_file_to_take_care = true;
343 343
 					endif;
344 344
 				break;
345 345
 			case 'product_listing_sorting':
346 346
 					$old_file_to_take_care_url = 'product_listing_sorting.tpl.php';
347
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
347
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
348 348
 						$old_file_to_take_care = true;
349 349
 					endif;
350 350
 				break;
351 351
 			case 'unavailable_product_button':
352 352
 					$old_file_to_take_care_url = 'not_available_product_button.tpl.php';
353
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
353
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
354 354
 						$old_file_to_take_care = true;
355 355
 					endif;
356 356
 				break;
357 357
 			case 'add_to_cart_button':
358 358
 					$old_file_to_take_care_url = 'available_product_button.tpl.php';
359
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
359
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
360 360
 						$old_file_to_take_care = true;
361 361
 					endif;
362 362
 				break;
363 363
 			case 'ask_quotation_button':
364 364
 					$old_file_to_take_care_url = 'quotation_button.tpl.php';
365
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
365
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
366 366
 						$old_file_to_take_care = true;
367 367
 					endif;
368 368
 				break;
369 369
 			case 'mini_cart_content':
370 370
 					$old_file_to_take_care_url = 'wpshop_mini_cart.tpl.php';
371
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
371
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
372 372
 						$old_file_to_take_care = true;
373 373
 					endif;
374 374
 				break;
375 375
 			case 'product_is_new_sticker':
376 376
 					$old_file_to_take_care_url = 'product-is-new.tpl.php';
377
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
377
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
378 378
 						$old_file_to_take_care = true;
379 379
 					endif;
380 380
 				break;
381 381
 			case 'product_is_featured_sticker':
382 382
 					$old_file_to_take_care_url = 'product-is-featured.tpl.php';
383
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
383
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
384 384
 						$old_file_to_take_care = true;
385 385
 					endif;
386 386
 				break;
387 387
 			case 'product_attribute_container':
388 388
 					$old_file_to_take_care_url = 'product-attribute-front-display-main-container.tpl.php';
389
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
389
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
390 390
 						$old_file_to_take_care = true;
391 391
 					endif;
392 392
 				break;
393 393
 			case 'product_attribute_tabs':
394 394
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs.tpl.php';
395
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
395
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
396 396
 						$old_file_to_take_care = true;
397 397
 					endif;
398 398
 				break;
399 399
 			case 'product_attribute_tabs_detail':
400 400
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs-content.tpl.php';
401
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
401
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
402 402
 						$old_file_to_take_care = true;
403 403
 					endif;
404 404
 				break;
405 405
 			case 'product_attachment_picture_galery':
406 406
 					$old_file_to_take_care_url = 'product_picture_galery.tpl.php';
407
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
407
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
408 408
 						$old_file_to_take_care = true;
409 409
 					endif;
410 410
 				break;
411 411
 			case 'product_attachment_galery':
412 412
 					$old_file_to_take_care_url = 'product_document_library.tpl.php';
413
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
413
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
414 414
 						$old_file_to_take_care = true;
415 415
 					endif;
416 416
 				break;
417 417
 			case 'product_attachment_item_picture':
418 418
 					$old_file_to_take_care_url = 'product_attachment_picture_line.tpl.php';
419
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
419
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
420 420
 						$old_file_to_take_care = true;
421 421
 					endif;
422 422
 				break;
423 423
 			case 'product_attachment_item_document':
424 424
 					$old_file_to_take_care_url = 'product_attachment_document_line.tpl.php';
425
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
425
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
426 426
 						$old_file_to_take_care = true;
427 427
 					endif;
428 428
 				break;
429 429
 			case 'product_added_to_cart_message':
430 430
 					$old_file_to_take_care_url = 'product_added_to_cart_message.tpl.php';
431
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
431
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
432 432
 						$old_file_to_take_care = true;
433 433
 					endif;
434 434
 				break;
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	public static function display_template_element($template_part, $template_part_component, $extras_args = array(), $default_template_dir = 'wpshop') {
460 460
 		/**	Set the template element to return by default before checking if custom exists in order to be sure to return something	*/
461
-		$default_template_element = wpshop_display::check_template_to_display( 'default', $template_part, $extras_args, $default_template_dir );
461
+		$default_template_element = wpshop_display::check_template_to_display('default', $template_part, $extras_args, $default_template_dir);
462 462
 
463 463
 		/**	Check in custom template if there is not a custom element to display for current 	*/
464
-		$custom_template_element = wpshop_display::check_template_to_display( 'custom', $template_part, $extras_args, $default_template_dir );
464
+		$custom_template_element = wpshop_display::check_template_to_display('custom', $template_part, $extras_args, $default_template_dir);
465 465
 		$tpl_element_to_return = !empty($custom_template_element) ? $custom_template_element : $default_template_element;
466 466
 
467
-		$template_part_component = apply_filters( 'wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir );
467
+		$template_part_component = apply_filters('wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir);
468 468
 
469 469
 		return self::feed_template($tpl_element_to_return, $template_part_component);
470 470
 	}
@@ -476,44 +476,44 @@  discard block
 block discarded – undo
476 476
 		/*	Load template component	*/
477 477
 		/*	Get default admin template	*/
478 478
 		require_once(WPSHOP_TEMPLATES_DIR . 'admin/main_elements.tpl.php');
479
-		$wpshop_template['admin']['default'] = ($tpl_element);unset($tpl_element);
479
+		$wpshop_template['admin']['default'] = ($tpl_element); unset($tpl_element);
480 480
 		/*	Get custom admin template	*/
481
-		if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) {
481
+		if (is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php')) {
482 482
 			require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php');
483 483
 			if (!empty($tpl_element))
484
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
484
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
485 485
 		}
486
-		if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) {
486
+		if (is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php')) {
487 487
 			require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php');
488 488
 			if (!empty($tpl_element))
489
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
489
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
490 490
 		}
491 491
 		/*	Get default frontend template	*/
492 492
 		require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php');
493
-		$wpshop_template['wpshop']['default'] = ($tpl_element);unset($tpl_element);
493
+		$wpshop_template['wpshop']['default'] = ($tpl_element); unset($tpl_element);
494 494
 		/*	Get custom frontend template	*/
495
-		if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) {
495
+		if (is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php')) {
496 496
 			require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php');
497 497
 			if (!empty($tpl_element))
498
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
498
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
499 499
 		}
500
-		if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) {
500
+		if (is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php')) {
501 501
 			require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php');
502 502
 			if (!empty($tpl_element))
503
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
503
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
504 504
 		}
505
-		foreach ( $wpshop_template as $site_side => $types ) {
506
-			foreach ( $types as $type => $tpl_component ) {
507
-				foreach ( $tpl_component as $tpl_key => $tpl_content ) {
505
+		foreach ($wpshop_template as $site_side => $types) {
506
+			foreach ($types as $type => $tpl_component) {
507
+				foreach ($tpl_component as $tpl_key => $tpl_content) {
508 508
 					$wpshop_template[$site_side][$type][$tpl_key] = str_replace("
509 509
 ", '', $tpl_content);
510 510
 				}
511 511
 			}
512 512
 		}
513 513
 
514
-		$wpshop_template = apply_filters( 'wpshop_custom_template', $wpshop_template);
514
+		$wpshop_template = apply_filters('wpshop_custom_template', $wpshop_template);
515 515
 
516
-		DEFINE( 'WPSHOP_TEMPLATE', serialize($wpshop_template) );
516
+		DEFINE('WPSHOP_TEMPLATE', serialize($wpshop_template));
517 517
 	}
518 518
 
519 519
 	/**
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
 	 *
525 525
 	 * @return array The new array with all elment, internal and module templates
526 526
 	 */
527
-	public static function add_modules_template_to_internal( $tpl_element, $templates ) {
528
-		if ( !empty($tpl_element) ) {
529
-			foreach ( $tpl_element as $template_part => $template_part_content) {
530
-				if ( !empty($template_part_content) && is_array($template_part_content) ) {
531
-					foreach ( $template_part_content as $template_type => $template_type_content) {
532
-						foreach ( $template_type_content as $template_key => $template) {
527
+	public static function add_modules_template_to_internal($tpl_element, $templates) {
528
+		if (!empty($tpl_element)) {
529
+			foreach ($tpl_element as $template_part => $template_part_content) {
530
+				if (!empty($template_part_content) && is_array($template_part_content)) {
531
+					foreach ($template_part_content as $template_type => $template_type_content) {
532
+						foreach ($template_type_content as $template_key => $template) {
533 533
 							$templates[$template_part][$template_type][$template_key] = $template;
534 534
 						}
535 535
 					}
@@ -549,20 +549,20 @@  discard block
 block discarded – undo
549 549
 	 *
550 550
 	 * @return string The good template to take in care, regarding on the given parameters
551 551
 	 */
552
-	public static function check_template_to_display( $part, $template_part, $extras_args, $default_template_dir  ) {
552
+	public static function check_template_to_display($part, $template_part, $extras_args, $default_template_dir) {
553 553
 		$tpl_element_to_return = '';
554 554
 
555 555
 		/**	Get the defined template	*/
556 556
 		$template = defined("WPSHOP_TEMPLATE") ? unserialize(WPSHOP_TEMPLATE) : array();
557 557
 
558
-		if ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty( $template[$default_template_dir][$part][$extras_args['page']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
558
+		if (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty($template[$default_template_dir][$part][$extras_args['page']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part])) {
559 559
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part];
560 560
 		}
561
-		elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
561
+		elseif (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part])) {
562 562
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part];
563 563
 		}
564 564
 		/**	Check if the file have been duplicated into theme directory for customization	*/
565
-		elseif ( !empty( $template[$default_template_dir][$part] ) && !empty( $template[$default_template_dir][$part][$template_part] ) ) {
565
+		elseif (!empty($template[$default_template_dir][$part]) && !empty($template[$default_template_dir][$part][$template_part])) {
566 566
 			$tpl_element_to_return = $template[$default_template_dir][$part][$template_part];
567 567
 		}
568 568
 
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
 		$feed['CURRENCY'] = wpshop_tools::wpshop_get_currency();
583 583
 		$feed['CURRENCY_CHOOSEN'] = wpshop_tools::wpshop_get_currency();
584 584
 		$feed['CURRENCY_SELECTOR'] = wpshop_attributes_unit::wpshop_shop_currency_list_field();
585
-		$feed['CART_LINK'] = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_cart_page_id') ) );
585
+		$feed['CART_LINK'] = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')));
586 586
 
587 587
 		$available_key = array();
588 588
 		foreach ($feed as $element => $value) {
589
-			$available_key[] = '{WPSHOP_'.$element.'}';
590
-			if ( !is_array($value) ) {
591
-				$template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill);
589
+			$available_key[] = '{WPSHOP_' . $element . '}';
590
+			if (!is_array($value)) {
591
+				$template_to_fill = str_replace('{WPSHOP_' . $element . '}', $value, $template_to_fill);
592 592
 			}
593 593
 		}
594 594
 		if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill;
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 * @param boolean $force_replacement Define if we overwrite in all case or just if it not exist
603 603
 	 */
604
-	public static function check_template_file( $force_replacement = false ) {
604
+	public static function check_template_file($force_replacement = false) {
605 605
 		$wpshop_directory = get_stylesheet_directory() . '/wpshop';
606 606
 
607 607
 		/*	Add different file template	*/
608
-		if(!is_dir($wpshop_directory)){
608
+		if (!is_dir($wpshop_directory)) {
609 609
 			@mkdir($wpshop_directory, 0755, true);
610 610
 		}
611 611
 		/* On s'assure que le dossier principal est bien en 0755	*/
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		$upload_dir = wp_upload_dir();
614 614
 
615 615
 		/*	Add the category template	*/
616
-		if(!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)){
616
+		if (!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)) {
617 617
 			@copy(WPSHOP_TEMPLATES_DIR . 'taxonomy-wpshop_product_category.php', get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php');
618 618
 		}
619 619
 	}
@@ -631,29 +631,29 @@  discard block
 block discarded – undo
631 631
 		/*	Check if user is on taxonomy edition page	*/
632 632
 		if ($pagenow == 'edit-tags.php') {
633 633
 
634
-			if(!user_can_richedit()) { return; }
634
+			if (!user_can_richedit()) { return; }
635 635
 
636 636
 			$taxonomies = get_taxonomies();
637 637
 
638 638
 			foreach ($taxonomies as $tax) {
639
-				if ( in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES)) ) {
640
-					add_action($tax . '_edit_form_fields', array('wpshop_display','wpshop_add_form'));
641
-					add_action($tax . '_add_form_fields', array('wpshop_display','wpshop_add_form'));
639
+				if (in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES))) {
640
+					add_action($tax . '_edit_form_fields', array('wpshop_display', 'wpshop_add_form'));
641
+					add_action($tax . '_add_form_fields', array('wpshop_display', 'wpshop_add_form'));
642 642
 				}
643 643
 			}
644 644
 
645 645
 			if ($pagenow == 'edit-tags.php' && isset($_REQUEST['action']) && sanitize_key($_REQUEST['action']) == 'edit' && empty($_REQUEST['taxonomy'])) {
646
-				add_action('edit_term',array('wpshop_display','wpshop_rt_taxonomy_save'));
646
+				add_action('edit_term', array('wpshop_display', 'wpshop_rt_taxonomy_save'));
647 647
 			}
648 648
 
649
-			foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
650
-				remove_filter( $filter, 'wp_filter_kses' );
649
+			foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) {
650
+				remove_filter($filter, 'wp_filter_kses');
651 651
 			}
652 652
 
653 653
 		}
654 654
 
655 655
 		/*	Enable shortcodes in category, taxonomy, tag descriptions */
656
-		if(function_exists('term_description')) {
656
+		if (function_exists('term_description')) {
657 657
 			add_filter('term_description', 'do_shortcode');
658 658
 		}
659 659
 		else {
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 
670 670
 		$a = array('description');
671 671
 		foreach ($a as $v) {
672
-			$term = (array) $_POST[$v];
673
-			wp_update_term($tag_ID,$v,$term);
672
+			$term = (array)$_POST[$v];
673
+			wp_update_term($tag_ID, $v, $term);
674 674
 		}
675 675
 	}
676 676
 
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
 	public static function wpshop_add_form($object = '') {
683 683
 		global $pagenow;
684 684
 
685
-		$content = is_object($object) && isset($object->description) ? ( html_entity_decode( $object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ) : '';
685
+		$content = is_object($object) && isset($object->description) ? (html_entity_decode($object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8')) : '';
686 686
 
687
-		if( in_array($pagenow, array('edit-tags.php')) ) {
687
+		if (in_array($pagenow, array('edit-tags.php'))) {
688 688
 			$editor_id = 'tag_description';
689 689
 			$editor_selector = 'description';
690 690
 		}
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 
731 731
 	public static function wps_hide_admin_bar_for_customers() {
732 732
 		$wpshop_hide_admin_bar_option = get_option('wpshop_display_option');
733
-		if ( !empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && ! current_user_can( 'manage_options' ) ) {
734
-			show_admin_bar( false );
733
+		if (!empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && !current_user_can('manage_options')) {
734
+			show_admin_bar(false);
735 735
 		}
736 736
 	}
737 737
 
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	 * @param string $content The content of a post
746 746
 	 * @return Ambigous <mixed, string>|unknown
747 747
 	 */
748
-	public static function products_page( $content = '' ) {
748
+	public static function products_page($content = '') {
749 749
 		global $wp_query;
750 750
 
751 751
 		if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) {
@@ -764,20 +764,20 @@  discard block
 block discarded – undo
764 764
 	 *
765 765
 	 * @return string The formated value
766 766
 	 */
767
-	public static function format_field_output( $output_type, $value ) {
767
+	public static function format_field_output($output_type, $value) {
768 768
 		$formated_value = $value;
769 769
 
770
-		if ( !empty($value) ) {
771
-			switch ( $output_type ) {
770
+		if (!empty($value)) {
771
+			switch ($output_type) {
772 772
 				case 'wpshop_product_price':
773
-					$formated_value = (is_numeric($value) ) ? number_format($value, 2, ',', '') : $value;
773
+					$formated_value = (is_numeric($value)) ? number_format($value, 2, ',', '') : $value;
774 774
 					$formated_value_content = explode(',', $formated_value);
775
-					if ( !empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0 ) {
775
+					if (!empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0) {
776 776
 						$formated_value = $formated_value_content[0];
777 777
 					}
778 778
 				break;
779 779
 				case 'date':
780
-					$formated_value = mysql2date('d/F/Y', $value, true);;
780
+					$formated_value = mysql2date('d/F/Y', $value, true); ;
781 781
 				break;
782 782
 			}
783 783
 		}
Please login to merge, or discard this patch.
includes/librairies/display/form.class.php 4 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	*	@param string $method The default method for the form Default is set to post
31 31
 	*	@param string $action The default action for the form Default is set to empty
32 32
 	*
33
-	*	@return mixed $the_form The complete html output of the form
33
+	*	@return string $the_form The complete html output of the form
34 34
 	*/
35 35
 	function form($name, $input_list, $method = 'post', $action = ''){
36 36
 		$the_form_content_hidden = $the_form_content = '';
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	*	@param string $type The input type Could be: text or hidden or passowrd
130 130
 	*	@param string $option Allows to define options for the input Could be readonly or disabled or style
131 131
 	*
132
-	*	@return mixed The output code to add to the form
132
+	*	@return string The output code to add to the form
133 133
 	*/
134 134
 	public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){
135 135
 		$allowedType = array('text', 'hidden', 'password', 'file');
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	*	@param mixed $value The default value for the field Default is empty
153 153
 	*	@param string $option Allows to define options for the input Could be maxlength or style
154 154
 	*
155
-	*	@return mixed The output code to add to the form
155
+	*	@return string The output code to add to the form
156 156
 	*/
157 157
 	public static function form_input_textarea($name, $id, $value = '', $option = '')
158 158
 	{
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	*	@param mixed $value The selected value for the field Default is empty
168 168
 	*	@param string $option Allows to define options for the input Could be onchange
169 169
 	*
170
-	*	@return mixed $output The output code to add to the form
170
+	*	@return string $output The output code to add to the form
171 171
 	*/
172 172
 	public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){
173 173
 		global $comboxOptionToHide;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	*	@param mixed $value The selected value for the field Default is empty
216 216
 	*	@param string $option Allows to define options for the input Could be onchange
217 217
 	*
218
-	*	@return mixed $output The output code to add to the form
218
+	*	@return string $output The output code to add to the form
219 219
 	*/
220 220
 	public static function form_input_multiple_select($name, $id, $content, $value = array(), $option = '', $optionValue = '') {
221 221
 		global $comboxOptionToHide;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	*	@param mixed $value The selected value for the field Default is empty
259 259
 	*	@param string $option Allows to define options for the input Could be onchange
260 260
 	*
261
-	*	@return mixed $output The output code to add to the form
261
+	*	@return string $output The output code to add to the form
262 262
 	*/
263 263
 	public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){
264 264
 		$output = '';
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 class wpshop_form {
24 24
 
25 25
 	/**
26
-	*	Create The complete form by defining the form open and close and call the different function that allows to create the different type of input
27
-	*
28
-	*	@param string $name The name of the form
29
-	*	@param array $input_list The list build by the database class' function that get the type of a table
30
-	*	@param string $method The default method for the form Default is set to post
31
-	*	@param string $action The default action for the form Default is set to empty
32
-	*
33
-	*	@return mixed $the_form The complete html output of the form
34
-	*/
26
+	 *	Create The complete form by defining the form open and close and call the different function that allows to create the different type of input
27
+	 *
28
+	 *	@param string $name The name of the form
29
+	 *	@param array $input_list The list build by the database class' function that get the type of a table
30
+	 *	@param string $method The default method for the form Default is set to post
31
+	 *	@param string $action The default action for the form Default is set to empty
32
+	 *
33
+	 *	@return mixed $the_form The complete html output of the form
34
+	 */
35 35
 	function form($name, $input_list, $method = 'post', $action = ''){
36 36
 		$the_form_content_hidden = $the_form_content = '';
37 37
 		foreach ($input_list as $input_key => $input_def) {
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	*	Check the input type
72
-	*
73
-	*	@param array $input_def The input definition
74
-	*
75
-	*	@return string $the_input
76
-	*/
71
+	 *	Check the input type
72
+	 *
73
+	 *	@param array $input_def The input definition
74
+	 *
75
+	 *	@return string $the_input
76
+	 */
77 77
 	public static function check_input_type($input_def, $input_domain = '') {
78 78
 
79 79
 		$input_option = '';
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 	/**
125
-	*	Create an input type text or hidden or password
126
-	*
127
-	*	@param string $name The name of the field given by the database
128
-	*	@param mixed $value The default value for the field Default is empty
129
-	*	@param string $type The input type Could be: text or hidden or passowrd
130
-	*	@param string $option Allows to define options for the input Could be readonly or disabled or style
131
-	*
132
-	*	@return mixed The output code to add to the form
133
-	*/
125
+	 *	Create an input type text or hidden or password
126
+	 *
127
+	 *	@param string $name The name of the field given by the database
128
+	 *	@param mixed $value The default value for the field Default is empty
129
+	 *	@param string $type The input type Could be: text or hidden or passowrd
130
+	 *	@param string $option Allows to define options for the input Could be readonly or disabled or style
131
+	 *
132
+	 *	@return mixed The output code to add to the form
133
+	 */
134 134
 	public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){
135 135
 		$allowedType = array('text', 'hidden', 'password', 'file');
136 136
 		if(in_array($type, $allowedType))
@@ -146,29 +146,29 @@  discard block
 block discarded – undo
146 146
 	}
147 147
 
148 148
 	/**
149
-	*	Create an textarea
150
-	*
151
-	*	@param string $name The name of the field given by the database
152
-	*	@param mixed $value The default value for the field Default is empty
153
-	*	@param string $option Allows to define options for the input Could be maxlength or style
154
-	*
155
-	*	@return mixed The output code to add to the form
156
-	*/
149
+	 *	Create an textarea
150
+	 *
151
+	 *	@param string $name The name of the field given by the database
152
+	 *	@param mixed $value The default value for the field Default is empty
153
+	 *	@param string $option Allows to define options for the input Could be maxlength or style
154
+	 *
155
+	 *	@return mixed The output code to add to the form
156
+	 */
157 157
 	public static function form_input_textarea($name, $id, $value = '', $option = '')
158 158
 	{
159 159
 		return '<textarea name="' . $name.'" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>';
160 160
 	}
161 161
 
162 162
 	/**
163
-	*	Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object
164
-	*
165
-	*	@param string $name The name of the field given by the database
166
-	*	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
167
-	*	@param mixed $value The selected value for the field Default is empty
168
-	*	@param string $option Allows to define options for the input Could be onchange
169
-	*
170
-	*	@return mixed $output The output code to add to the form
171
-	*/
163
+	 *	Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object
164
+	 *
165
+	 *	@param string $name The name of the field given by the database
166
+	 *	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
167
+	 *	@param mixed $value The selected value for the field Default is empty
168
+	 *	@param string $option Allows to define options for the input Could be onchange
169
+	 *
170
+	 *	@return mixed $output The output code to add to the form
171
+	 */
172 172
 	public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){
173 173
 		global $comboxOptionToHide;
174 174
 
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 	}
209 209
 
210 210
 	/**
211
-	*	Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object
212
-	*
213
-	*	@param string $name The name of the field given by the database
214
-	*	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
215
-	*	@param mixed $value The selected value for the field Default is empty
216
-	*	@param string $option Allows to define options for the input Could be onchange
217
-	*
218
-	*	@return mixed $output The output code to add to the form
219
-	*/
211
+	 *	Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object
212
+	 *
213
+	 *	@param string $name The name of the field given by the database
214
+	 *	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
215
+	 *	@param mixed $value The selected value for the field Default is empty
216
+	 *	@param string $option Allows to define options for the input Could be onchange
217
+	 *
218
+	 *	@return mixed $output The output code to add to the form
219
+	 */
220 220
 	public static function form_input_multiple_select($name, $id, $content, $value = array(), $option = '', $optionValue = '') {
221 221
 		global $comboxOptionToHide;
222 222
 		$values = array();
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 	/**
252
-	*	Create a checkbox input
253
-	*
254
-	*	@param string $name The name of the field given by the database
255
-	*	@param string $id The identifier of the field
256
-	*	@param string $type The input type Could be checkbox or radio
257
-	*	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
258
-	*	@param mixed $value The selected value for the field Default is empty
259
-	*	@param string $option Allows to define options for the input Could be onchange
260
-	*
261
-	*	@return mixed $output The output code to add to the form
262
-	*/
252
+	 *	Create a checkbox input
253
+	 *
254
+	 *	@param string $name The name of the field given by the database
255
+	 *	@param string $id The identifier of the field
256
+	 *	@param string $type The input type Could be checkbox or radio
257
+	 *	@param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field
258
+	 *	@param mixed $value The selected value for the field Default is empty
259
+	 *	@param string $option Allows to define options for the input Could be onchange
260
+	 *
261
+	 *	@return mixed $output The output code to add to the form
262
+	 */
263 263
 	public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){
264 264
 		$output = '';
265 265
 		$allowedType = array('checkbox', 'radio');
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	*
33 33
 	*	@return mixed $the_form The complete html output of the form
34 34
 	*/
35
-	function form($name, $input_list, $method = 'post', $action = ''){
35
+	function form($name, $input_list, $method = 'post', $action = '') {
36 36
 		$the_form_content_hidden = $the_form_content = '';
37 37
 		foreach ($input_list as $input_key => $input_def) {
38 38
 			$the_input = self::check_input_type($input_def);
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 			$input_value = $input_def['value'];
41 41
 			$input_type = $input_def['type'];
42 42
 
43
-			if($input_type != 'hidden')
43
+			if ($input_type != 'hidden')
44 44
 			{
45 45
 				$label = 'for="' . $input_name . '"';
46
-				if(($input_type == 'radio') || ($input_type == 'checkbox'))
46
+				if (($input_type == 'radio') || ($input_type == 'checkbox'))
47 47
 				{
48 48
 					$label = '';
49 49
 				}
@@ -77,45 +77,45 @@  discard block
 block discarded – undo
77 77
 	public static function check_input_type($input_def, $input_domain = '') {
78 78
 
79 79
 		$input_option = '';
80
-		if(!empty($input_def['option']) && $input_def['option'])
80
+		if (!empty($input_def['option']) && $input_def['option'])
81 81
 			$input_option = $input_def['option'];
82 82
 
83 83
 		$valueToPut = '';
84
-		if(!empty($input_def['valueToPut']) && $input_def['valueToPut'])
84
+		if (!empty($input_def['valueToPut']) && $input_def['valueToPut'])
85 85
 			$valueToPut = $input_def['valueToPut'];
86 86
 
87 87
 		$input_id = $input_def['name'];
88
-		if(!empty($input_def['id']))
88
+		if (!empty($input_def['id']))
89 89
 			$input_id = $input_def['id'];
90 90
 
91 91
 		$input_name = $input_def['name'];
92
-		if($input_domain != '')
92
+		if ($input_domain != '')
93 93
 			$input_name = $input_domain . '[' . $input_def['name'] . ']';
94 94
 		/**	Format data for saving without special chars	*/
95
-		if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value']))
96
-			$input_value = str_replace('.',',',$input_def['value']/* /1 */); // format francais avec virgule
95
+		if (!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value']))
96
+			$input_value = str_replace('.', ',', $input_def['value']/* /1 */); // format francais avec virgule
97 97
 		else $input_value = (!empty($input_def['value']) ? $input_def['value'] : '');
98 98
 
99 99
 		$input_type = $input_def['type'];
100 100
 		$the_input = '';
101 101
 
102
-		if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) )
103
-			$the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') );
104
-		elseif($input_type == 'password')
102
+		if (($input_type == 'text') || ($input_type == 'email') || ($input_type == 'tel'))
103
+			$the_input .= self::form_input($input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : ''));
104
+		elseif ($input_type == 'password')
105 105
 			$the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option);
106
-		elseif($input_type == 'textarea')
106
+		elseif ($input_type == 'textarea')
107 107
 			$the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option);
108
-		elseif($input_type == 'hidden')
108
+		elseif ($input_type == 'hidden')
109 109
 			$the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option);
110
-		elseif($input_type == 'select')
111
-			$the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
112
-		elseif($input_type == 'multiple-select')
113
-			$the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
114
-		elseif(($input_type == 'radio') || ($input_type == 'checkbox'))
115
-			$the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : ''));
116
-		elseif($input_type == 'file')
110
+		elseif ($input_type == 'select')
111
+			$the_input .= self::form_input_select($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_option, $valueToPut);
112
+		elseif ($input_type == 'multiple-select')
113
+			$the_input .= self::form_input_multiple_select($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_option, $valueToPut);
114
+		elseif (($input_type == 'radio') || ($input_type == 'checkbox'))
115
+			$the_input .= self::form_input_check($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : ''));
116
+		elseif ($input_type == 'file')
117 117
 			$the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option);
118
-		elseif($input_type == 'gallery')
118
+		elseif ($input_type == 'gallery')
119 119
 			$the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check';
120 120
 
121 121
 		return $the_input;
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	*
132 132
 	*	@return mixed The output code to add to the form
133 133
 	*/
134
-	public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){
134
+	public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = '') {
135 135
 		$allowedType = array('text', 'hidden', 'password', 'file');
136
-		if(in_array($type, $allowedType))
136
+		if (in_array($type, $allowedType))
137 137
 		{
138
-			$output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />' ;
138
+			$output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />';
139 139
 		}
140 140
 		else
141 141
 		{
142 142
 			return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__);
143 143
 		}
144
-		$output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':'');
144
+		$output .= (is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">' . $input_label['custom'] . '</label> ' : '');
145 145
 		return $output;
146 146
 	}
147 147
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	*/
157 157
 	public static function form_input_textarea($name, $id, $value = '', $option = '')
158 158
 	{
159
-		return '<textarea name="' . $name.'" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>';
159
+		return '<textarea name="' . $name . '" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>';
160 160
 	}
161 161
 
162 162
 	/**
@@ -169,38 +169,38 @@  discard block
 block discarded – undo
169 169
 	*
170 170
 	*	@return mixed $output The output code to add to the form
171 171
 	*/
172
-	public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){
172
+	public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = '') {
173 173
 		global $comboxOptionToHide;
174 174
 
175 175
 		$output = '<select id="' . $id . '" name="' . $name . '" ' . $option . ' data-placeholder="' . __('Select an Option', 'wpshop') . '" >';
176 176
 
177
-		if(is_array($content) && (count($content) > 0)){
178
-			foreach($content as $index => $datas){
179
-				if(is_object($datas) && (!is_array($comboxOptionToHide) || !in_array($datas->id, $comboxOptionToHide))){
177
+		if (is_array($content) && (count($content) > 0)) {
178
+			foreach ($content as $index => $datas) {
179
+				if (is_object($datas) && (!is_array($comboxOptionToHide) || !in_array($datas->id, $comboxOptionToHide))) {
180 180
 
181 181
 					$selected = ($value == $datas->id) ? ' selected="selected" ' : '';
182 182
 
183
-					$dataText = __('Nothing to output' ,'wpshop');
184
-					if(isset($datas->name))
185
-						$dataText = __($datas->name ,'wpshop');
186
-					elseif(isset($datas->code))
187
-						$dataText = __($datas->code ,'wpshop');
183
+					$dataText = __('Nothing to output', 'wpshop');
184
+					if (isset($datas->name))
185
+						$dataText = __($datas->name, 'wpshop');
186
+					elseif (isset($datas->code))
187
+						$dataText = __($datas->code, 'wpshop');
188 188
 
189
-					$output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText. '</option>';
189
+					$output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText . '</option>';
190 190
 				}
191
-				elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){
191
+				elseif (!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)) {
192 192
 					$valueToPut = $datas;
193 193
 					$selected = ($value == $datas) ? ' selected="selected" ' : '';
194
-					if($optionValue == 'index'){
194
+					if ($optionValue == 'index') {
195 195
 						$valueToPut = $index;
196 196
 						$selected = ($value == $index) ? ' selected="selected" ' : '';
197 197
 					}
198
-					$output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas ,'wpshop') . '</option>';
198
+					$output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas, 'wpshop') . '</option>';
199 199
 				}
200 200
 			}
201 201
 		}
202 202
 		else
203
-			$output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>';
203
+			$output .= '<option value="" >' . __('Nothing found here...', 'wpshop') . '</option>';
204 204
 
205 205
 			$output .= '</select>';
206 206
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$values = array();
223 223
 
224 224
 		if (!empty($value) && (is_array($value))) {
225
-			foreach($value as $v) {
225
+			foreach ($value as $v) {
226 226
 				$values[] = $v->value;
227 227
 			}
228 228
 		}
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 		if (is_array($content) && (count($content) > 0)) {
235 235
 			$output = '<select id="' . $id . '" name="' . $name . '[]" ' . $option . ' multiple size="4" data-placeholder="' . __('Select values from list', 'wpshop') . '" >';
236 236
 
237
-			foreach($content as $index => $datas) {
238
-				if ( !empty($datas) && !empty($index) ) {
237
+			foreach ($content as $index => $datas) {
238
+				if (!empty($datas) && !empty($index)) {
239 239
 					$selected = in_array($index, $values) ? ' selected="selected" ' : '';
240 240
 
241 241
 					$output .= '<option value="' . $index . '" ' . $selected . ' >' . $datas . '</option>';
@@ -260,41 +260,41 @@  discard block
 block discarded – undo
260 260
 	*
261 261
 	*	@return mixed $output The output code to add to the form
262 262
 	*/
263
-	public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){
263
+	public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label = '') {
264 264
 		$output = '';
265 265
 		$allowedType = array('checkbox', 'radio');
266 266
 		$container_start = (isset($input_label['container']) && $input_label['container'] ? '<div class="wpshop_input_' . $type . ' wpshop_input_' . $type . '_' . $id . '" >' : '');
267 267
 		$container_end = (isset($input_label['container']) && $input_label['container'] ? '</div>' : '');
268 268
 
269
-		if(in_array($type, $allowedType)){
270
-			if(is_array($content) && (count($content) > 0)){
271
-				foreach($content as $index => $datas){
272
-					if(is_object($datas)){
269
+		if (in_array($type, $allowedType)) {
270
+			if (is_array($content) && (count($content) > 0)) {
271
+				foreach ($content as $index => $datas) {
272
+					if (is_object($datas)) {
273 273
 						$id = $name . '_' . sanitize_title($datas->nom);
274 274
 						$checked = ($value == $datas->id) ? ' checked="checked" ' : '';
275 275
 					}
276
-					else{
276
+					else {
277 277
 
278 278
 						$valueToPut = $datas;
279
-						$checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
280
-						if($optionValue == 'index'){
279
+						$checked = (($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
280
+						if ($optionValue == 'index') {
281 281
 							$valueToPut = $index;
282
-							$checked = ( ($value == $index) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
282
+							$checked = (($value == $index) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
283 283
 						}
284 284
 
285 285
 						$id = $id . '_' . sanitize_title($datas);
286 286
 // 						$checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
287
-						$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />'.(!empty($input_label['original'])?'<label for="' . $id . '">'.__($datas,'wpshop').'</label>&nbsp;':'')  . $container_end ;
287
+						$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />' . (!empty($input_label['original']) ? '<label for="' . $id . '">' . __($datas, 'wpshop') . '</label>&nbsp;' : '') . $container_end;
288 288
 					}
289 289
 				}
290 290
 			}
291
-			else{
291
+			else {
292 292
 				$checked = (($value != '') && ($value == $content)) ? ' checked="checked" ' : '';
293
-				$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start ;
293
+				$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start;
294 294
 			}
295
-			$output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':'');
295
+			$output .= (is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">' . $input_label['custom'] . '</label> ' : '');
296 296
 
297
-			if ( isset($input_label['container']) && $input_label['container'] ) $output .= '<div class="wpshop_cls" ></div>';
297
+			if (isset($input_label['container']) && $input_label['container']) $output .= '<div class="wpshop_cls" ></div>';
298 298
 			return $output;
299 299
 		}
300 300
 		else
Please login to merge, or discard this patch.
Braces   +59 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -52,8 +54,7 @@  discard block
 block discarded – undo
52 54
 	<label ' . $label . ' >' . __($input_name, 'wpshop') . '</label>&nbsp;:&nbsp;
53 55
 	' . $the_input . '
54 56
 </div>';
55
-			}
56
-			else
57
+			} else
57 58
 			{
58 59
 				$the_form_content_hidden .= '
59 60
 	' . $the_input;
@@ -77,46 +78,55 @@  discard block
 block discarded – undo
77 78
 	public static function check_input_type($input_def, $input_domain = '') {
78 79
 
79 80
 		$input_option = '';
80
-		if(!empty($input_def['option']) && $input_def['option'])
81
-			$input_option = $input_def['option'];
81
+		if(!empty($input_def['option']) && $input_def['option']) {
82
+					$input_option = $input_def['option'];
83
+		}
82 84
 
83 85
 		$valueToPut = '';
84
-		if(!empty($input_def['valueToPut']) && $input_def['valueToPut'])
85
-			$valueToPut = $input_def['valueToPut'];
86
+		if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) {
87
+					$valueToPut = $input_def['valueToPut'];
88
+		}
86 89
 
87 90
 		$input_id = $input_def['name'];
88
-		if(!empty($input_def['id']))
89
-			$input_id = $input_def['id'];
91
+		if(!empty($input_def['id'])) {
92
+					$input_id = $input_def['id'];
93
+		}
90 94
 
91 95
 		$input_name = $input_def['name'];
92
-		if($input_domain != '')
93
-			$input_name = $input_domain . '[' . $input_def['name'] . ']';
96
+		if($input_domain != '') {
97
+					$input_name = $input_domain . '[' . $input_def['name'] . ']';
98
+		}
94 99
 		/**	Format data for saving without special chars	*/
95
-		if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value']))
96
-			$input_value = str_replace('.',',',$input_def['value']/* /1 */); // format francais avec virgule
97
-		else $input_value = (!empty($input_def['value']) ? $input_def['value'] : '');
100
+		if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) {
101
+					$input_value = str_replace('.',',',$input_def['value']/* /1 */);
102
+		}
103
+		// format francais avec virgule
104
+		else {
105
+			$input_value = (!empty($input_def['value']) ? $input_def['value'] : '');
106
+		}
98 107
 
99 108
 		$input_type = $input_def['type'];
100 109
 		$the_input = '';
101 110
 
102
-		if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) )
103
-			$the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') );
104
-		elseif($input_type == 'password')
105
-			$the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option);
106
-		elseif($input_type == 'textarea')
107
-			$the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option);
108
-		elseif($input_type == 'hidden')
109
-			$the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option);
110
-		elseif($input_type == 'select')
111
-			$the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
112
-		elseif($input_type == 'multiple-select')
113
-			$the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
114
-		elseif(($input_type == 'radio') || ($input_type == 'checkbox'))
115
-			$the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : ''));
116
-		elseif($input_type == 'file')
117
-			$the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option);
118
-		elseif($input_type == 'gallery')
119
-			$the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check';
111
+		if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) {
112
+					$the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') );
113
+		} elseif($input_type == 'password') {
114
+					$the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option);
115
+		} elseif($input_type == 'textarea') {
116
+					$the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option);
117
+		} elseif($input_type == 'hidden') {
118
+					$the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option);
119
+		} elseif($input_type == 'select') {
120
+					$the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
121
+		} elseif($input_type == 'multiple-select') {
122
+					$the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut);
123
+		} elseif(($input_type == 'radio') || ($input_type == 'checkbox')) {
124
+					$the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : ''));
125
+		} elseif($input_type == 'file') {
126
+					$the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option);
127
+		} elseif($input_type == 'gallery') {
128
+					$the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check';
129
+		}
120 130
 
121 131
 		return $the_input;
122 132
 	}
@@ -136,8 +146,7 @@  discard block
 block discarded – undo
136 146
 		if(in_array($type, $allowedType))
137 147
 		{
138 148
 			$output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />' ;
139
-		}
140
-		else
149
+		} else
141 150
 		{
142 151
 			return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__);
143 152
 		}
@@ -181,14 +190,14 @@  discard block
 block discarded – undo
181 190
 					$selected = ($value == $datas->id) ? ' selected="selected" ' : '';
182 191
 
183 192
 					$dataText = __('Nothing to output' ,'wpshop');
184
-					if(isset($datas->name))
185
-						$dataText = __($datas->name ,'wpshop');
186
-					elseif(isset($datas->code))
187
-						$dataText = __($datas->code ,'wpshop');
193
+					if(isset($datas->name)) {
194
+											$dataText = __($datas->name ,'wpshop');
195
+					} elseif(isset($datas->code)) {
196
+											$dataText = __($datas->code ,'wpshop');
197
+					}
188 198
 
189 199
 					$output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText. '</option>';
190
-				}
191
-				elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){
200
+				} elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){
192 201
 					$valueToPut = $datas;
193 202
 					$selected = ($value == $datas) ? ' selected="selected" ' : '';
194 203
 					if($optionValue == 'index'){
@@ -198,9 +207,9 @@  discard block
 block discarded – undo
198 207
 					$output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas ,'wpshop') . '</option>';
199 208
 				}
200 209
 			}
210
+		} else {
211
+					$output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>';
201 212
 		}
202
-		else
203
-			$output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>';
204 213
 
205 214
 			$output .= '</select>';
206 215
 
@@ -225,8 +234,7 @@  discard block
 block discarded – undo
225 234
 			foreach($value as $v) {
226 235
 				$values[] = $v->value;
227 236
 			}
228
-		}
229
-		else {
237
+		} else {
230 238
 			$values = (array)$value;
231 239
 		}
232 240
 
@@ -272,8 +280,7 @@  discard block
 block discarded – undo
272 280
 					if(is_object($datas)){
273 281
 						$id = $name . '_' . sanitize_title($datas->nom);
274 282
 						$checked = ($value == $datas->id) ? ' checked="checked" ' : '';
275
-					}
276
-					else{
283
+					} else{
277 284
 
278 285
 						$valueToPut = $datas;
279 286
 						$checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : '';
@@ -287,18 +294,19 @@  discard block
 block discarded – undo
287 294
 						$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />'.(!empty($input_label['original'])?'<label for="' . $id . '">'.__($datas,'wpshop').'</label>&nbsp;':'')  . $container_end ;
288 295
 					}
289 296
 				}
290
-			}
291
-			else{
297
+			} else{
292 298
 				$checked = (($value != '') && ($value == $content)) ? ' checked="checked" ' : '';
293 299
 				$output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start ;
294 300
 			}
295 301
 			$output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':'');
296 302
 
297
-			if ( isset($input_label['container']) && $input_label['container'] ) $output .= '<div class="wpshop_cls" ></div>';
303
+			if ( isset($input_label['container']) && $input_label['container'] ) {
304
+				$output .= '<div class="wpshop_cls" ></div>';
305
+			}
298 306
 			return $output;
307
+		} else {
308
+					return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__);
299 309
 		}
300
-		else
301
-			return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__);
302 310
 	}
303 311
 
304 312
 }
305 313
\ No newline at end of file
Please login to merge, or discard this patch.