Completed
Pull Request — master (#2)
by Jimmy
1075:13 queued 1053:53
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/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.
includes/librairies/display/form_management.class.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -26,6 +26,7 @@
 block discarded – undo
26 26
 
27 27
 	/**
28 28
 	* Add an error
29
+	* @param string $error
29 30
 	*/
30 31
 	function add_error( $error ) {
31 32
 		$this->errors[] = $error;
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
 	var $messages = array(); // Stores store messages
26 26
 
27 27
 	/**
28
-	* Add an error
29
-	*/
28
+	 * Add an error
29
+	 */
30 30
 	function add_error( $error ) {
31 31
 		$this->errors[] = $error;
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Add a message
36
-	*/
35
+	 * Add a message
36
+	 */
37 37
 	function add_message( $message ) {
38 38
 		$this->messages[] = $message;
39 39
 	}
40 40
 
41 41
 	/**
42
-	* Get error count
43
-	*/
42
+	 * Get error count
43
+	 */
44 44
 	function error_count() {
45 45
 		return sizeof($this->errors);
46 46
 	}
47 47
 
48 48
 	/**
49
-	* Get message count
50
-	*/
49
+	 * Get message count
50
+	 */
51 51
 	function message_count() {
52 52
 		return sizeof($this->messages);
53 53
 	}
54 54
 
55 55
 	/**
56
-	* Output the errors and messages
57
-	*/
56
+	 * Output the errors and messages
57
+	 */
58 58
 	function show_messages() {
59 59
 		if (!empty($this->errors) && $this->error_count()>0) :
60 60
 			$message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>';
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 
71 71
 	/** Valide les champs d'un formlaire
72
-	* @param array $array : Champs a lire
73
-	* @return boolean
74
-	*/
72
+	 * @param array $array : Champs a lire
73
+	 * @return boolean
74
+	 */
75 75
 	function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) {
76 76
 	
77 77
 		
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 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' ) ) {
@@ -63,8 +65,10 @@  discard block
 block discarded – undo
63 65
 			}
64 66
 			$message .= '</ul></div>';
65 67
 			return $message;
66
-		else :
68
+		else {
69
+			:
67 70
 			return null;
71
+		}
68 72
 		endif;
69 73
 	}
70 74
 
@@ -96,8 +100,7 @@  discard block
 block discarded – undo
96 100
 						$email_exist = email_exists($value);
97 101
 						if(!is_email($value)) {
98 102
 							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),$attribute_definition['label']));
99
-						}
100
-						elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) {
103
+						} elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) {
101 104
 							$this->add_error(__('An account is already registered with your email address. Please login.', 'wpshop'));
102 105
 						}
103 106
 					break;
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	* Add an error
29 29
 	*/
