@@ -214,6 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param mixed string | EED_Module $module |
217 | + * @param boolean|string $module |
|
217 | 218 | */ |
218 | 219 | public function add_module( $module ) { |
219 | 220 | if ( $module instanceof EED_Module ) { |
@@ -245,7 +246,7 @@ discard block |
||
245 | 246 | * @param string $class_name - simple class name ie: session |
246 | 247 | * @param mixed $arguments |
247 | 248 | * @param bool $load_only |
248 | - * @return mixed |
|
249 | + * @return boolean |
|
249 | 250 | */ |
250 | 251 | public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
251 | 252 | $core_paths = apply_filters( |
@@ -269,7 +270,7 @@ discard block |
||
269 | 270 | * @access public |
270 | 271 | * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0 |
271 | 272 | * @param mixed $arguments |
272 | - * @return EE_Data_Migration_Script_Base |
|
273 | + * @return boolean |
|
273 | 274 | */ |
274 | 275 | public function load_dms ( $class_name, $arguments = array() ) { |
275 | 276 | // retrieve instantiated class |
@@ -286,7 +287,7 @@ discard block |
||
286 | 287 | * @param bool $from_db - some classes are instantiated from the db and thus call a different method to instantiate |
287 | 288 | * @param bool $cache if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop) |
288 | 289 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
289 | - * @return EE_Base_Class |
|
290 | + * @return boolean |
|
290 | 291 | */ |
291 | 292 | public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
292 | 293 | $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
@@ -307,7 +308,7 @@ discard block |
||
307 | 308 | * @param string $class_name - simple class name ie: price |
308 | 309 | * @param mixed $arguments |
309 | 310 | * @param bool $load_only |
310 | - * @return EEH_Base |
|
311 | + * @return boolean |
|
311 | 312 | */ |
312 | 313 | public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
313 | 314 | $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
@@ -324,7 +325,7 @@ discard block |
||
324 | 325 | * @param string $class_name - simple class name ie: session |
325 | 326 | * @param mixed $arguments |
326 | 327 | * @param bool $load_only |
327 | - * @return mixed |
|
328 | + * @return boolean |
|
328 | 329 | */ |
329 | 330 | public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
330 | 331 | $paths = array( |
@@ -346,7 +347,7 @@ discard block |
||
346 | 347 | * @param string $class_name - simple class name ie: price |
347 | 348 | * @param mixed $arguments |
348 | 349 | * @param bool $load_only |
349 | - * @return EEM_Base |
|
350 | + * @return boolean |
|
350 | 351 | */ |
351 | 352 | public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
352 | 353 | $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
@@ -365,7 +366,7 @@ discard block |
||
365 | 366 | * @param string $class_name - simple class name ie: price |
366 | 367 | * @param mixed $arguments |
367 | 368 | * @param bool $load_only |
368 | - * @return mixed |
|
369 | + * @return boolean |
|
369 | 370 | */ |
370 | 371 | public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
371 | 372 | $paths = array( |
@@ -401,7 +402,7 @@ discard block |
||
401 | 402 | * @param string $type - file type - core? class? helper? model? |
402 | 403 | * @param mixed $arguments |
403 | 404 | * @param bool $load_only |
404 | - * @return mixed |
|
405 | + * @return boolean |
|
405 | 406 | */ |
406 | 407 | public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
407 | 408 | // retrieve instantiated class |
@@ -418,7 +419,7 @@ discard block |
||
418 | 419 | * @param string $type - file type - core? class? helper? model? |
419 | 420 | * @param mixed $arguments |
420 | 421 | * @param bool $load_only |
421 | - * @return EE_Addon |
|
422 | + * @return boolean |
|
422 | 423 | */ |
423 | 424 | public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
424 | 425 | // retrieve instantiated class |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -11,25 +11,25 @@ discard block |
||
11 | 11 | final class EE_Registry { |
12 | 12 | |
13 | 13 | /** |
14 | - * EE_Registry Object |
|
15 | - * @var EE_Registry $_instance |
|
16 | - * @access private |
|
17 | - */ |
|
14 | + * EE_Registry Object |
|
15 | + * @var EE_Registry $_instance |
|
16 | + * @access private |
|
17 | + */ |
|
18 | 18 | private static $_instance = NULL; |
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * EE_Cart Object |
|
23 | - * @access public |
|
24 | - * @var EE_Cart $CART |
|
25 | - */ |
|
22 | + * EE_Cart Object |
|
23 | + * @access public |
|
24 | + * @var EE_Cart $CART |
|
25 | + */ |
|
26 | 26 | public $CART = NULL; |
27 | 27 | |
28 | 28 | /** |
29 | - * EE_Config Object |
|
30 | - * @access public |
|
31 | - * @var EE_Config $CFG |
|
32 | - */ |
|
29 | + * EE_Config Object |
|
30 | + * @access public |
|
31 | + * @var EE_Config $CFG |
|
32 | + */ |
|
33 | 33 | public $CFG = NULL; |
34 | 34 | |
35 | 35 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | /** |
47 | - * StdClass object for storing library classes in |
|
48 | - * @public LIB |
|
49 | - */ |
|
47 | + * StdClass object for storing library classes in |
|
48 | + * @public LIB |
|
49 | + */ |
|
50 | 50 | public $LIB = NULL; |
51 | 51 | |
52 | 52 | /** |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public $REQ = NULL; |
58 | 58 | |
59 | 59 | /** |
60 | - * EE_Session Object |
|
61 | - * @access public |
|
62 | - * @var EE_Session $SSN |
|
63 | - */ |
|
60 | + * EE_Session Object |
|
61 | + * @access public |
|
62 | + * @var EE_Session $SSN |
|
63 | + */ |
|
64 | 64 | public $SSN = NULL; |
65 | 65 | |
66 | 66 | |
@@ -127,21 +127,21 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
130 | - * $i18n_js_strings - internationalization for JS strings |
|
131 | - * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | - * in js file: var translatedString = eei18n.string_key; |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @var array |
|
136 | - */ |
|
130 | + * $i18n_js_strings - internationalization for JS strings |
|
131 | + * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | + * in js file: var translatedString = eei18n.string_key; |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @var array |
|
136 | + */ |
|
137 | 137 | public static $i18n_js_strings = array(); |
138 | 138 | |
139 | 139 | /** |
140 | - * $main_file - path to espresso.php |
|
141 | - * |
|
142 | - * @access public |
|
143 | - * @var array |
|
144 | - */ |
|
140 | + * $main_file - path to espresso.php |
|
141 | + * |
|
142 | + * @access public |
|
143 | + * @var array |
|
144 | + */ |
|
145 | 145 | public $main_file; |
146 | 146 | |
147 | 147 |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function instance() { |
158 | 158 | // check if class object is instantiated |
159 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Registry )) { |
|
159 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Registry)) { |
|
160 | 160 | self::$_instance = new self(); |
161 | 161 | } |
162 | 162 | return self::$_instance; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @return EE_Registry |
172 | 172 | */ |
173 | 173 | private function __construct() { |
174 | - $this->load_core( 'Base' ); |
|
174 | + $this->load_core('Base'); |
|
175 | 175 | // class library |
176 | 176 | $this->LIB = new StdClass(); |
177 | 177 | $this->addons = new StdClass(); |
178 | 178 | $this->modules = new StdClass(); |
179 | 179 | $this->shortcodes = new StdClass(); |
180 | 180 | $this->widgets = new StdClass(); |
181 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' )); |
|
181 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function init() { |
193 | 193 | // Get current page protocol |
194 | - $protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://'; |
|
194 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
195 | 195 | // Output admin-ajax.php URL with same protocol as current page |
196 | - self::$i18n_js_strings['ajax_url'] = admin_url( 'admin-ajax.php', $protocol ); |
|
197 | - self::$i18n_js_strings['wp_debug'] = defined( 'WP_DEBUG' ) ? WP_DEBUG : FALSE; |
|
196 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
197 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : FALSE; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | */ |
207 | 207 | public static function localize_i18n_js_strings() { |
208 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
209 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
210 | - if ( is_scalar( $value ) ) { |
|
211 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
208 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
209 | + foreach ($i18n_js_strings as $key => $value) { |
|
210 | + if (is_scalar($value)) { |
|
211 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
215 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * @param mixed string | EED_Module $module |
222 | 222 | */ |
223 | - public function add_module( $module ) { |
|
224 | - if ( $module instanceof EED_Module ) { |
|
225 | - $module_class = get_class( $module ); |
|
223 | + public function add_module($module) { |
|
224 | + if ($module instanceof EED_Module) { |
|
225 | + $module_class = get_class($module); |
|
226 | 226 | $this->modules->{$module_class} = $module; |
227 | 227 | } else { |
228 | - if ( ! class_exists( 'EE_Module_Request_Router' )) { |
|
229 | - $this->load_core( 'Module_Request_Router' ); |
|
228 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
229 | + $this->load_core('Module_Request_Router'); |
|
230 | 230 | } |
231 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
231 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param string $module_name |
239 | 239 | * @return mixed EED_Module | NULL |
240 | 240 | */ |
241 | - public function get_module( $module_name = '' ) { |
|
242 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
241 | + public function get_module($module_name = '') { |
|
242 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * @param bool $load_only |
253 | 253 | * @return mixed |
254 | 254 | */ |
255 | - public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
255 | + public function load_core($class_name, $arguments = array(), $load_only = FALSE) { |
|
256 | 256 | $core_paths = apply_filters( |
257 | 257 | 'FHEE__EE_Registry__load_core__core_paths', |
258 | 258 | array( |
259 | 259 | EE_CORE, |
260 | 260 | EE_ADMIN, |
261 | 261 | EE_CPTS, |
262 | - EE_CORE . 'data_migration_scripts' . DS |
|
262 | + EE_CORE.'data_migration_scripts'.DS |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | // retrieve instantiated class |
266 | - return $this->_load( $core_paths, 'EE_' , $class_name, 'core', $arguments, FALSE, TRUE, $load_only ); |
|
266 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, FALSE, TRUE, $load_only); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param mixed $arguments |
277 | 277 | * @return EE_Data_Migration_Script_Base |
278 | 278 | */ |
279 | - public function load_dms ( $class_name, $arguments = array() ) { |
|
279 | + public function load_dms($class_name, $arguments = array()) { |
|
280 | 280 | // retrieve instantiated class |
281 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_' , $class_name, 'dms', $arguments, FALSE, FALSE, FALSE ); |
|
281 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, FALSE, FALSE, FALSE); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
294 | 294 | * @return EE_Base_Class |
295 | 295 | */ |
296 | - public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
297 | - $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
|
296 | + public function load_class($class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
297 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
298 | 298 | EE_CORE, |
299 | 299 | EE_CLASSES, |
300 | 300 | EE_BUSINESS |
301 | 301 | )); |
302 | 302 | // retrieve instantiated class |
303 | - return $this->_load( $paths, 'EE_' , $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
303 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @param bool $load_only |
315 | 315 | * @return EEH_Base |
316 | 316 | */ |
317 | - public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
318 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
|
317 | + public function load_helper($class_name, $arguments = array(), $load_only = TRUE) { |
|
318 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
319 | 319 | // retrieve instantiated class |
320 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only ); |
|
320 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * @param bool $load_only |
332 | 332 | * @return mixed |
333 | 333 | */ |
334 | - public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
334 | + public function load_lib($class_name, $arguments = array(), $load_only = FALSE) { |
|
335 | 335 | $paths = array( |
336 | 336 | EE_LIBRARIES, |
337 | - EE_LIBRARIES . 'messages' . DS, |
|
338 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
339 | - EE_LIBRARIES . 'qtips' . DS, |
|
340 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
337 | + EE_LIBRARIES.'messages'.DS, |
|
338 | + EE_LIBRARIES.'shortcodes'.DS, |
|
339 | + EE_LIBRARIES.'qtips'.DS, |
|
340 | + EE_LIBRARIES.'payment_methods'.DS, |
|
341 | 341 | ); |
342 | 342 | // retrieve instantiated class |
343 | - return $this->_load( $paths, 'EE_' , $class_name, 'lib', $arguments, FALSE, TRUE, $load_only ); |
|
343 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, FALSE, TRUE, $load_only); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @param bool $load_only |
354 | 354 | * @return EEM_Base |
355 | 355 | */ |
356 | - public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
357 | - $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
|
356 | + public function load_model($class_name, $arguments = array(), $load_only = FALSE) { |
|
357 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
358 | 358 | EE_MODELS, |
359 | 359 | EE_CORE |
360 | 360 | )); |
361 | 361 | // retrieve instantiated class |
362 | - return $this->_load( $paths, 'EEM_' , $class_name, 'model', $arguments, FALSE, TRUE, $load_only ); |
|
362 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, FALSE, TRUE, $load_only); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | * @param bool $load_only |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | - public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
375 | + public function load_model_class($class_name, $arguments = array(), $load_only = TRUE) { |
|
376 | 376 | $paths = array( |
377 | - EE_MODELS . 'fields' . DS, |
|
378 | - EE_MODELS . 'helpers' . DS, |
|
379 | - EE_MODELS . 'relations' . DS, |
|
380 | - EE_MODELS . 'strategies' . DS |
|
377 | + EE_MODELS.'fields'.DS, |
|
378 | + EE_MODELS.'helpers'.DS, |
|
379 | + EE_MODELS.'relations'.DS, |
|
380 | + EE_MODELS.'strategies'.DS |
|
381 | 381 | ); |
382 | 382 | // retrieve instantiated class |
383 | - return $this->_load( $paths, 'EE_' , $class_name, '', $arguments, FALSE, TRUE, $load_only ); |
|
383 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, FALSE, TRUE, $load_only); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
393 | 393 | * @return boolean |
394 | 394 | */ |
395 | - public function is_model_name( $model_name ){ |
|
396 | - return isset( $this->models[ $model_name ] ) ? TRUE : FALSE; |
|
395 | + public function is_model_name($model_name) { |
|
396 | + return isset($this->models[$model_name]) ? TRUE : FALSE; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @param bool $load_only |
409 | 409 | * @return mixed |
410 | 410 | */ |
411 | - public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
|
411 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE) { |
|
412 | 412 | // retrieve instantiated class |
413 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
413 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param bool $load_only |
426 | 426 | * @return EE_Addon |
427 | 427 | */ |
428 | - public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
|
428 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE) { |
|
429 | 429 | // retrieve instantiated class |
430 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
430 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @internal param string $file_path - file path including file name |
446 | 446 | * @return bool | object |
447 | 447 | */ |
448 | - private function _load ( $file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
448 | + private function _load($file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
449 | 449 | // strip php file extension |
450 | - $class_name = str_replace( '.php', '', trim( $class_name )); |
|
450 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
451 | 451 | // does the class have a prefix ? |
452 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
452 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
453 | 453 | // make sure $class_prefix is uppercase |
454 | - $class_prefix = strtoupper( trim( $class_prefix )); |
|
454 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
455 | 455 | // add class prefix ONCE!!! |
456 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
456 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $class_abbreviations = array( |
@@ -465,61 +465,61 @@ discard block |
||
465 | 465 | 'EE_Capabilities' => 'CAP' |
466 | 466 | ); |
467 | 467 | |
468 | - $class_abbreviation = isset( $class_abbreviations[ $class_name ] ) |
|
469 | - ? $class_abbreviations[ $class_name ] |
|
468 | + $class_abbreviation = isset($class_abbreviations[$class_name]) |
|
469 | + ? $class_abbreviations[$class_name] |
|
470 | 470 | : ''; |
471 | 471 | // check if class has already been loaded, and return it if it has been |
472 | - if ( $class_abbreviation !== '' && ! is_null( $this->{$class_abbreviation} ) |
|
472 | + if ($class_abbreviation !== '' && ! is_null($this->{$class_abbreviation} ) |
|
473 | 473 | ) { |
474 | 474 | return $this->{$class_abbreviation}; |
475 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
475 | + } else if (isset ($this->{$class_name} )) { |
|
476 | 476 | return $this->{$class_name}; |
477 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
477 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
478 | 478 | return $this->LIB->{$class_name}; |
479 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
479 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
480 | 480 | return $this->addons->{$class_name}; |
481 | 481 | } |
482 | 482 | |
483 | 483 | // assume all paths lead nowhere |
484 | 484 | $path = FALSE; |
485 | 485 | // make sure $file_paths is an array |
486 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
486 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
487 | 487 | // cycle thru paths |
488 | - foreach ( $file_paths as $key => $file_path ) { |
|
488 | + foreach ($file_paths as $key => $file_path) { |
|
489 | 489 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
490 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
490 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
491 | 491 | // prep file type |
492 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
492 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
493 | 493 | // build full file path |
494 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
494 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
495 | 495 | //does the file exist and can be read ? |
496 | - if ( is_readable( $file_paths[ $key ] )) { |
|
497 | - $path = $file_paths[ $key ]; |
|
496 | + if (is_readable($file_paths[$key])) { |
|
497 | + $path = $file_paths[$key]; |
|
498 | 498 | break; |
499 | 499 | } |
500 | 500 | } |
501 | 501 | // don't give up! you gotta... |
502 | 502 | try { |
503 | 503 | //does the file exist and can it be read ? |
504 | - if ( ! $path ) { |
|
504 | + if ( ! $path) { |
|
505 | 505 | // so sorry, can't find the file |
506 | - throw new EE_Error ( |
|
507 | - sprintf ( |
|
508 | - __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s','event_espresso'), |
|
509 | - trim( $type, '.' ), |
|
506 | + throw new EE_Error( |
|
507 | + sprintf( |
|
508 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
509 | + trim($type, '.'), |
|
510 | 510 | $class_name, |
511 | - '<br />' . implode( ',<br />', $file_paths ) |
|
511 | + '<br />'.implode(',<br />', $file_paths) |
|
512 | 512 | ) |
513 | 513 | ); |
514 | 514 | } |
515 | 515 | // get the file |
516 | - require_once( $path ); |
|
516 | + require_once($path); |
|
517 | 517 | // if the class isn't already declared somewhere |
518 | - if ( class_exists( $class_name, FALSE ) === FALSE ) { |
|
518 | + if (class_exists($class_name, FALSE) === FALSE) { |
|
519 | 519 | // so sorry, not a class |
520 | 520 | throw new EE_Error( |
521 | 521 | sprintf( |
522 | - __('The %s file %s does not appear to contain the %s Class.','event_espresso'), |
|
522 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
523 | 523 | $type, |
524 | 524 | $path, |
525 | 525 | $class_name |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ); |
528 | 528 | } |
529 | 529 | |
530 | - } catch ( EE_Error $e ) { |
|
530 | + } catch (EE_Error $e) { |
|
531 | 531 | $e->get_error(); |
532 | 532 | } |
533 | 533 | |
@@ -535,38 +535,38 @@ discard block |
||
535 | 535 | // don't give up! you gotta... |
536 | 536 | try { |
537 | 537 | // create reflection |
538 | - $reflector = new ReflectionClass( $class_name ); |
|
538 | + $reflector = new ReflectionClass($class_name); |
|
539 | 539 | // instantiate the class and add to the LIB array for tracking |
540 | 540 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
541 | - if ( $reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only ) { |
|
541 | + if ($reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only) { |
|
542 | 542 | // $instantiation_mode = 0; |
543 | 543 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
544 | 544 | return TRUE; |
545 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
545 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
546 | 546 | // $instantiation_mode = 1; |
547 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
548 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
547 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
548 | + } else if (method_exists($class_name, 'new_instance')) { |
|
549 | 549 | // $instantiation_mode = 2; |
550 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
551 | - } else if ( method_exists( $class_name, 'instance' )) { |
|
550 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
551 | + } else if (method_exists($class_name, 'instance')) { |
|
552 | 552 | // $instantiation_mode = 3; |
553 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
554 | - } else if ( $reflector->isInstantiable() ) { |
|
553 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
554 | + } else if ($reflector->isInstantiable()) { |
|
555 | 555 | // $instantiation_mode = 4; |
556 | - $class_obj = $reflector->newInstance( $arguments ); |
|
557 | - } else if ( ! $load_only ) { |
|
556 | + $class_obj = $reflector->newInstance($arguments); |
|
557 | + } else if ( ! $load_only) { |
|
558 | 558 | // heh ? something's not right ! |
559 | 559 | // $instantiation_mode = 5; |
560 | 560 | throw new EE_Error( |
561 | 561 | sprintf( |
562 | - __('The %s file %s could not be instantiated.','event_espresso'), |
|
562 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
563 | 563 | $type, |
564 | 564 | $class_name |
565 | 565 | ) |
566 | 566 | ); |
567 | 567 | } |
568 | 568 | |
569 | - } catch ( EE_Error $e ) { |
|
569 | + } catch (EE_Error $e) { |
|
570 | 570 | $e->get_error(); |
571 | 571 | } |
572 | 572 | |
@@ -578,15 +578,15 @@ discard block |
||
578 | 578 | // EEH_Debug_Tools::printr( $class_obj, '$class_obj <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
579 | 579 | |
580 | 580 | |
581 | - if ( isset( $class_obj )) { |
|
581 | + if (isset($class_obj)) { |
|
582 | 582 | // return newly instantiated class |
583 | - if ( $class_abbreviation !== '' ) { |
|
583 | + if ($class_abbreviation !== '') { |
|
584 | 584 | $this->{$class_abbreviation} = $class_obj; |
585 | - } else if ( EEH_Class_Tools::has_property( $this, $class_name )) { |
|
585 | + } else if (EEH_Class_Tools::has_property($this, $class_name)) { |
|
586 | 586 | $this->{$class_name} = $class_obj; |
587 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
587 | + } else if ($class_prefix == 'addon' && $cache) { |
|
588 | 588 | $this->addons->{$class_name} = $class_obj; |
589 | - } else if ( !$from_db && $cache ) { |
|
589 | + } else if ( ! $from_db && $cache) { |
|
590 | 590 | $this->LIB->{$class_name} = $class_obj; |
591 | 591 | } |
592 | 592 | return $class_obj; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @param $a |
612 | 612 | * @param $b |
613 | 613 | */ |
614 | - final function __call($a,$b) {} |
|
614 | + final function __call($a, $b) {} |
|
615 | 615 | |
616 | 616 | |
617 | 617 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param $a |
627 | 627 | * @param $b |
628 | 628 | */ |
629 | - final function __set($a,$b) {} |
|
629 | + final function __set($a, $b) {} |
|
630 | 630 | |
631 | 631 | |
632 | 632 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @param $a |
667 | 667 | * @param $b |
668 | 668 | */ |
669 | - final static function __callStatic($a,$b) {} |
|
669 | + final static function __callStatic($a, $b) {} |
|
670 | 670 | |
671 | 671 | /** |
672 | 672 | * Gets the addon by its name/slug (not classname. For that, just |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @param string $name |
675 | 675 | * @return EE_Addon |
676 | 676 | */ |
677 | - public function get_addon_by_name( $name ){ |
|
678 | - foreach($this->addons as $addon){ |
|
679 | - if( $addon->name() == $name){ |
|
677 | + public function get_addon_by_name($name) { |
|
678 | + foreach ($this->addons as $addon) { |
|
679 | + if ($addon->name() == $name) { |
|
680 | 680 | return $addon; |
681 | 681 | } |
682 | 682 | } |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @return EE_Addon[] where the KEYS are the addon's name() |
689 | 689 | */ |
690 | - public function get_addons_by_name(){ |
|
690 | + public function get_addons_by_name() { |
|
691 | 691 | $addons = array(); |
692 | - foreach($this->addons as $addon){ |
|
693 | - $addons[ $addon->name() ] = $addon; |
|
692 | + foreach ($this->addons as $addon) { |
|
693 | + $addons[$addon->name()] = $addon; |
|
694 | 694 | } |
695 | 695 | return $addons; |
696 | 696 | } |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | * @return EEM_Base |
706 | 706 | * @throws EE_Error |
707 | 707 | */ |
708 | - public function reset_model( $model_name ){ |
|
709 | - $model = $this->load_model( $model_name ); |
|
710 | - $model_class_name = get_class( $model ); |
|
708 | + public function reset_model($model_name) { |
|
709 | + $model = $this->load_model($model_name); |
|
710 | + $model_class_name = get_class($model); |
|
711 | 711 | //get that model reset it and make sure we nuke the old reference to it |
712 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
712 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
713 | 713 | $this->LIB->{$model_class_name} = $model::reset(); |
714 | - }else{ |
|
715 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
714 | + } else { |
|
715 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
716 | 716 | } |
717 | 717 | return $this->LIB->{$model_class_name}; |
718 | 718 | } |
@@ -728,15 +728,15 @@ discard block |
||
728 | 728 | * currently reinstantiate the singletons at the moment) |
729 | 729 | * @return EE_Registry |
730 | 730 | */ |
731 | - public static function reset( $hard = FALSE, $reinstantiate = TRUE ){ |
|
731 | + public static function reset($hard = FALSE, $reinstantiate = TRUE) { |
|
732 | 732 | $instance = self::instance(); |
733 | 733 | $instance->load_helper('Activation'); |
734 | 734 | EEH_Activation::reset(); |
735 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
735 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
736 | 736 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
737 | 737 | $instance->LIB = new stdClass(); |
738 | - foreach( array_keys( $instance->non_abstract_db_models ) as $model_name ){ |
|
739 | - $instance->reset_model( $model_name ); |
|
738 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
739 | + $instance->reset_model($model_name); |
|
740 | 740 | } |
741 | 741 | return $instance; |
742 | 742 | } |
@@ -747,9 +747,9 @@ discard block |
||
747 | 747 | */ |
748 | 748 | public function cpt_models() { |
749 | 749 | $cpt_models = array(); |
750 | - foreach( $this->non_abstract_db_models as $shortname => $classname ) { |
|
751 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
752 | - $cpt_models[ $shortname ] = $classname; |
|
750 | + foreach ($this->non_abstract_db_models as $shortname => $classname) { |
|
751 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
752 | + $cpt_models[$shortname] = $classname; |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | return $cpt_models; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * is_espresso_page |
272 | 272 | * |
273 | 273 | * @access public |
274 | - * @param null $value |
|
274 | + * @param boolean $value |
|
275 | 275 | * @return mixed |
276 | 276 | */ |
277 | 277 | public function set_espresso_page( $value = null ) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * setter |
308 | 308 | * |
309 | 309 | * @access public |
310 | - * @param $key |
|
310 | + * @param string $key |
|
311 | 311 | * @param $value |
312 | 312 | * @param bool $override_ee |
313 | 313 | * @return void |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * remove param |
353 | 353 | * |
354 | 354 | * @access public |
355 | - * @param $key |
|
355 | + * @param string $key |
|
356 | 356 | * @return void |
357 | 357 | */ |
358 | 358 | public function un_set( $key ) { |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * add_output |
393 | 393 | * |
394 | 394 | * @access public |
395 | - * @param $string |
|
395 | + * @param string $string |
|
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | public function add_output( $string ) { |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param WP $wp |
66 | 66 | * @return \EE_Request_Handler |
67 | 67 | */ |
68 | - public function __construct( $wp = null ) { |
|
68 | + public function __construct($wp = null) { |
|
69 | 69 | // grab request vars |
70 | 70 | // NOTE: WHEN MERGING TO 4.9 PLZ FAVOUR THE CHANGES IN 4.9 OVER THE FOLLOWING LINE |
71 | - $this->_params = array_merge( $_GET, $_POST ); |
|
71 | + $this->_params = array_merge($_GET, $_POST); |
|
72 | 72 | // AJAX ??? |
73 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
74 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
75 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
73 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
74 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
75 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @param WP $wp |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function parse_request( $wp = null ) { |
|
87 | + public function parse_request($wp = null) { |
|
88 | 88 | //if somebody forgot to provide us with WP, that's ok because its global |
89 | - if ( ! $wp instanceof WP ) { |
|
89 | + if ( ! $wp instanceof WP) { |
|
90 | 90 | global $wp; |
91 | 91 | } |
92 | - $this->set_request_vars( $wp ); |
|
92 | + $this->set_request_vars($wp); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * @param WP $wp |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function set_request_vars( $wp = null ) { |
|
105 | - if ( ! is_admin() ) { |
|
104 | + public function set_request_vars($wp = null) { |
|
105 | + if ( ! is_admin()) { |
|
106 | 106 | // set request post_id |
107 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
107 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
108 | 108 | // set request post name |
109 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
109 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
110 | 110 | // set request post_type |
111 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
111 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
112 | 112 | // true or false ? is this page being used by EE ? |
113 | 113 | $this->set_espresso_page(); |
114 | 114 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | * @param WP $wp |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function get_post_id_from_request( $wp = null ) { |
|
127 | - if ( ! $wp instanceof WP ){ |
|
126 | + public function get_post_id_from_request($wp = null) { |
|
127 | + if ( ! $wp instanceof WP) { |
|
128 | 128 | global $wp; |
129 | 129 | } |
130 | 130 | $post_id = null; |
131 | - if ( isset( $wp->query_vars['p'] )) { |
|
131 | + if (isset($wp->query_vars['p'])) { |
|
132 | 132 | $post_id = $wp->query_vars['p']; |
133 | 133 | } |
134 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
134 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
135 | 135 | $post_id = $wp->query_vars['page_id']; |
136 | 136 | } |
137 | - if ( ! $post_id && isset( $wp->request )) { |
|
138 | - if ( is_numeric( basename( $wp->request ))) { |
|
139 | - $post_id = basename( $wp->request ); |
|
137 | + if ( ! $post_id && isset($wp->request)) { |
|
138 | + if (is_numeric(basename($wp->request))) { |
|
139 | + $post_id = basename($wp->request); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | return $post_id; |
@@ -151,35 +151,35 @@ discard block |
||
151 | 151 | * @param WP $wp |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function get_post_name_from_request( $wp = null ) { |
|
155 | - if ( ! $wp instanceof WP ){ |
|
154 | + public function get_post_name_from_request($wp = null) { |
|
155 | + if ( ! $wp instanceof WP) { |
|
156 | 156 | global $wp; |
157 | 157 | } |
158 | 158 | $post_name = null; |
159 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
159 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
160 | 160 | $post_name = $wp->query_vars['name']; |
161 | 161 | } |
162 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
162 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
163 | 163 | $post_name = $wp->query_vars['pagename']; |
164 | 164 | } |
165 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
166 | - $possible_post_name = basename( $wp->request ); |
|
167 | - if ( ! is_numeric( $possible_post_name )) { |
|
165 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
166 | + $possible_post_name = basename($wp->request); |
|
167 | + if ( ! is_numeric($possible_post_name)) { |
|
168 | 168 | /** @type WPDB $wpdb */ |
169 | 169 | global $wpdb; |
170 | 170 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
171 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
172 | - if ( $possible_post_name ) { |
|
171 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
172 | + if ($possible_post_name) { |
|
173 | 173 | $post_name = $possible_post_name; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
177 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
177 | + if ( ! $post_name && $this->get('post_id')) { |
|
178 | 178 | /** @type WPDB $wpdb */ |
179 | 179 | global $wpdb; |
180 | 180 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
181 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
182 | - if( $possible_post_name ) { |
|
181 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
182 | + if ($possible_post_name) { |
|
183 | 183 | $post_name = $possible_post_name; |
184 | 184 | } |
185 | 185 | } |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @param WP $wp |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - public function get_post_type_from_request( $wp = null ) { |
|
199 | - if ( ! $wp instanceof WP ){ |
|
198 | + public function get_post_type_from_request($wp = null) { |
|
199 | + if ( ! $wp instanceof WP) { |
|
200 | 200 | global $wp; |
201 | 201 | } |
202 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
202 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param WP $wp |
210 | 210 | * @return bool|string|void |
211 | 211 | */ |
212 | - public function get_current_page_permalink( $wp = null ) { |
|
213 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
214 | - if ( $post_id ) { |
|
215 | - $current_page_permalink = get_permalink( $post_id ); |
|
212 | + public function get_current_page_permalink($wp = null) { |
|
213 | + $post_id = $this->get_post_id_from_request($wp); |
|
214 | + if ($post_id) { |
|
215 | + $current_page_permalink = get_permalink($post_id); |
|
216 | 216 | } else { |
217 | - if ( ! $wp instanceof WP ) { |
|
217 | + if ( ! $wp instanceof WP) { |
|
218 | 218 | global $wp; |
219 | 219 | } |
220 | - if ( $wp->request ) { |
|
221 | - $current_page_permalink = site_url( $wp->request ); |
|
220 | + if ($wp->request) { |
|
221 | + $current_page_permalink = site_url($wp->request); |
|
222 | 222 | } else { |
223 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
223 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | return $current_page_permalink; |
@@ -237,41 +237,41 @@ discard block |
||
237 | 237 | public function test_for_espresso_page() { |
238 | 238 | global $wp; |
239 | 239 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
240 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
240 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
241 | 241 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
242 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
243 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
244 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
242 | + if (is_array($espresso_CPT_taxonomies)) { |
|
243 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
244 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | 249 | // load espresso CPT endpoints |
250 | 250 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
251 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
252 | - $post_types = (array)$this->get( 'post_type' ); |
|
253 | - foreach ( $post_types as $post_type ) { |
|
251 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
252 | + $post_types = (array) $this->get('post_type'); |
|
253 | + foreach ($post_types as $post_type) { |
|
254 | 254 | // was a post name passed ? |
255 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
255 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
256 | 256 | // kk we know this is an espresso page, but is it a specific post ? |
257 | - if ( ! $this->get( 'post_name' ) ) { |
|
257 | + if ( ! $this->get('post_name')) { |
|
258 | 258 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
259 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
259 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
260 | 260 | // if the post type matches on of our then set the endpoint |
261 | - if ( $post_name ) { |
|
262 | - $this->set( 'post_name', $post_name ); |
|
261 | + if ($post_name) { |
|
262 | + $this->set('post_name', $post_name); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | } |
268 | - if ( $this->get( 'post_name' )) { |
|
268 | + if ($this->get('post_name')) { |
|
269 | 269 | // load all pages using espresso shortcodes |
270 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
270 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
271 | 271 | // make sure core pages are included |
272 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
272 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
273 | 273 | // was a post name passed ? |
274 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
274 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param null $value |
288 | 288 | * @return mixed |
289 | 289 | */ |
290 | - public function set_espresso_page( $value = null ) { |
|
290 | + public function set_espresso_page($value = null) { |
|
291 | 291 | $value = $value ? $value : $this->test_for_espresso_page(); |
292 | 292 | $this->_params['is_espresso_page'] = $value; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return mixed |
302 | 302 | */ |
303 | 303 | public function is_espresso_page() { |
304 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
304 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | * @param bool $override_ee |
326 | 326 | * @return void |
327 | 327 | */ |
328 | - public function set( $key, $value, $override_ee = false ) { |
|
328 | + public function set($key, $value, $override_ee = false) { |
|
329 | 329 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
330 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
331 | - $this->_params[ $key ] = $value; |
|
330 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
331 | + $this->_params[$key] = $value; |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param null $default |
343 | 343 | * @return mixed |
344 | 344 | */ |
345 | - public function get( $key, $default = null ) { |
|
346 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
345 | + public function get($key, $default = null) { |
|
346 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param $key |
356 | 356 | * @return boolean |
357 | 357 | */ |
358 | - public function is_set( $key ) { |
|
359 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
358 | + public function is_set($key) { |
|
359 | + return isset($this->_params[$key]) ? true : false; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param $key |
369 | 369 | * @return void |
370 | 370 | */ |
371 | - public function un_set( $key ) { |
|
372 | - unset( $this->_params[ $key ] ); |
|
371 | + public function un_set($key) { |
|
372 | + unset($this->_params[$key]); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param $value |
383 | 383 | * @return void |
384 | 384 | */ |
385 | - public function set_notice( $key, $value ) { |
|
386 | - $this->_notice[ $key ] = $value; |
|
385 | + public function set_notice($key, $value) { |
|
386 | + $this->_notice[$key] = $value; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param $key |
396 | 396 | * @return mixed |
397 | 397 | */ |
398 | - public function get_notice( $key ) { |
|
399 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
398 | + public function get_notice($key) { |
|
399 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param $string |
409 | 409 | * @return void |
410 | 410 | */ |
411 | - public function add_output( $string ) { |
|
411 | + public function add_output($string) { |
|
412 | 412 | $this->_output .= $string; |
413 | 413 | } |
414 | 414 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param $item |
431 | 431 | * @param $key |
432 | 432 | */ |
433 | - function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
434 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
433 | + function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
434 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param $b |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public function __set($a,$b) { return false; } |
|
444 | + public function __set($a, $b) { return false; } |
|
445 | 445 | |
446 | 446 | |
447 | 447 |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * retrieve session data |
338 | 338 | * @access public |
339 | - * @param null $key |
|
339 | + * @param string|null $key |
|
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * set session data |
361 | 361 | * @access public |
362 | 362 | * @param array $data |
363 | - * @return TRUE on success, FALSE on fail |
|
363 | + * @return boolean on success, FALSE on fail |
|
364 | 364 | */ |
365 | 365 | public function set_session_data( $data ) { |
366 | 366 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @initiate session |
392 | 392 | * @access private |
393 | - * @return TRUE on success, FALSE on fail |
|
393 | + * @return boolean on success, FALSE on fail |
|
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | 396 | private function _espresso_session() { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @update session data prior to saving to the db |
522 | 522 | * @access public |
523 | 523 | * @param bool $new_session |
524 | - * @return TRUE on success, FALSE on fail |
|
524 | + * @return boolean on success, FALSE on fail |
|
525 | 525 | */ |
526 | 526 | public function update( $new_session = FALSE ) { |
527 | 527 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @access public |
792 | 792 | * @param array $data_to_reset |
793 | 793 | * @param bool $show_all_notices |
794 | - * @return TRUE on success, FALSE on fail |
|
794 | + * @return boolean on success, FALSE on fail |
|
795 | 795 | */ |
796 | 796 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
797 | 797 | // if $data_to_reset is not in an array, then put it in one |
@@ -137,11 +137,11 @@ |
||
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
140 | - * private constructor to prevent direct creation |
|
141 | - * @Constructor |
|
142 | - * @access private |
|
143 | - * @return EE_Session |
|
144 | - */ |
|
140 | + * private constructor to prevent direct creation |
|
141 | + * @Constructor |
|
142 | + * @access private |
|
143 | + * @return EE_Session |
|
144 | + */ |
|
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
3 | 5 | * |
4 | 6 | * Event Espresso |
@@ -349,7 +351,7 @@ discard block |
||
349 | 351 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
350 | 352 | if ( ! empty( $key )) { |
351 | 353 | return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
352 | - } else { |
|
354 | + } else { |
|
353 | 355 | return $this->_session_data; |
354 | 356 | } |
355 | 357 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @return EE_Session |
128 | 128 | */ |
129 | - public static function instance ( ) { |
|
129 | + public static function instance( ) { |
|
130 | 130 | // check if class object is instantiated |
131 | - if ( ! self::$_instance instanceof EE_Session ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Session) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
148 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
148 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
149 | 149 | return NULL; |
150 | 150 | } |
151 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
152 | - define( 'ESPRESSO_SESSION', TRUE ); |
|
151 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
152 | + define('ESPRESSO_SESSION', TRUE); |
|
153 | 153 | // default session lifespan in seconds |
154 | 154 | $this->_lifespan = apply_filters( |
155 | 155 | 'FHEE__EE_Session__construct___lifespan', |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | * } |
163 | 163 | */ |
164 | 164 | // retrieve session options from db |
165 | - $session_settings = get_option( 'ee_session_settings' ); |
|
166 | - if ( $session_settings !== FALSE ) { |
|
165 | + $session_settings = get_option('ee_session_settings'); |
|
166 | + if ($session_settings !== FALSE) { |
|
167 | 167 | // cycle though existing session options |
168 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
168 | + foreach ($session_settings as $var_name => $session_setting) { |
|
169 | 169 | // set values for class properties |
170 | - $var_name = '_' . $var_name; |
|
170 | + $var_name = '_'.$var_name; |
|
171 | 171 | $this->{$var_name} = $session_setting; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | // are we using encryption? |
175 | - if ( $this->_use_encryption ) { |
|
175 | + if ($this->_use_encryption) { |
|
176 | 176 | // instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt(); |
177 | - $this->encryption = EE_Registry::instance()->load_core( 'Encryption' ); |
|
177 | + $this->encryption = EE_Registry::instance()->load_core('Encryption'); |
|
178 | 178 | } |
179 | 179 | // filter hook allows outside functions/classes/plugins to change default empty cart |
180 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
181 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
180 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
181 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
182 | 182 | // apply default session vars |
183 | 183 | $this->_set_defaults(); |
184 | 184 | // check for existing session and retrieve it from db |
185 | - if ( ! $this->_espresso_session() ) { |
|
185 | + if ( ! $this->_espresso_session()) { |
|
186 | 186 | // or just start a new one |
187 | 187 | $this->_create_espresso_session(); |
188 | 188 | } |
189 | 189 | // check request for 'clear_session' param |
190 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
190 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
191 | 191 | // once everything is all said and done, |
192 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
193 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
192 | + add_action('shutdown', array($this, 'update'), 100); |
|
193 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
194 | 194 | |
195 | 195 | } |
196 | 196 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function _set_defaults() { |
224 | 224 | // set some defaults |
225 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
226 | - if ( is_array( $default_var )) { |
|
227 | - $this->_session_data[ $key ] = array(); |
|
225 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
226 | + if (is_array($default_var)) { |
|
227 | + $this->_session_data[$key] = array(); |
|
228 | 228 | } else { |
229 | - $this->_session_data[ $key ] = ''; |
|
229 | + $this->_session_data[$key] = ''; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param \EE_Cart $cart |
249 | 249 | * @return bool |
250 | 250 | */ |
251 | - public function set_cart( EE_Cart $cart ) { |
|
251 | + public function set_cart(EE_Cart $cart) { |
|
252 | 252 | $this->_session_data['cart'] = $cart; |
253 | 253 | return TRUE; |
254 | 254 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return \EE_Cart |
269 | 269 | */ |
270 | 270 | public function cart() { |
271 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
271 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param \EE_Checkout $checkout |
278 | 278 | * @return bool |
279 | 279 | */ |
280 | - public function set_checkout( EE_Checkout $checkout ) { |
|
280 | + public function set_checkout(EE_Checkout $checkout) { |
|
281 | 281 | $this->_session_data['checkout'] = $checkout; |
282 | 282 | return TRUE; |
283 | 283 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return \EE_Checkout |
298 | 298 | */ |
299 | 299 | public function checkout() { |
300 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
300 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @param \EE_Transaction $transaction |
307 | 307 | * @return bool |
308 | 308 | */ |
309 | - public function set_transaction( EE_Transaction $transaction ) { |
|
309 | + public function set_transaction(EE_Transaction $transaction) { |
|
310 | 310 | // first remove the session from the transaction before we save the transaction in the session |
311 | - $transaction->set_txn_session_data( NULL ); |
|
311 | + $transaction->set_txn_session_data(NULL); |
|
312 | 312 | $this->_session_data['transaction'] = $transaction; |
313 | 313 | return TRUE; |
314 | 314 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return \EE_Transaction |
329 | 329 | */ |
330 | 330 | public function transaction() { |
331 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
331 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
343 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
344 | - if ( $reset_cache ) { |
|
343 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
344 | + if ($reset_cache) { |
|
345 | 345 | $this->reset_cart(); |
346 | 346 | $this->reset_checkout(); |
347 | 347 | $this->reset_transaction(); |
348 | 348 | } |
349 | - if ( ! empty( $key )) { |
|
350 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
351 | - } else { |
|
349 | + if ( ! empty($key)) { |
|
350 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
351 | + } else { |
|
352 | 352 | return $this->_session_data; |
353 | 353 | } |
354 | 354 | } |
@@ -361,20 +361,20 @@ discard block |
||
361 | 361 | * @param array $data |
362 | 362 | * @return TRUE on success, FALSE on fail |
363 | 363 | */ |
364 | - public function set_session_data( $data ) { |
|
364 | + public function set_session_data($data) { |
|
365 | 365 | |
366 | 366 | // nothing ??? bad data ??? go home! |
367 | - if ( empty( $data ) || ! is_array( $data )) { |
|
368 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
367 | + if (empty($data) || ! is_array($data)) { |
|
368 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
369 | 369 | return FALSE; |
370 | 370 | } |
371 | 371 | |
372 | - foreach ( $data as $key =>$value ) { |
|
373 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
374 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + foreach ($data as $key =>$value) { |
|
373 | + if (isset($this->_default_session_vars[$key])) { |
|
374 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
375 | 375 | return FALSE; |
376 | 376 | } else { |
377 | - $this->_session_data[ $key ] = $value; |
|
377 | + $this->_session_data[$key] = $value; |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * @throws \EE_Error |
392 | 392 | */ |
393 | 393 | private function _espresso_session() { |
394 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
394 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
395 | 395 | // check that session has started |
396 | - if ( session_id() === '' ) { |
|
396 | + if (session_id() === '') { |
|
397 | 397 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
398 | 398 | session_start(); |
399 | 399 | } |
@@ -402,57 +402,57 @@ discard block |
||
402 | 402 | // and the visitors IP |
403 | 403 | $this->_ip_address = $this->_visitor_ip(); |
404 | 404 | // set the "user agent" |
405 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
405 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
406 | 406 | // now let's retrieve what's in the db |
407 | 407 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
408 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
409 | - if ( $session_data ) { |
|
410 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
411 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
412 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
408 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
409 | + if ($session_data) { |
|
410 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
411 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
412 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
413 | 413 | EE_Error::add_error( |
414 | 414 | sprintf( |
415 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
416 | - EE_Session::session_id_prefix . $this->_sid |
|
415 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
416 | + EE_Session::session_id_prefix.$this->_sid |
|
417 | 417 | ), |
418 | 418 | __FILE__, __FUNCTION__, __LINE__ |
419 | 419 | ); |
420 | 420 | } |
421 | 421 | } |
422 | 422 | // un-encrypt the data |
423 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
423 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
424 | 424 | // unserialize |
425 | - $session_data = maybe_unserialize( $session_data ); |
|
425 | + $session_data = maybe_unserialize($session_data); |
|
426 | 426 | // just a check to make sure the session array is indeed an array |
427 | - if ( ! is_array( $session_data ) ) { |
|
427 | + if ( ! is_array($session_data)) { |
|
428 | 428 | // no?!?! then something is wrong |
429 | 429 | return FALSE; |
430 | 430 | } |
431 | 431 | // get the current time in UTC |
432 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
432 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
433 | 433 | // and reset the session expiration |
434 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
434 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
435 | 435 | |
436 | 436 | } else { |
437 | 437 | // set initial site access time and the session expiration |
438 | 438 | $this->_set_init_access_and_expiration(); |
439 | 439 | // set referer |
440 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
440 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
441 | 441 | // no previous session = go back and create one (on top of the data above) |
442 | 442 | return FALSE; |
443 | 443 | } |
444 | 444 | // now the user agent |
445 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
445 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
446 | 446 | return FALSE; |
447 | 447 | } |
448 | 448 | // wait a minute... how old are you? |
449 | - if ( $this->_time > $this->_expiration ) { |
|
449 | + if ($this->_time > $this->_expiration) { |
|
450 | 450 | // yer too old fer me! |
451 | 451 | // wipe out everything that isn't a default session datum |
452 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
452 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
453 | 453 | } |
454 | 454 | // make event espresso session data available to plugin |
455 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
455 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
456 | 456 | return TRUE; |
457 | 457 | |
458 | 458 | } |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | */ |
471 | 471 | protected function _generate_session_id() { |
472 | 472 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
473 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
474 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
473 | + if (isset($_REQUEST['EESID'])) { |
|
474 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
475 | 475 | } else { |
476 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
476 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
477 | 477 | } |
478 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
478 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -487,20 +487,20 @@ discard block |
||
487 | 487 | */ |
488 | 488 | protected function _get_sid_salt() { |
489 | 489 | // was session id salt already saved to db ? |
490 | - if ( empty( $this->_sid_salt ) ) { |
|
490 | + if (empty($this->_sid_salt)) { |
|
491 | 491 | // no? then maybe use WP defined constant |
492 | - if ( defined( 'AUTH_SALT' ) ) { |
|
492 | + if (defined('AUTH_SALT')) { |
|
493 | 493 | $this->_sid_salt = AUTH_SALT; |
494 | 494 | } |
495 | 495 | // if salt doesn't exist or is too short |
496 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
496 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
497 | 497 | // create a new one |
498 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
498 | + $this->_sid_salt = wp_generate_password(64); |
|
499 | 499 | } |
500 | 500 | // and save it as a permanent session setting |
501 | - $session_settings = get_option( 'ee_session_settings' ); |
|
502 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
503 | - update_option( 'ee_session_settings', $session_settings ); |
|
501 | + $session_settings = get_option('ee_session_settings'); |
|
502 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
503 | + update_option('ee_session_settings', $session_settings); |
|
504 | 504 | } |
505 | 505 | return $this->_sid_salt; |
506 | 506 | } |
@@ -528,19 +528,19 @@ discard block |
||
528 | 528 | * @param bool $new_session |
529 | 529 | * @return TRUE on success, FALSE on fail |
530 | 530 | */ |
531 | - public function update( $new_session = FALSE ) { |
|
532 | - $this->_session_data = isset( $this->_session_data ) |
|
533 | - && is_array( $this->_session_data ) |
|
534 | - && isset( $this->_session_data['id']) |
|
531 | + public function update($new_session = FALSE) { |
|
532 | + $this->_session_data = isset($this->_session_data) |
|
533 | + && is_array($this->_session_data) |
|
534 | + && isset($this->_session_data['id']) |
|
535 | 535 | ? $this->_session_data |
536 | 536 | : NULL; |
537 | - if ( empty( $this->_session_data )) { |
|
537 | + if (empty($this->_session_data)) { |
|
538 | 538 | $this->_set_defaults(); |
539 | 539 | } |
540 | 540 | $session_data = array(); |
541 | - foreach ( $this->_session_data as $key => $value ) { |
|
541 | + foreach ($this->_session_data as $key => $value) { |
|
542 | 542 | |
543 | - switch( $key ) { |
|
543 | + switch ($key) { |
|
544 | 544 | |
545 | 545 | case 'id' : |
546 | 546 | // session ID |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | break; |
559 | 559 | |
560 | 560 | case 'init_access' : |
561 | - $session_data['init_access'] = absint( $value ); |
|
561 | + $session_data['init_access'] = absint($value); |
|
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'last_access' : |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | case 'expiration' : |
570 | 570 | // when the session expires |
571 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
571 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
572 | 572 | ? $this->_expiration |
573 | 573 | : $session_data['init_access'] + $this->_lifespan; |
574 | 574 | break; |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | |
581 | 581 | case 'pages_visited' : |
582 | 582 | $page_visit = $this->_get_page_visit(); |
583 | - if ( $page_visit ) { |
|
583 | + if ($page_visit) { |
|
584 | 584 | // set pages visited where the first will be the http referrer |
585 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
585 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
586 | 586 | // we'll only save the last 10 page visits. |
587 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
587 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
588 | 588 | } |
589 | 589 | break; |
590 | 590 | |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | |
599 | 599 | $this->_session_data = $session_data; |
600 | 600 | // creating a new session does not require saving to the db just yet |
601 | - if ( ! $new_session ) { |
|
601 | + if ( ! $new_session) { |
|
602 | 602 | // ready? let's save |
603 | - if ( $this->_save_session_to_db() ) { |
|
603 | + if ($this->_save_session_to_db()) { |
|
604 | 604 | return TRUE; |
605 | 605 | } else { |
606 | 606 | return FALSE; |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | * @return bool |
622 | 622 | */ |
623 | 623 | private function _create_espresso_session( ) { |
624 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
624 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
625 | 625 | // use the update function for now with $new_session arg set to TRUE |
626 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
626 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -647,15 +647,15 @@ discard block |
||
647 | 647 | return FALSE; |
648 | 648 | } |
649 | 649 | // first serialize all of our session data |
650 | - $session_data = serialize( $this->_session_data ); |
|
650 | + $session_data = serialize($this->_session_data); |
|
651 | 651 | // encrypt it if we are using encryption |
652 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
652 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
653 | 653 | // maybe save hash check |
654 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
655 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
654 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
655 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
656 | 656 | } |
657 | 657 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
658 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
658 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | 'HTTP_FORWARDED', |
682 | 682 | 'REMOTE_ADDR' |
683 | 683 | ); |
684 | - foreach ( $server_keys as $key ){ |
|
685 | - if ( isset( $_SERVER[ $key ] )) { |
|
686 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
687 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
684 | + foreach ($server_keys as $key) { |
|
685 | + if (isset($_SERVER[$key])) { |
|
686 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
687 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
688 | 688 | $visitor_ip = $ip; |
689 | 689 | } |
690 | 690 | } |
@@ -705,45 +705,45 @@ discard block |
||
705 | 705 | public function _get_page_visit() { |
706 | 706 | |
707 | 707 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
708 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
708 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
709 | 709 | |
710 | 710 | // check for request url |
711 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
711 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
712 | 712 | |
713 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
713 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
714 | 714 | |
715 | - $ru_bits = explode( '?', $request_uri ); |
|
715 | + $ru_bits = explode('?', $request_uri); |
|
716 | 716 | $request_uri = $ru_bits[0]; |
717 | 717 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
718 | 718 | |
719 | 719 | // check for and grab host as well |
720 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
721 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
720 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
721 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
722 | 722 | } else { |
723 | 723 | $http_host = ''; |
724 | 724 | } |
725 | 725 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
726 | 726 | |
727 | 727 | // check for page_id in SERVER REQUEST |
728 | - if ( isset( $_REQUEST['page_id'] )) { |
|
728 | + if (isset($_REQUEST['page_id'])) { |
|
729 | 729 | // rebuild $e_reg without any of the extra parameters |
730 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
730 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
731 | 731 | } else { |
732 | 732 | $page_id = '?'; |
733 | 733 | } |
734 | 734 | // check for $e_reg in SERVER REQUEST |
735 | - if ( isset( $_REQUEST['ee'] )) { |
|
735 | + if (isset($_REQUEST['ee'])) { |
|
736 | 736 | // rebuild $e_reg without any of the extra parameters |
737 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
737 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
738 | 738 | } else { |
739 | 739 | $e_reg = ''; |
740 | 740 | } |
741 | 741 | |
742 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
742 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
746 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
747 | 747 | |
748 | 748 | } |
749 | 749 | |
@@ -772,14 +772,14 @@ discard block |
||
772 | 772 | * @param string $function |
773 | 773 | * @return void |
774 | 774 | */ |
775 | - public function clear_session( $class = '', $function = '' ) { |
|
775 | + public function clear_session($class = '', $function = '') { |
|
776 | 776 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
777 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
777 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
778 | 778 | $this->reset_cart(); |
779 | 779 | $this->reset_checkout(); |
780 | 780 | $this->reset_transaction(); |
781 | 781 | // wipe out everything that isn't a default session datum |
782 | - $this->reset_data( array_keys( $this->_session_data )); |
|
782 | + $this->reset_data(array_keys($this->_session_data)); |
|
783 | 783 | // reset initial site access time and the session expiration |
784 | 784 | $this->_set_init_access_and_expiration(); |
785 | 785 | $this->_save_session_to_db(); |
@@ -794,42 +794,42 @@ discard block |
||
794 | 794 | * @param bool $show_all_notices |
795 | 795 | * @return TRUE on success, FALSE on fail |
796 | 796 | */ |
797 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
797 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
798 | 798 | // if $data_to_reset is not in an array, then put it in one |
799 | - if ( ! is_array( $data_to_reset ) ) { |
|
800 | - $data_to_reset = array ( $data_to_reset ); |
|
799 | + if ( ! is_array($data_to_reset)) { |
|
800 | + $data_to_reset = array($data_to_reset); |
|
801 | 801 | } |
802 | 802 | // nothing ??? go home! |
803 | - if ( empty( $data_to_reset )) { |
|
804 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
803 | + if (empty($data_to_reset)) { |
|
804 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
805 | 805 | return FALSE; |
806 | 806 | } |
807 | 807 | $return_value = TRUE; |
808 | 808 | // since $data_to_reset is an array, cycle through the values |
809 | - foreach ( $data_to_reset as $reset ) { |
|
809 | + foreach ($data_to_reset as $reset) { |
|
810 | 810 | |
811 | 811 | // first check to make sure it is a valid session var |
812 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
812 | + if (isset($this->_session_data[$reset])) { |
|
813 | 813 | // then check to make sure it is not a default var |
814 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
814 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
815 | 815 | // remove session var |
816 | - unset( $this->_session_data[ $reset ] ); |
|
817 | - if ( $show_all_notices ) { |
|
818 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
816 | + unset($this->_session_data[$reset]); |
|
817 | + if ($show_all_notices) { |
|
818 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
819 | 819 | } |
820 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
820 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
821 | 821 | |
822 | 822 | } else { |
823 | 823 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
824 | - if ( $show_all_notices ) { |
|
825 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
824 | + if ($show_all_notices) { |
|
825 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
826 | 826 | } |
827 | 827 | $return_value = FALSE; |
828 | 828 | } |
829 | 829 | |
830 | - } else if ( $show_all_notices ) { |
|
830 | + } else if ($show_all_notices) { |
|
831 | 831 | // oops! that session var does not exist! |
832 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
832 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
833 | 833 | $return_value = FALSE; |
834 | 834 | } |
835 | 835 | |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @return string |
851 | 851 | */ |
852 | 852 | public function wp_loaded() { |
853 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
854 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
853 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
854 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
@@ -876,24 +876,24 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function garbage_collection() { |
878 | 878 | // only perform during regular requests |
879 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
879 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
880 | 880 | /** @type WPDB $wpdb */ |
881 | 881 | global $wpdb; |
882 | 882 | // since transient expiration timestamps are set in the future, we can compare against NOW |
883 | 883 | $expiration = time(); |
884 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
884 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
885 | 885 | // filter the query limit. Set to 0 to turn off garbage collection |
886 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
886 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
887 | 887 | // non-zero LIMIT means take out the trash |
888 | - if ( $expired_session_transient_delete_query_limit ) { |
|
888 | + if ($expired_session_transient_delete_query_limit) { |
|
889 | 889 | //array of transient keys that require garbage collection |
890 | 890 | $session_keys = array( |
891 | 891 | EE_Session::session_id_prefix, |
892 | 892 | EE_Session::hash_check_prefix, |
893 | 893 | ); |
894 | - foreach ( $session_keys as $session_key ) { |
|
895 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
896 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
894 | + foreach ($session_keys as $session_key) { |
|
895 | + $session_key = str_replace('_', '\_', $session_key); |
|
896 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
897 | 897 | $SQL = " |
898 | 898 | SELECT option_name |
899 | 899 | FROM {$wpdb->options} |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | OR option_value > {$too_far_in_the_the_future} ) |
904 | 904 | LIMIT {$expired_session_transient_delete_query_limit} |
905 | 905 | "; |
906 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
906 | + $expired_sessions = $wpdb->get_col($SQL); |
|
907 | 907 | // valid results? |
908 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
908 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
909 | 909 | // format array of results into something usable within the actual DELETE query's IN clause |
910 | 910 | $expired = array(); |
911 | - foreach ( $expired_sessions as $expired_session ) { |
|
912 | - $expired[ ] = "'" . $expired_session . "'"; |
|
913 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
911 | + foreach ($expired_sessions as $expired_session) { |
|
912 | + $expired[] = "'".$expired_session."'"; |
|
913 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
914 | 914 | } |
915 | - $expired = implode( ', ', $expired ); |
|
915 | + $expired = implode(', ', $expired); |
|
916 | 916 | $SQL = " |
917 | 917 | DELETE FROM {$wpdb->options} |
918 | 918 | WHERE option_name |
919 | 919 | IN ( $expired ); |
920 | 920 | "; |
921 | - $results = $wpdb->query( $SQL ); |
|
921 | + $results = $wpdb->query($SQL); |
|
922 | 922 | // if something went wrong, then notify the admin |
923 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
924 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
923 | + if ($results instanceof WP_Error && is_admin()) { |
|
924 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
925 | 925 | } |
926 | 926 | } |
927 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
927 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | } |
@@ -613,7 +613,7 @@ |
||
613 | 613 | * so that it will be done when migrations are finished |
614 | 614 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
615 | 615 | * however, |
616 | - * @param boolean $verify_db_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
616 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
617 | 617 | * so we prefer to only do it when necessary |
618 | 618 | * @return void |
619 | 619 | */ |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -578,7 +580,7 @@ discard block |
||
578 | 580 | $espresso_db_update = array( $espresso_db_update=>array() ); |
579 | 581 | update_option( 'espresso_db_update', $espresso_db_update ); |
580 | 582 | } |
581 | - }else{ |
|
583 | + } else{ |
|
582 | 584 | $corrected_db_update = array(); |
583 | 585 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
584 | 586 | foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
@@ -588,7 +590,7 @@ discard block |
||
588 | 590 | //fix it! |
589 | 591 | $version_string = $should_be_array; |
590 | 592 | $corrected_db_update[$version_string] = array('unknown-date'); |
591 | - }else{ |
|
593 | + } else{ |
|
592 | 594 | //ok it checks out |
593 | 595 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
594 | 596 | } |
@@ -633,7 +635,7 @@ discard block |
||
633 | 635 | $addon->initialize_db_if_no_migrations_required(); |
634 | 636 | } |
635 | 637 | } |
636 | - }else{ |
|
638 | + } else{ |
|
637 | 639 | EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
638 | 640 | } |
639 | 641 | if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
@@ -703,7 +705,7 @@ discard block |
||
703 | 705 | //it a version we haven't seen before |
704 | 706 | if( $version_is_higher === 1 ){ |
705 | 707 | $req_type = EE_System::req_type_upgrade; |
706 | - }else{ |
|
708 | + } else{ |
|
707 | 709 | $req_type = EE_System::req_type_downgrade; |
708 | 710 | } |
709 | 711 | delete_option( $activation_indicator_option_name ); |
@@ -712,10 +714,10 @@ discard block |
||
712 | 714 | if( get_option( $activation_indicator_option_name, FALSE ) ){ |
713 | 715 | if ( $version_is_higher === -1 ){ |
714 | 716 | $req_type = EE_System::req_type_downgrade; |
715 | - }elseif( $version_is_higher === 0 ){ |
|
717 | + } elseif( $version_is_higher === 0 ){ |
|
716 | 718 | //we've seen this version before, but it's an activation. must be a reactivation |
717 | 719 | $req_type = EE_System::req_type_reactivation; |
718 | - }else{//$version_is_higher === 1 |
|
720 | + } else{//$version_is_higher === 1 |
|
719 | 721 | $req_type = EE_System::req_type_upgrade; |
720 | 722 | } |
721 | 723 | delete_option( $activation_indicator_option_name ); |
@@ -723,10 +725,10 @@ discard block |
||
723 | 725 | //we've seen this version before and the activation indicate doesn't show it was just activated |
724 | 726 | if ( $version_is_higher === -1 ){ |
725 | 727 | $req_type = EE_System::req_type_downgrade; |
726 | - }elseif( $version_is_higher === 0 ){ |
|
728 | + } elseif( $version_is_higher === 0 ){ |
|
727 | 729 | //we've seen this version before and it's not an activation. its normal request |
728 | 730 | $req_type = EE_System::req_type_normal; |
729 | - }else{//$version_is_higher === 1 |
|
731 | + } else{//$version_is_higher === 1 |
|
730 | 732 | $req_type = EE_System::req_type_upgrade; |
731 | 733 | } |
732 | 734 | } |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | |
204 | 204 | |
205 | 205 | /** |
206 | - * detect_if_activation_or_upgrade |
|
207 | - * |
|
208 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | - * and either setting up the DB or setting up maintenance mode etc. |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - */ |
|
206 | + * detect_if_activation_or_upgrade |
|
207 | + * |
|
208 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | + * and either setting up the DB or setting up maintenance mode etc. |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + */ |
|
214 | 214 | public function detect_if_activation_or_upgrade() { |
215 | 215 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
216 | 216 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | $query_params = array( 'page' => 'espresso_about' ); |
515 | 515 | |
516 | 516 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
517 | - $query_params['new_activation'] = TRUE; |
|
517 | + $query_params['new_activation'] = TRUE; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
521 | - $query_params['reactivation'] = TRUE; |
|
521 | + $query_params['reactivation'] = TRUE; |
|
522 | 522 | } |
523 | 523 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
524 | 524 | wp_safe_redirect( $url ); |
@@ -621,11 +621,11 @@ discard block |
||
621 | 621 | |
622 | 622 | |
623 | 623 | /** |
624 | - * _incompatible_addon_error |
|
625 | - * |
|
626 | - * @access public |
|
627 | - * @return void |
|
628 | - */ |
|
624 | + * _incompatible_addon_error |
|
625 | + * |
|
626 | + * @access public |
|
627 | + * @return void |
|
628 | + */ |
|
629 | 629 | private function _incompatible_addon_error() { |
630 | 630 | // get array of classes hooking into here |
631 | 631 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -747,14 +747,14 @@ discard block |
||
747 | 747 | |
748 | 748 | |
749 | 749 | /** |
750 | - * load_controllers |
|
751 | - * |
|
752 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | - * |
|
755 | - * @access public |
|
756 | - * @return void |
|
757 | - */ |
|
750 | + * load_controllers |
|
751 | + * |
|
752 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | + * |
|
755 | + * @access public |
|
756 | + * @return void |
|
757 | + */ |
|
758 | 758 | public function load_controllers() { |
759 | 759 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
760 | 760 | // let's get it started |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | |
772 | 772 | |
773 | 773 | /** |
774 | - * core_loaded_and_ready |
|
775 | - * |
|
776 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | - * |
|
778 | - * @access public |
|
779 | - * @return void |
|
780 | - */ |
|
774 | + * core_loaded_and_ready |
|
775 | + * |
|
776 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | + * |
|
778 | + * @access public |
|
779 | + * @return void |
|
780 | + */ |
|
781 | 781 | public function core_loaded_and_ready() { |
782 | 782 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
783 | 783 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | |
789 | 789 | |
790 | 790 | /** |
791 | - * initialize |
|
792 | - * |
|
793 | - * this is the best place to begin initializing client code |
|
794 | - * |
|
795 | - * @access public |
|
796 | - * @return void |
|
797 | - */ |
|
791 | + * initialize |
|
792 | + * |
|
793 | + * this is the best place to begin initializing client code |
|
794 | + * |
|
795 | + * @access public |
|
796 | + * @return void |
|
797 | + */ |
|
798 | 798 | public function initialize() { |
799 | 799 | do_action( 'AHEE__EE_System__initialize' ); |
800 | 800 | } |
@@ -802,13 +802,13 @@ discard block |
||
802 | 802 | |
803 | 803 | |
804 | 804 | /** |
805 | - * initialize_last |
|
806 | - * |
|
807 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | - * |
|
809 | - * @access public |
|
810 | - * @return void |
|
811 | - */ |
|
805 | + * initialize_last |
|
806 | + * |
|
807 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | + * |
|
809 | + * @access public |
|
810 | + * @return void |
|
811 | + */ |
|
812 | 812 | public function initialize_last() { |
813 | 813 | do_action( 'AHEE__EE_System__initialize_last' ); |
814 | 814 | } |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | /** |
820 | - * set_hooks_for_shortcodes_modules_and_addons |
|
821 | - * |
|
822 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @return void |
|
827 | - */ |
|
820 | + * set_hooks_for_shortcodes_modules_and_addons |
|
821 | + * |
|
822 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @return void |
|
827 | + */ |
|
828 | 828 | public function set_hooks_for_shortcodes_modules_and_addons() { |
829 | 829 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
830 | 830 | } |
@@ -833,13 +833,13 @@ discard block |
||
833 | 833 | |
834 | 834 | |
835 | 835 | /** |
836 | - * do_not_cache |
|
837 | - * |
|
838 | - * sets no cache headers and defines no cache constants for WP plugins |
|
839 | - * |
|
840 | - * @access public |
|
841 | - * @return void |
|
842 | - */ |
|
836 | + * do_not_cache |
|
837 | + * |
|
838 | + * sets no cache headers and defines no cache constants for WP plugins |
|
839 | + * |
|
840 | + * @access public |
|
841 | + * @return void |
|
842 | + */ |
|
843 | 843 | public static function do_not_cache() { |
844 | 844 | // set no cache constants |
845 | 845 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | //Current post |
958 | 958 | global $post; |
959 | 959 | |
960 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | + if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
961 | 961 | //Events Edit Current Event |
962 | 962 | $admin_bar->add_menu(array( |
963 | 963 | 'id' => 'espresso-toolbar-events-edit', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,30 +173,30 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | 179 | //caps need to be initialized on every request so that capability maps are set. |
180 | 180 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
181 | 181 | EE_Registry::instance()->CAP->init_caps(); |
182 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
182 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
183 | 183 | //if the WP API basic auth plugin isn't already loaded, load it now. |
184 | 184 | //We want it for mobile apps. Just include the entire plugin |
185 | 185 | //also, don't load the basic auth when a plugin is getting activated, because |
186 | 186 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
187 | 187 | //and causes a fatal error |
188 | - if( !function_exists( 'json_basic_auth_handler' ) |
|
189 | - && ! function_exists( 'json_basic_auth_error' ) |
|
188 | + if ( ! function_exists('json_basic_auth_handler') |
|
189 | + && ! function_exists('json_basic_auth_error') |
|
190 | 190 | && ! ( |
191 | - isset( $_GET[ 'action'] ) |
|
192 | - && in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) ) |
|
191 | + isset($_GET['action']) |
|
192 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
193 | 193 | ) |
194 | 194 | && ! ( |
195 | - isset( $_GET['activate' ] ) |
|
196 | - && $_GET['activate' ] === 'true' |
|
195 | + isset($_GET['activate']) |
|
196 | + && $_GET['activate'] === 'true' |
|
197 | 197 | ) |
198 | 198 | ) { |
199 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
199 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function detect_activations_or_upgrades(){ |
|
215 | + public function detect_activations_or_upgrades() { |
|
216 | 216 | //first off: let's make sure to handle core |
217 | 217 | $this->detect_if_activation_or_upgrade(); |
218 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
218 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
219 | 219 | //detect teh request type for that addon |
220 | 220 | $addon->detect_activation_or_upgrade(); |
221 | 221 | } |
@@ -236,44 +236,44 @@ discard block |
||
236 | 236 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
237 | 237 | |
238 | 238 | // load M-Mode class |
239 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
239 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
240 | 240 | // check if db has been updated, or if its a brand-new installation |
241 | 241 | |
242 | 242 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
243 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
243 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
244 | 244 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
245 | - if( $request_type != EE_System::req_type_normal){ |
|
245 | + if ($request_type != EE_System::req_type_normal) { |
|
246 | 246 | EE_Registry::instance()->load_helper('Activation'); |
247 | 247 | } |
248 | 248 | |
249 | - switch($request_type){ |
|
249 | + switch ($request_type) { |
|
250 | 250 | case EE_System::req_type_new_activation: |
251 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
252 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
251 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
252 | + $this->_handle_core_version_change($espresso_db_update); |
|
253 | 253 | break; |
254 | 254 | case EE_System::req_type_reactivation: |
255 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
256 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
255 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
256 | + $this->_handle_core_version_change($espresso_db_update); |
|
257 | 257 | break; |
258 | 258 | case EE_System::req_type_upgrade: |
259 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
259 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
260 | 260 | //migrations may be required now that we've upgraded |
261 | 261 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
262 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
262 | + $this->_handle_core_version_change($espresso_db_update); |
|
263 | 263 | // echo "done upgrade";die; |
264 | 264 | break; |
265 | 265 | case EE_System::req_type_downgrade: |
266 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
266 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
267 | 267 | //its possible migrations are no longer required |
268 | 268 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
269 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
269 | + $this->_handle_core_version_change($espresso_db_update); |
|
270 | 270 | break; |
271 | 271 | case EE_System::req_type_normal: |
272 | 272 | default: |
273 | 273 | // $this->_maybe_redirect_to_ee_about(); |
274 | 274 | break; |
275 | 275 | } |
276 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
276 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | * initializing the database later during the request |
282 | 282 | * @param array $espresso_db_update |
283 | 283 | */ |
284 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
285 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
284 | + protected function _handle_core_version_change($espresso_db_update) { |
|
285 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
286 | 286 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
287 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
287 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -299,44 +299,44 @@ discard block |
||
299 | 299 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
300 | 300 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
301 | 301 | */ |
302 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
303 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
304 | - if( ! $espresso_db_update){ |
|
305 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
302 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
303 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
304 | + if ( ! $espresso_db_update) { |
|
305 | + $espresso_db_update = get_option('espresso_db_update'); |
|
306 | 306 | } |
307 | 307 | // check that option is an array |
308 | - if( ! is_array( $espresso_db_update )) { |
|
308 | + if ( ! is_array($espresso_db_update)) { |
|
309 | 309 | // if option is FALSE, then it never existed |
310 | - if ( $espresso_db_update === FALSE ) { |
|
310 | + if ($espresso_db_update === FALSE) { |
|
311 | 311 | // make $espresso_db_update an array and save option with autoload OFF |
312 | - $espresso_db_update = array(); |
|
313 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
312 | + $espresso_db_update = array(); |
|
313 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
314 | 314 | } else { |
315 | 315 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
316 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
317 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
316 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
317 | + update_option('espresso_db_update', $espresso_db_update); |
|
318 | 318 | } |
319 | - }else{ |
|
319 | + } else { |
|
320 | 320 | $corrected_db_update = array(); |
321 | 321 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
322 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
323 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
322 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
323 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
324 | 324 | //the key is an int, and the value IS NOT an array |
325 | 325 | //so it must be numerically-indexed, where values are versions installed... |
326 | 326 | //fix it! |
327 | 327 | $version_string = $should_be_array; |
328 | 328 | $corrected_db_update[$version_string] = array('unknown-date'); |
329 | - }else{ |
|
329 | + } else { |
|
330 | 330 | //ok it checks out |
331 | 331 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $espresso_db_update = $corrected_db_update; |
335 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
335 | + update_option('espresso_db_update', $espresso_db_update); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
339 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
339 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
340 | 340 | return $espresso_db_update; |
341 | 341 | } |
342 | 342 | |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | * so we prefer to only do it when necessary |
356 | 356 | * @return void |
357 | 357 | */ |
358 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
358 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
359 | 359 | $request_type = $this->detect_req_type(); |
360 | 360 | //only initialize system if we're not in maintenance mode. |
361 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
362 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
361 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
362 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
363 | 363 | |
364 | - if( $verify_schema ) { |
|
364 | + if ($verify_schema) { |
|
365 | 365 | EEH_Activation::initialize_db_and_folders(); |
366 | 366 | } |
367 | 367 | EEH_Activation::initialize_db_content(); |
368 | 368 | EEH_Activation::system_initialization(); |
369 | - if( $initialize_addons_too ) { |
|
369 | + if ($initialize_addons_too) { |
|
370 | 370 | $this->initialize_addons(); |
371 | 371 | } |
372 | - }else{ |
|
373 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
372 | + } else { |
|
373 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
374 | 374 | } |
375 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
376 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
375 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
376 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Initializes the db for all registered addons |
382 | 382 | */ |
383 | - public function initialize_addons(){ |
|
383 | + public function initialize_addons() { |
|
384 | 384 | //foreach registered addon, make sure its db is up-to-date too |
385 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
385 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
386 | 386 | $addon->initialize_db_if_no_migrations_required(); |
387 | 387 | } |
388 | 388 | } |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @param string $current_version_to_add version to be added to the version history |
395 | 395 | * @return boolean success as to whether or not this option was changed |
396 | 396 | */ |
397 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
398 | - if( ! $version_history ) { |
|
397 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
398 | + if ( ! $version_history) { |
|
399 | 399 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
400 | 400 | } |
401 | - if( $current_version_to_add == NULL){ |
|
401 | + if ($current_version_to_add == NULL) { |
|
402 | 402 | $current_version_to_add = espresso_version(); |
403 | 403 | } |
404 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
404 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
405 | 405 | // re-save |
406 | - return update_option( 'espresso_db_update', $version_history ); |
|
406 | + return update_option('espresso_db_update', $version_history); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -420,10 +420,10 @@ discard block |
||
420 | 420 | * but still know if this is a new install or not |
421 | 421 | * @return int one of the constants on EE_System::req_type_ |
422 | 422 | */ |
423 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
424 | - if ( $this->_req_type === NULL ){ |
|
425 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
423 | + public function detect_req_type($espresso_db_update = NULL) { |
|
424 | + if ($this->_req_type === NULL) { |
|
425 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
427 | 427 | } |
428 | 428 | return $this->_req_type; |
429 | 429 | } |
@@ -439,39 +439,39 @@ discard block |
||
439 | 439 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
440 | 440 | * @return int one of the constants on EE_System::req_type_* |
441 | 441 | */ |
442 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
443 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
444 | - if( $activation_history_for_addon ){ |
|
442 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
443 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
444 | + if ($activation_history_for_addon) { |
|
445 | 445 | //it exists, so this isn't a completely new install |
446 | 446 | //check if this version already in that list of previously installed versions |
447 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
447 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
448 | 448 | //it a version we haven't seen before |
449 | - if( $version_is_higher === 1 ){ |
|
449 | + if ($version_is_higher === 1) { |
|
450 | 450 | $req_type = EE_System::req_type_upgrade; |
451 | - }else{ |
|
451 | + } else { |
|
452 | 452 | $req_type = EE_System::req_type_downgrade; |
453 | 453 | } |
454 | - delete_option( $activation_indicator_option_name ); |
|
454 | + delete_option($activation_indicator_option_name); |
|
455 | 455 | } else { |
456 | 456 | // its not an update. maybe a reactivation? |
457 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
458 | - if ( $version_is_higher === -1 ){ |
|
457 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
458 | + if ($version_is_higher === -1) { |
|
459 | 459 | $req_type = EE_System::req_type_downgrade; |
460 | - }elseif( $version_is_higher === 0 ){ |
|
460 | + }elseif ($version_is_higher === 0) { |
|
461 | 461 | //we've seen this version before, but it's an activation. must be a reactivation |
462 | 462 | $req_type = EE_System::req_type_reactivation; |
463 | - }else{//$version_is_higher === 1 |
|
463 | + } else {//$version_is_higher === 1 |
|
464 | 464 | $req_type = EE_System::req_type_upgrade; |
465 | 465 | } |
466 | - delete_option( $activation_indicator_option_name ); |
|
466 | + delete_option($activation_indicator_option_name); |
|
467 | 467 | } else { |
468 | 468 | //we've seen this version before and the activation indicate doesn't show it was just activated |
469 | - if ( $version_is_higher === -1 ){ |
|
469 | + if ($version_is_higher === -1) { |
|
470 | 470 | $req_type = EE_System::req_type_downgrade; |
471 | - }elseif( $version_is_higher === 0 ){ |
|
471 | + }elseif ($version_is_higher === 0) { |
|
472 | 472 | //we've seen this version before and it's not an activation. its normal request |
473 | 473 | $req_type = EE_System::req_type_normal; |
474 | - }else{//$version_is_higher === 1 |
|
474 | + } else {//$version_is_higher === 1 |
|
475 | 475 | $req_type = EE_System::req_type_upgrade; |
476 | 476 | } |
477 | 477 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } else { |
480 | 480 | //brand new install |
481 | 481 | $req_type = EE_System::req_type_new_activation; |
482 | - delete_option( $activation_indicator_option_name ); |
|
482 | + delete_option($activation_indicator_option_name); |
|
483 | 483 | } |
484 | 484 | return $req_type; |
485 | 485 | } |
@@ -497,30 +497,30 @@ discard block |
||
497 | 497 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
498 | 498 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
499 | 499 | */ |
500 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
500 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
501 | 501 | //find the most recently-activated version |
502 | 502 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
503 | 503 | $most_recently_active_version = '0.0.0.dev.000'; |
504 | - if( is_array( $activation_history_for_addon ) ){ |
|
505 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
504 | + if (is_array($activation_history_for_addon)) { |
|
505 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
506 | 506 | //check there is a record of when this version was activated. Otherwise, |
507 | 507 | //mark it as unknown |
508 | - if( ! $times_activated ){ |
|
509 | - $times_activated = array( 'unknown-date'); |
|
508 | + if ( ! $times_activated) { |
|
509 | + $times_activated = array('unknown-date'); |
|
510 | 510 | } |
511 | - if( is_string( $times_activated ) ){ |
|
512 | - $times_activated = array( $times_activated ); |
|
511 | + if (is_string($times_activated)) { |
|
512 | + $times_activated = array($times_activated); |
|
513 | 513 | } |
514 | - foreach( $times_activated as $an_activation ){ |
|
515 | - if( $an_activation != 'unknown-date' && |
|
516 | - $an_activation > $most_recently_active_version_activation ){ |
|
514 | + foreach ($times_activated as $an_activation) { |
|
515 | + if ($an_activation != 'unknown-date' && |
|
516 | + $an_activation > $most_recently_active_version_activation) { |
|
517 | 517 | $most_recently_active_version = $version; |
518 | 518 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | } |
523 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
523 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -530,20 +530,20 @@ discard block |
||
530 | 530 | * @return void |
531 | 531 | */ |
532 | 532 | public function redirect_to_about_ee() { |
533 | - $notices = EE_Error::get_notices( FALSE ); |
|
533 | + $notices = EE_Error::get_notices(FALSE); |
|
534 | 534 | //if current user is an admin and it's not an ajax request |
535 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
536 | - $query_params = array( 'page' => 'espresso_about' ); |
|
535 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
536 | + $query_params = array('page' => 'espresso_about'); |
|
537 | 537 | |
538 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
538 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
539 | 539 | $query_params['new_activation'] = TRUE; |
540 | 540 | } |
541 | 541 | |
542 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
542 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
543 | 543 | $query_params['reactivation'] = TRUE; |
544 | 544 | } |
545 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
546 | - wp_safe_redirect( $url ); |
|
545 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
546 | + wp_safe_redirect($url); |
|
547 | 547 | exit(); |
548 | 548 | } |
549 | 549 | } |
@@ -557,31 +557,31 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return void |
559 | 559 | */ |
560 | - public function load_core_configuration(){ |
|
561 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
562 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
560 | + public function load_core_configuration() { |
|
561 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
562 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
563 | 563 | //load textdomain |
564 | 564 | EE_Load_Textdomain::load_textdomain(); |
565 | 565 | // load and setup EE_Config and EE_Network_Config |
566 | - EE_Registry::instance()->load_core( 'Config' ); |
|
567 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
566 | + EE_Registry::instance()->load_core('Config'); |
|
567 | + EE_Registry::instance()->load_core('Network_Config'); |
|
568 | 568 | // setup autoloaders |
569 | 569 | // enable logging? |
570 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
571 | - EE_Registry::instance()->load_core( 'Log' ); |
|
570 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
571 | + EE_Registry::instance()->load_core('Log'); |
|
572 | 572 | } |
573 | 573 | // check for activation errors |
574 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
575 | - if ( $activation_errors ) { |
|
576 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
577 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
574 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
575 | + if ($activation_errors) { |
|
576 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
577 | + update_option('ee_plugin_activation_errors', FALSE); |
|
578 | 578 | } |
579 | 579 | // get model names |
580 | 580 | $this->_parse_model_names(); |
581 | 581 | |
582 | 582 | //load caf stuff a chance to play during the activation process too. |
583 | 583 | $this->_maybe_brew_regular(); |
584 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
584 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -590,23 +590,23 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return void |
592 | 592 | */ |
593 | - private function _parse_model_names(){ |
|
593 | + private function _parse_model_names() { |
|
594 | 594 | //get all the files in the EE_MODELS folder that end in .model.php |
595 | - $models = glob( EE_MODELS.'*.model.php'); |
|
595 | + $models = glob(EE_MODELS.'*.model.php'); |
|
596 | 596 | $model_names = array(); |
597 | 597 | $non_abstract_db_models = array(); |
598 | - foreach( $models as $model ){ |
|
598 | + foreach ($models as $model) { |
|
599 | 599 | // get model classname |
600 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
601 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
600 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
601 | + $shortname = str_replace('EEM_', '', $classname); |
|
602 | 602 | $reflectionClass = new ReflectionClass($classname); |
603 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
603 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
604 | 604 | $non_abstract_db_models[$shortname] = $classname; |
605 | 605 | } |
606 | - $model_names[ $shortname ] = $classname; |
|
606 | + $model_names[$shortname] = $classname; |
|
607 | 607 | } |
608 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
609 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
608 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
609 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | * @return void |
617 | 617 | */ |
618 | 618 | private function _maybe_brew_regular() { |
619 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
620 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
619 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
620 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @return void |
635 | 635 | */ |
636 | 636 | public function register_shortcodes_modules_and_widgets() { |
637 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
637 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
638 | 638 | // check for addons using old hookpoint |
639 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
639 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
640 | 640 | $this->_incompatible_addon_error(); |
641 | 641 | } |
642 | 642 | } |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | */ |
651 | 651 | private function _incompatible_addon_error() { |
652 | 652 | // get array of classes hooking into here |
653 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
654 | - if ( ! empty( $class_names )) { |
|
655 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
653 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
654 | + if ( ! empty($class_names)) { |
|
655 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
656 | 656 | $msg .= '<ul>'; |
657 | - foreach ( $class_names as $class_name ) { |
|
658 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
657 | + foreach ($class_names as $class_name) { |
|
658 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
659 | 659 | } |
660 | 660 | $msg .= '</ul>'; |
661 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
661 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
662 | 662 | // save list of incompatible addons to wp-options for later use |
663 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
664 | - if ( is_admin() ) { |
|
665 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
663 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
664 | + if (is_admin()) { |
|
665 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | } |
@@ -679,25 +679,25 @@ discard block |
||
679 | 679 | * |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function brew_espresso(){ |
|
683 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
682 | + public function brew_espresso() { |
|
683 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
684 | 684 | // load some final core systems |
685 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
686 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
687 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
688 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
689 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
690 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
691 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
692 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
693 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
694 | - |
|
695 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
685 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
686 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
687 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
688 | + add_action('init', array($this, 'load_controllers'), 7); |
|
689 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
690 | + add_action('init', array($this, 'initialize'), 10); |
|
691 | + add_action('init', array($this, 'initialize_last'), 100); |
|
692 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
693 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
694 | + |
|
695 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
696 | 696 | // pew pew pew |
697 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
698 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
697 | + EE_Registry::instance()->load_core('PUE'); |
|
698 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
699 | 699 | } |
700 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
700 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function set_hooks_for_core() { |
713 | 713 | $this->_deactivate_incompatible_addons(); |
714 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
714 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | |
@@ -720,15 +720,15 @@ discard block |
||
720 | 720 | * Using the information gathered in EE_System::_incompatible_addon_error, |
721 | 721 | * deactivates any addons considered incompatible with the current version of EE |
722 | 722 | */ |
723 | - private function _deactivate_incompatible_addons(){ |
|
724 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
725 | - if ( ! empty( $incompatible_addons )) { |
|
726 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
727 | - foreach ( $active_plugins as $active_plugin ) { |
|
728 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
729 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
730 | - unset( $_GET['activate'] ); |
|
731 | - espresso_deactivate_plugin( $active_plugin ); |
|
723 | + private function _deactivate_incompatible_addons() { |
|
724 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
725 | + if ( ! empty($incompatible_addons)) { |
|
726 | + $active_plugins = get_option('active_plugins', array()); |
|
727 | + foreach ($active_plugins as $active_plugin) { |
|
728 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
729 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
730 | + unset($_GET['activate']); |
|
731 | + espresso_deactivate_plugin($active_plugin); |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | } |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function perform_activations_upgrades_and_migrations() { |
747 | 747 | //first check if we had previously attempted to setup EE's directories but failed |
748 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
748 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
749 | 749 | EEH_Activation::create_upload_directories(); |
750 | 750 | } |
751 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
751 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * @return void |
761 | 761 | */ |
762 | 762 | public function load_CPTs_and_session() { |
763 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
763 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
764 | 764 | // register Custom Post Types |
765 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
766 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
765 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
766 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -778,19 +778,19 @@ discard block |
||
778 | 778 | * @return void |
779 | 779 | */ |
780 | 780 | public function load_controllers() { |
781 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
781 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
782 | 782 | // let's get it started |
783 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
784 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
785 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
786 | - } else if ( ! EE_FRONT_AJAX ) { |
|
787 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
788 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
789 | - } else if ( EE_Maintenance_Mode::instance()->level() ) { |
|
783 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
784 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
785 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
786 | + } else if ( ! EE_FRONT_AJAX) { |
|
787 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
788 | + EE_Registry::instance()->load_core('Admin'); |
|
789 | + } else if (EE_Maintenance_Mode::instance()->level()) { |
|
790 | 790 | // still need to make sure template helper functions are loaded in M-Mode |
791 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
791 | + EE_Registry::instance()->load_helper('Template'); |
|
792 | 792 | } |
793 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
793 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | * @return void |
805 | 805 | */ |
806 | 806 | public function core_loaded_and_ready() { |
807 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
808 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
807 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
808 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
809 | 809 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
810 | - EE_Registry::instance()->load_core( 'Session' ); |
|
810 | + EE_Registry::instance()->load_core('Session'); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @return void |
822 | 822 | */ |
823 | 823 | public function initialize() { |
824 | - do_action( 'AHEE__EE_System__initialize' ); |
|
824 | + do_action('AHEE__EE_System__initialize'); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @return void |
836 | 836 | */ |
837 | 837 | public function initialize_last() { |
838 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
838 | + do_action('AHEE__EE_System__initialize_last'); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -867,21 +867,21 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public static function do_not_cache() { |
869 | 869 | // set no cache constants |
870 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
871 | - define( 'DONOTCACHEPAGE', true ); |
|
870 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
871 | + define('DONOTCACHEPAGE', true); |
|
872 | 872 | } |
873 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
874 | - define( 'DONOTCACHCEOBJECT', true ); |
|
873 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
874 | + define('DONOTCACHCEOBJECT', true); |
|
875 | 875 | } |
876 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
877 | - define( 'DONOTCACHEDB', true ); |
|
876 | + if ( ! defined('DONOTCACHEDB')) { |
|
877 | + define('DONOTCACHEDB', true); |
|
878 | 878 | } |
879 | 879 | // add no cache headers |
880 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
880 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
881 | 881 | // plus a little extra for nginx and Google Chrome |
882 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
882 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
883 | 883 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
884 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
884 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @param $headers |
894 | 894 | * @return array |
895 | 895 | */ |
896 | - public static function extra_nocache_headers ( $headers ) { |
|
896 | + public static function extra_nocache_headers($headers) { |
|
897 | 897 | // for NGINX |
898 | 898 | $headers['X-Accel-Expires'] = 0; |
899 | 899 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -922,15 +922,15 @@ discard block |
||
922 | 922 | * @param $admin_bar |
923 | 923 | * @return void |
924 | 924 | */ |
925 | - public function espresso_toolbar_items( $admin_bar ) { |
|
925 | + public function espresso_toolbar_items($admin_bar) { |
|
926 | 926 | |
927 | 927 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
928 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
928 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
929 | 929 | return; |
930 | 930 | } |
931 | 931 | |
932 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
933 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
932 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
933 | + EE_Registry::instance()->load_helper('URL'); |
|
934 | 934 | $menu_class = 'espresso_menu_item_class'; |
935 | 935 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
936 | 936 | //because they're only defined in each of their respective constructors |
@@ -942,20 +942,20 @@ discard block |
||
942 | 942 | //Top Level |
943 | 943 | $admin_bar->add_menu(array( |
944 | 944 | 'id' => 'espresso-toolbar', |
945 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
945 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
946 | 946 | 'href' => $events_admin_url, |
947 | 947 | 'meta' => array( |
948 | 948 | 'title' => __('Event Espresso', 'event_espresso'), |
949 | - 'class' => $menu_class . 'first' |
|
949 | + 'class' => $menu_class.'first' |
|
950 | 950 | ), |
951 | 951 | )); |
952 | 952 | |
953 | 953 | //Events |
954 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
954 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
955 | 955 | $admin_bar->add_menu(array( |
956 | 956 | 'id' => 'espresso-toolbar-events', |
957 | 957 | 'parent' => 'espresso-toolbar', |
958 | - 'title' => __( 'Events', 'event_espresso' ), |
|
958 | + 'title' => __('Events', 'event_espresso'), |
|
959 | 959 | 'href' => $events_admin_url, |
960 | 960 | 'meta' => array( |
961 | 961 | 'title' => __('Events', 'event_espresso'), |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | } |
967 | 967 | |
968 | 968 | |
969 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
969 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
970 | 970 | //Events Add New |
971 | 971 | $admin_bar->add_menu(array( |
972 | 972 | 'id' => 'espresso-toolbar-events-new', |
973 | 973 | 'parent' => 'espresso-toolbar-events', |
974 | 974 | 'title' => __('Add New', 'event_espresso'), |
975 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
975 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
976 | 976 | 'meta' => array( |
977 | 977 | 'title' => __('Add New', 'event_espresso'), |
978 | 978 | 'target' => '', |
@@ -981,18 +981,18 @@ discard block |
||
981 | 981 | )); |
982 | 982 | } |
983 | 983 | |
984 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
984 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
985 | 985 | |
986 | 986 | //Current post |
987 | 987 | global $post; |
988 | 988 | |
989 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
989 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
990 | 990 | //Events Edit Current Event |
991 | 991 | $admin_bar->add_menu(array( |
992 | 992 | 'id' => 'espresso-toolbar-events-edit', |
993 | 993 | 'parent' => 'espresso-toolbar-events', |
994 | 994 | 'title' => __('Edit Event', 'event_espresso'), |
995 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
995 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
996 | 996 | 'meta' => array( |
997 | 997 | 'title' => __('Edit Event', 'event_espresso'), |
998 | 998 | 'target' => '', |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | //Events View |
1007 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
1007 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
1008 | 1008 | $admin_bar->add_menu(array( |
1009 | 1009 | 'id' => 'espresso-toolbar-events-view', |
1010 | 1010 | 'parent' => 'espresso-toolbar-events', |
1011 | - 'title' => __( 'View', 'event_espresso' ), |
|
1011 | + 'title' => __('View', 'event_espresso'), |
|
1012 | 1012 | 'href' => $events_admin_url, |
1013 | 1013 | 'meta' => array( |
1014 | 1014 | 'title' => __('View', 'event_espresso'), |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | )); |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1021 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1022 | 1022 | //Events View All |
1023 | 1023 | $admin_bar->add_menu(array( |
1024 | 1024 | 'id' => 'espresso-toolbar-events-all', |
1025 | 1025 | 'parent' => 'espresso-toolbar-events-view', |
1026 | - 'title' => __( 'All', 'event_espresso' ), |
|
1026 | + 'title' => __('All', 'event_espresso'), |
|
1027 | 1027 | 'href' => $events_admin_url, |
1028 | 1028 | 'meta' => array( |
1029 | 1029 | 'title' => __('All', 'event_espresso'), |
@@ -1034,13 +1034,13 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
1037 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1037 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1038 | 1038 | //Events View Today |
1039 | 1039 | $admin_bar->add_menu(array( |
1040 | 1040 | 'id' => 'espresso-toolbar-events-today', |
1041 | 1041 | 'parent' => 'espresso-toolbar-events-view', |
1042 | 1042 | 'title' => __('Today', 'event_espresso'), |
1043 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1043 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1044 | 1044 | 'meta' => array( |
1045 | 1045 | 'title' => __('Today', 'event_espresso'), |
1046 | 1046 | 'target' => '', |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | |
1053 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1053 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1054 | 1054 | //Events View This Month |
1055 | 1055 | $admin_bar->add_menu(array( |
1056 | 1056 | 'id' => 'espresso-toolbar-events-month', |
1057 | 1057 | 'parent' => 'espresso-toolbar-events-view', |
1058 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1059 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1058 | + 'title' => __('This Month', 'event_espresso'), |
|
1059 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1060 | 1060 | 'meta' => array( |
1061 | 1061 | 'title' => __('This Month', 'event_espresso'), |
1062 | 1062 | 'target' => '', |
@@ -1066,11 +1066,11 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | //Registration Overview |
1069 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1069 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1070 | 1070 | $admin_bar->add_menu(array( |
1071 | 1071 | 'id' => 'espresso-toolbar-registrations', |
1072 | 1072 | 'parent' => 'espresso-toolbar', |
1073 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1073 | + 'title' => __('Registrations', 'event_espresso'), |
|
1074 | 1074 | 'href' => $reg_admin_url, |
1075 | 1075 | 'meta' => array( |
1076 | 1076 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1081,12 +1081,12 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | //Registration Overview Today |
1084 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1084 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1085 | 1085 | $admin_bar->add_menu(array( |
1086 | 1086 | 'id' => 'espresso-toolbar-registrations-today', |
1087 | 1087 | 'parent' => 'espresso-toolbar-registrations', |
1088 | - 'title' => __( 'Today', 'event_espresso'), |
|
1089 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1088 | + 'title' => __('Today', 'event_espresso'), |
|
1089 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1090 | 1090 | 'meta' => array( |
1091 | 1091 | 'title' => __('Today', 'event_espresso'), |
1092 | 1092 | 'target' => '', |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | //Registration Overview Today Completed |
1099 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1099 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1100 | 1100 | $admin_bar->add_menu(array( |
1101 | 1101 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1102 | 1102 | 'parent' => 'espresso-toolbar-registrations-today', |
1103 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1104 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1103 | + 'title' => __('Approved', 'event_espresso'), |
|
1104 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1105 | 1105 | 'meta' => array( |
1106 | - 'title' => __('Approved', 'event_espresso' ), |
|
1106 | + 'title' => __('Approved', 'event_espresso'), |
|
1107 | 1107 | 'target' => '', |
1108 | 1108 | 'class' => $menu_class |
1109 | 1109 | ), |
@@ -1111,14 +1111,14 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | //Registration Overview Today Pending\ |
1114 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1114 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1115 | 1115 | $admin_bar->add_menu(array( |
1116 | 1116 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1117 | 1117 | 'parent' => 'espresso-toolbar-registrations-today', |
1118 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1119 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1118 | + 'title' => __('Pending', 'event_espresso'), |
|
1119 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1120 | 1120 | 'meta' => array( |
1121 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1121 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1122 | 1122 | 'target' => '', |
1123 | 1123 | 'class' => $menu_class |
1124 | 1124 | ), |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | //Registration Overview Today Incomplete |
1129 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1129 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1130 | 1130 | $admin_bar->add_menu(array( |
1131 | 1131 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1132 | 1132 | 'parent' => 'espresso-toolbar-registrations-today', |
1133 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1134 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1133 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1134 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1135 | 1135 | 'meta' => array( |
1136 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1136 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1137 | 1137 | 'target' => '', |
1138 | 1138 | 'class' => $menu_class |
1139 | 1139 | ), |
@@ -1141,12 +1141,12 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | //Registration Overview Today Incomplete |
1144 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1144 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1145 | 1145 | $admin_bar->add_menu(array( |
1146 | 1146 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1147 | 1147 | 'parent' => 'espresso-toolbar-registrations-today', |
1148 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1149 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1148 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1149 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1150 | 1150 | 'meta' => array( |
1151 | 1151 | 'title' => __('Cancelled', 'event_espresso'), |
1152 | 1152 | 'target' => '', |
@@ -1156,12 +1156,12 @@ discard block |
||
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | //Registration Overview This Month |
1159 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1159 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1160 | 1160 | $admin_bar->add_menu(array( |
1161 | 1161 | 'id' => 'espresso-toolbar-registrations-month', |
1162 | 1162 | 'parent' => 'espresso-toolbar-registrations', |
1163 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1164 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1163 | + 'title' => __('This Month', 'event_espresso'), |
|
1164 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1165 | 1165 | 'meta' => array( |
1166 | 1166 | 'title' => __('This Month', 'event_espresso'), |
1167 | 1167 | 'target' => '', |
@@ -1171,12 +1171,12 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | //Registration Overview This Month Approved |
1174 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1174 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1175 | 1175 | $admin_bar->add_menu(array( |
1176 | 1176 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1177 | 1177 | 'parent' => 'espresso-toolbar-registrations-month', |
1178 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1179 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1178 | + 'title' => __('Approved', 'event_espresso'), |
|
1179 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1180 | 1180 | 'meta' => array( |
1181 | 1181 | 'title' => __('Approved', 'event_espresso'), |
1182 | 1182 | 'target' => '', |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | //Registration Overview This Month Pending |
1189 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1189 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1190 | 1190 | $admin_bar->add_menu(array( |
1191 | 1191 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1192 | 1192 | 'parent' => 'espresso-toolbar-registrations-month', |
1193 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1194 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1193 | + 'title' => __('Pending', 'event_espresso'), |
|
1194 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1195 | 1195 | 'meta' => array( |
1196 | 1196 | 'title' => __('Pending', 'event_espresso'), |
1197 | 1197 | 'target' => '', |
@@ -1201,14 +1201,14 @@ discard block |
||
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | //Registration Overview This Month Not Approved |
1204 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1204 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1205 | 1205 | $admin_bar->add_menu(array( |
1206 | 1206 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1207 | 1207 | 'parent' => 'espresso-toolbar-registrations-month', |
1208 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1209 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1208 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1209 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1210 | 1210 | 'meta' => array( |
1211 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1211 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1212 | 1212 | 'target' => '', |
1213 | 1213 | 'class' => $menu_class |
1214 | 1214 | ), |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | |
1219 | 1219 | //Registration Overview This Month Cancelled |
1220 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1220 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1221 | 1221 | $admin_bar->add_menu(array( |
1222 | 1222 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1223 | 1223 | 'parent' => 'espresso-toolbar-registrations-month', |
1224 | 1224 | 'title' => __('Cancelled', 'event_espresso'), |
1225 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1225 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1226 | 1226 | 'meta' => array( |
1227 | 1227 | 'title' => __('Cancelled', 'event_espresso'), |
1228 | 1228 | 'target' => '', |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | //Extensions & Services |
1235 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1235 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1236 | 1236 | $admin_bar->add_menu(array( |
1237 | 1237 | 'id' => 'espresso-toolbar-extensions-and-services', |
1238 | 1238 | 'parent' => 'espresso-toolbar', |
1239 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1239 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1240 | 1240 | 'href' => $extensions_admin_url, |
1241 | 1241 | 'meta' => array( |
1242 | 1242 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | * @param array $exclude_array any existing pages being excluded are in this array. |
1259 | 1259 | * @return array |
1260 | 1260 | */ |
1261 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1262 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1261 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1262 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | |
@@ -1279,12 +1279,12 @@ discard block |
||
1279 | 1279 | */ |
1280 | 1280 | public function wp_enqueue_scripts() { |
1281 | 1281 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1282 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1282 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1283 | 1283 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1284 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1284 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1285 | 1285 | // register jQuery Validate and additional methods |
1286 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE ); |
|
1287 | - wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE ); |
|
1286 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
1287 | + wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE); |
|
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param mixed $opt_group |
776 | 776 | * @param mixed $QSOs |
777 | - * @param mixed $answer |
|
777 | + * @param string $answer |
|
778 | 778 | * @return string |
779 | 779 | */ |
780 | 780 | private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * prep_required |
1124 | 1124 | * @param string|array $required |
1125 | - * @return array |
|
1125 | + * @return string |
|
1126 | 1126 | */ |
1127 | 1127 | static function prep_required( $required = array() ){ |
1128 | 1128 | // make sure required is an array |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * _load_system_dropdowns |
1176 | - * @param array $QFI |
|
1177 | - * @return array |
|
1176 | + * @param EE_Question_Form_Input $QFI |
|
1177 | + * @return EE_Question_Form_Input |
|
1178 | 1178 | */ |
1179 | 1179 | private static function _load_system_dropdowns( $QFI ){ |
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | * @param string $nonce_action - if using nonces |
1464 | 1464 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | - * @return void |
|
1466 | + * @return string |
|
1467 | 1467 | */ |
1468 | 1468 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1469 | 1469 | $btn = ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,22 +363,22 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | //load formatter helper |
374 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
374 | + EE_Registry::instance()->load_helper('Formatter'); |
|
375 | 375 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
376 | 376 | |
377 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
377 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
378 | 378 | //Debug |
379 | 379 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
380 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | - $field .= ' ' . $parameters; |
|
380 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | + $field .= ' '.$parameters; |
|
382 | 382 | if ($autosize) { |
383 | 383 | $size = 'med'; |
384 | 384 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | $size = ''; |
392 | 392 | } |
393 | 393 | |
394 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
394 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
395 | 395 | |
396 | 396 | if (empty($default) && isset($GLOBALS[$name])) |
397 | 397 | $default = stripslashes($GLOBALS[$name]); |
398 | 398 | |
399 | 399 | |
400 | 400 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
401 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
401 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
402 | 402 | if ($default == $values[$i]['id']) { |
403 | 403 | $field .= ' selected = "selected"'; |
404 | 404 | } |
405 | - if ( isset( $values[$i]['class'] ) ) { |
|
406 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
405 | + if (isset($values[$i]['class'])) { |
|
406 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
407 | 407 | } |
408 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
408 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
409 | 409 | } |
410 | 410 | $field .= '</select>'; |
411 | 411 | |
@@ -423,38 +423,38 @@ discard block |
||
423 | 423 | * @param string $question_groups |
424 | 424 | * @return string HTML |
425 | 425 | */ |
426 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
426 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
427 | 427 | |
428 | 428 | $html = ''; |
429 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
430 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
429 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
430 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
431 | 431 | |
432 | - if ( ! empty( $question_groups )) { |
|
432 | + if ( ! empty($question_groups)) { |
|
433 | 433 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
434 | 434 | // loop thru question groups |
435 | - foreach ( $question_groups as $QSG ) { |
|
435 | + foreach ($question_groups as $QSG) { |
|
436 | 436 | // check that questions exist |
437 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
437 | + if ( ! empty($QSG['QSG_questions'])) { |
|
438 | 438 | // use fieldsets |
439 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
439 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
440 | 440 | // group_name |
441 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
441 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
442 | 442 | // group_desc |
443 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
443 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
444 | 444 | |
445 | 445 | $html .= $before_question_group_questions; |
446 | 446 | // loop thru questions |
447 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
447 | + foreach ($QSG['QSG_questions'] as $question) { |
|
448 | 448 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
449 | 449 | $QFI = new EE_Question_Form_Input( |
450 | 450 | $question['qst_obj'], |
451 | 451 | $question['ans_obj'], |
452 | 452 | $question |
453 | 453 | ); |
454 | - $html .= self::generate_form_input( $QFI ); |
|
454 | + $html .= self::generate_form_input($QFI); |
|
455 | 455 | } |
456 | 456 | $html .= $after_question_group_questions; |
457 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
457 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $group_wrapper |
475 | 475 | * @return string HTML |
476 | 476 | */ |
477 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
477 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
478 | 478 | |
479 | 479 | $html = ''; |
480 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
481 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
480 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
481 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
482 | 482 | |
483 | 483 | $default_q_meta = array( |
484 | 484 | 'att_nmbr' => 1, |
@@ -487,55 +487,55 @@ discard block |
||
487 | 487 | 'input_id' => '', |
488 | 488 | 'input_class' => '' |
489 | 489 | ); |
490 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
490 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
491 | 491 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | |
493 | - if ( ! empty( $question_groups )) { |
|
493 | + if ( ! empty($question_groups)) { |
|
494 | 494 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
495 | 495 | // loop thru question groups |
496 | - foreach ( $question_groups as $QSG ) { |
|
497 | - if ( $QSG instanceof EE_Question_Group ) { |
|
496 | + foreach ($question_groups as $QSG) { |
|
497 | + if ($QSG instanceof EE_Question_Group) { |
|
498 | 498 | // check that questions exist |
499 | 499 | |
500 | - $where = array( 'QST_deleted' => 0 ); |
|
501 | - if ( ! $from_admin ) { |
|
500 | + $where = array('QST_deleted' => 0); |
|
501 | + if ( ! $from_admin) { |
|
502 | 502 | $where['QST_admin_only'] = 0; |
503 | 503 | } |
504 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
505 | - if ( ! empty( $questions )) { |
|
504 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
505 | + if ( ! empty($questions)) { |
|
506 | 506 | // use fieldsets |
507 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
507 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
508 | 508 | // group_name |
509 | - if ( $QSG->show_group_name() ) { |
|
510 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
509 | + if ($QSG->show_group_name()) { |
|
510 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
511 | 511 | } |
512 | 512 | // group_desc |
513 | - if ( $QSG->show_group_desc() ) { |
|
514 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
513 | + if ($QSG->show_group_desc()) { |
|
514 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $html .= $before_question_group_questions; |
518 | 518 | // loop thru questions |
519 | - foreach ( $questions as $QST ) { |
|
519 | + foreach ($questions as $QST) { |
|
520 | 520 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
521 | 521 | |
522 | 522 | $answer = NULL; |
523 | 523 | |
524 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
524 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
525 | 525 | // check for answer in $_GET in case we are reprocessing a form after an error |
526 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
527 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
526 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
527 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
528 | 528 | } |
529 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
529 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
530 | 530 | //attendee data from the session |
531 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
531 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | |
536 | 536 | $QFI = new EE_Question_Form_Input( |
537 | 537 | $QST, |
538 | - EE_Answer::new_instance ( array( |
|
538 | + EE_Answer::new_instance(array( |
|
539 | 539 | 'ANS_ID'=> 0, |
540 | 540 | 'QST_ID'=> 0, |
541 | 541 | 'REG_ID'=> 0, |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | $q_meta |
545 | 545 | ); |
546 | 546 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
547 | - $html .= self::generate_form_input( $QFI ); |
|
547 | + $html .= self::generate_form_input($QFI); |
|
548 | 548 | } |
549 | 549 | $html .= $after_question_group_questions; |
550 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
550 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -567,63 +567,63 @@ discard block |
||
567 | 567 | * @param EE_Question_Form_Input $QFI |
568 | 568 | * @return string HTML |
569 | 569 | */ |
570 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
571 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
570 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
571 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
576 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
575 | + $QFI = self::_load_system_dropdowns($QFI); |
|
576 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
577 | 577 | |
578 | 578 | //we also need to verify |
579 | 579 | |
580 | 580 | $display_text = $QFI->get('QST_display_text'); |
581 | 581 | $input_name = $QFI->get('QST_input_name'); |
582 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
582 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
583 | 583 | $input_id = $QFI->get('QST_input_id'); |
584 | 584 | $input_class = $QFI->get('QST_input_class'); |
585 | 585 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
586 | 586 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
587 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
587 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
588 | 588 | $QST_required = $QFI->get('QST_required'); |
589 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
590 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
591 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
592 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
589 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
590 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
591 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
592 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
593 | 593 | $label_class = 'espresso-form-input-lbl'; |
594 | - $QST_options = $QFI->options(true,$answer); |
|
595 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
594 | + $QST_options = $QFI->options(true, $answer); |
|
595 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
596 | 596 | $system_ID = $QFI->get('QST_system'); |
597 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
598 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
597 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
598 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
599 | 599 | |
600 | 600 | |
601 | - switch ( $QFI->get('QST_type') ){ |
|
601 | + switch ($QFI->get('QST_type')) { |
|
602 | 602 | |
603 | 603 | case 'TEXTAREA' : |
604 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
604 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
605 | 605 | break; |
606 | 606 | |
607 | 607 | case 'DROPDOWN' : |
608 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
608 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
609 | 609 | break; |
610 | 610 | |
611 | 611 | |
612 | 612 | case 'RADIO_BTN' : |
613 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
613 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
614 | 614 | break; |
615 | 615 | |
616 | 616 | case 'CHECKBOX' : |
617 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
617 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
618 | 618 | break; |
619 | 619 | |
620 | 620 | case 'DATE' : |
621 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
621 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
622 | 622 | break; |
623 | 623 | |
624 | 624 | case 'TEXT' : |
625 | 625 | default: |
626 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
626 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
627 | 627 | break; |
628 | 628 | |
629 | 629 | } |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string $disabled disabled="disabled" or null |
650 | 650 | * @return string HTML |
651 | 651 | */ |
652 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
652 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
653 | 653 | // need these |
654 | - if ( ! $question || ! $name ) { |
|
654 | + if ( ! $question || ! $name) { |
|
655 | 655 | return NULL; |
656 | 656 | } |
657 | 657 | // prep the answer |
658 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
658 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
659 | 659 | // prep the required array |
660 | - $required = self::prep_required( $required ); |
|
660 | + $required = self::prep_required($required); |
|
661 | 661 | // set disabled tag |
662 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
662 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
663 | 663 | // ya gots ta have style man!!! |
664 | 664 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
665 | - $class = empty( $class ) ? $txt_class : $class; |
|
666 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
667 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
665 | + $class = empty($class) ? $txt_class : $class; |
|
666 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
667 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
668 | 668 | |
669 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
669 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
670 | 670 | // filter label but ensure required text comes before it |
671 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
671 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
672 | 672 | |
673 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
673 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
674 | 674 | |
675 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
676 | - return $label_html . $input_html; |
|
675 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
676 | + return $label_html.$input_html; |
|
677 | 677 | |
678 | 678 | } |
679 | 679 | |
@@ -695,35 +695,35 @@ discard block |
||
695 | 695 | * @param string $disabled disabled="disabled" or null |
696 | 696 | * @return string HTML |
697 | 697 | */ |
698 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
698 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
699 | 699 | // need these |
700 | - if ( ! $question || ! $name ) { |
|
700 | + if ( ! $question || ! $name) { |
|
701 | 701 | return NULL; |
702 | 702 | } |
703 | 703 | // prep the answer |
704 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
704 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
705 | 705 | // prep the required array |
706 | - $required = self::prep_required( $required ); |
|
706 | + $required = self::prep_required($required); |
|
707 | 707 | // make sure $dimensions is an array |
708 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
708 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
709 | 709 | // and set some defaults |
710 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
710 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
711 | 711 | // set disabled tag |
712 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
712 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
713 | 713 | // ya gots ta have style man!!! |
714 | 714 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
715 | - $class = empty( $class ) ? $txt_class : $class; |
|
716 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
717 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
715 | + $class = empty($class) ? $txt_class : $class; |
|
716 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
717 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
718 | 718 | |
719 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
719 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
720 | 720 | // filter label but ensure required text comes before it |
721 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
721 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
722 | 722 | |
723 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
723 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
724 | 724 | |
725 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
726 | - return $label_html . $input_html; |
|
725 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
726 | + return $label_html.$input_html; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | |
@@ -746,47 +746,47 @@ discard block |
||
746 | 746 | * @param string $disabled disabled="disabled" or null |
747 | 747 | * @return string HTML |
748 | 748 | */ |
749 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
749 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
750 | 750 | |
751 | 751 | // need these |
752 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
752 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
753 | 753 | return NULL; |
754 | 754 | } |
755 | 755 | // prep the answer |
756 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
756 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
757 | 757 | // prep the required array |
758 | - $required = self::prep_required( $required ); |
|
758 | + $required = self::prep_required($required); |
|
759 | 759 | // set disabled tag |
760 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
760 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
761 | 761 | // ya gots ta have style man!!! |
762 | 762 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
763 | - $class = empty( $class ) ? $txt_class : $class; |
|
764 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
765 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
763 | + $class = empty($class) ? $txt_class : $class; |
|
764 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
765 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
766 | 766 | |
767 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
767 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
768 | 768 | // filter label but ensure required text comes before it |
769 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
769 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
770 | 770 | |
771 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
771 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
772 | 772 | // recursively count array elements, to determine total number of options |
773 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
774 | - if ( ! $only_option ) { |
|
773 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
774 | + if ( ! $only_option) { |
|
775 | 775 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
776 | 776 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
777 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
777 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
778 | 778 | } |
779 | - foreach ( $options as $key => $value ) { |
|
779 | + foreach ($options as $key => $value) { |
|
780 | 780 | // if value is an array, then create option groups, else create regular ol' options |
781 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
781 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
782 | 782 | } |
783 | 783 | |
784 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
784 | + $input_html .= "\n\t\t\t".'</select>'; |
|
785 | 785 | |
786 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
786 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
787 | 787 | |
788 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
789 | - return $label_html . $input_html; |
|
788 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
789 | + return $label_html.$input_html; |
|
790 | 790 | |
791 | 791 | } |
792 | 792 | |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | * @param boolean $use_html_entities |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
808 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
809 | - foreach ( $QSOs as $QSO ) { |
|
810 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
807 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
808 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
809 | + foreach ($QSOs as $QSO) { |
|
810 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
811 | 811 | } |
812 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
812 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
813 | 813 | return $html; |
814 | 814 | } |
815 | 815 | |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | * @param boolean $use_html_entities |
825 | 825 | * @return string |
826 | 826 | */ |
827 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
828 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
829 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
830 | - $value = ! empty( $value ) ? $value : $key; |
|
831 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
832 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
827 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
828 | + $key = self::prep_answer($key, $use_html_entities); |
|
829 | + $value = self::prep_answer($value, $use_html_entities); |
|
830 | + $value = ! empty($value) ? $value : $key; |
|
831 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
832 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -853,56 +853,56 @@ discard block |
||
853 | 853 | * @param bool $use_desc_4_label |
854 | 854 | * @return string HTML |
855 | 855 | */ |
856 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
856 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
857 | 857 | // need these |
858 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
858 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
859 | 859 | return NULL; |
860 | 860 | } |
861 | 861 | // prep the answer |
862 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
862 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
863 | 863 | // prep the required array |
864 | - $required = self::prep_required( $required ); |
|
864 | + $required = self::prep_required($required); |
|
865 | 865 | // set disabled tag |
866 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
866 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
867 | 867 | // ya gots ta have style man!!! |
868 | 868 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
869 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
870 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
869 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
870 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
871 | 871 | |
872 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
872 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
873 | 873 | // filter label but ensure required text comes before it |
874 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
874 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
875 | 875 | |
876 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
876 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
877 | 877 | |
878 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
879 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
878 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
879 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
880 | 880 | |
881 | - foreach ( $options as $OPT ) { |
|
882 | - if ( $OPT instanceof EE_Question_Option ) { |
|
883 | - $value = self::prep_option_value( $OPT->value() ); |
|
881 | + foreach ($options as $OPT) { |
|
882 | + if ($OPT instanceof EE_Question_Option) { |
|
883 | + $value = self::prep_option_value($OPT->value()); |
|
884 | 884 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
885 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
886 | - $desc = $OPT->desc();//no self::prep_answer |
|
887 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
888 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
889 | - $opt = '-' . sanitize_key( $value ); |
|
890 | - |
|
891 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
892 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
893 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
894 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
895 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
896 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
897 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
898 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
885 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
886 | + $desc = $OPT->desc(); //no self::prep_answer |
|
887 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
888 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
889 | + $opt = '-'.sanitize_key($value); |
|
890 | + |
|
891 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
892 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
893 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
894 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
895 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
896 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
897 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
898 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
902 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
903 | 903 | |
904 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
905 | - return $label_html . $input_html; |
|
904 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
905 | + return $label_html.$input_html; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -925,65 +925,65 @@ discard block |
||
925 | 925 | * @param string $disabled disabled="disabled" or null |
926 | 926 | * @return string HTML |
927 | 927 | */ |
928 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
928 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
929 | 929 | // need these |
930 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
930 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
931 | 931 | return NULL; |
932 | 932 | } |
933 | - $answer = maybe_unserialize( $answer ); |
|
933 | + $answer = maybe_unserialize($answer); |
|
934 | 934 | |
935 | 935 | // prep the answer(s) |
936 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
936 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
937 | 937 | |
938 | - foreach ( $answer as $key => $value ) { |
|
939 | - $key = self::prep_option_value( $key ); |
|
940 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
938 | + foreach ($answer as $key => $value) { |
|
939 | + $key = self::prep_option_value($key); |
|
940 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | // prep the required array |
944 | - $required = self::prep_required( $required ); |
|
944 | + $required = self::prep_required($required); |
|
945 | 945 | // set disabled tag |
946 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
946 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
947 | 947 | // ya gots ta have style man!!! |
948 | 948 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
949 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
950 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
949 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
950 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
951 | 951 | |
952 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
952 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
953 | 953 | // filter label but ensure required text comes before it |
954 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
955 | - |
|
956 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
957 | - |
|
958 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
959 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
960 | - |
|
961 | - foreach ( $options as $OPT ) { |
|
962 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
963 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
964 | - $text = self::prep_answer( $OPT->value() ); |
|
965 | - $desc = $OPT->desc() ; |
|
966 | - $opt = '-' . sanitize_key( $value ); |
|
967 | - |
|
968 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
969 | - |
|
970 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
971 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
972 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
973 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
974 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
975 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
976 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
977 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
954 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
955 | + |
|
956 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
957 | + |
|
958 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
959 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
960 | + |
|
961 | + foreach ($options as $OPT) { |
|
962 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
963 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
964 | + $text = self::prep_answer($OPT->value()); |
|
965 | + $desc = $OPT->desc(); |
|
966 | + $opt = '-'.sanitize_key($value); |
|
967 | + |
|
968 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
969 | + |
|
970 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
971 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
972 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
973 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
974 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
975 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
976 | + if ( ! empty($desc) && $desc != $text) { |
|
977 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
978 | 978 | } |
979 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
979 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
980 | 980 | |
981 | 981 | } |
982 | 982 | |
983 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
983 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
984 | 984 | |
985 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
986 | - return $label_html . $input_html; |
|
985 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
986 | + return $label_html.$input_html; |
|
987 | 987 | |
988 | 988 | } |
989 | 989 | |
@@ -1005,36 +1005,36 @@ discard block |
||
1005 | 1005 | * @param string $disabled disabled="disabled" or null |
1006 | 1006 | * @return string HTML |
1007 | 1007 | */ |
1008 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1008 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1009 | 1009 | // need these |
1010 | - if ( ! $question || ! $name ) { |
|
1010 | + if ( ! $question || ! $name) { |
|
1011 | 1011 | return NULL; |
1012 | 1012 | } |
1013 | 1013 | // prep the answer |
1014 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1014 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1015 | 1015 | // prep the required array |
1016 | - $required = self::prep_required( $required ); |
|
1016 | + $required = self::prep_required($required); |
|
1017 | 1017 | // set disabled tag |
1018 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1018 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1019 | 1019 | // ya gots ta have style man!!! |
1020 | 1020 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1021 | - $class = empty( $class ) ? $txt_class : $class; |
|
1022 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1023 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1021 | + $class = empty($class) ? $txt_class : $class; |
|
1022 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1023 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1024 | 1024 | |
1025 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1025 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1026 | 1026 | // filter label but ensure required text comes before it |
1027 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1027 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1028 | 1028 | |
1029 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1029 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1030 | 1030 | |
1031 | 1031 | // enqueue scripts |
1032 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1033 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1034 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1032 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1033 | + wp_enqueue_style('espresso-ui-theme'); |
|
1034 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1035 | 1035 | |
1036 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1037 | - return $label_html . $input_html; |
|
1036 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1037 | + return $label_html.$input_html; |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @access public |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1049 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1050 | 1050 | return $required_text; |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param string $value |
1061 | 1061 | * @return string HTML |
1062 | 1062 | */ |
1063 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1064 | - $id = ! empty( $id ) ? $id : $name; |
|
1065 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1063 | + static function hidden_input($name, $value, $id = '') { |
|
1064 | + $id = ! empty($id) ? $id : $name; |
|
1065 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @param string $question |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | - static function prep_question( $question ){ |
|
1077 | + static function prep_question($question) { |
|
1078 | 1078 | return $question; |
1079 | 1079 | // $link = ''; |
1080 | 1080 | // // does this label have a help link attached ? |
@@ -1097,13 +1097,13 @@ discard block |
||
1097 | 1097 | * @param mixed $answer |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1100 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1101 | 1101 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1102 | - if ( is_bool( $answer ) ) { |
|
1102 | + if (is_bool($answer)) { |
|
1103 | 1103 | $answer = $answer ? 1 : 0; |
1104 | 1104 | } |
1105 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1106 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1105 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1106 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
@@ -1113,18 +1113,18 @@ discard block |
||
1113 | 1113 | * @param array $QSOs array of EE_Question_Option objects |
1114 | 1114 | * @return array |
1115 | 1115 | */ |
1116 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1116 | + public static function prep_answer_options($QSOs = array()) { |
|
1117 | 1117 | $prepped_answer_options = array(); |
1118 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1119 | - foreach( $QSOs as $key => $QSO ) { |
|
1120 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1121 | - $QSO = EE_Question_Option::new_instance( array( |
|
1122 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1123 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1118 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1119 | + foreach ($QSOs as $key => $QSO) { |
|
1120 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1121 | + $QSO = EE_Question_Option::new_instance(array( |
|
1122 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1123 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1124 | 1124 | )); |
1125 | 1125 | } |
1126 | - if ( $QSO->opt_group() ) { |
|
1127 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1126 | + if ($QSO->opt_group()) { |
|
1127 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1128 | 1128 | } else { |
1129 | 1129 | $prepped_answer_options[] = $QSO; |
1130 | 1130 | } |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | * @param string $option_value |
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | - static function prep_option_value( $option_value ){ |
|
1144 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1143 | + static function prep_option_value($option_value) { |
|
1144 | + return esc_attr(trim(stripslashes($option_value))); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | * @param string|array $required |
1153 | 1153 | * @return array |
1154 | 1154 | */ |
1155 | - static function prep_required( $required = array() ){ |
|
1155 | + static function prep_required($required = array()) { |
|
1156 | 1156 | // make sure required is an array |
1157 | - $required = is_array( $required ) ? $required : array(); |
|
1157 | + $required = is_array($required) ? $required : array(); |
|
1158 | 1158 | // and set some defaults |
1159 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1159 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1160 | 1160 | return $required; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1167,30 +1167,30 @@ discard block |
||
1167 | 1167 | * @param string $value |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - static function get_label_size_class( $value = FALSE ){ |
|
1171 | - if ( $value === FALSE || $value == '' ) { |
|
1170 | + static function get_label_size_class($value = FALSE) { |
|
1171 | + if ($value === FALSE || $value == '') { |
|
1172 | 1172 | return ' class="medium-lbl"'; |
1173 | 1173 | } |
1174 | 1174 | // determine length of option value |
1175 | - $val_size = strlen( $value ); |
|
1176 | - switch( $val_size ){ |
|
1175 | + $val_size = strlen($value); |
|
1176 | + switch ($val_size) { |
|
1177 | 1177 | case $val_size < 3 : |
1178 | - $size = ' class="nano-lbl"'; |
|
1178 | + $size = ' class="nano-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 6 : |
1181 | - $size = ' class="micro-lbl"'; |
|
1181 | + $size = ' class="micro-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 12 : |
1184 | - $size = ' class="tiny-lbl"'; |
|
1184 | + $size = ' class="tiny-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size < 25 : |
1187 | - $size = ' class="small-lbl"'; |
|
1187 | + $size = ' class="small-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | case $val_size > 100 : |
1190 | - $size = ' class="big-lbl"'; |
|
1190 | + $size = ' class="big-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | default: |
1193 | - $size = ' class="medium-lbl"'; |
|
1193 | + $size = ' class="medium-lbl"'; |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | return $size; |
@@ -1204,20 +1204,20 @@ discard block |
||
1204 | 1204 | * @param array $QFI |
1205 | 1205 | * @return array |
1206 | 1206 | */ |
1207 | - private static function _load_system_dropdowns( $QFI ){ |
|
1207 | + private static function _load_system_dropdowns($QFI) { |
|
1208 | 1208 | $QST_system = $QFI->get('QST_system'); |
1209 | - switch ( $QST_system ) { |
|
1209 | + switch ($QST_system) { |
|
1210 | 1210 | case 'state' : |
1211 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_state_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'country' : |
1214 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1214 | + $QFI = self::generate_country_dropdown($QFI); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-state' : |
1217 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | case 'admin-country' : |
1220 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1220 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1221 | 1221 | break; |
1222 | 1222 | } |
1223 | 1223 | return $QFI; |
@@ -1234,13 +1234,13 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @return EE_Question_Form_Input |
1236 | 1236 | */ |
1237 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1238 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1237 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1238 | + switch ($QFI->get('QST_type')) { |
|
1239 | 1239 | case 'STATE' : |
1240 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_state_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | case 'COUNTRY' : |
1243 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1243 | + $QFI = self::generate_country_dropdown($QFI); |
|
1244 | 1244 | break; |
1245 | 1245 | } |
1246 | 1246 | return $QFI; |
@@ -1254,23 +1254,23 @@ discard block |
||
1254 | 1254 | * @param bool $get_all |
1255 | 1255 | * @return array |
1256 | 1256 | */ |
1257 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1257 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1258 | 1258 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1259 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1260 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1259 | + if ($states && count($states) != count($QST->options())) { |
|
1260 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1261 | 1261 | // if multiple countries, we'll create option groups within the dropdown |
1262 | - foreach ( $states as $state ) { |
|
1263 | - if ( $state instanceof EE_State ) { |
|
1264 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1262 | + foreach ($states as $state) { |
|
1263 | + if ($state instanceof EE_State) { |
|
1264 | + $QSO = EE_Question_Option::new_instance(array( |
|
1265 | 1265 | 'QSO_value' => $state->ID(), |
1266 | 1266 | 'QSO_desc' => $state->name(), |
1267 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1267 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1268 | 1268 | 'QSO_deleted' => FALSE |
1269 | 1269 | )); |
1270 | 1270 | // set option group |
1271 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1271 | + $QSO->set_opt_group($state->country()->name()); |
|
1272 | 1272 | // add option to question |
1273 | - $QST->add_temp_option( $QSO ); |
|
1273 | + $QST->add_temp_option($QSO); |
|
1274 | 1274 | } |
1275 | 1275 | } |
1276 | 1276 | } |
@@ -1286,20 +1286,20 @@ discard block |
||
1286 | 1286 | * @internal param array $question |
1287 | 1287 | * @return array |
1288 | 1288 | */ |
1289 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1289 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1290 | 1290 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1291 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1292 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1291 | + if ($countries && count($countries) != count($QST->options())) { |
|
1292 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1293 | 1293 | // now add countries |
1294 | - foreach ( $countries as $country ) { |
|
1295 | - if ( $country instanceof EE_Country ) { |
|
1296 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1294 | + foreach ($countries as $country) { |
|
1295 | + if ($country instanceof EE_Country) { |
|
1296 | + $QSO = EE_Question_Option::new_instance(array( |
|
1297 | 1297 | 'QSO_value' => $country->ID(), |
1298 | 1298 | 'QSO_desc' => $country->name(), |
1299 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1299 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1300 | 1300 | 'QSO_deleted' => FALSE |
1301 | 1301 | )); |
1302 | - $QST->add_temp_option( $QSO ); |
|
1302 | + $QST->add_temp_option($QSO); |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1316,11 +1316,11 @@ discard block |
||
1316 | 1316 | */ |
1317 | 1317 | public static function two_digit_months_dropdown_options() { |
1318 | 1318 | $options = array(); |
1319 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1320 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1321 | - $options[ (string)$mm ] = (string)$mm; |
|
1319 | + for ($x = 1; $x <= 12; $x++) { |
|
1320 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1321 | + $options[(string) $mm] = (string) $mm; |
|
1322 | 1322 | } |
1323 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1323 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | $options = array(); |
1336 | 1336 | $current_year = date('y'); |
1337 | 1337 | $next_decade = $current_year + 10; |
1338 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1339 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1340 | - $options[ (string)$yy ] = (string)$yy; |
|
1338 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1339 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1340 | + $options[(string) $yy] = (string) $yy; |
|
1341 | 1341 | } |
1342 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1342 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | |
@@ -1353,17 +1353,17 @@ discard block |
||
1353 | 1353 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1354 | 1354 | * @return string html |
1355 | 1355 | */ |
1356 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1356 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1357 | 1357 | $_where = array(); |
1358 | - if ( !empty( $status ) ) { |
|
1358 | + if ( ! empty($status)) { |
|
1359 | 1359 | $_where['STS_ID'] = $status; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( $evt_category > 0 ) { |
|
1362 | + if ($evt_category > 0) { |
|
1363 | 1363 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1366 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1367 | 1367 | |
1368 | 1368 | //setup vals for select input helper |
1369 | 1369 | $options = array( |
@@ -1373,15 +1373,15 @@ discard block |
||
1373 | 1373 | ) |
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - foreach ( $regdtts as $regdtt ) { |
|
1377 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1376 | + foreach ($regdtts as $regdtt) { |
|
1377 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1378 | 1378 | $options[] = array( |
1379 | 1379 | 'text' => $date, |
1380 | 1380 | 'id' => $date |
1381 | 1381 | ); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1384 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | |
@@ -1395,18 +1395,18 @@ discard block |
||
1395 | 1395 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1396 | 1396 | * @return string html |
1397 | 1397 | */ |
1398 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1398 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1399 | 1399 | //determine what post_status our condition will have for the query. |
1400 | - switch ( $status ) { |
|
1400 | + switch ($status) { |
|
1401 | 1401 | case 'month' : |
1402 | 1402 | case 'today' : |
1403 | 1403 | case NULL : |
1404 | 1404 | case 'all' : |
1405 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1405 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1406 | 1406 | break; |
1407 | 1407 | |
1408 | 1408 | case 'draft' : |
1409 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1409 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1410 | 1410 | |
1411 | 1411 | default : |
1412 | 1412 | $where['Event.status'] = $status; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | //categories? |
1416 | 1416 | |
1417 | 1417 | |
1418 | - if ( !empty ( $evt_category ) ) { |
|
1418 | + if ( ! empty ($evt_category)) { |
|
1419 | 1419 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1420 | 1420 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1421 | 1421 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | |
1424 | 1424 | // $where['DTT_is_primary'] = 1; |
1425 | 1425 | |
1426 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1426 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1427 | 1427 | |
1428 | 1428 | //let's setup vals for select input helper |
1429 | 1429 | $options = array( |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | //translate month and date |
1439 | 1439 | global $wp_locale; |
1440 | 1440 | |
1441 | - foreach ( $DTTS as $DTT ) { |
|
1442 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1443 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1441 | + foreach ($DTTS as $DTT) { |
|
1442 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1443 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1444 | 1444 | $options[] = array( |
1445 | 1445 | 'text' => $localized_date, |
1446 | 1446 | 'id' => $id |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | |
1451 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1451 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | * @param integer $current_cat currently selected category |
1460 | 1460 | * @return string html for dropdown |
1461 | 1461 | */ |
1462 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1462 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1463 | 1463 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1464 | 1464 | $options = array( |
1465 | 1465 | '0' => array( |
@@ -1469,14 +1469,14 @@ discard block |
||
1469 | 1469 | ); |
1470 | 1470 | |
1471 | 1471 | //setup categories for dropdown |
1472 | - foreach ( $categories as $category ) { |
|
1472 | + foreach ($categories as $category) { |
|
1473 | 1473 | $options[] = array( |
1474 | 1474 | 'text' => $category->get('name'), |
1475 | 1475 | 'id' => $category->ID() |
1476 | 1476 | ); |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1479 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | |
@@ -1495,20 +1495,20 @@ discard block |
||
1495 | 1495 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1496 | 1496 | * @return void |
1497 | 1497 | */ |
1498 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1498 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1499 | 1499 | $btn = ''; |
1500 | - if ( empty( $url ) || empty( $ID )) { |
|
1500 | + if (empty($url) || empty($ID)) { |
|
1501 | 1501 | return $btn; |
1502 | 1502 | } |
1503 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1504 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1505 | - if ( ! $input_only ) { |
|
1506 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1507 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1503 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1504 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1505 | + if ( ! $input_only) { |
|
1506 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1507 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1508 | 1508 | $btn_frm .= $btn; |
1509 | 1509 | $btn_frm .= '</form>'; |
1510 | 1510 | $btn = $btn_frm; |
1511 | - unset ( $btn_frm ); |
|
1511 | + unset ($btn_frm); |
|
1512 | 1512 | } |
1513 | 1513 | return $btn; |
1514 | 1514 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * Ensures that taxes have been applied to the order, if not applies them. |
575 | 575 | * Returns the total amount of tax |
576 | 576 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
577 | - * @return float |
|
577 | + * @return boolean |
|
578 | 578 | */ |
579 | 579 | public static function ensure_taxes_applied( $total_line_item ){ |
580 | 580 | $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Deletes ALL children of the passed line item |
591 | 591 | * |
592 | 592 | * @param EE_Line_Item $parent_line_item |
593 | - * @return bool |
|
593 | + * @return integer |
|
594 | 594 | */ |
595 | 595 | public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
596 | 596 | $deleted = 0; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * You should call EE_Registration_Processor::calculate_reg_final_prices_per_line_item() |
621 | 621 | * after using this, to keep the registration final prices in-sync with the transaction's total. |
622 | 622 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
623 | - * @param array|bool|string $line_item_codes |
|
623 | + * @param boolean $line_item_codes |
|
624 | 624 | * @return int number of items successfully removed |
625 | 625 | */ |
626 | 626 | public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
@@ -784,6 +784,7 @@ discard block |
||
784 | 784 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
785 | 785 | * @param string $line_item_type one of the EEM_Line_Item constants |
786 | 786 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
787 | + * @param string $obj_type |
|
787 | 788 | * @return EE_Line_Item[] |
788 | 789 | */ |
789 | 790 | protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
@@ -809,7 +810,7 @@ discard block |
||
809 | 810 | * @uses EEH_Line_Item::_get_descendants_by_type_and_object_type() |
810 | 811 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
811 | 812 | * @param string $OBJ_type object type (like Event) |
812 | - * @param array $OBJ_IDs array of OBJ_IDs |
|
813 | + * @param boolean[] $OBJ_IDs array of OBJ_IDs |
|
813 | 814 | * @return EE_Line_Item[] |
814 | 815 | */ |
815 | 816 | public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
41 | 41 | * @return boolean success |
42 | 42 | */ |
43 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
44 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
43 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
44 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
45 | 45 | $line_item = EE_Line_Item::new_instance(array( |
46 | 46 | 'LIN_name' => $name, |
47 | 47 | 'LIN_desc' => $description, |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | 'LIN_quantity' => $quantity, |
50 | 50 | 'LIN_percent' => null, |
51 | 51 | 'LIN_is_taxable' => $taxable, |
52 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
53 | - 'LIN_total' => floatval( $unit_price ) * intval( $quantity ), |
|
52 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
53 | + 'LIN_total' => floatval($unit_price) * intval($quantity), |
|
54 | 54 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
55 | 55 | 'LIN_code' => $code, |
56 | 56 | )); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $line_item, |
60 | 60 | $parent_line_item |
61 | 61 | ); |
62 | - return self::add_item( $parent_line_item, $line_item ); |
|
62 | + return self::add_item($parent_line_item, $line_item); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param boolean $taxable |
81 | 81 | * @return boolean success |
82 | 82 | */ |
83 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
83 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
84 | 84 | $line_item = EE_Line_Item::new_instance(array( |
85 | 85 | 'LIN_name' => $name, |
86 | 86 | 'LIN_desc' => $description, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'LIN_percent' => $percentage_amount, |
89 | 89 | 'LIN_quantity' => NULL, |
90 | 90 | 'LIN_is_taxable' => $taxable, |
91 | - 'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )), |
|
91 | + 'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)), |
|
92 | 92 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
93 | 93 | 'LIN_parent' => $parent_line_item->ID() |
94 | 94 | )); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
97 | 97 | $line_item |
98 | 98 | ); |
99 | - return self::add_item( $parent_line_item, $line_item ); |
|
99 | + return self::add_item($parent_line_item, $line_item); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @return \EE_Line_Item |
118 | 118 | * @throws \EE_Error |
119 | 119 | */ |
120 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
121 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
122 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
120 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
121 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
122 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
123 | 123 | } |
124 | 124 | // either increment the qty for an existing ticket |
125 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
125 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
126 | 126 | // or add a new one |
127 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
128 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
127 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
128 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
129 | 129 | } |
130 | 130 | $total_line_item->recalculate_total_including_taxes(); |
131 | 131 | return $line_item; |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | * @return \EE_Line_Item |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
144 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
145 | 145 | $line_item = null; |
146 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
147 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
148 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
149 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) { |
|
146 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
147 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
148 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
149 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) { |
|
150 | 150 | $line_item = $ticket_line_item; |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | - if ( $line_item instanceof EE_Line_Item ) { |
|
156 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
155 | + if ($line_item instanceof EE_Line_Item) { |
|
156 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
157 | 157 | return $line_item; |
158 | 158 | } |
159 | 159 | return null; |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | * @param int $qty |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
170 | - if( ! $line_item->is_percent() ) { |
|
169 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
170 | + if ( ! $line_item->is_percent()) { |
|
171 | 171 | $qty += $line_item->quantity(); |
172 | - $line_item->set_quantity( $qty ); |
|
173 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
172 | + $line_item->set_quantity($qty); |
|
173 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
174 | 174 | } |
175 | - foreach( $line_item->children() as $child ) { |
|
176 | - if( $child->is_sub_line_item() ) { |
|
177 | - EEH_Line_Item::update_quantity( $child, $line_item->quantity() ); |
|
175 | + foreach ($line_item->children() as $child) { |
|
176 | + if ($child->is_sub_line_item()) { |
|
177 | + EEH_Line_Item::update_quantity($child, $line_item->quantity()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @param EE_Line_Item $line_item |
186 | 186 | * @param int $new_quantity |
187 | 187 | */ |
188 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
189 | - if( ! $line_item->is_percent() ) { |
|
190 | - $line_item->set_quantity( $new_quantity ); |
|
191 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
188 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
189 | + if ( ! $line_item->is_percent()) { |
|
190 | + $line_item->set_quantity($new_quantity); |
|
191 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
192 | 192 | } |
193 | - foreach( $line_item->children() as $child ) { |
|
194 | - if( $child->is_sub_line_item() ) { |
|
195 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
193 | + foreach ($line_item->children() as $child) { |
|
194 | + if ($child->is_sub_line_item()) { |
|
195 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -207,45 +207,45 @@ discard block |
||
207 | 207 | * @return \EE_Line_Item |
208 | 208 | * @throws \EE_Error |
209 | 209 | */ |
210 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
210 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
211 | 211 | $datetimes = $ticket->datetimes(); |
212 | - $first_datetime = reset( $datetimes ); |
|
213 | - if( $first_datetime instanceof EE_Datetime && |
|
214 | - $first_datetime->event() instanceof EE_Event ) { |
|
212 | + $first_datetime = reset($datetimes); |
|
213 | + if ($first_datetime instanceof EE_Datetime && |
|
214 | + $first_datetime->event() instanceof EE_Event) { |
|
215 | 215 | $first_datetime_name = $first_datetime->event()->name(); |
216 | 216 | } else { |
217 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
217 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
218 | 218 | } |
219 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
219 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
220 | 220 | // get event subtotal line |
221 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
222 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
223 | - throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
221 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
222 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
223 | + throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
224 | 224 | } |
225 | 225 | // add $ticket to cart |
226 | - $line_item = EE_Line_Item::new_instance( array( |
|
226 | + $line_item = EE_Line_Item::new_instance(array( |
|
227 | 227 | 'LIN_name' => $ticket->name(), |
228 | - 'LIN_desc' => $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event, |
|
228 | + 'LIN_desc' => $ticket->description() != '' ? $ticket->description().' '.$event : $event, |
|
229 | 229 | 'LIN_unit_price' => $ticket->price(), |
230 | 230 | 'LIN_quantity' => $qty, |
231 | 231 | 'LIN_is_taxable' => $ticket->taxable(), |
232 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
232 | + 'LIN_order' => count($events_sub_total->children()), |
|
233 | 233 | 'LIN_total' => $ticket->price() * $qty, |
234 | 234 | 'LIN_type' => EEM_Line_Item::type_line_item, |
235 | 235 | 'OBJ_ID' => $ticket->ID(), |
236 | 236 | 'OBJ_type' => 'Ticket' |
237 | - ) ); |
|
237 | + )); |
|
238 | 238 | $line_item = apply_filters( |
239 | 239 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
240 | 240 | $line_item |
241 | 241 | ); |
242 | - $events_sub_total->add_child_line_item( $line_item ); |
|
242 | + $events_sub_total->add_child_line_item($line_item); |
|
243 | 243 | //now add the sub-line items |
244 | 244 | $running_total_for_ticket = 0; |
245 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
245 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
246 | 246 | $sign = $price->is_discount() ? -1 : 1; |
247 | 247 | $price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty; |
248 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
248 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
249 | 249 | 'LIN_name' => $price->name(), |
250 | 250 | 'LIN_desc' => $price->desc(), |
251 | 251 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
256 | 256 | 'OBJ_ID' => $price->ID(), |
257 | 257 | 'OBJ_type' => 'Price' |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | $sub_line_item = apply_filters( |
260 | 260 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
261 | 261 | $sub_line_item |
262 | 262 | ); |
263 | - if ( $price->is_percent() ) { |
|
264 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
263 | + if ($price->is_percent()) { |
|
264 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
265 | 265 | } else { |
266 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
266 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
267 | 267 | } |
268 | 268 | $running_total_for_ticket += $price_total; |
269 | - $line_item->add_child_line_item( $sub_line_item ); |
|
269 | + $line_item->add_child_line_item($sub_line_item); |
|
270 | 270 | } |
271 | 271 | return $line_item; |
272 | 272 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param EE_Line_Item $item to be added |
285 | 285 | * @return boolean |
286 | 286 | */ |
287 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
288 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
289 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
287 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
288 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
289 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
290 | 290 | $success = $pre_tax_subtotal->add_child_line_item($item); |
291 | - }else{ |
|
291 | + } else { |
|
292 | 292 | return FALSE; |
293 | 293 | } |
294 | 294 | $total_line_item->recalculate_total_including_taxes(); |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
303 | 303 | * @return \EE_Line_Item |
304 | 304 | */ |
305 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
306 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
307 | - return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item ); |
|
305 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
306 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
307 | + return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
315 | 315 | * @return \EE_Line_Item |
316 | 316 | */ |
317 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
318 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
319 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
317 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
318 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
319 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @param EE_Transaction $transaction |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
331 | - if( $transaction ){ |
|
330 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
331 | + if ($transaction) { |
|
332 | 332 | /** @type EEM_Transaction $EEM_Transaction */ |
333 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
334 | - $transaction = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
335 | - $line_item->set_TXN_ID( $transaction ); |
|
333 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
334 | + $transaction = $EEM_Transaction->ensure_is_ID($transaction); |
|
335 | + $line_item->set_TXN_ID($transaction); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param EE_Transaction $transaction |
346 | 346 | * @return \EE_Line_Item of type total |
347 | 347 | */ |
348 | - public static function create_total_line_item( $transaction = NULL ){ |
|
349 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
348 | + public static function create_total_line_item($transaction = NULL) { |
|
349 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
350 | 350 | 'LIN_code' => 'total', |
351 | 351 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
352 | 352 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
357 | 357 | $total_line_item |
358 | 358 | ); |
359 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
360 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
361 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
359 | + self::set_TXN_ID($total_line_item, $transaction); |
|
360 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
361 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
362 | 362 | return $total_line_item; |
363 | 363 | } |
364 | 364 | |
@@ -370,19 +370,19 @@ discard block |
||
370 | 370 | * @param EE_Transaction $transaction |
371 | 371 | * @return EE_Line_Item |
372 | 372 | */ |
373 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
374 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
373 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
374 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
375 | 375 | 'LIN_code' => 'pre-tax-subtotal', |
376 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
376 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
377 | 377 | 'LIN_type' => EEM_Line_Item::type_sub_total |
378 | - ) ); |
|
378 | + )); |
|
379 | 379 | $pre_tax_line_item = apply_filters( |
380 | 380 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
381 | 381 | $pre_tax_line_item |
382 | 382 | ); |
383 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
384 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
385 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
383 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
384 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
385 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
386 | 386 | return $pre_tax_line_item; |
387 | 387 | } |
388 | 388 | |
@@ -395,21 +395,21 @@ discard block |
||
395 | 395 | * @param EE_Transaction $transaction |
396 | 396 | * @return EE_Line_Item |
397 | 397 | */ |
398 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
398 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
399 | 399 | $tax_line_item = EE_Line_Item::new_instance(array( |
400 | 400 | 'LIN_code' => 'taxes', |
401 | 401 | 'LIN_name' => __('Taxes', 'event_espresso'), |
402 | 402 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
403 | - 'LIN_order' => 1000,//this should always come last |
|
403 | + 'LIN_order' => 1000, //this should always come last |
|
404 | 404 | )); |
405 | 405 | $tax_line_item = apply_filters( |
406 | 406 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
407 | 407 | $tax_line_item |
408 | 408 | ); |
409 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
410 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
409 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
410 | + $total_line_item->add_child_line_item($tax_line_item); |
|
411 | 411 | //and lastly, add the actual taxes |
412 | - self::apply_taxes( $total_line_item ); |
|
412 | + self::apply_taxes($total_line_item); |
|
413 | 413 | return $tax_line_item; |
414 | 414 | } |
415 | 415 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @param EE_Event $event |
423 | 423 | * @return EE_Line_Item |
424 | 424 | */ |
425 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
425 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
426 | 426 | $event_line_item = EE_Line_Item::new_instance(array( |
427 | - 'LIN_code' => self::get_event_code( $event ), |
|
428 | - 'LIN_name' => self::get_event_name( $event ), |
|
429 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
427 | + 'LIN_code' => self::get_event_code($event), |
|
428 | + 'LIN_name' => self::get_event_name($event), |
|
429 | + 'LIN_desc' => self::get_event_desc($event), |
|
430 | 430 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
431 | 431 | 'OBJ_type' => 'Event', |
432 | 432 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
436 | 436 | $event_line_item |
437 | 437 | ); |
438 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
439 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
438 | + self::set_TXN_ID($event_line_item, $transaction); |
|
439 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
440 | 440 | return $event_line_item; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @param EE_Event $event |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public static function get_event_code( $event ) { |
|
449 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
448 | + public static function get_event_code($event) { |
|
449 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param EE_Event $event |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public static function get_event_name( $event ) { |
|
458 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
457 | + public static function get_event_name($event) { |
|
458 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param EE_Event $event |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public static function get_event_desc( $event ) { |
|
466 | + public static function get_event_desc($event) { |
|
467 | 467 | return $event instanceof EE_Event ? $event->short_description() : ''; |
468 | 468 | } |
469 | 469 | |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @throws \EE_Error |
478 | 478 | * @return EE_Line_Item |
479 | 479 | */ |
480 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
480 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | - if( ! $first_datetime instanceof EE_Datetime ){ |
|
483 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) ); |
|
482 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
483 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())); |
|
484 | 484 | } |
485 | 485 | $event = $first_datetime->event(); |
486 | - if ( ! $event instanceof EE_Event ) { |
|
487 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) ); |
|
486 | + if ( ! $event instanceof EE_Event) { |
|
487 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID())); |
|
488 | 488 | } |
489 | - return EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
489 | + return EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -495,31 +495,31 @@ discard block |
||
495 | 495 | * @param EE_Event $event |
496 | 496 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
497 | 497 | */ |
498 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
498 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
499 | 499 | /** @type EE_Event $event */ |
500 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
500 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
501 | 501 | $event_line_item = NULL; |
502 | 502 | $found = false; |
503 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
503 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
504 | 504 | // default event subtotal, we should only ever find this the first time this method is called |
505 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
505 | + if ( ! $event_line_item->OBJ_ID()) { |
|
506 | 506 | // let's use this! but first... set the event details |
507 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
507 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
508 | 508 | $found = true; |
509 | 509 | break; |
510 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
510 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
511 | 511 | // found existing line item for this event in the cart, so break out of loop and use this one |
512 | 512 | $found = true; |
513 | 513 | break; |
514 | 514 | } |
515 | 515 | } |
516 | - if ( ! $found ) { |
|
516 | + if ( ! $found) { |
|
517 | 517 | //there is no event sub-total yet, so add it |
518 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
518 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
519 | 519 | // create a new "event" subtotal below that |
520 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
520 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
521 | 521 | // and set the event details |
522 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
522 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
523 | 523 | } |
524 | 524 | return $event_line_item; |
525 | 525 | } |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | * @param EE_Transaction $transaction |
534 | 534 | * @return EE_Line_Item |
535 | 535 | */ |
536 | - public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){ |
|
537 | - if ( $event instanceof EE_Event ) { |
|
538 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
539 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
540 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
541 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
536 | + public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) { |
|
537 | + if ($event instanceof EE_Event) { |
|
538 | + $event_line_item->set_code(self::get_event_code($event)); |
|
539 | + $event_line_item->set_name(self::get_event_name($event)); |
|
540 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
541 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
542 | 542 | } |
543 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
543 | + self::set_TXN_ID($event_line_item, $transaction); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
@@ -551,19 +551,19 @@ discard block |
||
551 | 551 | * any old taxes are removed |
552 | 552 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
553 | 553 | */ |
554 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
554 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
555 | 555 | /** @type EEM_Price $EEM_Price */ |
556 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
556 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
557 | 557 | // get array of taxes via Price Model |
558 | 558 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
559 | - ksort( $ordered_taxes ); |
|
560 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
559 | + ksort($ordered_taxes); |
|
560 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
561 | 561 | //just to be safe, remove its old tax line items |
562 | 562 | $taxes_line_item->delete_children_line_items(); |
563 | 563 | //loop thru taxes |
564 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
565 | - foreach ( $taxes as $tax ) { |
|
566 | - if ( $tax instanceof EE_Price ) { |
|
564 | + foreach ($ordered_taxes as $order => $taxes) { |
|
565 | + foreach ($taxes as $tax) { |
|
566 | + if ($tax instanceof EE_Price) { |
|
567 | 567 | $tax_line_item = EE_Line_Item::new_instance( |
568 | 568 | array( |
569 | 569 | 'LIN_name' => $tax->name(), |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
582 | 582 | $tax_line_item |
583 | 583 | ); |
584 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
584 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | } |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
597 | 597 | * @return float |
598 | 598 | */ |
599 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
600 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
601 | - if( ! $taxes_subtotal->children()){ |
|
602 | - self::apply_taxes( $total_line_item ); |
|
599 | + public static function ensure_taxes_applied($total_line_item) { |
|
600 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
601 | + if ( ! $taxes_subtotal->children()) { |
|
602 | + self::apply_taxes($total_line_item); |
|
603 | 603 | } |
604 | 604 | return $taxes_subtotal->total(); |
605 | 605 | } |
@@ -612,16 +612,16 @@ discard block |
||
612 | 612 | * @param EE_Line_Item $parent_line_item |
613 | 613 | * @return bool |
614 | 614 | */ |
615 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
615 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
616 | 616 | $deleted = 0; |
617 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
618 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
619 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
620 | - if ( $child_line_item->ID() ) { |
|
617 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
618 | + if ($child_line_item instanceof EE_Line_Item) { |
|
619 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
620 | + if ($child_line_item->ID()) { |
|
621 | 621 | $child_line_item->delete(); |
622 | - unset( $child_line_item ); |
|
622 | + unset($child_line_item); |
|
623 | 623 | } else { |
624 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
624 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
625 | 625 | } |
626 | 626 | $deleted++; |
627 | 627 | } |
@@ -643,25 +643,25 @@ discard block |
||
643 | 643 | * @param array|bool|string $line_item_codes |
644 | 644 | * @return int number of items successfully removed |
645 | 645 | */ |
646 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
646 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
647 | 647 | |
648 | - if( $total_line_item->type() != EEM_Line_Item::type_total ){ |
|
649 | - EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' ); |
|
648 | + if ($total_line_item->type() != EEM_Line_Item::type_total) { |
|
649 | + EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18'); |
|
650 | 650 | } |
651 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
651 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
652 | 652 | |
653 | 653 | // check if only a single line_item_id was passed |
654 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
654 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
655 | 655 | // place single line_item_id in an array to appear as multiple line_item_ids |
656 | - $line_item_codes = array ( $line_item_codes ); |
|
656 | + $line_item_codes = array($line_item_codes); |
|
657 | 657 | } |
658 | 658 | $removals = 0; |
659 | 659 | // cycle thru line_item_ids |
660 | - foreach ( $line_item_codes as $line_item_id ) { |
|
660 | + foreach ($line_item_codes as $line_item_id) { |
|
661 | 661 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
662 | 662 | } |
663 | 663 | |
664 | - if ( $removals > 0 ) { |
|
664 | + if ($removals > 0) { |
|
665 | 665 | $total_line_item->recalculate_taxes_and_tax_total(); |
666 | 666 | return $removals; |
667 | 667 | } else { |
@@ -684,32 +684,32 @@ discard block |
||
684 | 684 | * $amount will be added onto it; otherwise will simply set the taxes to match $amount |
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | - public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
|
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
687 | + public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false) { |
|
688 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
689 | 689 | $taxable_total = $total_line_item->taxable_total(); |
690 | 690 | |
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
691 | + if ($add_to_existing_line_item) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
693 | + EEM_Line_Item::instance()->delete(array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID()))); |
|
694 | 694 | } else { |
695 | 695 | $new_tax = null; |
696 | 696 | $tax_subtotal->delete_children_line_items(); |
697 | 697 | } |
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
698 | + if ($new_tax) { |
|
699 | + $new_tax->set_total($new_tax->total() + $amount); |
|
700 | + $new_tax->set_percent($taxable_total ? ($new_tax->total()) / $taxable_total * 100 : 0); |
|
701 | 701 | } else { |
702 | 702 | //no existing tax item. Create it |
703 | - $new_tax = EE_Line_Item::new_instance( array( |
|
703 | + $new_tax = EE_Line_Item::new_instance(array( |
|
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
705 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
706 | 706 | 'LIN_desc' => $description ? $description : '', |
707 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
707 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
708 | 708 | 'LIN_total' => $amount, |
709 | 709 | 'LIN_parent' => $tax_subtotal->ID(), |
710 | 710 | 'LIN_type' => EEM_Line_Item::type_tax, |
711 | 711 | 'LIN_code' => $code |
712 | - ) ); |
|
712 | + )); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | $new_tax = apply_filters( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $total_line_item |
719 | 719 | ); |
720 | 720 | $new_tax->save(); |
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
721 | + $tax_subtotal->set_total($new_tax->total()); |
|
722 | 722 | $tax_subtotal->save(); |
723 | 723 | $total_line_item->recalculate_total_including_taxes(); |
724 | 724 | return $new_tax; |
@@ -734,17 +734,17 @@ discard block |
||
734 | 734 | * it will be whitelisted (ie, except from becoming taxable) |
735 | 735 | * @param boolean $taxable |
736 | 736 | */ |
737 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ) { |
|
738 | - if( $code_substring_for_whitelist !== null ) { |
|
739 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
737 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null) { |
|
738 | + if ($code_substring_for_whitelist !== null) { |
|
739 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
740 | 740 | } else { |
741 | 741 | $whitelisted = false; |
742 | 742 | } |
743 | - if( $line_item->is_line_item() && ! $whitelisted ) { |
|
744 | - $line_item->set_is_taxable( $taxable ); |
|
743 | + if ($line_item->is_line_item() && ! $whitelisted) { |
|
744 | + $line_item->set_is_taxable($taxable); |
|
745 | 745 | } |
746 | - foreach( $line_item->children() as $child_line_item ) { |
|
747 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
746 | + foreach ($line_item->children() as $child_line_item) { |
|
747 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
758 | 758 | * @return EE_Line_Item[] |
759 | 759 | */ |
760 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
761 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
760 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
761 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * @param string $obj_type |
772 | 772 | * @return EE_Line_Item[] |
773 | 773 | */ |
774 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
775 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type ); |
|
774 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
775 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
785 | 785 | * @return EE_Line_Item[] |
786 | 786 | */ |
787 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
788 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
787 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
788 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | * @param string $obj_type |
799 | 799 | * @return EE_Line_Item[] |
800 | 800 | */ |
801 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
802 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
801 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
802 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
811 | 811 | * @return EE_Line_Item[] |
812 | 812 | */ |
813 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
814 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
813 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
814 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
823 | 823 | * @return EE_Line_Item[] |
824 | 824 | */ |
825 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
826 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
825 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
826 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | * @param string $line_item_type one of the EEM_Line_Item constants |
837 | 837 | * @return EE_Line_Item[] |
838 | 838 | */ |
839 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
840 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
839 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
840 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | |
@@ -850,15 +850,15 @@ discard block |
||
850 | 850 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
851 | 851 | * @return EE_Line_Item[] |
852 | 852 | */ |
853 | - protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
|
853 | + protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) { |
|
854 | 854 | $objects = array(); |
855 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
856 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
857 | - if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) { |
|
855 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
856 | + if ($child_line_item instanceof EE_Line_Item) { |
|
857 | + if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) { |
|
858 | 858 | $objects[] = $child_line_item; |
859 | 859 | } else { |
860 | 860 | //go-through-all-its children looking for more matches |
861 | - $objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type )); |
|
861 | + $objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type)); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param array $OBJ_IDs array of OBJ_IDs |
877 | 877 | * @return EE_Line_Item[] |
878 | 878 | */ |
879 | - public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
|
880 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
879 | + public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) { |
|
880 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | * @param array $OBJ_IDs array of OBJ_IDs |
891 | 891 | * @return EE_Line_Item[] |
892 | 892 | */ |
893 | - protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) { |
|
893 | + protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) { |
|
894 | 894 | $objects = array(); |
895 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
896 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
897 | - if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) { |
|
895 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
896 | + if ($child_line_item instanceof EE_Line_Item) { |
|
897 | + if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) { |
|
898 | 898 | $objects[] = $child_line_item; |
899 | 899 | } else { |
900 | 900 | //go-through-all-its children looking for more matches |
901 | - $objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs )); |
|
901 | + $objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs)); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | } |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $type like one of the EEM_Line_Item::type_* |
917 | 917 | * @return EE_Line_Item |
918 | 918 | */ |
919 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
920 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
919 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
920 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * @param string $code any value used for LIN_code |
931 | 931 | * @return EE_Line_Item |
932 | 932 | */ |
933 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
934 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
933 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
934 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | * @param string $value any value stored in $search_field |
945 | 945 | * @return EE_Line_Item |
946 | 946 | */ |
947 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
948 | - foreach( $parent_line_item->children() as $child ){ |
|
949 | - if ( $child->get( $search_field ) == $value ){ |
|
947 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
948 | + foreach ($parent_line_item->children() as $child) { |
|
949 | + if ($child->get($search_field) == $value) { |
|
950 | 950 | return $child; |
951 | 951 | } |
952 | 952 | } |
953 | - foreach( $parent_line_item->children() as $child ){ |
|
954 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
955 | - if ( $descendant_found ){ |
|
953 | + foreach ($parent_line_item->children() as $child) { |
|
954 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
955 | + if ($descendant_found) { |
|
956 | 956 | return $descendant_found; |
957 | 957 | } |
958 | 958 | } |
@@ -968,22 +968,22 @@ discard block |
||
968 | 968 | * @param int $indentation |
969 | 969 | * @return void |
970 | 970 | */ |
971 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
971 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
972 | 972 | echo "\n<br />"; |
973 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
973 | + for ($i = 0; $i < $indentation; $i++) { |
|
974 | 974 | echo " - "; |
975 | 975 | } |
976 | - if( $line_item->is_percent() ) { |
|
977 | - $breakdown = $line_item->percent() . '%'; |
|
976 | + if ($line_item->is_percent()) { |
|
977 | + $breakdown = $line_item->percent().'%'; |
|
978 | 978 | } else { |
979 | - $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity(); |
|
979 | + $breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity(); |
|
980 | 980 | } |
981 | - echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")"; |
|
982 | - if( $line_item->is_taxable() ){ |
|
981 | + echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")"; |
|
982 | + if ($line_item->is_taxable()) { |
|
983 | 983 | echo " * taxable"; |
984 | 984 | } |
985 | - if( $line_item->children() ){ |
|
986 | - foreach($line_item->children() as $child){ |
|
985 | + if ($line_item->children()) { |
|
986 | + foreach ($line_item->children() as $child) { |
|
987 | 987 | self::visualize($child, $indentation + 1); |
988 | 988 | } |
989 | 989 | } |
@@ -1024,88 +1024,88 @@ discard block |
||
1024 | 1024 | * is theirs, which can be done with |
1025 | 1025 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1026 | 1026 | */ |
1027 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1027 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1028 | 1028 | //init running grand total if not already |
1029 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1030 | - $running_totals[ 'total' ] = 0; |
|
1029 | + if ( ! isset($running_totals['total'])) { |
|
1030 | + $running_totals['total'] = 0; |
|
1031 | 1031 | } |
1032 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1033 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1032 | + if ( ! isset($running_totals['taxable'])) { |
|
1033 | + $running_totals['taxable'] = array('total' => 0); |
|
1034 | 1034 | } |
1035 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1036 | - switch ( $child_line_item->type() ) { |
|
1035 | + foreach ($line_item->children() as $child_line_item) { |
|
1036 | + switch ($child_line_item->type()) { |
|
1037 | 1037 | |
1038 | 1038 | case EEM_Line_Item::type_sub_total : |
1039 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1039 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1040 | 1040 | //combine arrays but preserve numeric keys |
1041 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1042 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1043 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1041 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1042 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1043 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1044 | 1044 | break; |
1045 | 1045 | |
1046 | 1046 | case EEM_Line_Item::type_tax_sub_total : |
1047 | 1047 | |
1048 | 1048 | //find how much the taxes percentage is |
1049 | - if ( $child_line_item->percent() != 0 ) { |
|
1049 | + if ($child_line_item->percent() != 0) { |
|
1050 | 1050 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1051 | 1051 | } else { |
1052 | 1052 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1053 | 1053 | } |
1054 | 1054 | //and apply to all the taxable totals, and add to the pretax totals |
1055 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1055 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1056 | 1056 | //"total" and "taxable" array key is an exception |
1057 | - if ( $line_item_id === 'taxable' ) { |
|
1057 | + if ($line_item_id === 'taxable') { |
|
1058 | 1058 | continue; |
1059 | 1059 | } |
1060 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1061 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1060 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1061 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1062 | 1062 | } |
1063 | 1063 | break; |
1064 | 1064 | |
1065 | 1065 | case EEM_Line_Item::type_line_item : |
1066 | 1066 | |
1067 | 1067 | // ticket line items or ???? |
1068 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1068 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1069 | 1069 | // kk it's a ticket |
1070 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1070 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1071 | 1071 | //huh? that shouldn't happen. |
1072 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1072 | + $running_totals['total'] += $child_line_item->total(); |
|
1073 | 1073 | } else { |
1074 | 1074 | //its not in our running totals yet. great. |
1075 | - if ( $child_line_item->is_taxable() ) { |
|
1075 | + if ($child_line_item->is_taxable()) { |
|
1076 | 1076 | $taxable_amount = $child_line_item->unit_price(); |
1077 | 1077 | } else { |
1078 | 1078 | $taxable_amount = 0; |
1079 | 1079 | } |
1080 | 1080 | // are we only calculating totals for some tickets? |
1081 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1082 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1083 | - $running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0; |
|
1081 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1082 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1083 | + $running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0; |
|
1085 | 1085 | } else { |
1086 | 1086 | $quantity = $child_line_item->quantity(); |
1087 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1088 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1087 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1088 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1089 | 1089 | } |
1090 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1091 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1090 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1091 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1092 | 1092 | } |
1093 | 1093 | } else { |
1094 | 1094 | // it's some other type of item added to the cart |
1095 | 1095 | // it should affect the running totals |
1096 | 1096 | // basically we want to convert it into a PERCENT modifier. Because |
1097 | 1097 | // more clearly affect all registration's final price equally |
1098 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1; |
|
1099 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1098 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1; |
|
1099 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1100 | 1100 | //the "taxable" array key is an exception |
1101 | - if ( $line_item_id === 'taxable' ) { |
|
1101 | + if ($line_item_id === 'taxable') { |
|
1102 | 1102 | continue; |
1103 | 1103 | } |
1104 | 1104 | // update the running totals |
1105 | 1105 | // yes this actually even works for the running grand total! |
1106 | - $running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | - if ( $child_line_item->is_taxable() ) { |
|
1108 | - $running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1106 | + $running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | + if ($child_line_item->is_taxable()) { |
|
1108 | + $running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | } |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | * @param EE_Registration[] $registrations |
1125 | 1125 | * @return \EE_Line_Item |
1126 | 1126 | */ |
1127 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1128 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1129 | - foreach ( $line_item->children() as $child_li ) { |
|
1130 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1127 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1128 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1129 | + foreach ($line_item->children() as $child_li) { |
|
1130 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1131 | 1131 | } |
1132 | 1132 | //if this is the grand total line item, make sure the totals all add up |
1133 | 1133 | //(we could have duplicated this logic AS we copied the line items, but |
1134 | 1134 | //it seems DRYer this way) |
1135 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1135 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1136 | 1136 | $copy_li->recalculate_total_including_taxes(); |
1137 | 1137 | } |
1138 | 1138 | return $copy_li; |
@@ -1147,26 +1147,26 @@ discard block |
||
1147 | 1147 | * @return EE_Line_Item |
1148 | 1148 | * @param EE_Registration[] $registrations |
1149 | 1149 | */ |
1150 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1150 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1151 | 1151 | $new_li_fields = $line_item->model_field_array(); |
1152 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1152 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1153 | 1153 | $line_item->OBJ_type() === 'Ticket' |
1154 | 1154 | ) { |
1155 | 1155 | $count = 0; |
1156 | - foreach ( $registrations as $registration ) { |
|
1157 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1156 | + foreach ($registrations as $registration) { |
|
1157 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1159 | 1159 | ) { |
1160 | 1160 | $count++; |
1161 | 1161 | } |
1162 | 1162 | } |
1163 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1163 | + $new_li_fields['LIN_quantity'] = $count; |
|
1164 | 1164 | } |
1165 | 1165 | //don't set the total. We'll leave that up to the code that calculates it |
1166 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1167 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1168 | - unset( $new_li_fields[ 'LIN_total' ] ); |
|
1169 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1166 | + unset($new_li_fields['LIN_ID']); |
|
1167 | + unset($new_li_fields['LIN_parent']); |
|
1168 | + unset($new_li_fields['LIN_total']); |
|
1169 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | |
@@ -1178,19 +1178,19 @@ discard block |
||
1178 | 1178 | * @param EE_Line_Item $line_item |null |
1179 | 1179 | * @return \EE_Line_Item|null |
1180 | 1180 | */ |
1181 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1182 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1183 | - if ( $copied_li === null ) { |
|
1181 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1182 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1183 | + if ($copied_li === null) { |
|
1184 | 1184 | return null; |
1185 | 1185 | } |
1186 | 1186 | //if this is an event subtotal, we want to only include it if it |
1187 | 1187 | //has a non-zero total and at least one ticket line item child |
1188 | 1188 | $ticket_children = 0; |
1189 | - foreach ( $line_item->children() as $child_li ) { |
|
1190 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1191 | - if ( $child_li_copy !== null ) { |
|
1192 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1193 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1189 | + foreach ($line_item->children() as $child_li) { |
|
1190 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1191 | + if ($child_li_copy !== null) { |
|
1192 | + $copied_li->add_child_line_item($child_li_copy); |
|
1193 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1194 | 1194 | $child_li_copy->OBJ_type() === 'Ticket' |
1195 | 1195 | ) { |
1196 | 1196 | $ticket_children++; |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | } |
1200 | 1200 | //if this is an event subtotal with NO ticket children |
1201 | 1201 | //we basically want to ignore it |
1202 | - if ( $line_item->type() === EEM_Line_Item::type_sub_total && |
|
1202 | + if ($line_item->type() === EEM_Line_Item::type_sub_total && |
|
1203 | 1203 | $line_item->OBJ_type() === 'Event' && |
1204 | 1204 | $ticket_children === 0 && |
1205 | 1205 | $line_item->total() === 0 |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | * @param EE_Line_Item $line_item |
1218 | 1218 | * @return EE_Line_Item |
1219 | 1219 | */ |
1220 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1221 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1220 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1221 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1222 | 1222 | $line_item->OBJ_type() === 'Ticket' && |
1223 | 1223 | $line_item->quantity() == 0 |
1224 | 1224 | ) { |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | } |
1227 | 1227 | $new_li_fields = $line_item->model_field_array(); |
1228 | 1228 | //don't set the total. We'll leave that up to the code that calculates it |
1229 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1230 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1231 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1229 | + unset($new_li_fields['LIN_ID']); |
|
1230 | + unset($new_li_fields['LIN_parent']); |
|
1231 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1242,9 +1242,9 @@ discard block |
||
1242 | 1242 | * @param EE_Line_Item $total_line_item |
1243 | 1243 | * @return \EE_Line_Item |
1244 | 1244 | */ |
1245 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1246 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1247 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1245 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1246 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1247 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
@@ -1254,9 +1254,9 @@ discard block |
||
1254 | 1254 | * @param EE_Transaction $transaction |
1255 | 1255 | * @return \EE_Line_Item |
1256 | 1256 | */ |
1257 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1258 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1259 | - return self::create_total_line_item( $transaction ); |
|
1257 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1258 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1259 | + return self::create_total_line_item($transaction); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
@@ -1267,9 +1267,9 @@ discard block |
||
1267 | 1267 | * @param EE_Transaction $transaction |
1268 | 1268 | * @return \EE_Line_Item |
1269 | 1269 | */ |
1270 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1272 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1270 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1272 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | * @param EE_Transaction $transaction |
1281 | 1281 | * @return \EE_Line_Item |
1282 | 1282 | */ |
1283 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1285 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1283 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1285 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | * @param EE_Transaction $transaction |
1294 | 1294 | * @return \EE_Line_Item |
1295 | 1295 | */ |
1296 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1298 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1296 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1298 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * EEH_Line_Item |
|
5 | - * |
|
6 | - * This should be the main class which is aware of the line item tree structure, and |
|
7 | - * should take care of common operations like inserting items into it, updating |
|
8 | - * items in it based on what the line items are for, and removed line items. |
|
9 | - * All this logic was originally contained in EE_Cart, but because there are |
|
10 | - * actually other places that need to modify the record of what was purchased |
|
11 | - * (eg when a PayPal IPN is received, if PayPal changes the taxes, we need to update the line items; |
|
12 | - * or admin-side cancellations etc). |
|
13 | - * Generally all these functions will first take the total line item and figure things out from there |
|
14 | - * |
|
15 | - * @package Event Espresso |
|
16 | - * @subpackage |
|
17 | - * @author Mike Nelson |
|
18 | - * |
|
19 | - */ |
|
3 | + * |
|
4 | + * EEH_Line_Item |
|
5 | + * |
|
6 | + * This should be the main class which is aware of the line item tree structure, and |
|
7 | + * should take care of common operations like inserting items into it, updating |
|
8 | + * items in it based on what the line items are for, and removed line items. |
|
9 | + * All this logic was originally contained in EE_Cart, but because there are |
|
10 | + * actually other places that need to modify the record of what was purchased |
|
11 | + * (eg when a PayPal IPN is received, if PayPal changes the taxes, we need to update the line items; |
|
12 | + * or admin-side cancellations etc). |
|
13 | + * Generally all these functions will first take the total line item and figure things out from there |
|
14 | + * |
|
15 | + * @package Event Espresso |
|
16 | + * @subpackage |
|
17 | + * @author Mike Nelson |
|
18 | + * |
|
19 | + */ |
|
20 | 20 | class EEH_Line_Item { |
21 | 21 | |
22 | 22 | //other functions: cancel ticket purchase |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | - * line item the ticket's purchase should be added onto |
|
473 | - * |
|
474 | - * @access public |
|
475 | - * @param EE_Line_Item $grand_total the grand total line item |
|
476 | - * @param EE_Ticket $ticket |
|
477 | - * @throws \EE_Error |
|
478 | - * @return EE_Line_Item |
|
479 | - */ |
|
471 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | + * line item the ticket's purchase should be added onto |
|
473 | + * |
|
474 | + * @access public |
|
475 | + * @param EE_Line_Item $grand_total the grand total line item |
|
476 | + * @param EE_Ticket $ticket |
|
477 | + * @throws \EE_Error |
|
478 | + * @return EE_Line_Item |
|
479 | + */ |
|
480 | 480 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | 482 | if( ! $first_datetime instanceof EE_Datetime ){ |
@@ -685,21 +685,21 @@ discard block |
||
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | 687 | public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | - $taxable_total = $total_line_item->taxable_total(); |
|
690 | - |
|
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | - } else { |
|
695 | - $new_tax = null; |
|
696 | - $tax_subtotal->delete_children_line_items(); |
|
697 | - } |
|
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | - } else { |
|
702 | - //no existing tax item. Create it |
|
688 | + $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | + $taxable_total = $total_line_item->taxable_total(); |
|
690 | + |
|
691 | + if( $add_to_existing_line_item ) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | + EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | + } else { |
|
695 | + $new_tax = null; |
|
696 | + $tax_subtotal->delete_children_line_items(); |
|
697 | + } |
|
698 | + if( $new_tax ) { |
|
699 | + $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | + $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | + } else { |
|
702 | + //no existing tax item. Create it |
|
703 | 703 | $new_tax = EE_Line_Item::new_instance( array( |
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | 705 | 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
@@ -712,16 +712,16 @@ discard block |
||
712 | 712 | ) ); |
713 | 713 | } |
714 | 714 | |
715 | - $new_tax = apply_filters( |
|
715 | + $new_tax = apply_filters( |
|
716 | 716 | 'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal', |
717 | 717 | $new_tax, |
718 | 718 | $total_line_item |
719 | - ); |
|
720 | - $new_tax->save(); |
|
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | - $tax_subtotal->save(); |
|
723 | - $total_line_item->recalculate_total_including_taxes(); |
|
724 | - return $new_tax; |
|
719 | + ); |
|
720 | + $new_tax->save(); |
|
721 | + $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | + $tax_subtotal->save(); |
|
723 | + $total_line_item->recalculate_total_including_taxes(); |
|
724 | + return $new_tax; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 |
@@ -31,7 +31,6 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * google_map - creates a Google Map Link |
34 | - * @param array $atts aray of attributes required for the map link generation |
|
35 | 34 | * @return string (link to map!) |
36 | 35 | */ |
37 | 36 | public static function google_map( $ee_gmaps_opts ){ |
@@ -116,7 +115,6 @@ discard block |
||
116 | 115 | |
117 | 116 | /** |
118 | 117 | * creates a Google Map Link |
119 | - * @param array $atts aray of attributes required for the map link generation |
|
120 | 118 | * @return string (link to map!) |
121 | 119 | */ |
122 | 120 | public static function espresso_google_map_js() { |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @param array $atts aray of attributes required for the map link generation |
35 | 35 | * @return string (link to map!) |
36 | 36 | */ |
37 | - public static function google_map( $ee_gmaps_opts ){ |
|
37 | + public static function google_map($ee_gmaps_opts) { |
|
38 | 38 | |
39 | 39 | //d( $ee_gmaps_opts ); |
40 | 40 | |
41 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
45 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
41 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
45 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
48 | 48 | |
49 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
50 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
49 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
50 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
51 | 51 | case "left": |
52 | 52 | $map_align = 'ee-gmap-align-left left'; |
53 | 53 | break; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | // Determine whether user has set a hardoded url to use and |
70 | 70 | // if so display a Google static iframe map else run V3 api |
71 | - if( $static_url ) { |
|
71 | + if ($static_url) { |
|
72 | 72 | |
73 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
74 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
73 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
74 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
75 | 75 | $html .= '</iframe>'; |
76 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
76 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
77 | 77 | $html .= '</div>'; |
78 | 78 | return $html; |
79 | 79 | |
80 | 80 | } else { |
81 | 81 | |
82 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
82 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
83 | 83 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
84 | 84 | 'ee_map_zoom' => $ee_map_zoom, |
85 | 85 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
92 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
92 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
93 | 93 | $html .= '</div>'; |
94 | 94 | |
95 | - wp_enqueue_script( 'gmap_api' ); |
|
96 | - wp_enqueue_script( 'ee_gmap' ); |
|
97 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
95 | + wp_enqueue_script('gmap_api'); |
|
96 | + wp_enqueue_script('ee_gmap'); |
|
97 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
98 | 98 | |
99 | 99 | return $html; |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return void |
110 | 110 | */ |
111 | 111 | public static function footer_enqueue_script() { |
112 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
112 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function espresso_google_map_js() { |
123 | 123 | $scheme = is_ssl() ? 'https://' : 'http://'; |
124 | - wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE ); |
|
125 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
124 | + wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE); |
|
125 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string (link to map!) |
132 | 132 | */ |
133 | 133 | public static function google_map_link($atts) { |
134 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | 135 | extract($atts); |
136 | 136 | |
137 | 137 | $address = "{$address}"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | $id = isset($id) ? $id : 'not_set'; |
147 | 147 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
148 | 148 | |
149 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
149 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
150 | 150 | |
151 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
151 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
152 | 152 | |
153 | 153 | switch ($type) { |
154 | 154 | case 'text': |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | case 'map': |
164 | 164 | $scheme = is_ssl() ? 'https://' : 'http://'; |
165 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false' ) . '" /></a>'; |
|
165 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false').'" /></a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
168 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 |
@@ -109,7 +109,7 @@ |
||
109 | 109 | * - registers and enqueues the qtip scripts and styles. |
110 | 110 | * |
111 | 111 | * @access public |
112 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
112 | + * @param string[] $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function instance() { |
34 | 34 | // check if class object is instantiated |
35 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
35 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
36 | 36 | self::$_instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$_instance; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function __construct() { |
50 | 50 | //let's just make sure this is instantiated in the right place. |
51 | - if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) { |
|
52 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' ); |
|
51 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
52 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,27 +61,27 @@ discard block |
||
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function register_and_enqueue() { |
64 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
65 | - $qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js'; |
|
66 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
67 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
64 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
65 | + $qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js'; |
|
66 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
67 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
68 | 68 | |
69 | - wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE ); |
|
70 | - wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE ); |
|
71 | - wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE ); |
|
72 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
69 | + wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE); |
|
70 | + wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE); |
|
71 | + wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE); |
|
72 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE); |
|
73 | 73 | |
74 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2' ); |
|
74 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
75 | 75 | |
76 | 76 | //k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
77 | - if ( !empty( $this->_qtips ) ) { |
|
77 | + if ( ! empty($this->_qtips)) { |
|
78 | 78 | wp_enqueue_script('ee-qtip-helper'); |
79 | 79 | wp_enqueue_style('qtip-css'); |
80 | 80 | $qtips = array(); |
81 | - foreach ( $this->_qtips as $qtip ) { |
|
81 | + foreach ($this->_qtips as $qtip) { |
|
82 | 82 | $qts = $qtip->get_tips(); |
83 | - foreach ( $qts as $qt ) { |
|
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
83 | + foreach ($qts as $qt) { |
|
84 | + if ( ! $qt instanceof EE_Qtip) |
|
85 | 85 | continue; |
86 | 86 | $qtips[] = array( |
87 | 87 | 'content_id' => $qt->content_id, |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
93 | + if ( ! empty($qtips)) |
|
94 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
95 | 95 | |
96 | 96 | } else { |
97 | 97 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function register( $configname, $paths = array() ) { |
|
116 | + public function register($configname, $paths = array()) { |
|
117 | 117 | |
118 | 118 | //let's just make sure this is instantiated in the right place. |
119 | - if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) { |
|
120 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' ); |
|
119 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
120 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $configname = (array) $configname; //typecast to array |
124 | - foreach ( $configname as $config ) { |
|
125 | - $this->_register( $config, $paths ); |
|
124 | + foreach ($configname as $config) { |
|
125 | + $this->_register($config, $paths); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | //hook into appropriate footer |
129 | 129 | $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
130 | - add_action($footer_action, array($this, 'setup_qtip'), 10 ); |
|
130 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
131 | 131 | |
132 | 132 | //make sure we "turn on" qtip js. |
133 | - add_filter('FHEE_load_qtip', '__return_true' ); |
|
133 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | * @throws EE_Error |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - private function _register( $config, $paths ) { |
|
147 | + private function _register($config, $paths) { |
|
148 | 148 | //before doing anything we have to make sure that EE_Qtip_Config parent is required. |
149 | - EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE ); |
|
149 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE); |
|
150 | 150 | |
151 | - if ( !empty( $paths ) ) { |
|
151 | + if ( ! empty($paths)) { |
|
152 | 152 | $paths = (array) $paths; |
153 | - foreach ( $paths as $path ) { |
|
154 | - $path = $path . $config . '.lib.php'; |
|
155 | - if ( !is_readable($path ) ) { |
|
153 | + foreach ($paths as $path) { |
|
154 | + $path = $path.$config.'.lib.php'; |
|
155 | + if ( ! is_readable($path)) { |
|
156 | 156 | continue; |
157 | 157 | } else { |
158 | 158 | require_once $path; |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | //does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
164 | - if ( !class_exists($config) ) { |
|
165 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
166 | - if ( !is_readable($path ) ) { |
|
167 | - throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) ); |
|
164 | + if ( ! class_exists($config)) { |
|
165 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
166 | + if ( ! is_readable($path)) { |
|
167 | + throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
168 | 168 | } else { |
169 | 169 | require_once $path; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
174 | + if ( ! class_exists($config)) |
|
175 | + throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
176 | 176 | |
177 | 177 | //made it HERE? FINALLY, let's get things setup. |
178 | 178 | $a = new ReflectionClass($config); |
179 | 179 | $qtip = $a->newInstance(); |
180 | 180 | |
181 | 181 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
182 | + if ( ! $qtip instanceof EE_Qtip_Config) |
|
183 | + throw new EE_Error(sprintf(__('The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config)); |
|
184 | 184 | |
185 | 185 | $this->_qtips[] = $a->newInstance(); |
186 | 186 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @return void |
197 | 197 | */ |
198 | 198 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
199 | + if (empty($this->_qtips)) |
|
200 | 200 | return; //no qtips! |
201 | 201 | |
202 | 202 | $content = array(); |
203 | 203 | |
204 | - foreach ( $this->_qtips as $qtip ) { |
|
204 | + foreach ($this->_qtips as $qtip) { |
|
205 | 205 | $content[] = $this->_generate_content_container($qtip); |
206 | 206 | } |
207 | 207 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | private function _generate_content_container($qtip) { |
219 | 219 | $qts = $qtip->get_tips(); |
220 | 220 | $content = array(); |
221 | - foreach ( $qts as $qt ) { |
|
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
221 | + foreach ($qts as $qt) { |
|
222 | + if ( ! $qt instanceof EE_Qtip) |
|
223 | 223 | continue; |
224 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
|
224 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return implode('<br />', $content); |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | foreach ( $this->_qtips as $qtip ) { |
82 | 82 | $qts = $qtip->get_tips(); |
83 | 83 | foreach ( $qts as $qt ) { |
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
85 | - continue; |
|
84 | + if ( ! $qt instanceof EE_Qtip ) { |
|
85 | + continue; |
|
86 | + } |
|
86 | 87 | $qtips[] = array( |
87 | 88 | 'content_id' => $qt->content_id, |
88 | 89 | 'options' => $qt->options, |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | ); |
91 | 92 | } |
92 | 93 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
94 | + if ( !empty($qtips) ) { |
|
95 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | } else { |
97 | 99 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -171,16 +173,18 @@ discard block |
||
171 | 173 | } |
172 | 174 | |
173 | 175 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
176 | + if ( !class_exists( $config ) ) { |
|
177 | + throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
178 | + } |
|
176 | 179 | |
177 | 180 | //made it HERE? FINALLY, let's get things setup. |
178 | 181 | $a = new ReflectionClass($config); |
179 | 182 | $qtip = $a->newInstance(); |
180 | 183 | |
181 | 184 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
185 | + if ( ! $qtip instanceof EE_Qtip_Config ) { |
|
186 | + throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
187 | + } |
|
184 | 188 | |
185 | 189 | $this->_qtips[] = $a->newInstance(); |
186 | 190 | |
@@ -196,8 +200,10 @@ discard block |
||
196 | 200 | * @return void |
197 | 201 | */ |
198 | 202 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
200 | - return; //no qtips! |
|
203 | + if ( empty( $this->_qtips ) ) { |
|
204 | + return; |
|
205 | + } |
|
206 | + //no qtips! |
|
201 | 207 | |
202 | 208 | $content = array(); |
203 | 209 | |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | $qts = $qtip->get_tips(); |
220 | 226 | $content = array(); |
221 | 227 | foreach ( $qts as $qt ) { |
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
223 | - continue; |
|
228 | + if ( ! $qt instanceof EE_Qtip ) { |
|
229 | + continue; |
|
230 | + } |
|
224 | 231 | $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
225 | 232 | } |
226 | 233 |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
2 | 2 | /** |
3 | - * EEH_Qtip_Loader |
|
4 | - * |
|
5 | - * This is a helper utility class that provides a PHP api for setting up qtip js library programmatically. |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage /helpers/EEH_Qtip_Loader.helper.php |
|
9 | - * @author Darren Ethier |
|
10 | - */ |
|
3 | + * EEH_Qtip_Loader |
|
4 | + * |
|
5 | + * This is a helper utility class that provides a PHP api for setting up qtip js library programmatically. |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage /helpers/EEH_Qtip_Loader.helper.php |
|
9 | + * @author Darren Ethier |
|
10 | + */ |
|
11 | 11 | class EEH_Qtip_Loader extends EEH_Base { |
12 | 12 | |
13 | 13 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * For verifying that a variable is indeed an array, else throw an EE_Error |
133 | 133 | * @param type $variable_to_test |
134 | - * @param type $variable_name |
|
134 | + * @param string $variable_name |
|
135 | 135 | * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty' |
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * for verifying that a variable is one of the string optiosn supplied |
160 | 160 | * @param mixed $variable_to_test |
161 | 161 | * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages |
162 | - * @param array $string_options an array of acceptable values |
|
162 | + * @param string[] $string_options an array of acceptable values |
|
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | * @throws EE_Error (indirectly) |
52 | 52 | */ |
53 | - static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
|
54 | - if(!WP_DEBUG)return; |
|
55 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
56 | - if('allow_null' == $allow_null && is_null($variable_to_test)){ |
|
53 | + static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null') { |
|
54 | + if ( ! WP_DEBUG)return; |
|
55 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
56 | + if ('allow_null' == $allow_null && is_null($variable_to_test)) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | self::verify_is_array($variable_to_test, $name_of_variable); |
60 | - foreach($variable_to_test as $key=>$array_element){ |
|
60 | + foreach ($variable_to_test as $key=>$array_element) { |
|
61 | 61 | self::verify_instanceof($array_element, $key, $class_name); |
62 | 62 | } |
63 | 63 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | * @throws EE_Error |
75 | 75 | */ |
76 | - static function verify_isnt_null($variable_to_test,$name_of_variable){ |
|
77 | - if(!WP_DEBUG)return; |
|
78 | - if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
|
79 | - $error[]=__('Variable named %s is null.','event_espresso'); |
|
80 | - $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
|
81 | - throw new EE_Error(sprintf(implode(",",$error),$name_of_variable,$name_of_variable)); |
|
76 | + static function verify_isnt_null($variable_to_test, $name_of_variable) { |
|
77 | + if ( ! WP_DEBUG)return; |
|
78 | + if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != FALSE) { |
|
79 | + $error[] = __('Variable named %s is null.', 'event_espresso'); |
|
80 | + $error[] = __("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso'); |
|
81 | + throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable)); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | * @throws EE_Error |
92 | 92 | */ |
93 | - static function verify_is_true($expression_to_test,$expression_string_representation){ |
|
94 | - if(!WP_DEBUG)return; |
|
95 | - if(!$expression_to_test){ |
|
96 | - $error[]=__('Template error.','event_espresso'); |
|
97 | - $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
|
98 | - throw new EE_Error(sprintf(implode(",",$error),$expression_string_representation)); |
|
93 | + static function verify_is_true($expression_to_test, $expression_string_representation) { |
|
94 | + if ( ! WP_DEBUG)return; |
|
95 | + if ( ! $expression_to_test) { |
|
96 | + $error[] = __('Template error.', 'event_espresso'); |
|
97 | + $error[] = __("%s evaluated to false, but it must be true!", 'event_espresso'); |
|
98 | + throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation)); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | * @throws EE_Error |
113 | 113 | */ |
114 | - static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
|
115 | - if(!WP_DEBUG)return; |
|
116 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
117 | - if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
|
114 | + static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null') { |
|
115 | + if ( ! WP_DEBUG)return; |
|
116 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
117 | + if ($allow_null == 'allow_null' && is_null($variable_to_test)) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - if( $variable_to_test == NULL || ! ( $variable_to_test instanceof $class_name )){ |
|
121 | - $msg[]=__('Variable %s is not of the correct type.','event_espresso'); |
|
122 | - $msg[]=__("It should be of type %s",'event_espresso'); |
|
123 | - throw new EE_Error(sprintf(implode(",",$msg),$name_of_variable,$name_of_variable,$class_name)); |
|
120 | + if ($variable_to_test == NULL || ! ($variable_to_test instanceof $class_name)) { |
|
121 | + $msg[] = __('Variable %s is not of the correct type.', 'event_espresso'); |
|
122 | + $msg[] = __("It should be of type %s", 'event_espresso'); |
|
123 | + throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name)); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
138 | 138 | */ |
139 | - static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
|
140 | - if(!WP_DEBUG)return; |
|
141 | - self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
|
142 | - if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
|
139 | + static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty') { |
|
140 | + if ( ! WP_DEBUG)return; |
|
141 | + self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty')); |
|
142 | + if (empty($variable_to_test) && 'allow_empty' == $allow_empty) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - if(!is_array($variable_to_test)){ |
|
146 | - $error[]=__('Variable %s should be an array, but it is not.'); |
|
147 | - $error[]=__("Its value is, instead '%s'",'event_espresso'); |
|
148 | - throw new EE_Error(sprintf(implode(",",$error),$variable_name,$variable_name,$variable_to_test)); |
|
145 | + if ( ! is_array($variable_to_test)) { |
|
146 | + $error[] = __('Variable %s should be an array, but it is not.'); |
|
147 | + $error[] = __("Its value is, instead '%s'", 'event_espresso'); |
|
148 | + throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test)); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
166 | - static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
|
167 | - if(!WP_DEBUG)return; |
|
168 | - if(!in_array($variable_to_test,$string_options)){ |
|
169 | - $msg[0]=__('Malconfigured template.','event_espresso'); |
|
170 | - $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
|
171 | - throw new EE_Error(sprintf(implode("||",$msg),$variable_name,$variable_to_test, implode("', '",$string_options))); |
|
166 | + static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options) { |
|
167 | + if ( ! WP_DEBUG)return; |
|
168 | + if ( ! in_array($variable_to_test, $string_options)) { |
|
169 | + $msg[0] = __('Malconfigured template.', 'event_espresso'); |
|
170 | + $msg[1] = __("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso'); |
|
171 | + throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options))); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * Event Espresso |
@@ -51,7 +53,9 @@ discard block |
||
51 | 53 | * @throws EE_Error (indirectly) |
52 | 54 | */ |
53 | 55 | static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
54 | - if(!WP_DEBUG)return; |
|
56 | + if(!WP_DEBUG) { |
|
57 | + return; |
|
58 | + } |
|
55 | 59 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
56 | 60 | if('allow_null' == $allow_null && is_null($variable_to_test)){ |
57 | 61 | return; |
@@ -74,7 +78,9 @@ discard block |
||
74 | 78 | * @throws EE_Error |
75 | 79 | */ |
76 | 80 | static function verify_isnt_null($variable_to_test,$name_of_variable){ |
77 | - if(!WP_DEBUG)return; |
|
81 | + if(!WP_DEBUG) { |
|
82 | + return; |
|
83 | + } |
|
78 | 84 | if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
79 | 85 | $error[]=__('Variable named %s is null.','event_espresso'); |
80 | 86 | $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | * @throws EE_Error |
92 | 98 | */ |
93 | 99 | static function verify_is_true($expression_to_test,$expression_string_representation){ |
94 | - if(!WP_DEBUG)return; |
|
100 | + if(!WP_DEBUG) { |
|
101 | + return; |
|
102 | + } |
|
95 | 103 | if(!$expression_to_test){ |
96 | 104 | $error[]=__('Template error.','event_espresso'); |
97 | 105 | $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
@@ -112,7 +120,9 @@ discard block |
||
112 | 120 | * @throws EE_Error |
113 | 121 | */ |
114 | 122 | static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
115 | - if(!WP_DEBUG)return; |
|
123 | + if(!WP_DEBUG) { |
|
124 | + return; |
|
125 | + } |
|
116 | 126 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
117 | 127 | if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
118 | 128 | return; |
@@ -137,7 +147,9 @@ discard block |
||
137 | 147 | * @throws EE_Error |
138 | 148 | */ |
139 | 149 | static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
140 | - if(!WP_DEBUG)return; |
|
150 | + if(!WP_DEBUG) { |
|
151 | + return; |
|
152 | + } |
|
141 | 153 | self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
142 | 154 | if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
143 | 155 | return; |
@@ -164,7 +176,9 @@ discard block |
||
164 | 176 | * @throws EE_Error |
165 | 177 | */ |
166 | 178 | static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
167 | - if(!WP_DEBUG)return; |
|
179 | + if(!WP_DEBUG) { |
|
180 | + return; |
|
181 | + } |
|
168 | 182 | if(!in_array($variable_to_test,$string_options)){ |
169 | 183 | $msg[0]=__('Malconfigured template.','event_espresso'); |
170 | 184 | $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |