Completed
Push — master ( f161aa...d0d50d )
by
unknown
15:24
created
includes/librairies/display/form.class.php 3 patches
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/display.class.php 3 patches
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   +128 added lines, -128 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,20 +88,20 @@  discard block
 block discarded – undo
88 88
 				$pageAddButton = false;
89 89
 				$objectType = new wpshop_messages();
90 90
 				$current_user_can_edit = true;
91
-				$mid = !empty( $_GET['mid'] ) ? sanitize_text_field( $_GET['mid'] ) : '';
92
-				if(!empty($mid)){
91
+				$mid = !empty($_GET['mid']) ? sanitize_text_field($_GET['mid']) : '';
92
+				if (!empty($mid)) {
93 93
 					$action = 'edit';
94 94
 				}
95 95
 			break;
96 96
 			default:{
97
-				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ - 4));
97
+				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ -4));
98 98
 				$pageAddButton = false;
99 99
 			}
100 100
 			break;
101 101
 		}
102 102
 
103
-		if($objectType != ''){
104
-			if(($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))){
103
+		if ($objectType != '') {
104
+			if (($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))) {
105 105
 				$outputType = 'adding';
106 106
 			}
107 107
 			$objectType->elementAction();
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 			$pageIconTitle = self::getPageIconInformation('title', $objectType);
111 111
 			$pageIconAlt = self::getPageIconInformation('alt', $objectType);
112 112
 
113
-			if($outputType == 'listing'){
113
+			if ($outputType == 'listing') {
114 114
 				$pageContent = $objectType->elementList();
115 115
 			}
116
-			elseif($outputType == 'adding'){
116
+			elseif ($outputType == 'adding') {
117 117
 				$pageAddButton = false;
118 118
 
119 119
 				$pageFormButton = $objectType->getPageFormButton($objectToEdit);
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
 			$pageTitle = $objectType->pageTitle();
125 125
 			$pageMessage = $objectType->pageMessage;
126
-			if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) {
126
+			if (in_array($objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING))) {
127 127
 				$addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&amp;action=add');
128 128
 			}
129 129
 			else {
130
-				$addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
130
+				$addButtonLink = admin_url('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
131 131
 			}
132 132
 		}
133 133
 
@@ -149,37 +149,37 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string The output builded from selected type
151 151
 	 */
152
-	public static function custom_page_output_builder($content, $output_type='tab') {
152
+	public static function custom_page_output_builder($content, $output_type = 'tab') {
153 153
 		$output_custom_layout = '';
154 154
 
155
-		switch ( $output_type ) {
155
+		switch ($output_type) {
156 156
 			case 'separated_bloc':
157
-				foreach ( $content as $element_type => $element_type_details ) {
158
-					$output_custom_layout.='
159
-	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type.'" >';
160
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
161
-						$output_custom_layout.='
162
-		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >
157
+				foreach ($content as $element_type => $element_type_details) {
158
+					$output_custom_layout .= '
159
+	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type . '" >';
160
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
161
+						$output_custom_layout .= '
162
+		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >
163 163
 			<h3>' . $element_type_content['title'] . '</h3>' . $element_type_content['content'] . '
164 164
 		</div>';
165 165
 					}
166
-					$output_custom_layout.='
166
+					$output_custom_layout .= '
167 167
 	</div>';
168 168
 				}
169 169
 			break;
170 170
 			case 'tab':
171
-				$tab_list=$tab_content_list='';
172
-				foreach ( $content as $element_type => $element_type_details ) {
173
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
174
-						$tab_list.='
175
-		<li><a href="#wpshop_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['title'].'</a></li>';
176
-						$tab_content_list.='
177
-		<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'].'
171
+				$tab_list = $tab_content_list = '';
172
+				foreach ($content as $element_type => $element_type_details) {
173
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
174
+						$tab_list .= '
175
+		<li><a href="#wpshop_'.$element_type . '_' . $element_type_key . '" >' . $element_type_content['title'] . '</a></li>';
176
+						$tab_content_list .= '
177
+		<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'] . '
178 178
 		</div>';
179 179
 					}
180 180
 				}
181
-				$output_custom_layout.='
182
-	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type.'_tabs" >
181
+				$output_custom_layout .= '
182
+	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type . '_tabs" >
183 183
 		<ul>' . $tab_list . '</ul>' . $tab_content_list . '
184 184
 	</div>';
185 185
 					break;
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 *	@return string $table The html code of the table to output
203 203
 	 */
204
-	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true){
204
+	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true) {
205 205
 		$tableTitleBar = $tableBody = '';
206 206
 
207 207
 		/*	Create the header and footer row	*/
208
-		for($i=0; $i<count($tableTitles); $i++){
208
+		for ($i = 0; $i < count($tableTitles); $i++) {
209 209
 			$tableTitleBar .= '
210 210
 				<th class="' . $tableClasses[$i] . '" scope="col" >' . $tableTitles[$i] . '</th>';
211 211
 		}
212 212
 
213 213
 		/*	Create each table row	*/
214
-		for($lineNumber=0; $lineNumber<count($tableRows); $lineNumber++){
214
+		for ($lineNumber = 0; $lineNumber < count($tableRows); $lineNumber++) {
215 215
 			$tableRow = $tableRows[$lineNumber];
216 216
 			$tableBody .= '
217 217
 		<tr id="' . $tableRowsId[$lineNumber] . '" class="tableRow" >';
218
-			for($i=0; $i<count($tableRow); $i++){
218
+			for ($i = 0; $i < count($tableRow); $i++) {
219 219
 				$tableBody .= '
220 220
 			<td class="' . $tableClasses[$i] . ' ' . $tableRow[$i]['class'] . '" >' . $tableRow[$i]['value'] . '</td>';
221 221
 			}
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
 		/*	Create the table output	*/
227 227
 		$table = '
228 228
 <table id="' . $tableId . '" cellspacing="0" cellpadding="0" class="widefat post fixed" >';
229
-		if($tableTitleBar != ''){
229
+		if ($tableTitleBar != '') {
230 230
 			$table .= '
231 231
 	<thead>
232 232
 			<tr class="tableTitleHeader" >' . $tableTitleBar . '
233 233
 			</tr>
234 234
 	</thead>';
235
-			if($withFooter){
235
+			if ($withFooter) {
236 236
 				$table .= '
237 237
 	<tfoot>
238 238
 			<tr class="tableTitleFooter" >' . $tableTitleBar . '
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return string $pageIconInformation The information to output in the page
257 257
 	 */
258
-	public static function getPageIconInformation($infoType, $object){
259
-		switch($infoType){
258
+	public static function getPageIconInformation($infoType, $object) {
259
+		switch ($infoType) {
260 260
 			case 'path':
261 261
 				$pageIconInformation = $object->pageIcon;
262 262
 			break;
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return string $file_path The good filepath to include
280 280
 	 */
281
-	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false){
281
+	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false) {
282 282
 		$file_path = '';
283 283
 		$the_file = $dir_name . '/' . $file_name;
284 284
 
285 285
 		if (is_file(get_stylesheet_directory() . '/' . $the_file)) {
286 286
 			$default_dir = str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, get_stylesheet_directory());
287
-			if($usage_type == 'include'){
287
+			if ($usage_type == 'include') {
288 288
 				$default_dir = get_stylesheet_directory();
289 289
 			}
290 290
 			$file_path = $default_dir . '/' . $the_file;
291 291
 		}
292
-		else if ( !$check_only_custom ) {
292
+		else if (!$check_only_custom) {
293 293
 			$file_path = $default_dir . $the_file;
294 294
 		}
295 295
 
@@ -312,124 +312,124 @@  discard block
 block discarded – undo
312 312
 		$custom_template_part = get_stylesheet_directory() . '/' . $default_template_dir . '/';
313 313
 
314 314
 		/** Let support the old way of template managing	*/
315
-		switch ( $template_part ) {
315
+		switch ($template_part) {
316 316
 			case 'category_mini_list':
317 317
 					$old_file_to_take_care_url = 'category-mini-list.tpl.php';
318
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
318
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
319 319
 						$old_file_to_take_care = true;
320 320
 					endif;
321 321
 				break;
322 322
 			case 'category_mini_grid':
323 323
 					$old_file_to_take_care_url = 'category-mini-grid.tpl.php';
324
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
324
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
325 325
 						$old_file_to_take_care = true;
326 326
 					endif;
327 327
 				break;
328 328
 			case 'product_complete_tpl':
329 329
 					$old_file_to_take_care_url = 'product.tpl.php';
330
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
330
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
331 331
 						$old_file_to_take_care = true;
332 332
 					endif;
333 333
 				break;
334 334
 			case 'product_mini_list':
335 335
 					$old_file_to_take_care_url = 'product-mini-list.tpl.php';
336
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
336
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
337 337
 						$old_file_to_take_care = true;
338 338
 					endif;
339 339
 				break;
340 340
 			case 'product_mini_grid':
341 341
 					$old_file_to_take_care_url = 'product-mini-grid.tpl.php';
342
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
342
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
343 343
 						$old_file_to_take_care = true;
344 344
 					endif;
345 345
 				break;
346 346
 			case 'product_listing_sorting':
347 347
 					$old_file_to_take_care_url = 'product_listing_sorting.tpl.php';
348
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
348
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
349 349
 						$old_file_to_take_care = true;
350 350
 					endif;
351 351
 				break;
352 352
 			case 'unavailable_product_button':
353 353
 					$old_file_to_take_care_url = 'not_available_product_button.tpl.php';
354
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
354
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
355 355
 						$old_file_to_take_care = true;
356 356
 					endif;
357 357
 				break;
358 358
 			case 'add_to_cart_button':
359 359
 					$old_file_to_take_care_url = 'available_product_button.tpl.php';
360
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
360
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
361 361
 						$old_file_to_take_care = true;
362 362
 					endif;
363 363
 				break;
364 364
 			case 'ask_quotation_button':
365 365
 					$old_file_to_take_care_url = 'quotation_button.tpl.php';
366
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
366
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
367 367
 						$old_file_to_take_care = true;
368 368
 					endif;
369 369
 				break;
370 370
 			case 'mini_cart_content':
371 371
 					$old_file_to_take_care_url = 'wpshop_mini_cart.tpl.php';
372
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
372
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
373 373
 						$old_file_to_take_care = true;
374 374
 					endif;
375 375
 				break;
376 376
 			case 'product_is_new_sticker':
377 377
 					$old_file_to_take_care_url = 'product-is-new.tpl.php';
378
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
378
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
379 379
 						$old_file_to_take_care = true;
380 380
 					endif;
381 381
 				break;
382 382
 			case 'product_is_featured_sticker':
383 383
 					$old_file_to_take_care_url = 'product-is-featured.tpl.php';
384
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
384
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
385 385
 						$old_file_to_take_care = true;
386 386
 					endif;
387 387
 				break;
388 388
 			case 'product_attribute_container':
389 389
 					$old_file_to_take_care_url = 'product-attribute-front-display-main-container.tpl.php';
390
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
390
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
391 391
 						$old_file_to_take_care = true;
392 392
 					endif;
393 393
 				break;
394 394
 			case 'product_attribute_tabs':
395 395
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs.tpl.php';
396
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
396
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
397 397
 						$old_file_to_take_care = true;
398 398
 					endif;
399 399
 				break;
400 400
 			case 'product_attribute_tabs_detail':
401 401
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs-content.tpl.php';
402
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
402
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
403 403
 						$old_file_to_take_care = true;
404 404
 					endif;
405 405
 				break;
406 406
 			case 'product_attachment_picture_galery':
407 407
 					$old_file_to_take_care_url = 'product_picture_galery.tpl.php';
408
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
408
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
409 409
 						$old_file_to_take_care = true;
410 410
 					endif;
411 411
 				break;
412 412
 			case 'product_attachment_galery':
413 413
 					$old_file_to_take_care_url = 'product_document_library.tpl.php';
414
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
414
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
415 415
 						$old_file_to_take_care = true;
416 416
 					endif;
417 417
 				break;
418 418
 			case 'product_attachment_item_picture':
419 419
 					$old_file_to_take_care_url = 'product_attachment_picture_line.tpl.php';
420
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
420
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
421 421
 						$old_file_to_take_care = true;
422 422
 					endif;
423 423
 				break;
424 424
 			case 'product_attachment_item_document':
425 425
 					$old_file_to_take_care_url = 'product_attachment_document_line.tpl.php';
426
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
426
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
427 427
 						$old_file_to_take_care = true;
428 428
 					endif;
429 429
 				break;
430 430
 			case 'product_added_to_cart_message':
431 431
 					$old_file_to_take_care_url = 'product_added_to_cart_message.tpl.php';
432
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
432
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
433 433
 						$old_file_to_take_care = true;
434 434
 					endif;
435 435
 				break;
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public static function display_template_element($template_part, $template_part_component, $extras_args = array(), $default_template_dir = 'wpshop') {
461 461
 		/**	Set the template element to return by default before checking if custom exists in order to be sure to return something	*/
462
-		$default_template_element = wpshop_display::check_template_to_display( 'default', $template_part, $extras_args, $default_template_dir );
462
+		$default_template_element = wpshop_display::check_template_to_display('default', $template_part, $extras_args, $default_template_dir);
463 463
 
464 464
 		/**	Check in custom template if there is not a custom element to display for current 	*/
465
-		$custom_template_element = wpshop_display::check_template_to_display( 'custom', $template_part, $extras_args, $default_template_dir );
465
+		$custom_template_element = wpshop_display::check_template_to_display('custom', $template_part, $extras_args, $default_template_dir);
466 466
 		$tpl_element_to_return = !empty($custom_template_element) ? $custom_template_element : $default_template_element;
467 467
 
468
-		$template_part_component = apply_filters( 'wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir );
468
+		$template_part_component = apply_filters('wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir);
469 469
 
470 470
 		return self::feed_template($tpl_element_to_return, $template_part_component);
471 471
 	}
@@ -477,44 +477,44 @@  discard block
 block discarded – undo
477 477
 		/*	Load template component	*/
478 478
 		/*	Get default admin template	*/
479 479
 		require_once(WPSHOP_TEMPLATES_DIR . 'admin/main_elements.tpl.php');
480
-		$wpshop_template['admin']['default'] = ($tpl_element);unset($tpl_element);
480
+		$wpshop_template['admin']['default'] = ($tpl_element); unset($tpl_element);
481 481
 		/*	Get custom admin template	*/
482
-		if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) {
482
+		if (is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php')) {
483 483
 			require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php');
484 484
 			if (!empty($tpl_element))
485
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
485
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
486 486
 		}
487
-		if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) {
487
+		if (is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php')) {
488 488
 			require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php');
489 489
 			if (!empty($tpl_element))
490
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
490
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
491 491
 		}
492 492
 		/*	Get default frontend template	*/
493 493
 		require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php');
494
-		$wpshop_template['wpshop']['default'] = ($tpl_element);unset($tpl_element);
494
+		$wpshop_template['wpshop']['default'] = ($tpl_element); unset($tpl_element);
495 495
 		/*	Get custom frontend template	*/
496
-		if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) {
496
+		if (is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php')) {
497 497
 			require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php');
498 498
 			if (!empty($tpl_element))
499
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
499
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
500 500
 		}
501
-		if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) {
501
+		if (is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php')) {
502 502
 			require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php');
503 503
 			if (!empty($tpl_element))
504
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
504
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
505 505
 		}
506
-		foreach ( $wpshop_template as $site_side => $types ) {
507
-			foreach ( $types as $type => $tpl_component ) {
508
-				foreach ( $tpl_component as $tpl_key => $tpl_content ) {
506
+		foreach ($wpshop_template as $site_side => $types) {
507
+			foreach ($types as $type => $tpl_component) {
508
+				foreach ($tpl_component as $tpl_key => $tpl_content) {
509 509
 					$wpshop_template[$site_side][$type][$tpl_key] = str_replace("
510 510
 ", '', $tpl_content);
511 511
 				}
512 512
 			}
513 513
 		}
514 514
 
515
-		$wpshop_template = apply_filters( 'wpshop_custom_template', $wpshop_template);
515
+		$wpshop_template = apply_filters('wpshop_custom_template', $wpshop_template);
516 516
 
517
-		DEFINE( 'WPSHOP_TEMPLATE', serialize($wpshop_template) );
517
+		DEFINE('WPSHOP_TEMPLATE', serialize($wpshop_template));
518 518
 	}
519 519
 
520 520
 	/**
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return array The new array with all elment, internal and module templates
527 527
 	 */
528
-	public static function add_modules_template_to_internal( $tpl_element, $templates ) {
529
-		if ( !empty($tpl_element) ) {
530
-			foreach ( $tpl_element as $template_part => $template_part_content) {
531
-				if ( !empty($template_part_content) && is_array($template_part_content) ) {
532
-					foreach ( $template_part_content as $template_type => $template_type_content) {
533
-						foreach ( $template_type_content as $template_key => $template) {
528
+	public static function add_modules_template_to_internal($tpl_element, $templates) {
529
+		if (!empty($tpl_element)) {
530
+			foreach ($tpl_element as $template_part => $template_part_content) {
531
+				if (!empty($template_part_content) && is_array($template_part_content)) {
532
+					foreach ($template_part_content as $template_type => $template_type_content) {
533
+						foreach ($template_type_content as $template_key => $template) {
534 534
 							$templates[$template_part][$template_type][$template_key] = $template;
535 535
 						}
536 536
 					}
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
 	 *
551 551
 	 * @return string The good template to take in care, regarding on the given parameters
552 552
 	 */
553
-	public static function check_template_to_display( $part, $template_part, $extras_args, $default_template_dir  ) {
553
+	public static function check_template_to_display($part, $template_part, $extras_args, $default_template_dir) {
554 554
 		$tpl_element_to_return = '';
555 555
 
556 556
 		/**	Get the defined template	*/
557 557
 		$template = defined("WPSHOP_TEMPLATE") ? unserialize(WPSHOP_TEMPLATE) : array();
558 558
 
559
-		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
+		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])) {
560 560
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part];
561 561
 		}
562
-		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
+		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])) {
563 563
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part];
564 564
 		}
565 565
 		/**	Check if the file have been duplicated into theme directory for customization	*/
566
-		elseif ( !empty( $template[$default_template_dir][$part] ) && !empty( $template[$default_template_dir][$part][$template_part] ) ) {
566
+		elseif (!empty($template[$default_template_dir][$part]) && !empty($template[$default_template_dir][$part][$template_part])) {
567 567
 			$tpl_element_to_return = $template[$default_template_dir][$part][$template_part];
568 568
 		}
569 569
 
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 		$feed['CURRENCY'] = wpshop_tools::wpshop_get_currency();
584 584
 		$feed['CURRENCY_CHOOSEN'] = wpshop_tools::wpshop_get_currency();
585 585
 		$feed['CURRENCY_SELECTOR'] = wpshop_attributes_unit::wpshop_shop_currency_list_field();
586
-		$feed['CART_LINK'] = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_cart_page_id') ) );
586
+		$feed['CART_LINK'] = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')));
587 587
 
588 588
 		$available_key = array();
589 589
 		foreach ($feed as $element => $value) {
590
-			$available_key[] = '{WPSHOP_'.$element.'}';
591
-			if ( !is_array($value) ) {
592
-				$template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill);
590
+			$available_key[] = '{WPSHOP_' . $element . '}';
591
+			if (!is_array($value)) {
592
+				$template_to_fill = str_replace('{WPSHOP_' . $element . '}', $value, $template_to_fill);
593 593
 			}
594 594
 		}
595 595
 		if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill;
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
 	 *
603 603
 	 * @param boolean $force_replacement Define if we overwrite in all case or just if it not exist
604 604
 	 */
605
-	public static function check_template_file( $force_replacement = false ) {
605
+	public static function check_template_file($force_replacement = false) {
606 606
 		$wpshop_directory = get_stylesheet_directory() . '/wpshop';
607 607
 
608 608
 		/*	Add different file template	*/
609
-		if(!is_dir($wpshop_directory)){
609
+		if (!is_dir($wpshop_directory)) {
610 610
 			@mkdir($wpshop_directory, 0755, true);
611 611
 		}
612 612
 		/* On s'assure que le dossier principal est bien en 0755	*/
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 		$upload_dir = wp_upload_dir();
615 615
 
616 616
 		/*	Add the category template	*/
617
-		if(!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)){
617
+		if (!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)) {
618 618
 			@copy(WPSHOP_TEMPLATES_DIR . 'taxonomy-wpshop_product_category.php', get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php');
619 619
 		}
620 620
 
621 621
 		/*	Add the product template	*/
622
-		if(!is_file(get_stylesheet_directory() . '/single-wpshop_product.php') || ($force_replacement)){
622
+		if (!is_file(get_stylesheet_directory() . '/single-wpshop_product.php') || ($force_replacement)) {
623 623
 			@copy(WPSHOP_TEMPLATES_DIR . 'single-wpshop_product.php', get_stylesheet_directory() . '/single-wpshop_product.php');
624 624
 		}
625 625
 	}
@@ -637,31 +637,31 @@  discard block
 block discarded – undo
637 637
 		/*	Check if user is on taxonomy edition page	*/
638 638
 		if ($pagenow == 'edit-tags.php') {
639 639
 
640
-			if(!user_can_richedit()) { return; }
640
+			if (!user_can_richedit()) { return; }
641 641
 
642 642
 			$taxonomies = get_taxonomies();
643 643
 
644 644
 			foreach ($taxonomies as $tax) {
645
-				if ( in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES)) ) {
646
-					add_action($tax . '_edit_form_fields', array('wpshop_display','wpshop_add_form'));
647
-					add_action($tax . '_add_form_fields', array('wpshop_display','wpshop_add_form'));
645
+				if (in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES))) {
646
+					add_action($tax . '_edit_form_fields', array('wpshop_display', 'wpshop_add_form'));
647
+					add_action($tax . '_add_form_fields', array('wpshop_display', 'wpshop_add_form'));
648 648
 				}
649 649
 			}
650
-			$action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
651
-			$taxonomy = !empty( $_REQUEST['taxonomy'] ) ? sanitize_text_field( $_REQUEST['taxonomy'] ) : '';
650
+			$action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
651
+			$taxonomy = !empty($_REQUEST['taxonomy']) ? sanitize_text_field($_REQUEST['taxonomy']) : '';
652 652
 
653 653
 			if ($pagenow == 'edit-tags.php' && isset($action) && $action == 'edit' && empty($taxonomy)) {
654
-				add_action('edit_term',array('wpshop_display','wpshop_rt_taxonomy_save'));
654
+				add_action('edit_term', array('wpshop_display', 'wpshop_rt_taxonomy_save'));
655 655
 			}
656 656
 
657
-			foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
658
-				remove_filter( $filter, 'wp_filter_kses' );
657
+			foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) {
658
+				remove_filter($filter, 'wp_filter_kses');
659 659
 			}
660 660
 
661 661
 		}
662 662
 
663 663
 		/*	Enable shortcodes in category, taxonomy, tag descriptions */
664
-		if(function_exists('term_description')) {
664
+		if (function_exists('term_description')) {
665 665
 			add_filter('term_description', 'do_shortcode');
666 666
 		}
667 667
 		else {
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 
678 678
 		$a = array('description');
679 679
 		foreach ($a as $v) {
680
-			$term = (array) $_POST[$v];
681
-			wp_update_term($tag_ID,$v,$term);
680
+			$term = (array)$_POST[$v];
681
+			wp_update_term($tag_ID, $v, $term);
682 682
 		}
683 683
 	}
684 684
 
@@ -690,9 +690,9 @@  discard block
 block discarded – undo
690 690
 	public static function wpshop_add_form($object = '') {
691 691
 		global $pagenow;
692 692
 
693
-		$content = is_object($object) && isset($object->description) ? ( html_entity_decode( $object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ) : '';
693
+		$content = is_object($object) && isset($object->description) ? (html_entity_decode($object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8')) : '';
694 694
 
695
-		if( in_array($pagenow, array('edit-tags.php')) ) {
695
+		if (in_array($pagenow, array('edit-tags.php'))) {
696 696
 			$editor_id = 'tag_description';
697 697
 			$editor_selector = 'description';
698 698
 		}
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
 
723 723
 	public static function wps_hide_admin_bar_for_customers() {
724 724
 		$wpshop_hide_admin_bar_option = get_option('wpshop_display_option');
725
-		if ( !empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && ! current_user_can( 'manage_options' ) ) {
726
-			show_admin_bar( false );
725
+		if (!empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && !current_user_can('manage_options')) {
726
+			show_admin_bar(false);
727 727
 		}
728 728
 	}
729 729
 
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 * @param string $content The content of a post
738 738
 	 * @return Ambigous <mixed, string>|unknown
739 739
 	 */
740
-	public static function products_page( $content = '' ) {
740
+	public static function products_page($content = '') {
741 741
 		global $wp_query;
742 742
 
743 743
 		if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) {
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 	 *
757 757
 	 * @return string The formated value
758 758
 	 */
759
-	public static function format_field_output( $output_type, $value ) {
759
+	public static function format_field_output($output_type, $value) {
760 760
 		$formated_value = $value;
761 761
 
762
-		if ( !empty($value) ) {
763
-			switch ( $output_type ) {
762
+		if (!empty($value)) {
763
+			switch ($output_type) {
764 764
 				case 'wpshop_product_price':
765
-					$formated_value = (is_numeric($value) ) ? number_format($value, 2, ',', '') : $value;
765
+					$formated_value = (is_numeric($value)) ? number_format($value, 2, ',', '') : $value;
766 766
 					$formated_value_content = explode(',', $formated_value);
767
-					if ( !empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0 ) {
767
+					if (!empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0) {
768 768
 						$formated_value = $formated_value_content[0];
769 769
 					}
770 770
 				break;
Please login to merge, or discard this patch.
includes/librairies/display/widgets/categories.widget.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 
35 35
 	/**
36
-	*	Define the content for the widget
37
-	*
38
-	*	@param mixed $instance The current widget instance
39
-	*/
36
+	 *	Define the content for the widget
37
+	 *
38
+	 *	@param mixed $instance The current widget instance
39
+	 */
40 40
 	function form($instance){
41 41
 		$instance = wp_parse_args((array) $instance, array(
42 42
 			'title' => '',
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	/**
75
-	* Widget Output
76
-	*
77
-	* @param array $args
78
-	* @param array $instance Widget values.
79
-	*/
75
+	 * Widget Output
76
+	 *
77
+	 * @param array $args
78
+	 * @param array $instance Widget values.
79
+	 */
80 80
 	function widget($args, $instance){
81 81
 		$widget_content = '';
82 82
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	*	Get the sub categories of a given category
100
-	*
101
-	*	@param integer $parent_category The main category we want to have the sub categories for
102
-	*/
99
+	 *	Get the sub categories of a given category
100
+	 *
101
+	 *	@param integer $parent_category The main category we want to have the sub categories for
102
+	 */
103 103
 	function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){
104 104
 		$category_tree_output = '';
105 105
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
 * WpShop categories menu widget management
4 4
 *
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * Widget Constructor
23 23
 	 */
24 24
 	public function __construct() {
25
-		add_action('widgets_init', create_function('', 'return register_widget("WP_Widget_Wpshop_Product_categories");' ) );
25
+		add_action('widgets_init', create_function('', 'return register_widget("WP_Widget_Wpshop_Product_categories");'));
26 26
 		
27 27
 		$params = array(
28 28
 			'classname' => 'widget_wpshop_pdt_categories',
29 29
 			'description' => __('Wpshop product categories widget', 'wpshop')
30 30
 		);
31 31
 		
32
-		parent::__construct( 'wpshop_pdt_categories', __('• Wpshop Categories', 'wpshop'), $params );
32
+		parent::__construct('wpshop_pdt_categories', __('• Wpshop Categories', 'wpshop'), $params);
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,36 +37,36 @@  discard block
 block discarded – undo
37 37
 	*
38 38
 	*	@param mixed $instance The current widget instance
39 39
 	*/
40
-	function form($instance){
41
-		$instance = wp_parse_args((array) $instance, array(
40
+	function form($instance) {
41
+		$instance = wp_parse_args((array)$instance, array(
42 42
 			'title' => '',
43 43
 			'show_product' => '',
44 44
 			'show_all_cat' => '',
45 45
 			'wpshop_widget_categories' => ''
46 46
 		));
47 47
 
48
-		$title    		= esc_attr($instance['title']);
48
+		$title = esc_attr($instance['title']);
49 49
 		$show_all_cat	= esc_attr($instance['show_all_cat']);
50 50
 		$show_product	= esc_attr($instance['show_product']);
51
-		if ( !isset( $instance['wpshop_widget_categories'] ) ){
51
+		if (!isset($instance['wpshop_widget_categories'])) {
52 52
 			$categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('hide_empty' => '0', 'parent' => 0));
53
-			if(!empty($categories)){
54
-				foreach($categories as $category){
53
+			if (!empty($categories)) {
54
+				foreach ($categories as $category) {
55 55
 					$instance['wpshop_widget_categories'][$category->term_id] = 'on';
56 56
 				}
57 57
 			}
58 58
 		}
59
-		$wpshop_widget_categories	= esc_attr($instance['wpshop_widget_categories']);
59
+		$wpshop_widget_categories = esc_attr($instance['wpshop_widget_categories']);
60 60
 		$checked = (($show_product != '') && ($show_product == 'yes')) ? 'checked="checked"' : '';
61 61
 ?>
62 62
 		<p>
63
-			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'wpshop' ); ?></label>
64
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
63
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'wpshop'); ?></label>
64
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
65 65
 		</p>
66 66
 		<p>
67
-			<input id="<?php echo $this->get_field_id( 'show_all_cat' ); ?>" class="wpshop-widget-all-cat" name="<?php echo $this->get_field_name( 'show_all_cat' ); ?>" type="hidden" value="yes" />
68
-			<input <?php echo $checked; ?> id="<?php echo $this->get_field_id( 'show_product' ); ?>" name="<?php echo $this->get_field_name( 'show_product' ); ?>" type="checkbox" value="yes" />
69
-			<label for="<?php echo $this->get_field_id( 'show_product' ); ?>" ><?php _e( 'Show product', 'wpshop' ); ?></label>
67
+			<input id="<?php echo $this->get_field_id('show_all_cat'); ?>" class="wpshop-widget-all-cat" name="<?php echo $this->get_field_name('show_all_cat'); ?>" type="hidden" value="yes" />
68
+			<input <?php echo $checked; ?> id="<?php echo $this->get_field_id('show_product'); ?>" name="<?php echo $this->get_field_name('show_product'); ?>" type="checkbox" value="yes" />
69
+			<label for="<?php echo $this->get_field_id('show_product'); ?>" ><?php _e('Show product', 'wpshop'); ?></label>
70 70
 		</p>
71 71
 <?php
72 72
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	* @param array $args
78 78
 	* @param array $instance Widget values.
79 79
 	*/
80
-	function widget($args, $instance){
80
+	function widget($args, $instance) {
81 81
 		$widget_content = '';
82 82
 
83 83
 		/*	Get the default args from wordpress	*/
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	*
101 101
 	*	@param integer $parent_category The main category we want to have the sub categories for
102 102
 	*/
103
-	function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){
103
+	function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance) {
104 104
 		$category_tree_output = '';
105 105
 
106 106
 		$categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('hide_empty' => '0', 'parent' => $category_id));
107
-		if(count($categories) > 0){
108
-			foreach($categories as $category){
107
+		if (count($categories) > 0) {
108
+			foreach ($categories as $category) {
109 109
 				$checked = (is_array($instance['wpshop_widget_categories']) && in_array($category->term_id, $instance['wpshop_widget_categories'])) ? ' checked="checked" ' : '';
110 110
 				$category_main_class = ($category_id > 0) ? 'class="wpshop_categories_children"' : '';
111 111
 				$category_tree_output .= '
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
 * WpShop categories menu widget management
4 6
 *
Please login to merge, or discard this patch.
includes/librairies/display/form_management.class.php 3 patches
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.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,43 +26,43 @@  discard block
 block discarded – undo
26 26
 	var $filters = array(); // Stores store filters
27 27
 
28 28
 	/**
29
-	* Add an error
30
-	*/
29
+	 * Add an error
30
+	 */
31 31
 	function add_error( $error ) {
32 32
 		$this->errors[] = $error;
33 33
 	}
34 34
 
35 35
 	/**
36
-	* Add a message
37
-	*/
36
+	 * Add a message
37
+	 */
38 38
 	function add_message( $message ) {
39 39
 		$this->messages[] = $message;
40 40
 	}
41 41
 
42 42
 		/**
43
-		* Add a filter
44
-		*/
43
+		 * Add a filter
44
+		 */
45 45
 		function add_filter( $attribute_frontend_verification, $function ) {
46 46
 			$this->filters[$attribute_frontend_verification] = $function;
47 47
 		}
48 48
 
49 49
 	/**
50
-	* Get error count
51
-	*/
50
+	 * Get error count
51
+	 */
52 52
 	function error_count() {
53 53
 		return sizeof($this->errors);
54 54
 	}
55 55
 
56 56
 	/**
57
-	* Get message count
58
-	*/
57
+	 * Get message count
58
+	 */
59 59
 	function message_count() {
60 60
 		return sizeof($this->messages);
61 61
 	}
62 62
 
63 63
 	/**
64
-	* Output the errors and messages
65
-	*/
64
+	 * Output the errors and messages
65
+	 */
66 66
 	function show_messages() {
67 67
 		if (!empty($this->errors) && $this->error_count()>0) :
68 68
 			$message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>';
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	}
78 78
 
79 79
 	/** Valide les champs d'un formlaire
80
-	* @param array $array : Champs a lire
81
-	* @return boolean
82
-	*/
80
+	 * @param array $array : Champs a lire
81
+	 * @return boolean
82
+	 */
83 83
 	function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) {
84 84
 
85 85
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 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
 /**
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	* Add an error
30 30
 	*/
31
-	function add_error( $error ) {
31
+	function add_error($error) {
32 32
 		$this->errors[] = $error;
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	* Add a message
37 37
 	*/
38
-	function add_message( $message ) {
38
+	function add_message($message) {
39 39
 		$this->messages[] = $message;
40 40
 	}
41 41
 
42 42
 		/**
43 43
 		* Add a filter
44 44
 		*/
45
-		function add_filter( $attribute_frontend_verification, $function ) {
45
+		function add_filter($attribute_frontend_verification, $function) {
46 46
 			$this->filters[$attribute_frontend_verification] = $function;
47 47
 		}
48 48
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	* Output the errors and messages
65 65
 	*/
66 66
 	function show_messages() {
67
-		if (!empty($this->errors) && $this->error_count()>0) :
68
-			$message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>';
69
-			foreach($this->errors as $e) {
70
-				$message .= '<li>'.$e.'</li>';
67
+		if (!empty($this->errors) && $this->error_count() > 0) :
68
+			$message = '<div class="error_bloc">' . __('Errors were detected', 'wpshop') . ' :<ul>';
69
+			foreach ($this->errors as $e) {
70
+				$message .= '<li>' . $e . '</li>';
71 71
 			}
72 72
 			$message .= '</ul></div>';
73 73
 			return $message;
@@ -83,42 +83,42 @@  discard block
 block discarded – undo
83 83
 	function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) {
84 84
 
85 85
 
86
-		$user_id = empty( $user ) ? get_current_user_id() : $user;
87
-		foreach($array as $attribute_id => $attribute_definition):
88
-			$values_array = !empty($values) ? $values : (array) $_POST['attribute'];
89
-			$value = ( !empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']]) ) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : '';
86
+		$user_id = empty($user) ? get_current_user_id() : $user;
87
+		foreach ($array as $attribute_id => $attribute_definition):
88
+			$values_array = !empty($values) ? $values : (array)$_POST['attribute'];
89
+			$value = (!empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']])) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : '';
90 90
 
91 91
 			// Si le champ est obligatoire
92
-			if ( empty($value) && ($attribute_definition['required'] == 'yes') ) {
93
-				$this->add_error(sprintf(__('The field "%s" is required','wpshop'),__( $attribute_definition['label'], 'wpshop' ) ));
92
+			if (empty($value) && ($attribute_definition['required'] == 'yes')) {
93
+				$this->add_error(sprintf(__('The field "%s" is required', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
94 94
 			}
95
-			if( $partial == false && $attribute_definition['_need_verification'] == 'yes'  ) {
96
-				$value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'].'2'];
97
-				if ( $value != $value2) {
98
-					$this->add_error(sprintf(__('The  "%s" confirmation is incorrect','wpshop'),__($attribute_definition['label'], 'wpshop') ));
95
+			if ($partial == false && $attribute_definition['_need_verification'] == 'yes') {
96
+				$value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'] . '2'];
97
+				if ($value != $value2) {
98
+					$this->add_error(sprintf(__('The  "%s" confirmation is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
99 99
 				}
100 100
 			}
101
-			if(!empty($value) && !empty($attribute_definition['type'])) {
102
-				switch($attribute_definition['frontend_verification']) {
101
+			if (!empty($value) && !empty($attribute_definition['type'])) {
102
+				switch ($attribute_definition['frontend_verification']) {
103 103
 					case 'email':
104 104
 						$email_exist = email_exists($value);
105
-						if(!is_email($value)) {
106
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),$attribute_definition['label']));
105
+						if (!is_email($value)) {
106
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), $attribute_definition['label']));
107 107
 						}
108
-						elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) {
108
+						elseif (empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0))) {
109 109
 							$this->add_error(__('An account is already registered with your email address. Please login.', 'wpshop'));
110 110
 						}
111 111
 					break;
112 112
 
113 113
 					case 'postcode':
114
-						if(!wpshop_tools::is_postcode($value)) {
115
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),__( $attribute_definition['label'], 'wpshop' ) ));
114
+						if (!wpshop_tools::is_postcode($value)) {
115
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
116 116
 						}
117 117
 					break;
118 118
 
119 119
 					case 'phone':
120
-						if(!wpshop_tools::is_phone($value)) {
121
-							$this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'), __( $attribute_definition['label'], 'wpshop' ) ));
120
+						if (!wpshop_tools::is_phone($value)) {
121
+							$this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop')));
122 122
 						}
123 123
 					break;
124 124
 
@@ -126,22 +126,22 @@  discard block
 block discarded – undo
126 126
 						$username_exists = username_exists($value);
127 127
 						// On s'assure que le nom d'utilisateur est libre
128 128
 						if (!validate_username($value)) :
129
-							$this->add_error( __('Invalid email/username.', 'wpshop') );
130
-						elseif ( ($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0) ) :
131
-							$this->add_error( __('An account is already registered with that username. Please choose another.', 'wpshop') );
129
+							$this->add_error(__('Invalid email/username.', 'wpshop'));
130
+						elseif (($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0)) :
131
+							$this->add_error(__('An account is already registered with that username. Please choose another.', 'wpshop'));
132 132
 						endif;
133 133
 					break;
134 134
 				}
135 135
 				if (array_key_exists($attribute_definition['name'], $this->filters) && is_callable($this->filters[$attribute_definition['name']])) {
136 136
 					$validation = call_user_func($this->filters[$attribute_definition['name']], $value);
137
-					if( !filter_var($validation, FILTER_VALIDATE_BOOLEAN) ) {
138
-						$this->add_error( $validation );
137
+					if (!filter_var($validation, FILTER_VALIDATE_BOOLEAN)) {
138
+						$this->add_error($validation);
139 139
 					}
140 140
 				}
141 141
 			}
142 142
 		endforeach;
143 143
 
144
-		return ($this->error_count()==0);
144
+		return ($this->error_count() == 0);
145 145
 	}
146 146
 
147 147
 }
Please login to merge, or discard this patch.
includes/librairies/notices.class.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /*	Check if file is include. No direct access possible with file url	*/
3 5
 if ( !defined( 'WPSHOP_VERSION' ) ) {
4 6
 	die( __('Access is not allowed by this way', 'wpshop') );
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /*	Check if file is include. No direct access possible with file url	*/
3
-if ( !defined( 'WPSHOP_VERSION' ) ) {
4
-	die( __('Access is not allowed by this way', 'wpshop') );
3
+if (!defined('WPSHOP_VERSION')) {
4
+	die(__('Access is not allowed by this way', 'wpshop'));
5 5
 }
6 6
 
7 7
 /**
@@ -19,36 +19,36 @@  discard block
 block discarded – undo
19 19
 * @package wpshop
20 20
 * @subpackage librairies
21 21
 */
22
-class wpshop_notices{
22
+class wpshop_notices {
23 23
 
24 24
 	/** Notice the user to install the plugin */
25 25
 	public static function sale_shop_notice() {
26
-		$plug_version = substr( WPSHOP_VERSION, 0, 5 );
26
+		$plug_version = substr(WPSHOP_VERSION, 0, 5);
27 27
 
28 28
 
29
-		$notice_display_user_option = get_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', true);
29
+		$notice_display_user_option = get_user_meta(get_current_user_id(), '_wps_hide_notice_messages_indicator', true);
30 30
 
31 31
 		$notice = '';
32 32
 		$messages_to_hide = '';
33 33
 		/* Check that the user has already choose a payment method */
34
-		$paymentMethod = get_option( 'wps_payment_mode' );
34
+		$paymentMethod = get_option('wps_payment_mode');
35 35
 		$no_payment_mode_configurated = true;
36
-		if ( !empty($paymentMethod ) && !empty($paymentMethod['mode']) ) {
37
-			foreach( $paymentMethod['mode'] as $k => $pm ) {
38
-				if ( !empty($pm['active'] ) ) {
36
+		if (!empty($paymentMethod) && !empty($paymentMethod['mode'])) {
37
+			foreach ($paymentMethod['mode'] as $k => $pm) {
38
+				if (!empty($pm['active'])) {
39 39
 					$no_payment_mode_configurated = false;
40 40
 				}
41 41
 			}
42 42
 		}
43 43
 
44
-		if( $no_payment_mode_configurated ) {
45
-			$notice .= '<li>' . __('Payment method are missing', 'wpshop') . '&nbsp;<a href="' . admin_url('options-general.php?page='.WPSHOP_URL_SLUG_OPTION.'#wpshop_payments_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Choose a payment method', 'wpshop') . '</a></li>';
44
+		if ($no_payment_mode_configurated) {
45
+			$notice .= '<li>' . __('Payment method are missing', 'wpshop') . '&nbsp;<a href="' . admin_url('options-general.php?page=' . WPSHOP_URL_SLUG_OPTION . '#wpshop_payments_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Choose a payment method', 'wpshop') . '</a></li>';
46 46
 		}
47 47
 
48 48
 		/* Check that the user has already choose a payment method */
49 49
 		$emails = get_option('wpshop_emails', array());
50
-		if(empty($emails)) {
51
-			$notice .= '<li>' . __('Shop emails are misssing', 'wpshop') . '&nbsp;<a href="' . admin_url('options-general.php?page='.WPSHOP_URL_SLUG_OPTION.'#wpshop_emails_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Configure shop emails', 'wpshop') . '</a></li>';
50
+		if (empty($emails)) {
51
+			$notice .= '<li>' . __('Shop emails are misssing', 'wpshop') . '&nbsp;<a href="' . admin_url('options-general.php?page=' . WPSHOP_URL_SLUG_OPTION . '#wpshop_emails_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Configure shop emails', 'wpshop') . '</a></li>';
52 52
 		}
53 53
 
54 54
 
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
 			$messages_to_hide .= 'SLICKSHOP,';
59 59
 		}*/
60 60
 
61
-		$install = !empty( $_GET[ 'install' ] ) ? sanitize_text_field( $_GET[ 'install' ] ) : '';
61
+		$install = !empty($_GET['install']) ? sanitize_text_field($_GET['install']) : '';
62 62
 
63
-		if(!empty($notice) && ( empty( $install ) ) ) {
64
-			$notice='<p>'.__('You configure your shop to be a sale shop. But some configuration are missing for this type of shop using', 'wpshop').'</p><ul>'.$notice.'</ul>';
65
-			if ( !empty($messages_to_hide) ) {
66
-				$notice .= '<button data-nonce="' . wp_create_nonce( 'wps_hide_notice_messages' ) . '" class="wps_hide_notice_message button-secondary" id="wps_hide_notice_message">' .__('Hide this message', 'wpshop'). '</button>';
67
-				$notice .= '<input type="hidden" id="hide_messages_indicator" value="' .$messages_to_hide. '"/>';
63
+		if (!empty($notice) && (empty($install))) {
64
+			$notice = '<p>' . __('You configure your shop to be a sale shop. But some configuration are missing for this type of shop using', 'wpshop') . '</p><ul>' . $notice . '</ul>';
65
+			if (!empty($messages_to_hide)) {
66
+				$notice .= '<button data-nonce="' . wp_create_nonce('wps_hide_notice_messages') . '" class="wps_hide_notice_message button-secondary" id="wps_hide_notice_message">' . __('Hide this message', 'wpshop') . '</button>';
67
+				$notice .= '<input type="hidden" id="hide_messages_indicator" value="' . $messages_to_hide . '"/>';
68 68
 			}
69 69
 			self::admin_notice_container($notice, 'wpshop_shop_sale_type_notice');
70 70
 		}
71 71
 	}
72 72
 
73 73
 	/**		*/
74
-	public static function admin_notice_container($message, $container_class = ''){
74
+	public static function admin_notice_container($message, $container_class = '') {
75 75
 		?>
76 76
 		<div class="updated wpshop_admin_notice <?php echo $container_class; ?>" id="<?php echo $container_class; ?>" >
77 77
 			<h3><?php _e('Configure my shop', 'wpshop') ?></h3>
Please login to merge, or discard this patch.
includes/librairies/payments/payment.class.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 	/**
221
-	* Reduce the stock regarding the order
222
-	*/
221
+	 * Reduce the stock regarding the order
222
+	 */
223 223
 	function the_order_payment_is_completed($order_id, $txn_id = null) {
224 224
 		// Donnees commandes
225 225
 		$order = get_post_meta($order_id, '_order_postmeta', true);
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Get payment method
297
-	*/
296
+	 * Get payment method
297
+	 */
298 298
 	function get_payment_method($post_id){
299 299
 		$pm = __('Nc','wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Set payment transaction number
325
-	*/
324
+	 * Set payment transaction number
325
+	 */
326 326
 	function display_payment_receiver_interface($post_id) {
327 327
 		$payment_validation = '';
328 328
 		$display_button = false;
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$wpshop_paypal = new wpshop_paypal();
22 22
 		// If the CIC payment method is active
23
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
24
-		if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) {
23
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
24
+		if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) {
25 25
 			$wpshop_cic = new wpshop_CIC();
26 26
 		}
27
-		wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse');
27
+		wpshop_tools::create_custom_hook('wpshop_bankserver_reponse');
28 28
 
29 29
 	}
30 30
 
31 31
 	public static function get_success_payment_url() {
32
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) );
32
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id')));
33 33
 		return self::construct_url_parameters($url, 'paymentResult', 'success');
34 34
 	}
35 35
 
36 36
 	public static function get_cancel_payment_url() {
37
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) );
37
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id')));
38 38
 		return $url;
39 39
 	}
40 40
 
41 41
 	public static function construct_url_parameters($url, $param, $value) {
42 42
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
43
+		if ($interoguation_marker_pos === false)
44
+			return $url . '?' . $param . '=' . $value;
45
+		else return $url . '&' . $param . '=' . $value;
46 46
 	}
47 47
 
48 48
 	/**
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
 	public static function wpshop_payment_result() {
52 52
 		global $wpdb;
53 53
 		$user_ID = get_current_user_id();
54
-		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
-		$order_post_id = $wpdb->get_var( $query );
56
-		if ( !empty($order_post_id) ) {
57
-			$order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true);
58
-			if ( !empty($order_postmeta) ) {
59
-				switch ( $order_postmeta ) {
54
+		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
+		$order_post_id = $wpdb->get_var($query);
56
+		if (!empty($order_post_id)) {
57
+			$order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true);
58
+			if (!empty($order_postmeta)) {
59
+				switch ($order_postmeta) {
60 60
 					case 'awaiting_payment':
61
-						echo __('We wait your payment.','wpshop');
61
+						echo __('We wait your payment.', 'wpshop');
62 62
 					break;
63 63
 					case 'completed':
64
-						echo __('Thank you ! Your payment has been recorded.','wpshop');
64
+						echo __('Thank you ! Your payment has been recorded.', 'wpshop');
65 65
 					break;
66 66
 					case 'partially_paid':
67
-						echo __('Thank you ! Your first payment has been recorded.','wpshop');
67
+						echo __('Thank you ! Your first payment has been recorded.', 'wpshop');
68 68
 					break;
69 69
 					default:
70
-						echo __('Your payment and your order has been cancelled.','wpshop');
70
+						echo __('Your payment and your order has been cancelled.', 'wpshop');
71 71
 					break;
72 72
 				}
73 73
 			}
@@ -88,56 +88,56 @@  discard block
 block discarded – undo
88 88
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89 89
 	 * @return string The different payment method
90 90
 	 */
91
-	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
91
+	function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
92 92
 		$output = '';
93 93
 		/**	Get available payment method	*/
94 94
 		$paymentMethod = get_option('wpshop_paymentMethod', array());
95 95
 
96
-		if(!empty($order_id) && is_numeric($order_id)) {
97
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
96
+		if (!empty($order_id) && is_numeric($order_id)) {
97
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
98 98
 		}
99 99
 
100 100
 		if ($cart_type == 'cart') {
101 101
 			$payment_methods = array();
102
-			if(!empty($paymentMethod['paypal'])) {
102
+			if (!empty($paymentMethod['paypal'])) {
103 103
 				$payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'),
104 104
 														'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png',
105
-														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop')
105
+														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop')
106 106
 								 );
107 107
 			}
108
-			if(!empty($paymentMethod['checks'])) {
108
+			if (!empty($paymentMethod['checks'])) {
109 109
 				$payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'),
110 110
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
111
-						'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop')
111
+						'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop')
112 112
 				);
113 113
 			}
114
-			if(!empty($paymentMethod['banktransfer'])) {
114
+			if (!empty($paymentMethod['banktransfer'])) {
115 115
 				$payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'),
116 116
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
117
-						'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop')
117
+						'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop')
118 118
 				);
119 119
 			}
120
-			if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
120
+			if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
121 121
 				$payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'),
122 122
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg',
123
-						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop')
123
+						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop')
124 124
 				);
125 125
 			}
126 126
 			$payment_methods = apply_filters('wpshop_payment_method', $payment_methods);
127 127
 
128 128
 			$payment_method_table = array();
129 129
 
130
-			if ( !empty( $paymentMethod['display_position'] ) ) {
130
+			if (!empty($paymentMethod['display_position'])) {
131 131
 				$position_determinated = false;
132
-				foreach ( $paymentMethod['display_position'] as $key => $position) {
133
-					if ( $position != null) {
132
+				foreach ($paymentMethod['display_position'] as $key => $position) {
133
+					if ($position != null) {
134 134
 						$position_determinated = true;
135 135
 					}
136 136
 				}
137
-				if ( $position_determinated ) {
138
-					for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) {
139
-						foreach ( $paymentMethod['display_position'] as $key => $position ) {
140
-							if ( $position == $i  && !empty($paymentMethod[$key])) {
137
+				if ($position_determinated) {
138
+					for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) {
139
+						foreach ($paymentMethod['display_position'] as $key => $position) {
140
+							if ($position == $i && !empty($paymentMethod[$key])) {
141 141
 								if ($key == 'checks') {
142 142
 									$key = 'check';
143 143
 								}
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 					$payment_methods = $payment_method_table;
149 149
 				}
150 150
 			}
151
-			if (!empty($payment_methods) ) {
151
+			if (!empty($payment_methods)) {
152 152
 
153
-				foreach( $payment_methods as  $payment_method_identifier =>  $payment_method_def ) {
153
+				foreach ($payment_methods as  $payment_method_identifier =>  $payment_method_def) {
154 154
 					$tpl_component = array();
155 155
 					$checked = $active = '';
156 156
 					$payment_identifier_for_test = $payment_method_identifier;
157 157
 					if ($payment_method_identifier == 'check') {
158 158
 						$payment_identifier_for_test = 'checks';
159 159
 					}
160
-					if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
160
+					if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
161 161
 						$checked = ' checked="checked"';
162 162
 						$active = ' active';
163 163
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active;
166 166
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked;
167 167
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168
-					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
168
+					if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) {
169
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : '';
170 170
 					}
171 171
 					else {
172
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
172
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : '';
173 173
 					}
174 174
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
175 175
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name'];
@@ -180,32 +180,32 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 		}
182 182
 
183
-		return array( $output, $paymentMethod['mode'] );
183
+		return array($output, $paymentMethod['mode']);
184 184
 	}
185 185
 
186 186
 
187
-	public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
188
-		$payment_option = get_option( 'wps_payment_mode' );
187
+	public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
188
+		$payment_option = get_option('wps_payment_mode');
189 189
 		$output = '';
190
-		if(!empty($order_id) && is_numeric($order_id)) {
191
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
190
+		if (!empty($order_id) && is_numeric($order_id)) {
191
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
192 192
 		}
193
-		if( $cart_type == 'cart' ) {
194
-			if ( !empty($payment_option) && !empty($payment_option['mode']) ) {
195
-				foreach( $payment_option['mode'] as $payment_id => $payment_config ) {
196
-					if( !empty($payment_config['active']) ) {
197
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : '');
198
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : '');
193
+		if ($cart_type == 'cart') {
194
+			if (!empty($payment_option) && !empty($payment_option['mode'])) {
195
+				foreach ($payment_option['mode'] as $payment_id => $payment_config) {
196
+					if (!empty($payment_config['active'])) {
197
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : '');
198
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : '');
199 199
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id;
200 200
 
201
-						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
201
+						if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) {
202
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : '';
203 203
 						}
204 204
 						else {
205
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
205
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : '';
206 206
 						}
207
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
208
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : '';
207
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : '';
208
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : '';
209 209
 						$output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id));
210 210
 						unset($tpl_component);
211 211
 					}
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$wps_message = new wps_message_ctr();
229 229
 
230
-		if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
-			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' );
232
-			$first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
233
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
230
+		if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
232
+			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
233
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
234 234
 
235 235
 			// Envoie du message de confirmation de paiement au client
236
-			switch($order['payment_method']) {
236
+			switch ($order['payment_method']) {
237 237
 				case 'check':
238 238
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']));
239 239
 				break;
@@ -250,24 +250,24 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 
253
-	function setOrderPaymentStatus( $order_id, $payment_status ) {
253
+	function setOrderPaymentStatus($order_id, $payment_status) {
254 254
 		/**	Get order main information	*/
255 255
 		$order = get_post_meta($order_id, '_order_postmeta', true);
256 256
 		$send_email = false;
257 257
 
258
-		if ( !empty($order) ) {
258
+		if (!empty($order)) {
259 259
 			/**	Change order status to given status	*/
260 260
 			$order['order_status'] = strtolower($payment_status);
261 261
 			/**	Put order status into a single meta, allowing to use it easily later	*/
262 262
 			update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
263 263
 
264 264
 			/**	In case the set status is completed, make specific treatment: add the completed date	*/
265
-			if ( $payment_status == 'completed' ) {
265
+			if ($payment_status == 'completed') {
266 266
 				/**	Read order items list, if not empty and check if each item is set to manage stock or not */
267 267
 				if (!empty($order['order_items'])) {
268 268
 					foreach ($order['order_items'] as $o) {
269
-						$product = wpshop_products::get_product_data( $o['item_id'] );
270
-						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) {
269
+						$product = wpshop_products::get_product_data($o['item_id']);
270
+						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) {
271 271
 							wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']);
272 272
 						}
273 273
 					}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			/**	Send email to customer when specific case need it	*/
284
-			if ( $send_email ) {
284
+			if ($send_email) {
285 285
 				/**	Get information about customer that make the order	*/
286 286
 				$order_info = get_post_meta($order_id, '_order_info', true);
287 287
 				$mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']);
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
 	/**
296 296
 	* Get payment method
297 297
 	*/
298
-	function get_payment_method($post_id){
299
-		$pm = __('Nc','wpshop');
298
+	function get_payment_method($post_id) {
299
+		$pm = __('Nc', 'wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
301
-		if ( !empty($order_postmeta['payment_method']) ) {
302
-			switch($order_postmeta['payment_method']){
301
+		if (!empty($order_postmeta['payment_method'])) {
302
+			switch ($order_postmeta['payment_method']) {
303 303
 				case 'check':
304
-					$pm = __('Check','wpshop');
304
+					$pm = __('Check', 'wpshop');
305 305
 				break;
306 306
 				case 'paypal':
307
-					$pm = __('Paypal','wpshop');
307
+					$pm = __('Paypal', 'wpshop');
308 308
 				break;
309 309
 				case 'banktransfer':
310
-					$pm = __('Bank transfer','wpshop');
310
+					$pm = __('Bank transfer', 'wpshop');
311 311
 				break;
312 312
 				case 'cic':
313
-					$pm = __('Credit card','wpshop');
313
+					$pm = __('Credit card', 'wpshop');
314 314
 				break;
315 315
 				default:
316
-					$pm = __('Nc','wpshop');
316
+					$pm = __('Nc', 'wpshop');
317 317
 				break;
318 318
 			}
319 319
 		}
@@ -333,38 +333,38 @@  discard block
 block discarded – undo
333 333
 
334 334
 		$paymentMethod = $paymentMethod['mode'];
335 335
 		$payment_validation .= '
336
-<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" >
337
-	<input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
-	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
336
+<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" >
337
+	<input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
+	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
339 339
 
340
-		if(!empty($order_postmeta['payment_method'])){
340
+		if (!empty($order_postmeta['payment_method'])) {
341 341
 			$payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>';
342 342
 		}
343 343
 
344
-		if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
344
+		if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
345 345
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>';
346 346
 			$display_button = true;
347 347
 		}
348 348
 
349
-		if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
349
+		if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
350 350
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>';
351 351
 			$display_button = true;
352 352
 		}
353 353
 
354
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
355
-		if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) {
354
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
355
+		if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) {
356 356
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>';
357 357
 			$display_button = true;
358 358
 		}
359 359
 
360
-		if(empty($payment_transaction)){
361
-			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />';
360
+		if (empty($payment_transaction)) {
361
+			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />';
362 362
 			$display_button = true;
363 363
 		}
364 364
 
365
-		if($display_button){
365
+		if ($display_button) {
366 366
 			$payment_validation .= '
367
-		<br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>';
367
+		<br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>';
368 368
 		}
369 369
 
370 370
 		$payment_validation .= '
@@ -379,21 +379,21 @@  discard block
 block discarded – undo
379 379
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380 380
 	 * @return array The amount to pay / A html output with amount to pay and different information
381 381
 	 */
382
-	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
382
+	function partial_payment_calcul($current_order_total, $for = 'for_all') {
383 383
 		$output = '';
384 384
 		$tpl_component = array();
385 385
 
386 386
 		/**	Get current configuration	*/
387 387
 		$partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array()));
388
-		if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) {
388
+		if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) {
389 389
 			$amount_of_partial_payment = 0;
390
-			if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) {
390
+			if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) {
391 391
 				$amount_of_partial_payment = $partial_payment_configuration[$for]['value'];
392 392
 			}
393 393
 
394 394
 			$partial_amount_to_pay = 0;
395 395
 			$type_of_partial_payment = null;
396
-			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) {
396
+			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) {
397 397
 				switch ($partial_payment_configuration[$for]['type']) {
398 398
 					case 'percentage':
399 399
 						$type_of_partial_payment = '%';
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	function set_payment_transaction_number($order_id, $transaction_number) {
454 454
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
455 455
 
456
-		if ( !empty($order_postmeta['order_payment']['received']) ) {
456
+		if (!empty($order_postmeta['order_payment']['received'])) {
457 457
 			if (count($order_postmeta['order_payment']['received']) == 1) {
458 458
 				$order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number;
459 459
 			}
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param integer $order_id
469 469
 	 */
470
-	function save_payment_return_data( $order_id ) {
470
+	function save_payment_return_data($order_id) {
471 471
 		$data = wpshop_tools::getMethode();
472 472
 
473
-		$current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true);
473
+		$current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true);
474 474
 		$current_payment_return[] = $data;
475 475
 
476 476
 		update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return);
@@ -484,23 +484,23 @@  discard block
 block discarded – undo
484 484
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
485 485
 	 * @return array The order new meta informations
486 486
 	 */
487
-	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
488
-
489
-		$order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null;
490
-		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null;
491
-		$order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null;
492
-		$order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id();
493
-		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null;
494
-		$order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null;
495
-		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null;
487
+	public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) {
488
+
489
+		$order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null;
490
+		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null;
491
+		$order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null;
492
+		$order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id();
493
+		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null;
494
+		$order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null;
495
+		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null;
496 496
 		$order_meta['order_payment']['received'][$payment_index]['comment'] = '';
497 497
 
498 498
 		$order_info = get_post_meta($order_id, '_order_info', true);
499
-		if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
499
+		if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
500 500
 
501 501
 			/**	Generate an invoice number for the current payment. Check if the payment is complete or not	*/
502
-			if ( empty($order_meta['order_invoice_ref']) ) {
503
-				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id );
502
+			if (empty($order_meta['order_invoice_ref'])) {
503
+				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id);
504 504
 			}
505 505
 		}
506 506
 
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 * @param string $payment_method
514 514
 	 * @return integer $key : array id of [order_payment][received] in the order postmeta
515 515
 	 */
516
-	public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) {
516
+	public static function get_order_waiting_payment_array_id($oid, $payment_method) {
517 517
 		$key = 0;
518
-		$order_meta = get_post_meta( $oid, '_order_postmeta', true);
519
-		if ( !empty($order_meta) ) {
520
-			$key = count( $order_meta['order_payment']['received'] );
521
-			foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) {
522
-				if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) {
518
+		$order_meta = get_post_meta($oid, '_order_postmeta', true);
519
+		if (!empty($order_meta)) {
520
+			$key = count($order_meta['order_payment']['received']);
521
+			foreach ($order_meta['order_payment']['received'] as $k => $payment_test) {
522
+				if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) {
523 523
 					$key = $k;
524 524
 				}
525 525
 			}
@@ -534,52 +534,52 @@  discard block
 block discarded – undo
534 534
 	 * @param array $params_array
535 535
 	 * @return string
536 536
 	 */
537
-	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) {
537
+	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) {
538 538
 		global $wpshop_payment; global $wpdb;
539
-		$order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true);
539
+		$order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true);
540 540
 
541 541
 		$wps_message = new wps_message_ctr();
542
-		if ( !empty($order_meta) ) {
542
+		if (!empty($order_meta)) {
543 543
 			$order_info = get_post_meta($order_id, '_order_info', true);
544
-			$user_data = get_userdata( $order_meta['customer_id'] );
545
-			$email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : '';
544
+			$user_data = get_userdata($order_meta['customer_id']);
545
+			$email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : '';
546 546
 // 			$email = ( !empty($order_info) &&  !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ;
547
-			$first_name = (!empty($order_info) && !empty($order_info['billing']) &&  !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
548
-			$last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
547
+			$first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
548
+			$last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
549 549
 
550
-			$key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']);
550
+			$key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']);
551 551
 			$order_grand_total = $order_meta['order_grand_total'];
552
-			$total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 );
553
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
554
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
552
+			$total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0);
553
+			foreach ($order_meta['order_payment']['received'] as $received) {
554
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
555 555
 			}
556 556
 			$order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received;
557
-			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response );
557
+			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response);
558 558
 
559 559
 			if ($bank_response == 'completed') {
560 560
 
561
-				if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) {
561
+				if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) {
562 562
 					$payment_status = 'completed';
563 563
 
564
-					$order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : ( empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref'] ) ;
564
+					$order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : (empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref']);
565 565
 					$order_meta['order_invoice_date'] = current_time('mysql', 0);
566 566
 
567 567
 					if (!empty($order_meta['order_items'])) {
568 568
 						foreach ($order_meta['order_items'] as $item_id => $o) {
569 569
 							$pid = $o['item_id'];
570
-							if (strpos($item_id,'__') !== false) {
571
-								$product_data_id = explode( '__', $item_id );
572
-								$pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid;
570
+							if (strpos($item_id, '__') !== false) {
571
+								$product_data_id = explode('__', $item_id);
572
+								$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid;
573 573
 							}
574
-							$product = wpshop_products::get_product_data( $pid );
575
-							if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
576
-								$parent_def = wpshop_products::get_parent_variation ( $pid );
574
+							$product = wpshop_products::get_product_data($pid);
575
+							if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
576
+								$parent_def = wpshop_products::get_parent_variation($pid);
577 577
 								$parent_post = $parent_def['parent_post'];
578
-								$product = wpshop_products::get_product_data( $parent_post->ID );
578
+								$product = wpshop_products::get_product_data($parent_post->ID);
579 579
 							}
580 580
 
581
-							if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) {
582
-								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid );
581
+							if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
582
+								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid);
583 583
 							}
584 584
 						}
585 585
 					}
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 					update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0));
589 589
 
590 590
 					// Send confirmation e-mail to administrator
591
-					if ( empty($_SESSION['wps-pos-addon']) ) {
591
+					if (empty($_SESSION['wps-pos-addon'])) {
592 592
 						$email_option = get_option('wpshop_emails');
593
-						if(  !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){
594
-							wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data );
593
+						if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) {
594
+							wpshop_checkout::send_order_email_to_administrator($order_id, $user_data);
595 595
 						}
596 596
 					}
597 597
 
598 598
 					// POS Status
599
-					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
599
+					if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') {
600 600
 						$payment_status = 'pos';
601 601
 					}
602 602
 				}
@@ -605,27 +605,27 @@  discard block
 block discarded – undo
605 605
 				}
606 606
 
607 607
 				$order_meta['order_status'] = $payment_status;
608
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
608
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
609 609
 				$save_metadata = false;
610 610
 
611
-				$allow_send_invoice = get_option( 'wpshop_send_invoice' );
612
-				$invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, empty( $order_meta['order_payment']['received'][$key]['invoice_ref'] ) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : '';
611
+				$allow_send_invoice = get_option('wpshop_send_invoice');
612
+				$invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref']) : '';
613 613
 
614
-				$email_option = get_option( 'wpshop_emails' );
614
+				$email_option = get_option('wpshop_emails');
615 615
 
616
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
617
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
616
+				$shipping_mode_option = get_option('wps_shipping_mode');
617
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
618 618
 
619
-				$payment_method_option = get_option( 'wps_payment_mode' );
620
-				$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode'])  && !empty($order_meta['order_payment']['customer_choice']['method'])  && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
619
+				$payment_method_option = get_option('wps_payment_mode');
620
+				$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
621 621
 
622
-				if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed'
623
-						&& ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) {
624
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method ) );
622
+				if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed'
623
+						&& (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) {
624
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method));
625 625
 				}
626 626
 
627
-				if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) {
628
-					$wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
627
+				if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) {
628
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
629 629
 				}
630 630
 			}
631 631
 			else {
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 
635 635
 			$order_meta['order_status'] = $payment_status;
636 636
 
637
-			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
638
-			if( $save_metadata ) {
639
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
637
+			update_post_meta($order_id, '_wpshop_order_status', $payment_status);
638
+			if ($save_metadata) {
639
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
640 640
 			}
641 641
 		}
642
-		do_action( 'wps_after_check_order_payment_total_amount', $order_id );
643
-		if ( ! $save_metadata ) {
642
+		do_action('wps_after_check_order_payment_total_amount', $order_id);
643
+		if (!$save_metadata) {
644 644
 			return $order_meta;
645 645
 		}
646 646
 	}
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 	 * @param integer $order_id The order identifier we want to get the old transaction reference for
654 654
 	 * @return integer
655 655
 	 */
656
-	public static function get_payment_transaction_number_old_way($order_id){
656
+	public static function get_payment_transaction_number_old_way($order_id) {
657 657
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
658 658
 		$transaction_indentifier = 0;
659
-		if(!empty($order_postmeta['payment_method'])){
660
-			switch($order_postmeta['payment_method']){
659
+		if (!empty($order_postmeta['payment_method'])) {
660
+			switch ($order_postmeta['payment_method']) {
661 661
 				case 'check':
662 662
 					$transaction_indentifier = get_post_meta($order_id, '_order_check_number', true);
663 663
 					break;
@@ -676,26 +676,26 @@  discard block
 block discarded – undo
676 676
 		return $transaction_indentifier;
677 677
 	}
678 678
 
679
-	public static function reverify_payment_invoice_ref( $order_id, $index_payment ) {
679
+	public static function reverify_payment_invoice_ref($order_id, $index_payment) {
680 680
 		$status = false;
681
-		$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
682
-		if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) {
681
+		$order_meta = get_post_meta($order_id, '_order_postmeta', true);
682
+		if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) {
683 683
 			$order_invoice = $invoice_ref = false;
684 684
 
685
-			end( $order_meta['order_payment']['received'] );
686
-			$last_payment = key( $order_meta['order_payment']['received'] );
687
-			if( $last_payment == $index_payment ) {
685
+			end($order_meta['order_payment']['received']);
686
+			$last_payment = key($order_meta['order_payment']['received']);
687
+			if ($last_payment == $index_payment) {
688 688
 				$payments = 0;
689
-				foreach( $order_meta['order_payment']['received'] as $payment ) {
690
-					$payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0;
689
+				foreach ($order_meta['order_payment']['received'] as $payment) {
690
+					$payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0;
691 691
 				}
692
-				if( $order_meta['order_grand_total'] <= $payments ) {
693
-					if( $order_meta['order_status'] == 'partially_paid' ) {
694
-						$order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true );
692
+				if ($order_meta['order_grand_total'] <= $payments) {
693
+					if ($order_meta['order_status'] == 'partially_paid') {
694
+						$order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true);
695 695
 						$order_meta['order_status'] = 'completed';
696
-						$status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' );
696
+						$status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed');
697 697
 					}
698
-					if( !empty( $order_meta['order_invoice_ref'] ) ) {
698
+					if (!empty($order_meta['order_invoice_ref'])) {
699 699
 						$invoice_ref = $order_meta['order_invoice_ref'];
700 700
 						$status = true;
701 701
 					} else {
@@ -706,16 +706,16 @@  discard block
 block discarded – undo
706 706
 				$status = true;
707 707
 			}
708 708
 
709
-			if( $status ) {
710
-				if( empty( $invoice_ref ) ) {
711
-					$invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id );
712
-					if( $order_invoice ) {
709
+			if ($status) {
710
+				if (empty($invoice_ref)) {
711
+					$invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id);
712
+					if ($order_invoice) {
713 713
 						$order_meta['order_invoice_ref'] = $invoice_ref;
714 714
 					}
715 715
 				}
716 716
 
717 717
 				$order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref;
718
-				$status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta );
718
+				$status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta);
719 719
 			}
720 720
 		}
721 721
 		return $status;
Please login to merge, or discard this patch.
Braces   +12 added lines, -12 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' ) ) {
@@ -40,9 +42,11 @@  discard block
 block discarded – undo
40 42
 
41 43
 	public static function construct_url_parameters($url, $param, $value) {
42 44
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
45
+		if($interoguation_marker_pos===false) {
46
+					return $url.'?'.$param.'='.$value;
47
+		} else {
48
+			return $url.'&'.$param.'='.$value;
49
+		}
46 50
 	}
47 51
 
48 52
 	/**
@@ -167,8 +171,7 @@  discard block
 block discarded – undo
167 171
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168 172
 					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169 173
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
170
-					}
171
-					else {
174
+					} else {
172 175
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
173 176
 					}
174 177
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
@@ -200,8 +203,7 @@  discard block
 block discarded – undo
200 203
 
201 204
 						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202 205
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
203
-						}
204
-						else {
206
+						} else {
205 207
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
206 208
 						}
207 209
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
@@ -599,8 +601,7 @@  discard block
 block discarded – undo
599 601
 					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
600 602
 						$payment_status = 'pos';
601 603
 					}
602
-				}
603
-				else {
604
+				} else {
604 605
 					$payment_status = 'partially_paid';
605 606
 				}
606 607
 
@@ -627,8 +628,7 @@  discard block
 block discarded – undo
627 628
 				if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) {
628 629
 					$wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
629 630
 				}
630
-			}
631
-			else {
631
+			} else {
632 632
 				$payment_status = $bank_response;
633 633
 			}
634 634
 
Please login to merge, or discard this patch.
includes/librairies/payments/cic.class.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -198,22 +198,22 @@
 block discarded – undo
198 198
 // ----------------------------------------------------------------------------
199 199
 function HtmlEncode ($data)
200 200
 {
201
-    $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
-    $encoded_data = "";
203
-    $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
205
-    {
206
-        if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
-            $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
-            $result .= "&#x" . $var . ";";
211
-        }
212
-        else
213
-            $result .= $data{$i};
214
-
215
-    }
216
-    return $result;
201
+	$SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
+	$encoded_data = "";
203
+	$result = "";
204
+	for ($i=0; $i<strlen($data); $i++)
205
+	{
206
+		if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
+			$result .= $data{$i};
208
+		}
209
+		else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
+			$result .= "&#x" . $var . ";";
211
+		}
212
+		else
213
+			$result .= $data{$i};
214
+
215
+	}
216
+	return $result;
217 217
 }
218 218
 
219 219
 class wpshop_CIC {
Please login to merge, or discard this patch.
Braces   +18 added lines, -16 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' ) ) {
@@ -81,9 +83,10 @@  discard block
 block discarded – undo
81 83
 
82 84
 	private function _checkTpeParams($aConstants) {
83 85
 
84
-		for ($i = 0; $i < count($aConstants); $i++)
85
-			if (!defined($aConstants[$i]))
86
+		for ($i = 0; $i < count($aConstants); $i++) {
87
+					if (!defined($aConstants[$i]))
86 88
 				die ("Erreur param�tre " . $aConstants[$i] . " ind�fini");
89
+		}
87 90
 	}
88 91
 
89 92
 }
@@ -126,13 +129,14 @@  discard block
 block discarded – undo
126 129
 
127 130
 		$cca0=ord($hexFinal);
128 131
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
131
-		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
133
-				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134
-			else
135
-				$hexStrKey .= substr($hexFinal, 0, 2);
132
+		if ($cca0>70 && $cca0<97) {
133
+					$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
134
+		} else {
135
+			if (substr($hexFinal, 1, 1)=="M") {
136
+							$hexStrKey .= substr($hexFinal, 0, 1) . "0";
137
+			} else {
138
+							$hexStrKey .= substr($hexFinal, 0, 2);
139
+			}
136 140
 		}
137 141
 
138 142
 		return pack("H*", $hexStrKey);
@@ -205,12 +209,11 @@  discard block
 block discarded – undo
205 209
     {
206 210
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 211
             $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
212
+        } else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210 213
             $result .= "&#x" . $var . ";";
214
+        } else {
215
+                    $result .= $data{$i};
211 216
         }
212
-        else
213
-            $result .= $data{$i};
214 217
 
215 218
     }
216 219
     return $result;
@@ -329,8 +332,7 @@  discard block
 block discarded – undo
329 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
330 333
 
331 334
 			$receipt = CMCIC_CGI2_MACOK;
332
-		}
333
-		else {
335
+		} else {
334 336
 			// your code if the HMAC doesn't match
335 337
 			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
336 338
 		}
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 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
 
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 ***************************************************************************************/
14 14
 
15 15
 
16
-define("CMCIC_CTLHMAC","V1.04.sha1.php--[CtlHmac%s%s]-%s");
16
+define("CMCIC_CTLHMAC", "V1.04.sha1.php--[CtlHmac%s%s]-%s");
17 17
 define("CMCIC_CTLHMACSTR", "CtlHmac%s%s");
18
-define("CMCIC_CGI2_RECEIPT","version=2\ncdr=%s");
19
-define("CMCIC_CGI2_MACOK","0");
20
-define("CMCIC_CGI2_MACNOTOK","1\n");
18
+define("CMCIC_CGI2_RECEIPT", "version=2\ncdr=%s");
19
+define("CMCIC_CGI2_MACOK", "0");
20
+define("CMCIC_CGI2_MACNOTOK", "1\n");
21 21
 define("CMCIC_CGI2_FIELDS", "%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*");
22 22
 define("CMCIC_CGI1_FIELDS", "%s*%s*%s%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s");
23 23
 define("CMCIC_URLPAIEMENT", "paiement.cgi");
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 class CMCIC_Tpe {
26 26
 
27 27
 
28
-	public $sVersion;	// Version du TPE - TPE Version (Ex : 3.0)
29
-	public $sNumero;	// Numero du TPE - TPE Number (Ex : 1234567)
30
-	public $sCodeSociete;	// Code Societe - Company code (Ex : companyname)
31
-	public $sLangue;	// Langue - Language (Ex : FR, DE, EN, ..)
32
-	public $sUrlOK;		// Url de retour OK - Return URL OK
33
-	public $sUrlKO;		// Url de retour KO - Return URL KO
34
-	public $sUrlPaiement;	// Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
28
+	public $sVersion; // Version du TPE - TPE Version (Ex : 3.0)
29
+	public $sNumero; // Numero du TPE - TPE Number (Ex : 1234567)
30
+	public $sCodeSociete; // Code Societe - Company code (Ex : companyname)
31
+	public $sLangue; // Langue - Language (Ex : FR, DE, EN, ..)
32
+	public $sUrlOK; // Url de retour OK - Return URL OK
33
+	public $sUrlKO; // Url de retour KO - Return URL KO
34
+	public $sUrlPaiement; // Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
35 35
 
36
-	private $_sCle;		// La cl� - The Key
36
+	private $_sCle; // La cl� - The Key
37 37
 
38 38
 
39 39
 	// Constructeur / Constructor
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 		$this->sCodeSociete = CMCIC_CODESOCIETE;
53 53
 		$this->sLangue = $sLangue;
54 54
 
55
-		$this->sUrlOK = wpshop_payment::get_success_payment_url();;
56
-		$this->sUrlKO = wpshop_payment::get_cancel_payment_url();;
55
+		$this->sUrlOK = wpshop_payment::get_success_payment_url(); ;
56
+		$this->sUrlKO = wpshop_payment::get_cancel_payment_url(); ;
57 57
 
58 58
 	}
59 59
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 class CMCIC_Hmac {
99 99
 
100
-	private $_sUsableKey;	// La cl� du TPE en format op�rationnel / The usable TPE key
100
+	private $_sUsableKey; // La cl� du TPE en format op�rationnel / The usable TPE key
101 101
 
102 102
 	// ----------------------------------------------------------------------------
103 103
 	//
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	//
120 120
 	// ----------------------------------------------------------------------------
121 121
 
122
-	private function _getUsableKey($oTpe){
122
+	private function _getUsableKey($oTpe) {
123 123
 
124 124
 		$hexStrKey  = substr($oTpe->getCle(), 0, 38);
125 125
 		$hexFinal   = "" . substr($oTpe->getCle(), 38, 2) . "00";
126 126
 
127
-		$cca0=ord($hexFinal);
127
+		$cca0 = ord($hexFinal);
128 128
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
129
+		if ($cca0 > 70 && $cca0 < 97)
130
+			$hexStrKey .= chr($cca0 - 23) . substr($hexFinal, 1, 1);
131 131
 		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
132
+			if (substr($hexFinal, 1, 1) == "M")
133 133
 				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134 134
 			else
135 135
 				$hexStrKey .= substr($hexFinal, 0, 2);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	//
171 171
 	// ----------------------------------------------------------------------------
172 172
 
173
-	public function hmac_sha1 ($key, $data) {
173
+	public function hmac_sha1($key, $data) {
174 174
 
175 175
 		$length = 64; // block length for SHA1
176
-		if (strlen($key) > $length) { $key = pack("H*",sha1($key)); }
176
+		if (strlen($key) > $length) { $key = pack("H*", sha1($key)); }
177 177
 		$key  = str_pad($key, $length, chr(0x00));
178 178
 		$ipad = str_pad('', $length, chr(0x36));
179 179
 		$opad = str_pad('', $length, chr(0x5c));
180
-		$k_ipad = $key ^ $ipad ;
180
+		$k_ipad = $key ^ $ipad;
181 181
 		$k_opad = $key ^ $opad;
182 182
 
183
-		return sha1($k_opad  . pack("H*",sha1($k_ipad . $data)));
183
+		return sha1($k_opad . pack("H*", sha1($k_ipad . $data)));
184 184
 	}
185 185
 
186 186
 }
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 //                           ********************
197 197
 //              Encodage des caract�res sp�ciaux au format HTML
198 198
 // ----------------------------------------------------------------------------
199
-function HtmlEncode ($data)
199
+function HtmlEncode($data)
200 200
 {
201 201
     $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202 202
     $encoded_data = "";
203 203
     $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
204
+    for ($i = 0; $i < strlen($data); $i++)
205 205
     {
206 206
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 207
             $result .= $data{$i};
208 208
         }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
209
+        else if (($var = bin2hex(substr($data, $i, 1))) <= "7F") {
210 210
             $result .= "&#x" . $var . ";";
211 211
         }
212 212
         else
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
 
221 221
 	public function __construct() {
222 222
 		global $wpshop;
223
-		$cic_option = get_option( 'wpshop_addons' );
224
-		if ( !empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']) ) {
223
+		$cic_option = get_option('wpshop_addons');
224
+		if (!empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC'])) {
225 225
 			/** Check if SystemPay is registred in Payment Main Option **/
226
-			$payment_option = get_option( 'wps_payment_mode' );
227
-			if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode']) ) {
226
+			$payment_option = get_option('wps_payment_mode');
227
+			if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode'])) {
228 228
 				$payment_option['mode']['cic']['name'] = __('CIC', 'wpshop');
229
-				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/cic_payment_logo.jpg';
229
+				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg';
230 230
 				$payment_option['mode']['cic']['description'] = __('Reservation of products upon confirmation of payment.', 'wpshop');
231
-				update_option( 'wps_payment_mode', $payment_option );
231
+				update_option('wps_payment_mode', $payment_option);
232 232
 			}
233 233
 		}
234 234
 
235
-		$paymentListener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : '';
235
+		$paymentListener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : '';
236 236
 
237
-		if(!empty($paymentListener) && $paymentListener=='cic') {
237
+		if (!empty($paymentListener) && $paymentListener == 'cic') {
238 238
 			header("Pragma: no-cache");
239 239
 			header("Content-type: text/plain");
240 240
 			self::display_response();
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC'])) {
279 279
 			wpshop_payment::save_payment_return_data($CMCIC_bruteVars['reference']);
280 280
 			$payment_status = 'denied';
281
-			switch($CMCIC_bruteVars['code-retour']) {
281
+			switch ($CMCIC_bruteVars['code-retour']) {
282 282
 				case "Annulation" :
283 283
 					// Attention : an autorization may still be delivered for this payment
284 284
 					//wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'denied');
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 				break;
320 320
 			}
321 321
 
322
-			$order_meta = get_post_meta( $CMCIC_bruteVars['reference'], '_order_postmeta', true);
322
+			$order_meta = get_post_meta($CMCIC_bruteVars['reference'], '_order_postmeta', true);
323 323
 			$params_array = array(
324 324
 				'method' => 'cic',
325
-				'waited_amount' => number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
-				'status' => (($payment_status == 'completed') ? ( ( number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' ) ) ? 'payment_received' : 'incorrect_amount' ) : $payment_status),
325
+				'waited_amount' => number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
+				'status' => (($payment_status == 'completed') ? ((number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')) ? 'payment_received' : 'incorrect_amount') : $payment_status),
327 327
 				'author' => $order_meta['customer_id'],
328 328
 				'payment_reference' => $CMCIC_bruteVars['numauto'],
329 329
 				'date' => current_time('mysql', 0),
330
-				'received_amount' => number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' )
330
+				'received_amount' => number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')
331 331
 			);
332 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
333 333
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		}
336 336
 		else {
337 337
 			// your code if the HMAC doesn't match
338
-			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
338
+			$receipt = CMCIC_CGI2_MACNOTOK . $cgi2_fields;
339 339
 		}
340 340
 
341 341
 		// Send receipt to CMCIC server
342
-		printf (CMCIC_CGI2_RECEIPT, $receipt);
342
+		printf(CMCIC_CGI2_RECEIPT, $receipt);
343 343
 	}
344 344
 
345 345
 	public static function display_form($oid) {
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 		$order_customer_info = get_post_meta($oid, '_order_info', true);
350 350
 		//$currency_code = wpshop_tools::wpshop_get_currency($code=true);
351 351
 		$current_currency = get_option('wpshop_shop_default_currency');
352
-		$query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
353
-		$currency_code = $wpdb->get_var( $query );
352
+		$query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
353
+		$currency_code = $wpdb->get_var($query);
354 354
 
355
-		if(!empty($order) && !empty($currency_code)) {
355
+		if (!empty($order) && !empty($currency_code)) {
356 356
 
357 357
 			$sOptions = "";
358 358
 			// ----------------------------------------------------------------------------
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 			//  That's your job to set actual order fields. Here is a stub.
361 361
 			// -----------------------------------------------------------------------------
362 362
 			$sReference = $oid; // Reference: unique, alphaNum (A-Z a-z 0-9), 12 characters max
363
-			$sMontant = number_format($order['order_grand_total'],2,'.',''); // Amount : format  "xxxxx.yy" (no spaces)
363
+			$sMontant = number_format($order['order_grand_total'], 2, '.', ''); // Amount : format  "xxxxx.yy" (no spaces)
364 364
 			$sDevise  = $currency_code; // Currency : ISO 4217 compliant
365 365
 			$sTexteLibre = ""; // free texte : a bigger reference, session context for the return on the merchant website
366 366
 			$sDate = date("d/m/Y:H:i:s"); // transaction date : format d/m/y:h:m:s
367 367
 			$sLangue = "FR"; // Language of the company code
368
-			$sEmail = $order_customer_info['billing']['address']['address_user_email'];//"[email protected]"; // customer email
368
+			$sEmail = $order_customer_info['billing']['address']['address_user_email']; //"[email protected]"; // customer email
369 369
 			///////////////////////////////////////////////////////////////////////////////////////////
370 370
 			$sNbrEch = ""; //$sNbrEch = "4"; // between 2 and 4
371 371
 			$sDateEcheance1 = ""; // date echeance 1 - format dd/mm/yyyy //$sDateEcheance1 = date("d/m/Y");
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			$CtlHmac = sprintf(CMCIC_CTLHMAC, $oTpe->sVersion, $oTpe->sNumero, $oHmac->computeHmac(sprintf(CMCIC_CTLHMACSTR, $oTpe->sVersion, $oTpe->sNumero)));
387 387
 
388 388
 			// Data to certify
389
-			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS,     $oTpe->sNumero,
389
+			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS, $oTpe->sNumero,
390 390
 															$sDate,
391 391
 															$sMontant,
392 392
 															$sDevise,
@@ -413,30 +413,30 @@  discard block
 block discarded – undo
413 413
 		?>
414 414
 		<script type="text/javascript">jQuery(document).ready(function(){ jQuery('#PaymentRequest_cic').submit(); });</script>
415 415
 		<div class="paypalPaymentLoading"><span><?php _e('Redirect to the CIC site in progress, please wait...', 'wpshop'); ?></span></div>
416
-		<form action="<?php echo $oTpe->sUrlPaiement;?>" method="post" id="PaymentRequest_cic">
417
-			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion;?>" />
418
-			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero;?>" />
419
-			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate;?>" />
420
-			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise;?>" />
421
-			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference;?>" />
422
-			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC;?>" />
423
-			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO;?>" />
424
-			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK;?>" />
425
-			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO;?>" />
426
-			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue;?>" />
427
-			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete;?>" />
428
-			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre);?>" />
429
-			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail;?>" />
416
+		<form action="<?php echo $oTpe->sUrlPaiement; ?>" method="post" id="PaymentRequest_cic">
417
+			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion; ?>" />
418
+			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero; ?>" />
419
+			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate; ?>" />
420
+			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise; ?>" />
421
+			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference; ?>" />
422
+			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC; ?>" />
423
+			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO; ?>" />
424
+			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK; ?>" />
425
+			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO; ?>" />
426
+			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue; ?>" />
427
+			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete; ?>" />
428
+			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre); ?>" />
429
+			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail; ?>" />
430 430
 			<!-- Uniquement pour le Paiement fractionn� -->
431
-			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch;?>" />
432
-			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1;?>" />
433
-			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1;?>" />
434
-			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2;?>" />
435
-			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2;?>" />
436
-			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3;?>" />
437
-			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3;?>" />
438
-			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4;?>" />
439
-			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4;?>" />
431
+			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch; ?>" />
432
+			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1; ?>" />
433
+			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1; ?>" />
434
+			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2; ?>" />
435
+			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2; ?>" />
436
+			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3; ?>" />
437
+			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3; ?>" />
438
+			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4; ?>" />
439
+			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4; ?>" />
440 440
 			<!-- -->
441 441
 			<noscript><input type="submit" name="bouton"              id="bouton"         value="Connexion / Connection" /></noscript>
442 442
 		</form>
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
 		return $output;
448 448
 	}
449 449
 
450
-	public static function display_admin_part( $k ) {
450
+	public static function display_admin_part($k) {
451 451
 		$cmcic_params = get_option('wpshop_cmcic_params', array());
452 452
 		$output = '';
453
-		$output .= '<h2>' .__('CIC configurations', 'wpshop'). '</h2>';
453
+		$output .= '<h2>' . __('CIC configurations', 'wpshop') . '</h2>';
454 454
 		$output .= '<div class="wps_shipping_mode_configuration_part">';
455
-		$output .= '<label class="simple_right">'.__('Key', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'cle' ] ) ? $cmcic_params['cle'] : '' ).'" /><br />';
456
-		$output .= '<label class="simple_right">'.__('TPE', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'tpe' ] ) ? $cmcic_params['tpe']: '' ).'" /><br />';
457
-		$output .= '<label class="simple_right">'.__('Version', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'version' ] ) ? $cmcic_params['version']: '' ).'" /> => 3.0<br />';
458
-		$output .= '<label class="simple_right">'.__('Serveur', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'serveur' ] ) ? $cmcic_params['serveur']: '' ).'" /><br />';
459
-		$output .= '<label class="simple_right">'.__('Company code', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'codesociete' ] ) ? $cmcic_params['codesociete']: '' ).'" /><br />';
455
+		$output .= '<label class="simple_right">' . __('Key', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['cle']) ? $cmcic_params['cle'] : '') . '" /><br />';
456
+		$output .= '<label class="simple_right">' . __('TPE', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['tpe']) ? $cmcic_params['tpe'] : '') . '" /><br />';
457
+		$output .= '<label class="simple_right">' . __('Version', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['version']) ? $cmcic_params['version'] : '') . '" /> => 3.0<br />';
458
+		$output .= '<label class="simple_right">' . __('Serveur', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['serveur']) ? $cmcic_params['serveur'] : '') . '" /><br />';
459
+		$output .= '<label class="simple_right">' . __('Company code', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['codesociete']) ? $cmcic_params['codesociete'] : '') . '" /><br />';
460 460
 		$output .= '</div>';
461 461
 
462 462
 		return $output;
Please login to merge, or discard this patch.
includes/librairies/payments/paypal.class.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -149,8 +149,8 @@
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Display the paypal form in order to redirect correctly to paypal
153
-	*/
152
+	 * Display the paypal form in order to redirect correctly to paypal
153
+	 */
154 154
 	public static function display_form($oid) {
155 155
 		global $wpdb;
156 156
 		$order = get_post_meta($oid, '_order_postmeta', true);
Please login to merge, or discard this patch.
Braces   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -45,8 +47,7 @@  discard block
 block discarded – undo
45 47
 			if($paypalMode == 'sandbox') {
46 48
 				$fp = fsockopen ('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30);
47 49
 				$host = "www.sandbox.paypal.com";
48
-			}
49
-			else {
50
+			} else {
50 51
 				$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
51 52
 				$host = "www.paypal.com";
52 53
 			}
@@ -84,8 +85,7 @@  discard block
 block discarded – undo
84 85
 
85 86
 			if (!$fp){
86 87
 				echo 'HTTP ERROR!';
87
-			}
88
-			else {
88
+			} else {
89 89
 				fputs ($fp, $header.$req);
90 90
 				while (!feof($fp)) {
91 91
 					$res = fgets ($fp, 1024);
@@ -113,13 +113,11 @@  discard block
 block discarded – undo
113 113
 								/*	Check if the paid amount is equal to the order amount	*/
114 114
 								if ( $amount_paid == $amount2pay ) {
115 115
 									$payment_status = 'completed';
116
-								}
117
-								else {
116
+								} else {
118 117
 									$payment_status = 'incorrect_amount';
119 118
 								}
120 119
 
121
-							}
122
-							else {
120
+							} else {
123 121
 								@mail($notify_email, 'VERIFIED DUPLICATED TRANSACTION', 'VERIFIED DUPLICATED TRANSACTION');
124 122
 								$payment_status = 'completed';
125 123
 							}
@@ -164,8 +162,11 @@  discard block
 block discarded – undo
164 162
 			if(!empty($paypalBusinessEmail)) {
165 163
 
166 164
 				$paypalMode = get_option('wpshop_paypalMode', null);
167
-				if($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
168
-				else $paypal = 'https://www.paypal.com/cgi-bin/webscr';
165
+				if($paypalMode == 'sandbox') {
166
+					$paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
167
+				} else {
168
+					$paypal = 'https://www.paypal.com/cgi-bin/webscr';
169
+				}
169 170
 
170 171
 				$current_currency = get_option('wpshop_shop_default_currency');
171 172
 				$query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
@@ -202,8 +203,7 @@  discard block
 block discarded – undo
202 203
 									<input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" />
203 204
 									<input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" />
204 205
 									';
205
-				}
206
-				else {
206
+				} else {
207 207
 
208 208
 					$output .=	'
209 209
 									<input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$order['order_key']. '" />
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -18,38 +18,38 @@  discard block
 block discarded – undo
18 18
 class wpshop_paypal {
19 19
 
20 20
 	public function __construct() {
21
-		add_filter( 'wps_payment_mode_interface_paypal', array( &$this, 'display_admin_part') );
21
+		add_filter('wps_payment_mode_interface_paypal', array(&$this, 'display_admin_part'));
22 22
 
23 23
 		/** Check if SystemPay is registred in Payment Main Option **/
24
-		$payment_option = get_option( 'wps_payment_mode' );
25
-		if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('paypal', $payment_option['mode']) ) {
24
+		$payment_option = get_option('wps_payment_mode');
25
+		if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('paypal', $payment_option['mode'])) {
26 26
 			$payment_option['mode']['paypal']['name'] = __('Paypal', 'wpshop');
27
-			$payment_option['mode']['paypal']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/paypal.png';
27
+			$payment_option['mode']['paypal']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png';
28 28
 			$payment_option['mode']['paypal']['description'] = __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop');
29
-			update_option( 'wps_payment_mode', $payment_option );
29
+			update_option('wps_payment_mode', $payment_option);
30 30
 		}
31 31
 
32
-		$payment_listener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : '';
32
+		$payment_listener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : '';
33 33
 
34
-		if(!empty($payment_listener) && $payment_listener=='paypal') {
34
+		if (!empty($payment_listener) && $payment_listener == 'paypal') {
35 35
 			$payment_status = 'denied';
36 36
 			// read the post from PayPal system and add 'cmd'
37 37
 			$req = 'cmd=_notify-validate';
38 38
 			// @TODO : REQUEST
39
-			$post = !empty($_POST) ? (array) $_POST : array();
40
-			foreach ( $post as $key => $value) {
39
+			$post = !empty($_POST) ? (array)$_POST : array();
40
+			foreach ($post as $key => $value) {
41 41
 				$value = urlencode(stripslashes($value));
42 42
 				$req .= "&$key=$value";
43 43
 			}
44 44
 
45 45
 			// If testing on Sandbox use:
46 46
 			$paypalMode = get_option('wpshop_paypalMode', null);
47
-			if($paypalMode == 'sandbox') {
48
-				$fp = fsockopen ('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30);
47
+			if ($paypalMode == 'sandbox') {
48
+				$fp = fsockopen('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30);
49 49
 				$host = "www.sandbox.paypal.com";
50 50
 			}
51 51
 			else {
52
-				$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
52
+				$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
53 53
 				$host = "www.paypal.com";
54 54
 			}
55 55
 
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			$shipping = $_POST['mc_shipping']; // frais de livraison
65 65
 			$business = $_POST['business']; // compte pro
66 66
 			$order_id = (int)$_POST['invoice']; // num de facture
67
-			$receiver_email = sanitize_text_field( $_POST['receiver_email'] );
67
+			$receiver_email = sanitize_text_field($_POST['receiver_email']);
68 68
 			$amount_paid = $_POST['mc_gross']; // total (hors frais livraison)
69 69
 			$txn_id = $_POST['txn_id']; // num�ro de transaction
70 70
 			$payment_status = $_POST['payment_status']; // status du paiement
71 71
 			$payer_email = $_POST['payer_email']; // email du client
72
-			$txn_type = sanitize_text_field( $_POST['txn_type'] );
72
+			$txn_type = sanitize_text_field($_POST['txn_type']);
73 73
 
74 74
 			// @TODO : REQUEST
75
-			$post = !empty($_POST) ? (array) $_POST : array();
76
-			if ( !empty($post) ) {
77
-				foreach ( $post as $key => $value) {
78
-					if ( substr($key, 0, 9) == 'item_name' ) {
75
+			$post = !empty($_POST) ? (array)$_POST : array();
76
+			if (!empty($post)) {
77
+				foreach ($post as $key => $value) {
78
+					if (substr($key, 0, 9) == 'item_name') {
79 79
 						//$_POST[$key] = htmlentities($value);
80 80
 					}
81 81
 				}
82 82
 			}
83 83
 
84 84
 			/**	Save paypal return data automatically	*/
85
-			wpshop_payment::save_payment_return_data( $order_id );
85
+			wpshop_payment::save_payment_return_data($order_id);
86 86
 
87 87
 			$notify_email = get_option('wpshop_paypalEmail', null); // email address to which debug emails are sent to
88 88
 
89
-			if (!$fp){
89
+			if (!$fp) {
90 90
 				echo 'HTTP ERROR!';
91 91
 			}
92 92
 			else {
93
-				fputs ($fp, $header.$req);
93
+				fputs($fp, $header . $req);
94 94
 				while (!feof($fp)) {
95
-					$res = fgets ($fp, 1024);
96
-					if (strcmp ($res, "VERIFIED") == 0) {
95
+					$res = fgets($fp, 1024);
96
+					if (strcmp($res, "VERIFIED") == 0) {
97 97
 						$paypalBusinessEmail = get_option('wpshop_paypalEmail', null);
98 98
 
99 99
 						/**	Check if payment has been send to good paypal account	*/
100 100
 						if ($receiver_email == $paypalBusinessEmail) {
101 101
 							/**	Get the payment transaction identifier	*/
102
-							$paypal_txn_id = wpshop_payment::get_payment_transaction_number( $order_id,  wpshop_payment::get_order_waiting_payment_array_id( $order_id, 'paypal'));
102
+							$paypal_txn_id = wpshop_payment::get_payment_transaction_number($order_id, wpshop_payment::get_order_waiting_payment_array_id($order_id, 'paypal'));
103 103
 
104 104
 							/**	If no transaction reference has been saved for this order	*/
105
-							if ( empty($paypal_txn_id) ) {
105
+							if (empty($paypal_txn_id)) {
106 106
 								/**	Set the payment reference for the order	*/
107 107
 								wpshop_payment::set_payment_transaction_number($order_id, $txn_id);
108 108
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 								$amount_paid = number_format(floatval($amount_paid), 2, '.', '');
116 116
 
117 117
 								/*	Check if the paid amount is equal to the order amount	*/
118
-								if ( $amount_paid == $amount2pay ) {
118
+								if ($amount_paid == $amount2pay) {
119 119
 									$payment_status = 'completed';
120 120
 								}
121 121
 								else {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 						}
131 131
 					}
132 132
 					// if the IPN POST was 'INVALID'...do this
133
-					elseif (strcmp ($res, "INVALID") == 0) {
133
+					elseif (strcmp($res, "INVALID") == 0) {
134 134
 						@mail($notify_email, "INVALID IPN", "$res\n $req");
135 135
 						$payment_status = 'payment_refused';
136 136
 					}
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 				fclose($fp);
139 139
 			}
140 140
 
141
-			$mc_gross = !empty( $_POST['mc_gross'] ) ? (float)$_POST['mc_gross'] : 0;
141
+			$mc_gross = !empty($_POST['mc_gross']) ? (float)$_POST['mc_gross'] : 0;
142 142
 
143 143
 			$params_array = array('method' => 'paypal',
144 144
 					'waited_amount' => number_format((float)$order['order_amount_to_pay_now'], 2, '.', ''),
145
-					'status' => ( ( number_format((float)$order['order_amount_to_pay_now'], 2, '.', '') == number_format($mc_gross, 2, '.', '') ) ? 'payment_received' : 'incorrect_amount' ),
145
+					'status' => ((number_format((float)$order['order_amount_to_pay_now'], 2, '.', '') == number_format($mc_gross, 2, '.', '')) ? 'payment_received' : 'incorrect_amount'),
146 146
 					'author' => $order['customer_id'],
147 147
 					'payment_reference' => $txn_id,
148 148
 					'date' => current_time('mysql', 0),
149
-					'received_amount' => number_format($mc_gross, 2, '.', '') );
149
+					'received_amount' => number_format($mc_gross, 2, '.', ''));
150 150
 			wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status);
151 151
 
152 152
 		}
@@ -162,25 +162,25 @@  discard block
 block discarded – undo
162 162
 		$order = get_post_meta($oid, '_order_postmeta', true);
163 163
 
164 164
 		// If the order exist
165
-		if(!empty($order)) {
165
+		if (!empty($order)) {
166 166
 
167 167
 			$paypalBusinessEmail = get_option('wpshop_paypalEmail', null);
168 168
 
169 169
 			// Si l'email Paypal n'est pas vide
170
-			if(!empty($paypalBusinessEmail)) {
170
+			if (!empty($paypalBusinessEmail)) {
171 171
 
172 172
 				$paypalMode = get_option('wpshop_paypalMode', null);
173
-				if($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
173
+				if ($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
174 174
 				else $paypal = 'https://www.paypal.com/cgi-bin/webscr';
175 175
 
176 176
 				$current_currency = get_option('wpshop_shop_default_currency');
177
-				$query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
177
+				$query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
178 178
 				$currency = $wpdb->get_var($query);
179 179
 
180 180
 				$output  = '<script type="text/javascript">jQuery(document).ready(function(){ jQuery("#paypalForm").submit(); });</script>';
181 181
 				$output .= '<div class="paypalPaymentLoading"><span>' . __('Redirecting to paypal. Please wait', 'wpshop') . '</span></div>';
182 182
 				$output .= '
183
-						<form action="'.$paypal.'" id="paypalForm" method="post">
183
+						<form action="'.$paypal . '" id="paypalForm" method="post">
184 184
 						<input id="cmd" name="cmd" type="hidden" value="_cart" />
185 185
 						<input id="upload" name="upload" type="hidden" value="1" />
186 186
 						<input id="charset" name="charset" type="hidden" value="utf-8" />
@@ -188,41 +188,41 @@  discard block
 block discarded – undo
188 188
 						<input id="no_note" name="no_note" type="hidden" value="0" />
189 189
 						<input id="rm" name="rm" type="hidden" value="0" />
190 190
 
191
-						<input id="custom" name="custom" type="hidden" value="'.$order['customer_id'].'" />
192
-						<input id="invoice" name="invoice" type="hidden" value="'.$oid.'" /> <!-- Invoice number -->
193
-						<input id="business" name="business" type="hidden" value="'.$paypalBusinessEmail.'" /> <!-- Paypal business account -->
191
+						<input id="custom" name="custom" type="hidden" value="'.$order['customer_id'] . '" />
192
+						<input id="invoice" name="invoice" type="hidden" value="'.$oid . '" /> <!-- Invoice number -->
193
+						<input id="business" name="business" type="hidden" value="'.$paypalBusinessEmail . '" /> <!-- Paypal business account -->
194 194
 						<input id="cbt" name="cbt" type="hidden" value="' . __('Back to shop', 'wpshop') . '" />
195 195
 						<input id="lc" name="lc" type="hidden" value="FR" />
196
-						<input id="currency_code" name="currency_code" type="hidden" value="'.$currency.'" />
196
+						<input id="currency_code" name="currency_code" type="hidden" value="'.$currency . '" />
197 197
 
198
-						<input id="return" name="return" type="hidden" value="'.wpshop_payment::get_success_payment_url().'" />
199
-						<input id="cancel_return" name="cancel_return" type="hidden" value="'.wpshop_payment::get_cancel_payment_url().'" />
200
-						<input id="notify_url" name="notify_url" type="hidden" value="'.wpshop_payment::construct_url_parameters(trailingslashit(home_url()), 'paymentListener', 'paypal').'" />
198
+						<input id="return" name="return" type="hidden" value="'.wpshop_payment::get_success_payment_url() . '" />
199
+						<input id="cancel_return" name="cancel_return" type="hidden" value="'.wpshop_payment::get_cancel_payment_url() . '" />
200
+						<input id="notify_url" name="notify_url" type="hidden" value="'.wpshop_payment::construct_url_parameters(trailingslashit(home_url()), 'paymentListener', 'paypal') . '" />
201 201
 				';
202 202
 
203
-				$i=1;
204
-				if ( !empty( $order['order_partial_payment']) && !empty($order['order_partial_payment']['amount_of_partial_payment']) ) {
205
-					$output .=	'
206
-									<input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$oid. '_partial_payment" />
207
-									<input id="item_name_'.$i.'" name="item_name_'.$i.'" type="hidden" value="'.__('Partial payment', 'wpshop').' (' .__('Order number', 'wpshop'). ' : ' .$order['order_key']. ')" />
208
-									<input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" />
209
-									<input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" />
203
+				$i = 1;
204
+				if (!empty($order['order_partial_payment']) && !empty($order['order_partial_payment']['amount_of_partial_payment'])) {
205
+					$output .= '
206
+									<input id="item_number_'.$i . '" name="item_number_' . $i . '" type="hidden" value="' . $oid . '_partial_payment" />
207
+									<input id="item_name_'.$i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Partial payment', 'wpshop') . ' (' . __('Order number', 'wpshop') . ' : ' . $order['order_key'] . ')" />
208
+									<input id="quantity_'.$i . '" name="quantity_' . $i . '" type="hidden" value="1" />
209
+									<input id="amount_'.$i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" />
210 210
 									';
211 211
 				}
212 212
 				else {
213 213
 
214
-					$output .=	'
215
-									<input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$order['order_key']. '" />
216
-									<input id="item_name_'.$i.'" name="item_name_'.$i.'" type="hidden" value="' .__('Current order', 'wpshop'). ' : ' .$order['order_key']. '" />
217
-									<input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" />
218
-									<input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" />
214
+					$output .= '
215
+									<input id="item_number_'.$i . '" name="item_number_' . $i . '" type="hidden" value="' . $order['order_key'] . '" />
216
+									<input id="item_name_'.$i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Current order', 'wpshop') . ' : ' . $order['order_key'] . '" />
217
+									<input id="quantity_'.$i . '" name="quantity_' . $i . '" type="hidden" value="1" />
218
+									<input id="amount_'.$i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" />
219 219
 									';
220 220
 
221 221
 				}
222 222
 
223 223
 
224 224
 
225
-				$output .=	'<noscript><input type="submit" value="' . __('Checkout', 'wpshop') . '" /></noscript></form>';
225
+				$output .= '<noscript><input type="submit" value="' . __('Checkout', 'wpshop') . '" /></noscript></form>';
226 226
 			}
227 227
 		}
228 228
 
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 
233 233
 	function display_admin_part() {
234 234
 		$paypalEmail = get_option('wpshop_paypalEmail');
235
-		$paypalMode = get_option('wpshop_paypalMode',0);
235
+		$paypalMode = get_option('wpshop_paypalMode', 0);
236 236
 		$output  = '<div class="wps-boxed">';
237
-		$output .= '<div class="wps-form-group"><label>'.__('Business email','wpshop').'</label><div class="wps-form"><input name="wpshop_paypalEmail" type="text" value="'.$paypalEmail.'" /></div></div>';
238
-		$output .= '<label class="simple_right">'.__('Mode','wpshop').'</label>';
237
+		$output .= '<div class="wps-form-group"><label>' . __('Business email', 'wpshop') . '</label><div class="wps-form"><input name="wpshop_paypalEmail" type="text" value="' . $paypalEmail . '" /></div></div>';
238
+		$output .= '<label class="simple_right">' . __('Mode', 'wpshop') . '</label>';
239 239
 		$output .= '<div class="wps-form"><select name="wpshop_paypalMode">';
240
-		$output .= '<option value="normal"'.(($paypalMode=='sandbox') ? null : ' selected="selected"').'>'.__('Production mode','wpshop').'</option>';
241
-		$output .= '<option value="sandbox"'.(($paypalMode=='sandbox') ? ' selected="selected"' : null).'>'.__('Sandbox mode','wpshop').'</option>';
240
+		$output .= '<option value="normal"' . (($paypalMode == 'sandbox') ? null : ' selected="selected"') . '>' . __('Production mode', 'wpshop') . '</option>';
241
+		$output .= '<option value="sandbox"' . (($paypalMode == 'sandbox') ? ' selected="selected"' : null) . '>' . __('Sandbox mode', 'wpshop') . '</option>';
242 242
 		$output .= '</select>';
243 243
 		$output .= '</div>';
244
-		$output .= '<a href="#" title="'.__('This checkbox allow to use Paypal in Sandbox mode (test) or production mode (real money)','wpshop').'" class="wpshop_infobulle_marker">?</a>';
244
+		$output .= '<a href="#" title="' . __('This checkbox allow to use Paypal in Sandbox mode (test) or production mode (real money)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
245 245
 		$output .= '</div>';
246 246
 		return $output;
247 247
 	}
Please login to merge, or discard this patch.
includes/librairies/db/database.class.php 3 patches
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.