30
-	function add_error( $error ) {
30
+	function add_error($error) {
31 31
 		$this->errors[] = $error;
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	* Add a message
36 36
 	*/
37
-	function add_message( $message ) {
37
+	function add_message($message) {
38 38
 		$this->messages[] = $message;
39 39
 	}
40 40
 
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	* Output the errors and messages
57 57
 	*/
58 58
 	function show_messages() {
59
-		if (!empty($this->errors) && $this->error_count()>0) :
60
-			$message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>';
61
-			foreach($this->errors as $e) {
62
-				$message .= '<li>'.$e.'</li>';
59
+		if (!empty($this->errors) && $this->error_count() > 0) :
60
+			$message = '<div class="error_bloc">' . __('Errors were detected', 'wpshop') . ' :<ul>';
61
+			foreach ($this->errors as $e) {
62
+				$message .= '<li>' . $e . '</li>';
63 63
 			}
64 64
 			$message .= '</ul></div>';
65 65
 			return $message;
@@ -75,42 +75,42 @@  discard block
 block discarded – undo
75 75
 	function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) {
76 76
 	
77 77
 		
78
-		$user_id = empty( $user ) ? get_current_user_id() : $user;
79
-		foreach($array as $attribute_id => $attribute_definition):
80
-			$values_array = !empty($values) ? $values : (array) $_POST['attribute'];
81
-			$value = ( !empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']]) ) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : '';
78
+		$user_id = empty($user) ? get_current_user_id() : $user;
79
+		foreach ($array as $attribute_id => $attribute_definition):
80
+			$values_array = !empty($values) ? $values : (array)$_POST['attribute'];
81
+			$value = (!empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']])) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : '';
82 82
 		
83 83
 			// Si le champ est obligatoire
84
-			if ( empty($value) && ($attribute_definition['required'] == 'yes') ) {
85
-				$this->add_error(sprintf(__('The field "%s" is required','wpshop'),__( $attribute_definition['label'], 'wpshop' ) ));
84
+			if (empty($value) && ($attribute_definition['required'] == 'yes')) {
85
+				$this->add_error(sprintf(__('The field "%s" is required', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
86 86
 			}
87
-			if( $partial == false && $attribute_definition['_need_verification'] == 'yes'  ) {
88
-				$value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'].'2'];
89
-				if ( $value != $value2) {
90
-					$this->add_error(sprintf(__('The  "%s" confirmation is incorrect','wpshop'),__($attribute_definition['label'], 'wpshop') ));
87
+			if ($partial == false && $attribute_definition['_need_verification'] == 'yes') {
88
+				$value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'] . '2'];
89
+				if ($value != $value2) {
90
+					$this->add_error(sprintf(__('The  "%s" confirmation is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
91 91
 				}
92 92
 			}
93
-			if(!empty($value) && !empty($attribute_definition['type'])) {
94
-				switch($attribute_definition['frontend_verification']) {
93
+			if (!empty($value) && !empty($attribute_definition['type'])) {
94
+				switch ($attribute_definition['frontend_verification']) {
95 95
 					case 'email':
96 96
 						$email_exist = email_exists($value);
97
-						if(!is_email($value)) {
98
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),$attribute_definition['label']));
97
+						if (!is_email($value)) {
98
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), $attribute_definition['label']));
99 99
 						}
100
-						elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) {
100
+						elseif (empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0))) {
101 101
 							$this->add_error(__('An account is already registered with your email address. Please login.', 'wpshop'));
102 102
 						}
103 103
 					break;
104 104
 
105 105
 					case 'postcode':
106
-						if(!wpshop_tools::is_postcode($value)) {
107
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),__( $attribute_definition['label'], 'wpshop' ) ));
106
+						if (!wpshop_tools::is_postcode($value)) {
107
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
108 108
 						}
109 109
 					break;
110 110
 
111 111
 					case 'phone':
112
-						if(!wpshop_tools::is_phone($value)) {
113
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'), __( $attribute_definition['label'], 'wpshop' ) ));
112
+						if (!wpshop_tools::is_phone($value)) {
113
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
114 114
 						}
115 115
 					break;
116 116
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 						$username_exists = username_exists($value);
119 119
 						// On s'assure que le nom d'utilisateur est libre
120 120
 						if (!validate_username($value)) :
121
-							$this->add_error( __('Invalid email/username.', 'wpshop') );
122
-						elseif ( ($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0) ) :
123
-							$this->add_error( __('An account is already registered with that username. Please choose another.', 'wpshop') );
121
+							$this->add_error(__('Invalid email/username.', 'wpshop'));
122
+						elseif (($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0)) :
123
+							$this->add_error(__('An account is already registered with that username. Please choose another.', 'wpshop'));
124 124
 						endif;
125 125
 					break;
126 126
 				}
127 127
 			}
128 128
 		endforeach;
129 129
 
130
-		return ($this->error_count()==0);
130
+		return ($this->error_count() == 0);
131 131
 	}
132 132
 
133 133
 }
Please login to merge, or discard this patch.