@@ -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 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function instance() { |
91 | 91 | // check if class object is instantiated, and instantiated properly |
92 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_System )) { |
|
92 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_System)) { |
|
93 | 93 | self::$_instance = new self(); |
94 | 94 | } |
95 | 95 | return self::$_instance; |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | * resets the instance and returns it |
99 | 99 | * @return EE_System |
100 | 100 | */ |
101 | - public static function reset(){ |
|
101 | + public static function reset() { |
|
102 | 102 | self::$_instance->_req_type = NULL; |
103 | 103 | //we need to reset the migration manager in order for it to detect DMSs properly |
104 | 104 | EE_Data_Migration_Manager::reset(); |
105 | 105 | //make sure none of the old hooks are left hanging around |
106 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
106 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
107 | 107 | self::instance()->detect_activations_or_upgrades(); |
108 | 108 | self::instance()->perform_activations_upgrades_and_migrations(); |
109 | 109 | return self::instance(); |
@@ -124,72 +124,72 @@ discard block |
||
124 | 124 | * @return \EE_System |
125 | 125 | */ |
126 | 126 | private function __construct() { |
127 | - do_action( 'AHEE__EE_System__construct__begin',$this ); |
|
127 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
128 | 128 | // check required WP version |
129 | - if ( ! $this->_minimum_wp_version_required() ) { |
|
130 | - unset( $_GET['activate'] ); |
|
131 | - add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 ); |
|
129 | + if ( ! $this->_minimum_wp_version_required()) { |
|
130 | + unset($_GET['activate']); |
|
131 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | // check required PHP version |
135 | - if ( ! $this->minimum_php_version_required() ) { |
|
136 | - unset( $_GET['activate'] ); |
|
137 | - add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 ); |
|
135 | + if ( ! $this->minimum_php_version_required()) { |
|
136 | + unset($_GET['activate']); |
|
137 | + add_action('admin_notices', array($this, 'minimum_php_version_error'), 1); |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | // check recommended WP version |
141 | - if ( ! $this->_minimum_wp_version_recommended() ) { |
|
141 | + if ( ! $this->_minimum_wp_version_recommended()) { |
|
142 | 142 | $this->_display_minimum_recommended_wp_version_notice(); |
143 | 143 | } |
144 | 144 | // check recommended PHP version |
145 | - if ( ! $this->_minimum_php_version_recommended() ) { |
|
145 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
146 | 146 | $this->_display_minimum_recommended_php_version_notice(); |
147 | 147 | } |
148 | 148 | |
149 | 149 | //all the below should ONLY run if minimum php version requirement is met |
150 | - if ( $this->minimum_php_version_required() ) { |
|
150 | + if ($this->minimum_php_version_required()) { |
|
151 | 151 | $this->display_alpha_banner_warning(); |
152 | 152 | // central repository for classes |
153 | 153 | $this->_load_registry(); |
154 | 154 | // workarounds for PHP < 5.3 |
155 | 155 | $this->_load_class_tools(); |
156 | 156 | // load a few helper files |
157 | - EE_Registry::instance()->load_helper( 'File' ); |
|
158 | - EE_Registry::instance()->load_helper( 'Autoloader', array(), false ); |
|
157 | + EE_Registry::instance()->load_helper('File'); |
|
158 | + EE_Registry::instance()->load_helper('Autoloader', array(), false); |
|
159 | 159 | // instantiate PSR4 autoloader |
160 | - require_once( EE_CORE . 'Psr4Autoloader.php' ); |
|
160 | + require_once(EE_CORE.'Psr4Autoloader.php'); |
|
161 | 161 | $psr4_loader = new \EventEspresso\Core\Psr4Autoloader; |
162 | 162 | // register the autoloader |
163 | 163 | $psr4_loader->register(); |
164 | 164 | // register the base directories for the namespace prefix |
165 | - $psr4_loader->addNamespace( 'EventEspresso', EE_PLUGIN_DIR_PATH ); |
|
166 | - require_once EE_CORE . 'EE_Deprecated.core.php'; |
|
165 | + $psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH); |
|
166 | + require_once EE_CORE.'EE_Deprecated.core.php'; |
|
167 | 167 | // load interfaces |
168 | - require_once EE_CORE . 'EEI_Interfaces.php'; |
|
169 | - require_once EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'; |
|
168 | + require_once EE_CORE.'EEI_Interfaces.php'; |
|
169 | + require_once EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'; |
|
170 | 170 | // WP cron jobs |
171 | - EE_Registry::instance()->load_core( 'Cron_Tasks' ); |
|
171 | + EE_Registry::instance()->load_core('Cron_Tasks'); |
|
172 | 172 | |
173 | 173 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
174 | - add_action( 'plugins_loaded', array( $this, 'load_espresso_addons' ), 1 ); |
|
174 | + add_action('plugins_loaded', array($this, 'load_espresso_addons'), 1); |
|
175 | 175 | // when an ee addon is activated, we want to call the core hook(s) again |
176 | 176 | // because the newly-activated addon didn't get a chance to run at all |
177 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
177 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
178 | 178 | // detect whether install or upgrade |
179 | - add_action( 'plugins_loaded', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
179 | + add_action('plugins_loaded', array($this, 'detect_activations_or_upgrades'), 3); |
|
180 | 180 | // load EE_Config, EE_Textdomain, etc |
181 | - add_action( 'plugins_loaded', array( $this, 'load_core_configuration' ), 5 ); |
|
181 | + add_action('plugins_loaded', array($this, 'load_core_configuration'), 5); |
|
182 | 182 | // load EE_Config, EE_Textdomain, etc |
183 | - add_action( 'plugins_loaded', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
183 | + add_action('plugins_loaded', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
184 | 184 | // you wanna get going? I wanna get going... let's get going! |
185 | - add_action( 'plugins_loaded', array( $this, 'brew_espresso' ), 9 ); |
|
185 | + add_action('plugins_loaded', array($this, 'brew_espresso'), 9); |
|
186 | 186 | |
187 | 187 | //other housekeeping |
188 | 188 | //exclude EE critical pages from wp_list_pages |
189 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
189 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
190 | 190 | // ALL EE Addons should use the following hook point to attach their initial setup too |
191 | 191 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
192 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
192 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -205,22 +205,22 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function display_alpha_banner_warning() { |
207 | 207 | // skip AJAX requests |
208 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
208 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | // skip stable releases |
212 | - if ( strpos( EVENT_ESPRESSO_VERSION, '.alpha' ) === false ) { |
|
212 | + if (strpos(EVENT_ESPRESSO_VERSION, '.alpha') === false) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | // post release candidate warning |
216 | - if ( is_admin() ) { |
|
217 | - add_action( 'admin_notices', array( $this, 'alpha_banner_admin_notice' ), -999 ); |
|
216 | + if (is_admin()) { |
|
217 | + add_action('admin_notices', array($this, 'alpha_banner_admin_notice'), -999); |
|
218 | 218 | } else { |
219 | 219 | // site admin has authorized use of non-stable release candidate for production |
220 | - if ( defined( 'ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE' ) && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE ) { |
|
220 | + if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | - add_action( 'shutdown', array( $this, 'alpha_banner_warning_notice' ), 10 ); |
|
223 | + add_action('shutdown', array($this, 'alpha_banner_warning_notice'), 10); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public function alpha_banner_admin_notice() { |
237 | 237 | EE_Error::add_attention( |
238 | 238 | sprintf( |
239 | - __( 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', 'event_espresso' ), |
|
239 | + __('This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', 'event_espresso'), |
|
240 | 240 | '<strong>', |
241 | 241 | '</strong>' |
242 | 242 | ), |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function alpha_banner_warning_notice() { |
257 | 257 | global $pagenow; |
258 | - if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ) ) ) { |
|
258 | + if (in_array($pagenow, array('wp-login.php', 'wp-register.php'))) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | printf( |
262 | - __( '%1$sThis version of Event Espresso is for testing and/or evaluation purposes only. It is %2$snot%3$s considered a stable release and should therefore %2$snot%3$s be activated on a live or production website.%4$s', 'event_espresso' ), |
|
262 | + __('%1$sThis version of Event Espresso is for testing and/or evaluation purposes only. It is %2$snot%3$s considered a stable release and should therefore %2$snot%3$s be activated on a live or production website.%4$s', 'event_espresso'), |
|
263 | 263 | '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>', |
264 | 264 | '<strong>', |
265 | 265 | '</strong>', |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param string $min_version |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) { |
|
279 | + private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) { |
|
280 | 280 | global $wp_version; |
281 | - return version_compare( $wp_version, $min_version, '>=' ) ? TRUE : FALSE; |
|
281 | + return version_compare($wp_version, $min_version, '>=') ? TRUE : FALSE; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @return boolean |
289 | 289 | */ |
290 | 290 | private function _minimum_wp_version_required() { |
291 | - return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED ); |
|
291 | + return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return boolean |
299 | 299 | */ |
300 | 300 | private function _minimum_wp_version_recommended() { |
301 | - return $this->_check_wp_version( EE_MIN_WP_VER_RECOMMENDED ); |
|
301 | + return $this->_check_wp_version(EE_MIN_WP_VER_RECOMMENDED); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * @param string $min_version |
311 | 311 | * @return boolean |
312 | 312 | */ |
313 | - private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) { |
|
314 | - return version_compare( PHP_VERSION, $min_version, '>=' ) ? TRUE : FALSE; |
|
313 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) { |
|
314 | + return version_compare(PHP_VERSION, $min_version, '>=') ? TRUE : FALSE; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @return boolean |
321 | 321 | */ |
322 | 322 | public function minimum_php_version_required() { |
323 | - return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED ); |
|
323 | + return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return boolean |
331 | 331 | */ |
332 | 332 | private function _minimum_php_version_recommended() { |
333 | - return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED ); |
|
333 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | <p> |
348 | 348 | <?php |
349 | 349 | printf( |
350 | - __( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
350 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
351 | 351 | EE_MIN_WP_VER_REQUIRED, |
352 | 352 | $wp_version, |
353 | 353 | '<br/>', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | </p> |
358 | 358 | </div> |
359 | 359 | <?php |
360 | - EE_System::deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
360 | + EE_System::deactivate_plugin(EE_PLUGIN_BASENAME); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | <p> |
374 | 374 | <?php |
375 | 375 | printf( |
376 | - __( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on supported versions of PHP, please go to %4$s, or %5$s to download the latest stable versions.', 'event_espresso' ), |
|
376 | + __('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on supported versions of PHP, please go to %4$s, or %5$s to download the latest stable versions.', 'event_espresso'), |
|
377 | 377 | EE_MIN_PHP_VER_REQUIRED, |
378 | 378 | PHP_VERSION, |
379 | 379 | '<br/>', |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | </p> |
385 | 385 | </div> |
386 | 386 | <?php |
387 | - deactivate_plugins( EE_PLUGIN_BASENAME ); |
|
387 | + deactivate_plugins(EE_PLUGIN_BASENAME); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | private function _display_minimum_recommended_wp_version_notice() { |
399 | 399 | global $wp_version; |
400 | 400 | EE_Error::add_persistent_admin_notice( |
401 | - 'wp_version_' . str_replace( '.', '-', EE_MIN_WP_VER_RECOMMENDED ) . '_recommended', |
|
401 | + 'wp_version_'.str_replace('.', '-', EE_MIN_WP_VER_RECOMMENDED).'_recommended', |
|
402 | 402 | sprintf( |
403 | - __( 'Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
403 | + __('Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
404 | 404 | EE_MIN_WP_VER_RECOMMENDED, |
405 | 405 | $wp_version, |
406 | 406 | '<br/>', |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | */ |
420 | 420 | private function _display_minimum_recommended_php_version_notice() { |
421 | 421 | EE_Error::add_persistent_admin_notice( |
422 | - 'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended', |
|
422 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
423 | 423 | sprintf( |
424 | - __( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on supported versions of PHP, please go to %4$s, or %5$s to download the latest stable versions.', 'event_espresso' ), |
|
424 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on supported versions of PHP, please go to %4$s, or %5$s to download the latest stable versions.', 'event_espresso'), |
|
425 | 425 | EE_MIN_PHP_VER_RECOMMENDED, |
426 | 426 | PHP_VERSION, |
427 | 427 | '<br/>', |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | */ |
442 | 442 | private function _load_registry() { |
443 | - if ( is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
444 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
443 | + if (is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
444 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
445 | 445 | } else { |
446 | - $msg = __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ); |
|
447 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
448 | - wp_die( EE_Error::get_notices() ); |
|
446 | + $msg = __('The EE_Registry core class could not be loaded.', 'event_espresso'); |
|
447 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
448 | + wp_die(EE_Error::get_notices()); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | * @return void |
458 | 458 | */ |
459 | 459 | private function _load_class_tools() { |
460 | - if ( is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
461 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
460 | + if (is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
461 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
462 | 462 | } else { |
463 | - $msg = __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ); |
|
464 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
463 | + $msg = __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'); |
|
464 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | public function load_espresso_addons() { |
479 | 479 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
480 | 480 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
481 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
481 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
482 | 482 | //load and setup EE_Capabilities |
483 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
484 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
483 | + EE_Registry::instance()->load_core('Capabilities'); |
|
484 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | * Checks for activation or upgrade of core first; then also checks if any registered |
490 | 490 | * addons have been activated or upgraded |
491 | 491 | */ |
492 | - public function detect_activations_or_upgrades(){ |
|
492 | + public function detect_activations_or_upgrades() { |
|
493 | 493 | //first off: let's make sure to handle core |
494 | 494 | $this->detect_if_activation_or_upgrade(); |
495 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
495 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
496 | 496 | //detect teh request type for that addon |
497 | 497 | $addon->detect_activation_or_upgrade(); |
498 | 498 | } |
@@ -510,44 +510,44 @@ discard block |
||
510 | 510 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
511 | 511 | |
512 | 512 | // load M-Mode class |
513 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
513 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
514 | 514 | // check if db has been updated, or if its a brand-new installation |
515 | 515 | |
516 | 516 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
517 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
517 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
518 | 518 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
519 | - if( $request_type != EE_System::req_type_normal){ |
|
519 | + if ($request_type != EE_System::req_type_normal) { |
|
520 | 520 | EE_Registry::instance()->load_helper('Activation'); |
521 | 521 | } |
522 | 522 | |
523 | - switch($request_type){ |
|
523 | + switch ($request_type) { |
|
524 | 524 | case EE_System::req_type_new_activation: |
525 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
526 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
525 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
526 | + $this->_handle_core_version_change($espresso_db_update); |
|
527 | 527 | break; |
528 | 528 | case EE_System::req_type_reactivation: |
529 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
530 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
529 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
530 | + $this->_handle_core_version_change($espresso_db_update); |
|
531 | 531 | break; |
532 | 532 | case EE_System::req_type_upgrade: |
533 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
533 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
534 | 534 | //migrations may be required now that we've upgraded |
535 | 535 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
536 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
536 | + $this->_handle_core_version_change($espresso_db_update); |
|
537 | 537 | // echo "done upgrade";die; |
538 | 538 | break; |
539 | 539 | case EE_System::req_type_downgrade: |
540 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
540 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
541 | 541 | //its possible migrations are no longer required |
542 | 542 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
543 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
543 | + $this->_handle_core_version_change($espresso_db_update); |
|
544 | 544 | break; |
545 | 545 | case EE_System::req_type_normal: |
546 | 546 | default: |
547 | 547 | // $this->_maybe_redirect_to_ee_about(); |
548 | 548 | break; |
549 | 549 | } |
550 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
550 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -555,10 +555,10 @@ discard block |
||
555 | 555 | * initializing the database later during the request |
556 | 556 | * @param array $espresso_db_update |
557 | 557 | */ |
558 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
559 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
558 | + protected function _handle_core_version_change($espresso_db_update) { |
|
559 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
560 | 560 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
561 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
561 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | |
@@ -573,44 +573,44 @@ discard block |
||
573 | 573 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
574 | 574 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
575 | 575 | */ |
576 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
577 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
578 | - if( ! $espresso_db_update){ |
|
579 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
576 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
577 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
578 | + if ( ! $espresso_db_update) { |
|
579 | + $espresso_db_update = get_option('espresso_db_update'); |
|
580 | 580 | } |
581 | 581 | // check that option is an array |
582 | - if( ! is_array( $espresso_db_update )) { |
|
582 | + if ( ! is_array($espresso_db_update)) { |
|
583 | 583 | // if option is FALSE, then it never existed |
584 | - if ( $espresso_db_update === FALSE ) { |
|
584 | + if ($espresso_db_update === FALSE) { |
|
585 | 585 | // make $espresso_db_update an array and save option with autoload OFF |
586 | - $espresso_db_update = array(); |
|
587 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
586 | + $espresso_db_update = array(); |
|
587 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
588 | 588 | } else { |
589 | 589 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
590 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
591 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
590 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
591 | + update_option('espresso_db_update', $espresso_db_update); |
|
592 | 592 | } |
593 | - }else{ |
|
593 | + } else { |
|
594 | 594 | $corrected_db_update = array(); |
595 | 595 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
596 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
597 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
596 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
597 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
598 | 598 | //the key is an int, and the value IS NOT an array |
599 | 599 | //so it must be numerically-indexed, where values are versions installed... |
600 | 600 | //fix it! |
601 | 601 | $version_string = $should_be_array; |
602 | 602 | $corrected_db_update[$version_string] = array('unknown-date'); |
603 | - }else{ |
|
603 | + } else { |
|
604 | 604 | //ok it checks out |
605 | 605 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
606 | 606 | } |
607 | 607 | } |
608 | 608 | $espresso_db_update = $corrected_db_update; |
609 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
609 | + update_option('espresso_db_update', $espresso_db_update); |
|
610 | 610 | |
611 | 611 | } |
612 | 612 | |
613 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
613 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
614 | 614 | return $espresso_db_update; |
615 | 615 | } |
616 | 616 | |
@@ -629,27 +629,27 @@ discard block |
||
629 | 629 | * so we prefer to only do it when necessary |
630 | 630 | * @return void |
631 | 631 | */ |
632 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
632 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
633 | 633 | $request_type = $this->detect_req_type(); |
634 | 634 | //only initialize system if we're not in maintenance mode. |
635 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
636 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
635 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
636 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
637 | 637 | EEH_Activation::system_initialization(); |
638 | - if( $verify_schema ) { |
|
638 | + if ($verify_schema) { |
|
639 | 639 | EEH_Activation::initialize_db_and_folders(); |
640 | 640 | } |
641 | 641 | EEH_Activation::initialize_db_content(); |
642 | - if( $initialize_addons_too ) { |
|
642 | + if ($initialize_addons_too) { |
|
643 | 643 | //foreach registered addon, make sure its db is up-to-date too |
644 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
644 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
645 | 645 | $addon->initialize_db_if_no_migrations_required(); |
646 | 646 | } |
647 | 647 | } |
648 | - }else{ |
|
649 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
648 | + } else { |
|
649 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
650 | 650 | } |
651 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
652 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
651 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
652 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
@@ -661,16 +661,16 @@ discard block |
||
661 | 661 | * @param string $current_version_to_add version to be added to the version history |
662 | 662 | * @return boolean success as to whether or not this option was changed |
663 | 663 | */ |
664 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
665 | - if( ! $version_history ) { |
|
664 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
665 | + if ( ! $version_history) { |
|
666 | 666 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
667 | 667 | } |
668 | - if( $current_version_to_add == NULL){ |
|
668 | + if ($current_version_to_add == NULL) { |
|
669 | 669 | $current_version_to_add = espresso_version(); |
670 | 670 | } |
671 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
671 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
672 | 672 | // re-save |
673 | - return update_option( 'espresso_db_update', $version_history ); |
|
673 | + return update_option('espresso_db_update', $version_history); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | * but still know if this is a new install or not |
688 | 688 | * @return int one of the constants on EE_System::req_type_ |
689 | 689 | */ |
690 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
691 | - if ( $this->_req_type === NULL ){ |
|
692 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
693 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
690 | + public function detect_req_type($espresso_db_update = NULL) { |
|
691 | + if ($this->_req_type === NULL) { |
|
692 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
693 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
694 | 694 | } |
695 | 695 | return $this->_req_type; |
696 | 696 | } |
@@ -706,39 +706,39 @@ discard block |
||
706 | 706 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
707 | 707 | * @return int one of the constants on EE_System::req_type_* |
708 | 708 | */ |
709 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
710 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
711 | - if( $activation_history_for_addon ){ |
|
709 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
710 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
711 | + if ($activation_history_for_addon) { |
|
712 | 712 | //it exists, so this isn't a completely new install |
713 | 713 | //check if this version already in that list of previously installed versions |
714 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
714 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
715 | 715 | //it a version we haven't seen before |
716 | - if( $version_is_higher === 1 ){ |
|
716 | + if ($version_is_higher === 1) { |
|
717 | 717 | $req_type = EE_System::req_type_upgrade; |
718 | - }else{ |
|
718 | + } else { |
|
719 | 719 | $req_type = EE_System::req_type_downgrade; |
720 | 720 | } |
721 | - delete_option( $activation_indicator_option_name ); |
|
721 | + delete_option($activation_indicator_option_name); |
|
722 | 722 | } else { |
723 | 723 | // its not an update. maybe a reactivation? |
724 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
725 | - if ( $version_is_higher === -1 ){ |
|
724 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
725 | + if ($version_is_higher === -1) { |
|
726 | 726 | $req_type = EE_System::req_type_downgrade; |
727 | - }elseif( $version_is_higher === 0 ){ |
|
727 | + }elseif ($version_is_higher === 0) { |
|
728 | 728 | //we've seen this version before, but it's an activation. must be a reactivation |
729 | 729 | $req_type = EE_System::req_type_reactivation; |
730 | - }else{//$version_is_higher === 1 |
|
730 | + } else {//$version_is_higher === 1 |
|
731 | 731 | $req_type = EE_System::req_type_upgrade; |
732 | 732 | } |
733 | - delete_option( $activation_indicator_option_name ); |
|
733 | + delete_option($activation_indicator_option_name); |
|
734 | 734 | } else { |
735 | 735 | //we've seen this version before and the activation indicate doesn't show it was just activated |
736 | - if ( $version_is_higher === -1 ){ |
|
736 | + if ($version_is_higher === -1) { |
|
737 | 737 | $req_type = EE_System::req_type_downgrade; |
738 | - }elseif( $version_is_higher === 0 ){ |
|
738 | + }elseif ($version_is_higher === 0) { |
|
739 | 739 | //we've seen this version before and it's not an activation. its normal request |
740 | 740 | $req_type = EE_System::req_type_normal; |
741 | - }else{//$version_is_higher === 1 |
|
741 | + } else {//$version_is_higher === 1 |
|
742 | 742 | $req_type = EE_System::req_type_upgrade; |
743 | 743 | } |
744 | 744 | } |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | } else { |
747 | 747 | //brand new install |
748 | 748 | $req_type = EE_System::req_type_new_activation; |
749 | - delete_option( $activation_indicator_option_name ); |
|
749 | + delete_option($activation_indicator_option_name); |
|
750 | 750 | } |
751 | 751 | return $req_type; |
752 | 752 | } |
@@ -764,30 +764,30 @@ discard block |
||
764 | 764 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
765 | 765 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
766 | 766 | */ |
767 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
767 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
768 | 768 | //find the most recently-activated version |
769 | 769 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
770 | 770 | $most_recently_active_version = '0.0.0.dev.000'; |
771 | - if( is_array( $activation_history_for_addon ) ){ |
|
772 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
771 | + if (is_array($activation_history_for_addon)) { |
|
772 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
773 | 773 | //check there is a record of when this version was activated. Otherwise, |
774 | 774 | //mark it as unknown |
775 | - if( ! $times_activated ){ |
|
776 | - $times_activated = array( 'unknown-date'); |
|
775 | + if ( ! $times_activated) { |
|
776 | + $times_activated = array('unknown-date'); |
|
777 | 777 | } |
778 | - if( is_string( $times_activated ) ){ |
|
779 | - $times_activated = array( $times_activated ); |
|
778 | + if (is_string($times_activated)) { |
|
779 | + $times_activated = array($times_activated); |
|
780 | 780 | } |
781 | - foreach( $times_activated as $an_activation ){ |
|
782 | - if( $an_activation != 'unknown-date' && |
|
783 | - $an_activation > $most_recently_active_version_activation ){ |
|
781 | + foreach ($times_activated as $an_activation) { |
|
782 | + if ($an_activation != 'unknown-date' && |
|
783 | + $an_activation > $most_recently_active_version_activation) { |
|
784 | 784 | $most_recently_active_version = $version; |
785 | 785 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
786 | 786 | } |
787 | 787 | } |
788 | 788 | } |
789 | 789 | } |
790 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
790 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -797,20 +797,20 @@ discard block |
||
797 | 797 | * @return void |
798 | 798 | */ |
799 | 799 | public function redirect_to_about_ee() { |
800 | - $notices = EE_Error::get_notices( FALSE ); |
|
800 | + $notices = EE_Error::get_notices(FALSE); |
|
801 | 801 | //if current user is an admin and it's not an ajax request |
802 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
803 | - $query_params = array( 'page' => 'espresso_about' ); |
|
802 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
803 | + $query_params = array('page' => 'espresso_about'); |
|
804 | 804 | |
805 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
805 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
806 | 806 | $query_params['new_activation'] = TRUE; |
807 | 807 | } |
808 | 808 | |
809 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
809 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
810 | 810 | $query_params['reactivation'] = TRUE; |
811 | 811 | } |
812 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
813 | - wp_safe_redirect( $url ); |
|
812 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
813 | + wp_safe_redirect($url); |
|
814 | 814 | exit(); |
815 | 815 | } |
816 | 816 | } |
@@ -821,31 +821,31 @@ discard block |
||
821 | 821 | * |
822 | 822 | * @return void |
823 | 823 | */ |
824 | - public function load_core_configuration(){ |
|
825 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
826 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
824 | + public function load_core_configuration() { |
|
825 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
826 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
827 | 827 | //load textdomain |
828 | 828 | EE_Load_Textdomain::load_textdomain(); |
829 | 829 | // load and setup EE_Config and EE_Network_Config |
830 | - EE_Registry::instance()->load_core( 'Config' ); |
|
831 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
830 | + EE_Registry::instance()->load_core('Config'); |
|
831 | + EE_Registry::instance()->load_core('Network_Config'); |
|
832 | 832 | // setup autoloaders |
833 | 833 | // enable logging? |
834 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
835 | - EE_Registry::instance()->load_core( 'Log' ); |
|
834 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
835 | + EE_Registry::instance()->load_core('Log'); |
|
836 | 836 | } |
837 | 837 | // check for activation errors |
838 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
839 | - if ( $activation_errors ) { |
|
840 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
841 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
838 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
839 | + if ($activation_errors) { |
|
840 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
841 | + update_option('ee_plugin_activation_errors', FALSE); |
|
842 | 842 | } |
843 | 843 | // get model names |
844 | 844 | $this->_parse_model_names(); |
845 | 845 | |
846 | 846 | //load caf stuff a chance to play during the activation process too. |
847 | 847 | $this->_maybe_brew_regular(); |
848 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
848 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | |
@@ -854,23 +854,23 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @return void |
856 | 856 | */ |
857 | - private function _parse_model_names(){ |
|
857 | + private function _parse_model_names() { |
|
858 | 858 | //get all the files in the EE_MODELS folder that end in .model.php |
859 | - $models = glob( EE_MODELS.'*.model.php'); |
|
859 | + $models = glob(EE_MODELS.'*.model.php'); |
|
860 | 860 | $model_names = array(); |
861 | 861 | $non_abstract_db_models = array(); |
862 | - foreach( $models as $model ){ |
|
862 | + foreach ($models as $model) { |
|
863 | 863 | // get model classname |
864 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
865 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
864 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
865 | + $shortname = str_replace('EEM_', '', $classname); |
|
866 | 866 | $reflectionClass = new ReflectionClass($classname); |
867 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
867 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
868 | 868 | $non_abstract_db_models[$shortname] = $classname; |
869 | 869 | } |
870 | - $model_names[ $shortname ] = $classname; |
|
870 | + $model_names[$shortname] = $classname; |
|
871 | 871 | } |
872 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
873 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
872 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
873 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @return void |
881 | 881 | */ |
882 | 882 | private function _maybe_brew_regular() { |
883 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
884 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
883 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
884 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | |
@@ -896,9 +896,9 @@ discard block |
||
896 | 896 | * @return void |
897 | 897 | */ |
898 | 898 | public function register_shortcodes_modules_and_widgets() { |
899 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
899 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
900 | 900 | // check for addons using old hookpoint |
901 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
901 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
902 | 902 | $this->_incompatible_addon_error(); |
903 | 903 | } |
904 | 904 | } |
@@ -912,19 +912,19 @@ discard block |
||
912 | 912 | */ |
913 | 913 | private function _incompatible_addon_error() { |
914 | 914 | // get array of classes hooking into here |
915 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
916 | - if ( ! empty( $class_names )) { |
|
917 | - $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' ); |
|
915 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
916 | + if ( ! empty($class_names)) { |
|
917 | + $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'); |
|
918 | 918 | $msg .= '<ul>'; |
919 | - foreach ( $class_names as $class_name ) { |
|
920 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
919 | + foreach ($class_names as $class_name) { |
|
920 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
921 | 921 | } |
922 | 922 | $msg .= '</ul>'; |
923 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
923 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
924 | 924 | // save list of incompatible addons to wp-options for later use |
925 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
926 | - if ( is_admin() ) { |
|
927 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
925 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
926 | + if (is_admin()) { |
|
927 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | } |
@@ -940,25 +940,25 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return void |
942 | 942 | */ |
943 | - public function brew_espresso(){ |
|
944 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
943 | + public function brew_espresso() { |
|
944 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
945 | 945 | // load some final core systems |
946 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
947 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
948 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
949 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
950 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
951 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
952 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
953 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
954 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
955 | - |
|
956 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
946 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
947 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
948 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
949 | + add_action('init', array($this, 'load_controllers'), 7); |
|
950 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
951 | + add_action('init', array($this, 'initialize'), 10); |
|
952 | + add_action('init', array($this, 'initialize_last'), 100); |
|
953 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
954 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
955 | + |
|
956 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
957 | 957 | // pew pew pew |
958 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
959 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
958 | + EE_Registry::instance()->load_core('PUE'); |
|
959 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
960 | 960 | } |
961 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
961 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | */ |
973 | 973 | public function set_hooks_for_core() { |
974 | 974 | $this->_deactivate_incompatible_addons(); |
975 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
975 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | |
@@ -981,15 +981,15 @@ discard block |
||
981 | 981 | * Using the information gathered in EE_System::_incompatible_addon_error, |
982 | 982 | * deactivates any addons considered incompatible with the current version of EE |
983 | 983 | */ |
984 | - private function _deactivate_incompatible_addons(){ |
|
985 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
986 | - if ( ! empty( $incompatible_addons )) { |
|
987 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
988 | - foreach ( $active_plugins as $active_plugin ) { |
|
989 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
990 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
991 | - unset( $_GET['activate'] ); |
|
992 | - EE_System::deactivate_plugin( $active_plugin ); |
|
984 | + private function _deactivate_incompatible_addons() { |
|
985 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
986 | + if ( ! empty($incompatible_addons)) { |
|
987 | + $active_plugins = get_option('active_plugins', array()); |
|
988 | + foreach ($active_plugins as $active_plugin) { |
|
989 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
990 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
991 | + unset($_GET['activate']); |
|
992 | + EE_System::deactivate_plugin($active_plugin); |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | } |
@@ -1006,11 +1006,11 @@ discard block |
||
1006 | 1006 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
1007 | 1007 | * @return void |
1008 | 1008 | */ |
1009 | - public static function deactivate_plugin( $plugin_basename = '' ) { |
|
1010 | - if ( ! function_exists( 'deactivate_plugins' )) { |
|
1011 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
1009 | + public static function deactivate_plugin($plugin_basename = '') { |
|
1010 | + if ( ! function_exists('deactivate_plugins')) { |
|
1011 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
1012 | 1012 | } |
1013 | - deactivate_plugins( $plugin_basename ); |
|
1013 | + deactivate_plugins($plugin_basename); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | * @return void |
1023 | 1023 | */ |
1024 | 1024 | public function perform_activations_upgrades_and_migrations() { |
1025 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
1025 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | // EEM_Datetime::instance()->show_next_x_db_queries(); |
1039 | 1039 | // $ds = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time($e->ID(),false); |
1040 | 1040 | // |
1041 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
1041 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1042 | 1042 | // register Custom Post Types |
1043 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
1043 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
1044 | 1044 | // EE_Registry::instance()->load_core( 'Session' ); |
1045 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
1045 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | |
@@ -1057,16 +1057,16 @@ discard block |
||
1057 | 1057 | * @return void |
1058 | 1058 | */ |
1059 | 1059 | public function load_controllers() { |
1060 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
1060 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
1061 | 1061 | // let's get it started |
1062 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
1063 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
1064 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
1065 | - } else if ( ! EE_FRONT_AJAX ) { |
|
1066 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
1067 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
1062 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
1063 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1064 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
1065 | + } else if ( ! EE_FRONT_AJAX) { |
|
1066 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1067 | + EE_Registry::instance()->load_core('Admin'); |
|
1068 | 1068 | } |
1069 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
1069 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
@@ -1080,10 +1080,10 @@ discard block |
||
1080 | 1080 | * @return void |
1081 | 1081 | */ |
1082 | 1082 | public function core_loaded_and_ready() { |
1083 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
1084 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
1083 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1084 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1085 | 1085 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
1086 | - EE_Registry::instance()->load_core( 'Session' ); |
|
1086 | + EE_Registry::instance()->load_core('Session'); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * @return void |
1098 | 1098 | */ |
1099 | 1099 | public function initialize() { |
1100 | - do_action( 'AHEE__EE_System__initialize' ); |
|
1100 | + do_action('AHEE__EE_System__initialize'); |
|
1101 | 1101 | // EE_Cron_Tasks::check_for_abandoned_transactions( 802 ); |
1102 | 1102 | } |
1103 | 1103 | |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * @return void |
1113 | 1113 | */ |
1114 | 1114 | public function initialize_last() { |
1115 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
1115 | + do_action('AHEE__EE_System__initialize_last'); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | |
@@ -1144,21 +1144,21 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public static function do_not_cache() { |
1146 | 1146 | // set no cache constants |
1147 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
1148 | - define( 'DONOTCACHEPAGE', true ); |
|
1147 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
1148 | + define('DONOTCACHEPAGE', true); |
|
1149 | 1149 | } |
1150 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
1151 | - define( 'DONOTCACHCEOBJECT', true ); |
|
1150 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
1151 | + define('DONOTCACHCEOBJECT', true); |
|
1152 | 1152 | } |
1153 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
1154 | - define( 'DONOTCACHEDB', true ); |
|
1153 | + if ( ! defined('DONOTCACHEDB')) { |
|
1154 | + define('DONOTCACHEDB', true); |
|
1155 | 1155 | } |
1156 | 1156 | // add no cache headers |
1157 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
1157 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1158 | 1158 | // plus a little extra for nginx |
1159 | - add_filter( 'nocache_headers', array( 'EE_System', 'nocache_headers_nginx' ), 10, 1 ); |
|
1159 | + add_filter('nocache_headers', array('EE_System', 'nocache_headers_nginx'), 10, 1); |
|
1160 | 1160 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
1161 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
1161 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | * @param $headers |
1171 | 1171 | * @return array |
1172 | 1172 | */ |
1173 | - public static function nocache_headers_nginx ( $headers ) { |
|
1173 | + public static function nocache_headers_nginx($headers) { |
|
1174 | 1174 | $headers['X-Accel-Expires'] = 0; |
1175 | 1175 | return $headers; |
1176 | 1176 | } |
@@ -1196,15 +1196,15 @@ discard block |
||
1196 | 1196 | * @param $admin_bar |
1197 | 1197 | * @return void |
1198 | 1198 | */ |
1199 | - public function espresso_toolbar_items( $admin_bar ) { |
|
1199 | + public function espresso_toolbar_items($admin_bar) { |
|
1200 | 1200 | |
1201 | 1201 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
1202 | - 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' )) { |
|
1202 | + 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')) { |
|
1203 | 1203 | return; |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1207 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1206 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1207 | + EE_Registry::instance()->load_helper('URL'); |
|
1208 | 1208 | $menu_class = 'espresso_menu_item_class'; |
1209 | 1209 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
1210 | 1210 | //because they're only defined in each of their respective constructors |
@@ -1215,20 +1215,20 @@ discard block |
||
1215 | 1215 | //Top Level |
1216 | 1216 | $admin_bar->add_menu(array( |
1217 | 1217 | 'id' => 'espresso-toolbar', |
1218 | - '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>', |
|
1218 | + '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>', |
|
1219 | 1219 | 'href' => $events_admin_url, |
1220 | 1220 | 'meta' => array( |
1221 | 1221 | 'title' => __('Event Espresso', 'event_espresso'), |
1222 | - 'class' => $menu_class . 'first' |
|
1222 | + 'class' => $menu_class.'first' |
|
1223 | 1223 | ), |
1224 | 1224 | )); |
1225 | 1225 | |
1226 | 1226 | //Events |
1227 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
1227 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1228 | 1228 | $admin_bar->add_menu(array( |
1229 | 1229 | 'id' => 'espresso-toolbar-events', |
1230 | 1230 | 'parent' => 'espresso-toolbar', |
1231 | - 'title' => __( 'Events', 'event_espresso' ), |
|
1231 | + 'title' => __('Events', 'event_espresso'), |
|
1232 | 1232 | 'href' => $events_admin_url, |
1233 | 1233 | 'meta' => array( |
1234 | 1234 | 'title' => __('Events', 'event_espresso'), |
@@ -1239,13 +1239,13 @@ discard block |
||
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | |
1242 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
1242 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1243 | 1243 | //Events Add New |
1244 | 1244 | $admin_bar->add_menu(array( |
1245 | 1245 | 'id' => 'espresso-toolbar-events-new', |
1246 | 1246 | 'parent' => 'espresso-toolbar-events', |
1247 | 1247 | 'title' => __('Add New', 'event_espresso'), |
1248 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
1248 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
1249 | 1249 | 'meta' => array( |
1250 | 1250 | 'title' => __('Add New', 'event_espresso'), |
1251 | 1251 | 'target' => '', |
@@ -1255,11 +1255,11 @@ discard block |
||
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | //Events View |
1258 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
1258 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
1259 | 1259 | $admin_bar->add_menu(array( |
1260 | 1260 | 'id' => 'espresso-toolbar-events-view', |
1261 | 1261 | 'parent' => 'espresso-toolbar-events', |
1262 | - 'title' => __( 'View', 'event_espresso' ), |
|
1262 | + 'title' => __('View', 'event_espresso'), |
|
1263 | 1263 | 'href' => $events_admin_url, |
1264 | 1264 | 'meta' => array( |
1265 | 1265 | 'title' => __('View', 'event_espresso'), |
@@ -1269,12 +1269,12 @@ discard block |
||
1269 | 1269 | )); |
1270 | 1270 | } |
1271 | 1271 | |
1272 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1272 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1273 | 1273 | //Events View All |
1274 | 1274 | $admin_bar->add_menu(array( |
1275 | 1275 | 'id' => 'espresso-toolbar-events-all', |
1276 | 1276 | 'parent' => 'espresso-toolbar-events-view', |
1277 | - 'title' => __( 'All', 'event_espresso' ), |
|
1277 | + 'title' => __('All', 'event_espresso'), |
|
1278 | 1278 | 'href' => $events_admin_url, |
1279 | 1279 | 'meta' => array( |
1280 | 1280 | 'title' => __('All', 'event_espresso'), |
@@ -1285,13 +1285,13 @@ discard block |
||
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | |
1288 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1288 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1289 | 1289 | //Events View Today |
1290 | 1290 | $admin_bar->add_menu(array( |
1291 | 1291 | 'id' => 'espresso-toolbar-events-today', |
1292 | 1292 | 'parent' => 'espresso-toolbar-events-view', |
1293 | 1293 | 'title' => __('Today', 'event_espresso'), |
1294 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1294 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1295 | 1295 | 'meta' => array( |
1296 | 1296 | 'title' => __('Today', 'event_espresso'), |
1297 | 1297 | 'target' => '', |
@@ -1301,13 +1301,13 @@ discard block |
||
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | |
1304 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1304 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1305 | 1305 | //Events View This Month |
1306 | 1306 | $admin_bar->add_menu(array( |
1307 | 1307 | 'id' => 'espresso-toolbar-events-month', |
1308 | 1308 | 'parent' => 'espresso-toolbar-events-view', |
1309 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1310 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1309 | + 'title' => __('This Month', 'event_espresso'), |
|
1310 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1311 | 1311 | 'meta' => array( |
1312 | 1312 | 'title' => __('This Month', 'event_espresso'), |
1313 | 1313 | 'target' => '', |
@@ -1317,11 +1317,11 @@ discard block |
||
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | //Registration Overview |
1320 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1320 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1321 | 1321 | $admin_bar->add_menu(array( |
1322 | 1322 | 'id' => 'espresso-toolbar-registrations', |
1323 | 1323 | 'parent' => 'espresso-toolbar', |
1324 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1324 | + 'title' => __('Registrations', 'event_espresso'), |
|
1325 | 1325 | 'href' => $reg_admin_url, |
1326 | 1326 | 'meta' => array( |
1327 | 1327 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1332,12 +1332,12 @@ discard block |
||
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | //Registration Overview Today |
1335 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1335 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1336 | 1336 | $admin_bar->add_menu(array( |
1337 | 1337 | 'id' => 'espresso-toolbar-registrations-today', |
1338 | 1338 | 'parent' => 'espresso-toolbar-registrations', |
1339 | - 'title' => __( 'Today', 'event_espresso'), |
|
1340 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1339 | + 'title' => __('Today', 'event_espresso'), |
|
1340 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1341 | 1341 | 'meta' => array( |
1342 | 1342 | 'title' => __('Today', 'event_espresso'), |
1343 | 1343 | 'target' => '', |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | //Registration Overview Today Completed |
1350 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1350 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1351 | 1351 | $admin_bar->add_menu(array( |
1352 | 1352 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1353 | 1353 | 'parent' => 'espresso-toolbar-registrations-today', |
1354 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1355 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1354 | + 'title' => __('Approved', 'event_espresso'), |
|
1355 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1356 | 1356 | 'meta' => array( |
1357 | - 'title' => __('Approved', 'event_espresso' ), |
|
1357 | + 'title' => __('Approved', 'event_espresso'), |
|
1358 | 1358 | 'target' => '', |
1359 | 1359 | 'class' => $menu_class |
1360 | 1360 | ), |
@@ -1362,14 +1362,14 @@ discard block |
||
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | //Registration Overview Today Pending\ |
1365 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1365 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1366 | 1366 | $admin_bar->add_menu(array( |
1367 | 1367 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1368 | 1368 | 'parent' => 'espresso-toolbar-registrations-today', |
1369 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1370 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1369 | + 'title' => __('Pending', 'event_espresso'), |
|
1370 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1371 | 1371 | 'meta' => array( |
1372 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1372 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1373 | 1373 | 'target' => '', |
1374 | 1374 | 'class' => $menu_class |
1375 | 1375 | ), |
@@ -1377,14 +1377,14 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | //Registration Overview Today Incomplete |
1380 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1380 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1381 | 1381 | $admin_bar->add_menu(array( |
1382 | 1382 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1383 | 1383 | 'parent' => 'espresso-toolbar-registrations-today', |
1384 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1385 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1384 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1385 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1386 | 1386 | 'meta' => array( |
1387 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1387 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1388 | 1388 | 'target' => '', |
1389 | 1389 | 'class' => $menu_class |
1390 | 1390 | ), |
@@ -1392,12 +1392,12 @@ discard block |
||
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | //Registration Overview Today Incomplete |
1395 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1395 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1396 | 1396 | $admin_bar->add_menu(array( |
1397 | 1397 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1398 | 1398 | 'parent' => 'espresso-toolbar-registrations-today', |
1399 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1400 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1399 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1400 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1401 | 1401 | 'meta' => array( |
1402 | 1402 | 'title' => __('Cancelled', 'event_espresso'), |
1403 | 1403 | 'target' => '', |
@@ -1407,12 +1407,12 @@ discard block |
||
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | //Registration Overview This Month |
1410 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1410 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1411 | 1411 | $admin_bar->add_menu(array( |
1412 | 1412 | 'id' => 'espresso-toolbar-registrations-month', |
1413 | 1413 | 'parent' => 'espresso-toolbar-registrations', |
1414 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1415 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1414 | + 'title' => __('This Month', 'event_espresso'), |
|
1415 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1416 | 1416 | 'meta' => array( |
1417 | 1417 | 'title' => __('This Month', 'event_espresso'), |
1418 | 1418 | 'target' => '', |
@@ -1422,12 +1422,12 @@ discard block |
||
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | //Registration Overview This Month Approved |
1425 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1425 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1426 | 1426 | $admin_bar->add_menu(array( |
1427 | 1427 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1428 | 1428 | 'parent' => 'espresso-toolbar-registrations-month', |
1429 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1430 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1429 | + 'title' => __('Approved', 'event_espresso'), |
|
1430 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1431 | 1431 | 'meta' => array( |
1432 | 1432 | 'title' => __('Approved', 'event_espresso'), |
1433 | 1433 | 'target' => '', |
@@ -1437,12 +1437,12 @@ discard block |
||
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | //Registration Overview This Month Pending |
1440 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1440 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1441 | 1441 | $admin_bar->add_menu(array( |
1442 | 1442 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1443 | 1443 | 'parent' => 'espresso-toolbar-registrations-month', |
1444 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1445 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1444 | + 'title' => __('Pending', 'event_espresso'), |
|
1445 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1446 | 1446 | 'meta' => array( |
1447 | 1447 | 'title' => __('Pending', 'event_espresso'), |
1448 | 1448 | 'target' => '', |
@@ -1452,14 +1452,14 @@ discard block |
||
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | //Registration Overview This Month Not Approved |
1455 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1455 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1456 | 1456 | $admin_bar->add_menu(array( |
1457 | 1457 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1458 | 1458 | 'parent' => 'espresso-toolbar-registrations-month', |
1459 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1460 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1459 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1460 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1461 | 1461 | 'meta' => array( |
1462 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1462 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1463 | 1463 | 'target' => '', |
1464 | 1464 | 'class' => $menu_class |
1465 | 1465 | ), |
@@ -1468,12 +1468,12 @@ discard block |
||
1468 | 1468 | |
1469 | 1469 | |
1470 | 1470 | //Registration Overview This Month Cancelled |
1471 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1471 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1472 | 1472 | $admin_bar->add_menu(array( |
1473 | 1473 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1474 | 1474 | 'parent' => 'espresso-toolbar-registrations-month', |
1475 | 1475 | 'title' => __('Cancelled', 'event_espresso'), |
1476 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1476 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1477 | 1477 | 'meta' => array( |
1478 | 1478 | 'title' => __('Cancelled', 'event_espresso'), |
1479 | 1479 | 'target' => '', |
@@ -1494,8 +1494,8 @@ discard block |
||
1494 | 1494 | * @param array $exclude_array any existing pages being excluded are in this array. |
1495 | 1495 | * @return array |
1496 | 1496 | */ |
1497 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1498 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1497 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1498 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | |
@@ -1515,11 +1515,11 @@ discard block |
||
1515 | 1515 | */ |
1516 | 1516 | public function wp_enqueue_scripts() { |
1517 | 1517 | // 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' ); |
1518 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1518 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1519 | 1519 | // 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' ); |
1520 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1520 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1521 | 1521 | // register jQuery Validate |
1522 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE ); |
|
1522 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
1523 | 1523 | } |
1524 | 1524 | } |
1525 | 1525 | } |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | |
469 | 469 | |
470 | 470 | /** |
471 | - * load_espresso_addons |
|
472 | - * |
|
473 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
474 | - * |
|
475 | - * @access public |
|
476 | - * @return void |
|
477 | - */ |
|
471 | + * load_espresso_addons |
|
472 | + * |
|
473 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
474 | + * |
|
475 | + * @access public |
|
476 | + * @return void |
|
477 | + */ |
|
478 | 478 | public function load_espresso_addons() { |
479 | 479 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
480 | 480 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | } |
499 | 499 | } |
500 | 500 | /** |
501 | - * detect_if_activation_or_upgrade |
|
502 | - * |
|
503 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
504 | - * and either setting up the DB or setting up maintenance mode etc. |
|
505 | - * |
|
506 | - * @access private |
|
507 | - * @return void |
|
508 | - */ |
|
501 | + * detect_if_activation_or_upgrade |
|
502 | + * |
|
503 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
504 | + * and either setting up the DB or setting up maintenance mode etc. |
|
505 | + * |
|
506 | + * @access private |
|
507 | + * @return void |
|
508 | + */ |
|
509 | 509 | public function detect_if_activation_or_upgrade() { |
510 | 510 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
511 | 511 | |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | $query_params = array( 'page' => 'espresso_about' ); |
804 | 804 | |
805 | 805 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
806 | - $query_params['new_activation'] = TRUE; |
|
806 | + $query_params['new_activation'] = TRUE; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
810 | - $query_params['reactivation'] = TRUE; |
|
810 | + $query_params['reactivation'] = TRUE; |
|
811 | 811 | } |
812 | 812 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
813 | 813 | wp_safe_redirect( $url ); |
@@ -888,13 +888,13 @@ discard block |
||
888 | 888 | |
889 | 889 | |
890 | 890 | /** |
891 | - * register_shortcodes_modules_and_widgets |
|
892 | - * |
|
893 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
894 | - * |
|
895 | - * @access public |
|
896 | - * @return void |
|
897 | - */ |
|
891 | + * register_shortcodes_modules_and_widgets |
|
892 | + * |
|
893 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
894 | + * |
|
895 | + * @access public |
|
896 | + * @return void |
|
897 | + */ |
|
898 | 898 | public function register_shortcodes_modules_and_widgets() { |
899 | 899 | do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
900 | 900 | // check for addons using old hookpoint |
@@ -905,11 +905,11 @@ discard block |
||
905 | 905 | |
906 | 906 | |
907 | 907 | /** |
908 | - * _incompatible_addon_error |
|
909 | - * |
|
910 | - * @access public |
|
911 | - * @return void |
|
912 | - */ |
|
908 | + * _incompatible_addon_error |
|
909 | + * |
|
910 | + * @access public |
|
911 | + * @return void |
|
912 | + */ |
|
913 | 913 | private function _incompatible_addon_error() { |
914 | 914 | // get array of classes hooking into here |
915 | 915 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -1048,14 +1048,14 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | |
1050 | 1050 | /** |
1051 | - * load_controllers |
|
1052 | - * |
|
1053 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
1054 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
1055 | - * |
|
1056 | - * @access public |
|
1057 | - * @return void |
|
1058 | - */ |
|
1051 | + * load_controllers |
|
1052 | + * |
|
1053 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
1054 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
1055 | + * |
|
1056 | + * @access public |
|
1057 | + * @return void |
|
1058 | + */ |
|
1059 | 1059 | public function load_controllers() { |
1060 | 1060 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
1061 | 1061 | // let's get it started |
@@ -1072,13 +1072,13 @@ discard block |
||
1072 | 1072 | |
1073 | 1073 | |
1074 | 1074 | /** |
1075 | - * core_loaded_and_ready |
|
1076 | - * |
|
1077 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1078 | - * |
|
1079 | - * @access public |
|
1080 | - * @return void |
|
1081 | - */ |
|
1075 | + * core_loaded_and_ready |
|
1076 | + * |
|
1077 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1078 | + * |
|
1079 | + * @access public |
|
1080 | + * @return void |
|
1081 | + */ |
|
1082 | 1082 | public function core_loaded_and_ready() { |
1083 | 1083 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
1084 | 1084 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -1089,13 +1089,13 @@ discard block |
||
1089 | 1089 | |
1090 | 1090 | |
1091 | 1091 | /** |
1092 | - * initialize |
|
1093 | - * |
|
1094 | - * this is the best place to begin initializing client code |
|
1095 | - * |
|
1096 | - * @access public |
|
1097 | - * @return void |
|
1098 | - */ |
|
1092 | + * initialize |
|
1093 | + * |
|
1094 | + * this is the best place to begin initializing client code |
|
1095 | + * |
|
1096 | + * @access public |
|
1097 | + * @return void |
|
1098 | + */ |
|
1099 | 1099 | public function initialize() { |
1100 | 1100 | do_action( 'AHEE__EE_System__initialize' ); |
1101 | 1101 | // EE_Cron_Tasks::check_for_abandoned_transactions( 802 ); |
@@ -1104,13 +1104,13 @@ discard block |
||
1104 | 1104 | |
1105 | 1105 | |
1106 | 1106 | /** |
1107 | - * initialize_last |
|
1108 | - * |
|
1109 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
1110 | - * |
|
1111 | - * @access public |
|
1112 | - * @return void |
|
1113 | - */ |
|
1107 | + * initialize_last |
|
1108 | + * |
|
1109 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
1110 | + * |
|
1111 | + * @access public |
|
1112 | + * @return void |
|
1113 | + */ |
|
1114 | 1114 | public function initialize_last() { |
1115 | 1115 | do_action( 'AHEE__EE_System__initialize_last' ); |
1116 | 1116 | } |
@@ -1119,14 +1119,14 @@ discard block |
||
1119 | 1119 | |
1120 | 1120 | |
1121 | 1121 | /** |
1122 | - * set_hooks_for_shortcodes_modules_and_addons |
|
1123 | - * |
|
1124 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
1125 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
1126 | - * |
|
1127 | - * @access public |
|
1128 | - * @return void |
|
1129 | - */ |
|
1122 | + * set_hooks_for_shortcodes_modules_and_addons |
|
1123 | + * |
|
1124 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
1125 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
1126 | + * |
|
1127 | + * @access public |
|
1128 | + * @return void |
|
1129 | + */ |
|
1130 | 1130 | public function set_hooks_for_shortcodes_modules_and_addons() { |
1131 | 1131 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
1132 | 1132 | } |
@@ -1135,13 +1135,13 @@ discard block |
||
1135 | 1135 | |
1136 | 1136 | |
1137 | 1137 | /** |
1138 | - * do_not_cache |
|
1139 | - * |
|
1140 | - * sets no cache headers and defines no cache constants for WP plugins |
|
1141 | - * |
|
1142 | - * @access public |
|
1143 | - * @return void |
|
1144 | - */ |
|
1138 | + * do_not_cache |
|
1139 | + * |
|
1140 | + * sets no cache headers and defines no cache constants for WP plugins |
|
1141 | + * |
|
1142 | + * @access public |
|
1143 | + * @return void |
|
1144 | + */ |
|
1145 | 1145 | public static function do_not_cache() { |
1146 | 1146 | // set no cache constants |
1147 | 1147 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -204,7 +204,7 @@ |
||
204 | 204 | * |
205 | 205 | * @access private |
206 | 206 | * @param string $sort |
207 | - * @return array |
|
207 | + * @return string |
|
208 | 208 | */ |
209 | 209 | private static function _sort( $sort = 'ASC' ) { |
210 | 210 | $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function add_query_filters() { |
87 | 87 | //add query filters |
88 | - add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 ); |
|
88 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param \WP_Query $WP_Query |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - public static function apply_query_filters( WP_Query $WP_Query ) { |
|
101 | - return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) || apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false; |
|
100 | + public static function apply_query_filters(WP_Query $WP_Query) { |
|
101 | + return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * @access public |
109 | 109 | * @param \WP_Query $WP_Query |
110 | 110 | */ |
111 | - public static function filter_query_parts( WP_Query $WP_Query ) { |
|
111 | + public static function filter_query_parts(WP_Query $WP_Query) { |
|
112 | 112 | //ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in. |
113 | - if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) { |
|
113 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
114 | 114 | // build event list query |
115 | - add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 ); |
|
116 | - add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 ); |
|
117 | - add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 ); |
|
118 | - add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 ); |
|
119 | - add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 ); |
|
115 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
116 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
117 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
118 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
119 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param string $orderby |
132 | 132 | * @param string $sort |
133 | 133 | */ |
134 | - public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) { |
|
134 | + public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') { |
|
135 | 135 | self::$_query_params = array(); |
136 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month ); |
|
137 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category ); |
|
138 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired ); |
|
139 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby ); |
|
140 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort ); |
|
136 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
137 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
138 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
139 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
140 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param string $month |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - private static function _display_month( $month = '' ) { |
|
153 | - return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month; |
|
152 | + private static function _display_month($month = '') { |
|
153 | + return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @param string $category |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - private static function _event_category_slug( $category = '' ) { |
|
166 | - return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category; |
|
165 | + private static function _event_category_slug($category = '') { |
|
166 | + return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @param bool $show_expired |
176 | 176 | * @return boolean |
177 | 177 | */ |
178 | - private static function _show_expired( $show_expired = FALSE ) { |
|
178 | + private static function _show_expired($show_expired = FALSE) { |
|
179 | 179 | // override default expired option if set via filter |
180 | - $_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired; |
|
181 | - return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN ); |
|
180 | + $_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired; |
|
181 | + return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * @param string $orderby |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - private static function _orderby( $orderby = 'start_date' ) { |
|
194 | - $event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby; |
|
195 | - $event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby ); |
|
196 | - $event_query_orderby = array_map( 'trim', $event_query_orderby ); |
|
193 | + private static function _orderby($orderby = 'start_date') { |
|
194 | + $event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby; |
|
195 | + $event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby); |
|
196 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
197 | 197 | return $event_query_orderby; |
198 | 198 | } |
199 | 199 | |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | * @param string $sort |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - private static function _sort( $sort = 'ASC' ) { |
|
210 | - $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
|
211 | - return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC'; |
|
209 | + private static function _sort($sort = 'ASC') { |
|
210 | + $sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort; |
|
211 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array array of clauses |
223 | 223 | */ |
224 | - public static function posts_clauses( $clauses, WP_Query $wp_query ) { |
|
225 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
224 | + public static function posts_clauses($clauses, WP_Query $wp_query) { |
|
225 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
226 | 226 | $clauses['distinct'] = "DISTINCT"; |
227 | 227 | } |
228 | 228 | return $clauses; |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | * @param WP_Query $wp_query |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - public static function posts_fields( $SQL, WP_Query $wp_query ) { |
|
242 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
241 | + public static function posts_fields($SQL, WP_Query $wp_query) { |
|
242 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
243 | 243 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
244 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby ); |
|
244 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
245 | 245 | } |
246 | 246 | return $SQL; |
247 | 247 | } |
@@ -256,29 +256,29 @@ discard block |
||
256 | 256 | * @internal param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
260 | - $SQL= ''; |
|
261 | - foreach( (array)$orderby_params as $orderby ) { |
|
262 | - switch ( $orderby ) { |
|
259 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
260 | + $SQL = ''; |
|
261 | + foreach ((array) $orderby_params as $orderby) { |
|
262 | + switch ($orderby) { |
|
263 | 263 | |
264 | 264 | case 'ticket_start' : |
265 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ; |
|
265 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'ticket_end' : |
269 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ; |
|
269 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case 'venue_title' : |
273 | - $SQL .= ', Venue.post_title AS venue_title' ; |
|
273 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
274 | 274 | break; |
275 | 275 | |
276 | 276 | case 'city' : |
277 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ; |
|
277 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
278 | 278 | break; |
279 | 279 | |
280 | 280 | case 'state' : |
281 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ; |
|
281 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * @param WP_Query $wp_query |
297 | 297 | * @return string |
298 | 298 | */ |
299 | - public static function posts_join( $SQL = '', WP_Query $wp_query ) { |
|
300 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
299 | + public static function posts_join($SQL = '', WP_Query $wp_query) { |
|
300 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
301 | 301 | // Category |
302 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired ); |
|
303 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category ); |
|
304 | - $SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby ); |
|
302 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
303 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
304 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
305 | 305 | } |
306 | 306 | return $SQL; |
307 | 307 | } |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | * @param boolean $show_expired if TRUE, then displayed past events |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) { |
|
320 | - if ( ! $show_expired ) { |
|
321 | - $join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
322 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
323 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
319 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) { |
|
320 | + if ( ! $show_expired) { |
|
321 | + $join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
322 | + if (strpos($SQL, $join) === FALSE) { |
|
323 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | return $SQL; |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) { |
|
340 | - if ( ! empty( $join_terms ) ) { |
|
339 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') { |
|
340 | + if ( ! empty($join_terms)) { |
|
341 | 341 | global $wpdb; |
342 | 342 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
343 | 343 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -357,25 +357,25 @@ discard block |
||
357 | 357 | * @param array $orderby_params |
358 | 358 | * @return string |
359 | 359 | */ |
360 | - public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) { |
|
361 | - foreach ( (array)$orderby_params as $orderby ) { |
|
362 | - switch ( $orderby ) { |
|
360 | + public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) { |
|
361 | + foreach ((array) $orderby_params as $orderby) { |
|
362 | + switch ($orderby) { |
|
363 | 363 | case 'ticket_start' : |
364 | 364 | case 'ticket_end' : |
365 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() ); |
|
366 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )'; |
|
365 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name()); |
|
366 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )'; |
|
367 | 367 | break; |
368 | 368 | case 'venue_title' : |
369 | 369 | case 'city' : |
370 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
370 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
371 | 371 | break; |
372 | 372 | case 'state' : |
373 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
374 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL ); |
|
373 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
374 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
375 | 375 | break; |
376 | 376 | case 'start_date' : |
377 | 377 | default : |
378 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' ); |
|
378 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
379 | 379 | break; |
380 | 380 | |
381 | 381 | } |
@@ -393,11 +393,11 @@ discard block |
||
393 | 393 | * @param string $join |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) { |
|
397 | - if ( ! empty( $join )) { |
|
398 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
399 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
400 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
396 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') { |
|
397 | + if ( ! empty($join)) { |
|
398 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
399 | + if (strpos($SQL, $join) === FALSE) { |
|
400 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | return ''; |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @param string $SQL |
413 | 413 | * @return string |
414 | 414 | */ |
415 | - protected static function _posts_join_for_event_venue( $SQL = '' ) { |
|
415 | + protected static function _posts_join_for_event_venue($SQL = '') { |
|
416 | 416 | // Event Venue table name |
417 | 417 | $event_venue_table = EEM_Event_Venue::instance()->table(); |
418 | 418 | // generate conditions for: Event <=> Event Venue JOIN clause |
419 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
419 | + $event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name(); |
|
420 | 420 | // don't add joins if they have already been added |
421 | - if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) { |
|
421 | + if (strpos($SQL, $event_to_event_venue_join) === FALSE) { |
|
422 | 422 | // Venue table name |
423 | 423 | $venue_table = EEM_Venue::instance()->table(); |
424 | 424 | // Venue table pk |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
432 | 432 | // generate JOIN clause for: Venue <=> Venue Meta |
433 | 433 | $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
434 | - unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table ); |
|
434 | + unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
435 | 435 | return $venue_SQL; |
436 | 436 | } |
437 | - unset( $event_venue_table, $event_to_event_venue_join ); |
|
437 | + unset($event_venue_table, $event_to_event_venue_join); |
|
438 | 438 | return ''; |
439 | 439 | } |
440 | 440 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param string $SQL |
448 | 448 | * @return string |
449 | 449 | */ |
450 | - protected static function _posts_join_for_venue_state( $SQL = '' ) { |
|
450 | + protected static function _posts_join_for_venue_state($SQL = '') { |
|
451 | 451 | // Venue Meta table name |
452 | 452 | $venue_meta_table = EEM_Venue::instance()->second_table(); |
453 | 453 | // State table name |
@@ -455,16 +455,16 @@ discard block |
||
455 | 455 | // State table pk |
456 | 456 | $state_table_pk = EEM_State::instance()->primary_key_name(); |
457 | 457 | // verify vars |
458 | - if ( $venue_meta_table && $state_table && $state_table_pk ) { |
|
458 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
459 | 459 | // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
460 | 460 | $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
461 | 461 | // don't add join if it has already been added |
462 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
463 | - unset( $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
462 | + if (strpos($SQL, $join) === FALSE) { |
|
463 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
464 | 464 | return " LEFT JOIN $state_table ON ( $join )"; |
465 | 465 | } |
466 | 466 | } |
467 | - unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
467 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
468 | 468 | return ''; |
469 | 469 | } |
470 | 470 | |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | * @param WP_Query $wp_query |
479 | 479 | * @return string |
480 | 480 | */ |
481 | - public static function posts_where( $SQL = '', WP_Query $wp_query ) { |
|
482 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
481 | + public static function posts_where($SQL = '', WP_Query $wp_query) { |
|
482 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
483 | 483 | // Show Expired ? |
484 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired ); |
|
484 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
485 | 485 | // Category |
486 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category ); |
|
486 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
487 | 487 | // Start Date |
488 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month ); |
|
488 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
489 | 489 | } |
490 | 490 | return $SQL; |
491 | 491 | } |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param boolean $show_expired if TRUE, then displayed past events |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
503 | - return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : ''; |
|
502 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
503 | + return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : ''; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | * @param boolean $event_category_slug |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
515 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
516 | 516 | global $wpdb; |
517 | - return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
517 | + return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : ''; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | * @param boolean $month |
527 | 527 | * @return string |
528 | 528 | */ |
529 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
529 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
530 | 530 | $SQL = ''; |
531 | - if ( ! empty( $month ) ) { |
|
531 | + if ( ! empty($month)) { |
|
532 | 532 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
533 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"'; |
|
533 | + $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.gmdate('Y-m-t 23:59:59', strtotime($month)).'"'; |
|
534 | 534 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
535 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" '; |
|
535 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.gmdate('Y-m-01 0:0:00', strtotime($month)).'" '; |
|
536 | 536 | } |
537 | 537 | return $SQL; |
538 | 538 | } |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | * @param WP_Query $wp_query |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - public static function posts_orderby( $SQL = '', WP_Query $wp_query ) { |
|
551 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
552 | - $SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort ); |
|
550 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) { |
|
551 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
552 | + $SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort); |
|
553 | 553 | } |
554 | 554 | return $SQL; |
555 | 555 | } |
@@ -580,63 +580,63 @@ discard block |
||
580 | 580 | * @param string $sort |
581 | 581 | * @return string |
582 | 582 | */ |
583 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
583 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
584 | 584 | global $wpdb; |
585 | 585 | $SQL = ''; |
586 | 586 | $counter = 0; |
587 | 587 | //make sure 'orderby' is set in query params |
588 | - if ( ! isset( self::$_query_params['orderby'] )) { |
|
588 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
589 | 589 | self::$_query_params['orderby'] = array(); |
590 | 590 | } |
591 | 591 | // loop thru $orderby_params (type cast as array) |
592 | - foreach ( (array)$orderby_params as $orderby ) { |
|
592 | + foreach ((array) $orderby_params as $orderby) { |
|
593 | 593 | // check if we have already added this param |
594 | - if ( isset( self::$_query_params['orderby'][ $orderby ] )) { |
|
594 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
595 | 595 | // if so then remove from the $orderby_params so that the count() method below is accurate |
596 | - unset( $orderby_params[ $orderby ] ); |
|
596 | + unset($orderby_params[$orderby]); |
|
597 | 597 | // then bump ahead to the next param |
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | // this will ad a comma depending on whether this is the first or last param |
601 | - $glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', '; |
|
601 | + $glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', '; |
|
602 | 602 | // ok what's we dealing with? |
603 | - switch ( $orderby ) { |
|
603 | + switch ($orderby) { |
|
604 | 604 | case 'id' : |
605 | 605 | case 'ID' : |
606 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
606 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
607 | 607 | break; |
608 | 608 | case 'end_date' : |
609 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
609 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
610 | 610 | break; |
611 | 611 | case 'event_name' : |
612 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
612 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
613 | 613 | break; |
614 | 614 | case 'category_slug' : |
615 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
615 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
616 | 616 | break; |
617 | 617 | case 'ticket_start' : |
618 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
618 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
619 | 619 | break; |
620 | 620 | case 'ticket_end' : |
621 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
621 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
622 | 622 | break; |
623 | 623 | case 'venue_title' : |
624 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
624 | + $SQL .= $glue.'venue_title '.$sort; |
|
625 | 625 | break; |
626 | 626 | case 'city' : |
627 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
627 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
628 | 628 | break; |
629 | 629 | case 'state' : |
630 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
630 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
631 | 631 | break; |
632 | 632 | case 'start_date' : |
633 | 633 | default : |
634 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort; |
|
634 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort; |
|
635 | 635 | break; |
636 | 636 | } |
637 | 637 | // add to array of orderby params that have been added |
638 | - self::$_query_params['orderby'][ $orderby ] = TRUE; |
|
639 | - $counter ++; |
|
638 | + self::$_query_params['orderby'][$orderby] = TRUE; |
|
639 | + $counter++; |
|
640 | 640 | } |
641 | 641 | return $SQL; |
642 | 642 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @access public |
118 | 118 | * @param int $EVT_ID |
119 | - * @return string |
|
119 | + * @return boolean |
|
120 | 120 | */ |
121 | 121 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
122 | 122 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * event_active_status |
137 | 137 | * |
138 | 138 | * @access public |
139 | - * @param null $num_words |
|
139 | + * @param integer $num_words |
|
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @access public |
324 | 324 | * @param int $EVT_ID |
325 | - * @return string |
|
325 | + * @return string|null |
|
326 | 326 | */ |
327 | 327 | public static function get_primary_date_obj( $EVT_ID = 0 ) { |
328 | 328 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @access public |
349 | 349 | * @param int $EVT_ID |
350 | - * @return string |
|
350 | + * @return string|null |
|
351 | 351 | */ |
352 | 352 | public static function get_last_date_obj( $EVT_ID = 0 ) { |
353 | 353 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @access public |
374 | 374 | * @param int $EVT_ID |
375 | - * @return string |
|
375 | + * @return string|null |
|
376 | 376 | */ |
377 | 377 | public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
378 | 378 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @access public |
424 | 424 | * @param int $EVT_ID |
425 | - * @param null $include_expired |
|
425 | + * @param false|null $include_expired |
|
426 | 426 | * @param bool $include_deleted |
427 | 427 | * @param null $limit |
428 | 428 | * @return EE_Datetime[] |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | * @param int $EVT_ID |
41 | 41 | * @return object |
42 | 42 | */ |
43 | - public static function get_event( $EVT_ID = 0 ) { |
|
44 | - $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
|
43 | + public static function get_event($EVT_ID = 0) { |
|
44 | + $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID); |
|
45 | 45 | // do we already have the Event you are looking for? |
46 | - if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) { |
|
46 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
47 | 47 | return EEH_Event_View::$_event; |
48 | 48 | } |
49 | 49 | EEH_Event_View::$_event = NULL; |
50 | 50 | // international newspaper? |
51 | 51 | global $post; |
52 | 52 | // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object |
53 | - if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) { |
|
53 | + if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) { |
|
54 | 54 | // d( $post ); |
55 | 55 | // grab the event we're looking for |
56 | - if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) { |
|
56 | + if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) { |
|
57 | 57 | EEH_Event_View::$_event = $post->EE_Event; |
58 | 58 | // d( EEH_Event_View::$_event ); |
59 | 59 | } |
60 | 60 | // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID... |
61 | - if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) { |
|
61 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
62 | 62 | // sigh... pull it from the db |
63 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
63 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
64 | 64 | // d( EEH_Event_View::$_event ); |
65 | 65 | } |
66 | 66 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param int $EVT_ID |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
80 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
79 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
80 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
81 | 81 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
82 | 82 | } |
83 | 83 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param int $EVT_ID |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public static function event_status( $EVT_ID = 0 ) { |
|
94 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
95 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
93 | + public static function event_status($EVT_ID = 0) { |
|
94 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
95 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param int $EVT_ID |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
108 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
107 | + public static function event_active_status($EVT_ID = 0) { |
|
108 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
109 | 109 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
110 | 110 | } |
111 | 111 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param int $EVT_ID |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
122 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
121 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
122 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
123 | 123 | $has_content_or_excerpt = FALSE; |
124 | - if ( $event instanceof EE_Event ) { |
|
125 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
124 | + if ($event instanceof EE_Event) { |
|
125 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
126 | 126 | } |
127 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
127 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
128 | 128 | $has_content_or_excerpt = FALSE; |
129 | 129 | } |
130 | 130 | return $has_content_or_excerpt; |
@@ -140,39 +140,39 @@ discard block |
||
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
143 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
144 | 144 | |
145 | 145 | global $post; |
146 | 146 | $content = ''; |
147 | 147 | |
148 | 148 | ob_start(); |
149 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
149 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
150 | 150 | //echo '<h2 style="color:#E76700;">the_content<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; |
151 | 151 | the_content(); |
152 | - } else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) || apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', FALSE )) { |
|
152 | + } else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list()) || apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', FALSE)) { |
|
153 | 153 | //echo '<h2 style="color:#E76700;">the_excerpt<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; |
154 | 154 | the_excerpt(); |
155 | - } else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) { |
|
155 | + } else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
156 | 156 | //echo '<h2 style="color:#E76700;">get_the_content<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span><b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; |
157 | - if ( ! empty( $num_words )) { |
|
158 | - if ( empty( $more )) { |
|
159 | - $more = ' <a href="' . get_permalink() . '" class="more-link">' . __( '(more…)' ) . '</a>'; |
|
160 | - $more = apply_filters( 'the_content_more_link', $more ); |
|
157 | + if ( ! empty($num_words)) { |
|
158 | + if (empty($more)) { |
|
159 | + $more = ' <a href="'.get_permalink().'" class="more-link">'.__('(more…)').'</a>'; |
|
160 | + $more = apply_filters('the_content_more_link', $more); |
|
161 | 161 | } |
162 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
162 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
163 | 163 | |
164 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
164 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
165 | 165 | } else { |
166 | - $content = get_the_content(); |
|
166 | + $content = get_the_content(); |
|
167 | 167 | } |
168 | 168 | global $allowedtags; |
169 | - $content = wp_kses( $content, $allowedtags ); |
|
170 | - $content = strip_shortcodes( $content ); |
|
171 | - echo apply_filters( 'the_content', $content ); |
|
169 | + $content = wp_kses($content, $allowedtags); |
|
170 | + $content = strip_shortcodes($content); |
|
171 | + echo apply_filters('the_content', $content); |
|
172 | 172 | |
173 | 173 | } else { |
174 | 174 | //echo '<h2 style="color:#E76700;">nothing<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h2>'; |
175 | - echo apply_filters( 'the_content', $content ); |
|
175 | + echo apply_filters('the_content', $content); |
|
176 | 176 | } |
177 | 177 | return ob_get_clean(); |
178 | 178 | } |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | * @param int $EVT_ID |
187 | 187 | * @return EE_Ticket[] |
188 | 188 | */ |
189 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
190 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
189 | + public static function event_tickets_available($EVT_ID = 0) { |
|
190 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
191 | 191 | $tickets_available_for_purchase = array(); |
192 | - if( $event instanceof EE_Event ) { |
|
193 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
194 | - foreach( $datetimes as $datetime ) { |
|
195 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
192 | + if ($event instanceof EE_Event) { |
|
193 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
194 | + foreach ($datetimes as $datetime) { |
|
195 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | return $tickets_available_for_purchase; |
@@ -208,22 +208,22 @@ discard block |
||
208 | 208 | * @param bool $hide_uncategorized |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
211 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
212 | 212 | $category_links = array(); |
213 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
214 | - if ( $event instanceof EE_Event ) { |
|
215 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
216 | - if ( $event_categories ) { |
|
213 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
214 | + if ($event instanceof EE_Event) { |
|
215 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
216 | + if ($event_categories) { |
|
217 | 217 | // loop thru terms and create links |
218 | - foreach ( $event_categories as $term ) { |
|
219 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
220 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
221 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>'; |
|
218 | + foreach ($event_categories as $term) { |
|
219 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
220 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
221 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>'; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
226 | - return implode( ', ', $category_links ); |
|
226 | + return implode(', ', $category_links); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | * @param int $EVT_ID |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
241 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
242 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
243 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
240 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
241 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
242 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
243 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | * @param int $EVT_ID |
255 | 255 | * @return string |
256 | 256 | */ |
257 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
258 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
259 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
260 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
257 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
258 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
259 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
260 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | * @param int $EVT_ID |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
275 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
276 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
277 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
274 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
275 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
276 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
277 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param int $EVT_ID |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
292 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
293 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
294 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
291 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
292 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
293 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
294 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | * @param int $EVT_ID |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
307 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
308 | - if ( $datetime instanceof EE_Datetime ) { |
|
306 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
307 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
308 | + if ($datetime instanceof EE_Datetime) { |
|
309 | 309 | ?> |
310 | 310 | <div class="event-date-calendar-page-dv"> |
311 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
312 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
311 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
312 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
313 | 313 | </div> |
314 | 314 | <?php |
315 | 315 | } |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | * @param int $EVT_ID |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
328 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
329 | - if ( $event instanceof EE_Event ) { |
|
327 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
328 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
329 | + if ($event instanceof EE_Event) { |
|
330 | 330 | $datetimes = $event->get_many_related( |
331 | 331 | 'Datetime', |
332 | 332 | array( |
333 | 333 | 'limit' => 1, |
334 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
334 | + 'order_by' => array('DTT_order' => 'ASC') |
|
335 | 335 | ) |
336 | 336 | ); |
337 | - return reset( $datetimes ); |
|
337 | + return reset($datetimes); |
|
338 | 338 | } else { |
339 | 339 | return FALSE; |
340 | 340 | } |
@@ -349,17 +349,17 @@ discard block |
||
349 | 349 | * @param int $EVT_ID |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
353 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
354 | - if ( $event instanceof EE_Event ) { |
|
352 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
353 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
354 | + if ($event instanceof EE_Event) { |
|
355 | 355 | $datetimes = $event->get_many_related( |
356 | 356 | 'Datetime', |
357 | 357 | array( |
358 | 358 | 'limit' => 1, |
359 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
359 | + 'order_by' => array('DTT_order' => 'DESC') |
|
360 | 360 | ) |
361 | 361 | ); |
362 | - return end( $datetimes ); |
|
362 | + return end($datetimes); |
|
363 | 363 | } else { |
364 | 364 | return FALSE; |
365 | 365 | } |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | * @param int $EVT_ID |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
378 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
379 | - if ( $event instanceof EE_Event ) { |
|
377 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
378 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
379 | + if ($event instanceof EE_Event) { |
|
380 | 380 | $datetimes = $event->get_many_related( |
381 | 381 | 'Datetime', |
382 | 382 | array( |
383 | 383 | 'limit' => 1, |
384 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
384 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
385 | 385 | ) |
386 | 386 | ); |
387 | - return reset( $datetimes ); |
|
387 | + return reset($datetimes); |
|
388 | 388 | } else { |
389 | 389 | return FALSE; |
390 | 390 | } |
@@ -399,17 +399,17 @@ discard block |
||
399 | 399 | * @param int $EVT_ID |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
403 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
404 | - if ( $event instanceof EE_Event ) { |
|
402 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
403 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
404 | + if ($event instanceof EE_Event) { |
|
405 | 405 | $datetimes = $event->get_many_related( |
406 | 406 | 'Datetime', |
407 | 407 | array( |
408 | 408 | 'limit' => 1, |
409 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
409 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
410 | 410 | ) |
411 | 411 | ); |
412 | - return end( $datetimes ); |
|
412 | + return end($datetimes); |
|
413 | 413 | } else { |
414 | 414 | return FALSE; |
415 | 415 | } |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | * @param null $limit |
428 | 428 | * @return EE_Datetime[] |
429 | 429 | */ |
430 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
431 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
432 | - if($include_expired === null){ |
|
433 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
430 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
431 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
432 | + if ($include_expired === null) { |
|
433 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
434 | 434 | $include_expired = true; |
435 | - }else{ |
|
435 | + } else { |
|
436 | 436 | $include_expired = false; |
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | - if ( $event instanceof EE_Event ) { |
|
440 | + if ($event instanceof EE_Event) { |
|
441 | 441 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
442 | 442 | } else { |
443 | 443 | return array(); |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | * @param int $EVT_ID |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
457 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
458 | - if ( $event instanceof EE_Event ) { |
|
459 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
460 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
456 | + public static function event_link_url($EVT_ID = 0) { |
|
457 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
458 | + if ($event instanceof EE_Event) { |
|
459 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
460 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
461 | 461 | } |
462 | 462 | return NULL; |
463 | 463 | } |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | * @param int $EVT_ID |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public static function event_phone( $EVT_ID = 0 ) { |
|
475 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
476 | - if ( $event instanceof EE_Event ) { |
|
477 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
478 | - return EEH_Schema::telephone( $event->phone() ); |
|
474 | + public static function event_phone($EVT_ID = 0) { |
|
475 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
476 | + if ($event instanceof EE_Event) { |
|
477 | + EE_Registry::instance()->load_helper('Formatter'); |
|
478 | + return EEH_Schema::telephone($event->phone()); |
|
479 | 479 | } |
480 | 480 | return NULL; |
481 | 481 | } |
@@ -492,23 +492,23 @@ discard block |
||
492 | 492 | * @param string $after |
493 | 493 | * @return string |
494 | 494 | */ |
495 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
496 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
497 | - if ( $event instanceof EE_Event ) { |
|
495 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
496 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
497 | + if ($event instanceof EE_Event) { |
|
498 | 498 | // can the user edit this post ? |
499 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
499 | + if (current_user_can('edit_post', $event->ID())) { |
|
500 | 500 | // set link text |
501 | - $link = ! empty( $link ) ? $link : __('edit this event'); |
|
501 | + $link = ! empty($link) ? $link : __('edit this event'); |
|
502 | 502 | // generate nonce |
503 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
503 | + $nonce = wp_create_nonce('edit_nonce'); |
|
504 | 504 | // generate url to event editor for this event |
505 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
505 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
506 | 506 | // get edit CPT text |
507 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
507 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
508 | 508 | // build final link html |
509 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
509 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
510 | 510 | // put it all together |
511 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
511 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | return ''; |
@@ -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 | * |
@@ -432,7 +434,7 @@ discard block |
||
432 | 434 | if($include_expired === null){ |
433 | 435 | if($event instanceof EE_Event && $event->is_expired()){ |
434 | 436 | $include_expired = true; |
435 | - }else{ |
|
437 | + } else{ |
|
436 | 438 | $include_expired = false; |
437 | 439 | } |
438 | 440 | } |
@@ -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 |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * @return string |
59 | 59 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
60 | 60 | */ |
61 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
61 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
62 | 62 | |
63 | - if ( empty($input_vars) ) { |
|
64 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
63 | + if (empty($input_vars)) { |
|
64 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
65 | 65 | return FALSE; |
66 | 66 | } |
67 | 67 | |
@@ -87,25 +87,25 @@ discard block |
||
87 | 87 | 'append_content' => '' |
88 | 88 | ); |
89 | 89 | |
90 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
90 | + $input_value = wp_parse_args($input_value, $defaults); |
|
91 | 91 | |
92 | 92 | // required fields get a * |
93 | 93 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
94 | 94 | // and the css class "required" |
95 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
96 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
95 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
96 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
97 | 97 | |
98 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
99 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
98 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
99 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
100 | 100 | |
101 | 101 | //rows or cols? |
102 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
103 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
102 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
103 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
104 | 104 | |
105 | 105 | //any content? |
106 | 106 | $append_content = $input_value['append_content']; |
107 | 107 | |
108 | - $output .= (!$close) ? '<ul>' : ''; |
|
108 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
109 | 109 | $output .= '<li>'; |
110 | 110 | |
111 | 111 | // what type of input are we dealing with ? |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | |
114 | 114 | // text inputs |
115 | 115 | case 'text' : |
116 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
117 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
116 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
117 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
118 | 118 | break; |
119 | 119 | |
120 | 120 | // dropdowns |
121 | 121 | case 'select' : |
122 | 122 | |
123 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
124 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
123 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
124 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
125 | 125 | |
126 | 126 | if (is_array($input_value['options'])) { |
127 | 127 | $options = $input_value['options']; |
@@ -130,30 +130,30 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | foreach ($options as $key => $value) { |
133 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
133 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
134 | 134 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
135 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
135 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
136 | 136 | } |
137 | - $output .= "\n\t\t\t" . '</select>'; |
|
137 | + $output .= "\n\t\t\t".'</select>'; |
|
138 | 138 | |
139 | 139 | break; |
140 | 140 | |
141 | 141 | case 'textarea' : |
142 | 142 | |
143 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
144 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
143 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
144 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case 'hidden' : |
148 | 148 | $close = false; |
149 | 149 | $output .= "</li></ul>"; |
150 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
150 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
151 | 151 | break; |
152 | 152 | |
153 | 153 | case 'checkbox' : |
154 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
155 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
156 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
154 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
155 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
156 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
157 | 157 | break; |
158 | 158 | |
159 | 159 | case 'wp_editor' : |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | ); |
167 | 167 | $output .= '</li>'; |
168 | 168 | $output .= '</ul>'; |
169 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
170 | - if ( $append_content ) { |
|
169 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
170 | + if ($append_content) { |
|
171 | 171 | $output .= $append_content; |
172 | 172 | } |
173 | 173 | ob_start(); |
174 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
174 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
175 | 175 | $editor = ob_get_contents(); |
176 | 176 | ob_end_clean(); |
177 | 177 | $output .= $editor; |
178 | 178 | break; |
179 | 179 | |
180 | 180 | } |
181 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
181 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | $output .= ($close) ? '</li>' : ''; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $form_fields = array(); |
220 | 220 | $fields = (array) $fields; |
221 | 221 | |
222 | - foreach ( $fields as $field_name => $field_atts ) { |
|
222 | + foreach ($fields as $field_name => $field_atts) { |
|
223 | 223 | //defaults: |
224 | 224 | $defaults = array( |
225 | 225 | 'label' => '', |
@@ -237,67 +237,67 @@ discard block |
||
237 | 237 | 'wpeditor_args' => array() |
238 | 238 | ); |
239 | 239 | // merge defaults with passed arguments |
240 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
241 | - extract( $_fields ); |
|
240 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
241 | + extract($_fields); |
|
242 | 242 | // generate label |
243 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
243 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
244 | 244 | // generate field name |
245 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
245 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
246 | 246 | |
247 | 247 | //tabindex |
248 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
248 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
249 | 249 | |
250 | 250 | //we determine what we're building based on the type |
251 | - switch ( $type ) { |
|
251 | + switch ($type) { |
|
252 | 252 | |
253 | 253 | case 'textarea' : |
254 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
254 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
255 | 255 | $fld .= $extra_desc; |
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'checkbox' : |
259 | 259 | $c_input = ''; |
260 | - if ( is_array($value) ) { |
|
261 | - foreach ( $value as $key => $val ) { |
|
262 | - $c_id = $field_name . '_' . $value; |
|
263 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
264 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
265 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
260 | + if (is_array($value)) { |
|
261 | + foreach ($value as $key => $val) { |
|
262 | + $c_id = $field_name.'_'.$value; |
|
263 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
264 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
265 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
267 | 267 | } |
268 | 268 | $fld = $c_input; |
269 | 269 | } else { |
270 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
270 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
272 | 272 | } |
273 | 273 | break; |
274 | 274 | |
275 | 275 | case 'radio' : |
276 | 276 | $c_input = ''; |
277 | - if ( is_array($value) ) { |
|
278 | - foreach ( $value as $key => $val ) { |
|
279 | - $c_id = $field_name . '_' . $value; |
|
280 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
281 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
282 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
277 | + if (is_array($value)) { |
|
278 | + foreach ($value as $key => $val) { |
|
279 | + $c_id = $field_name.'_'.$value; |
|
280 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
281 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
282 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
284 | 284 | } |
285 | 285 | $fld = $c_input; |
286 | 286 | } else { |
287 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
287 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
289 | 289 | } |
290 | 290 | break; |
291 | 291 | |
292 | 292 | case 'hidden' : |
293 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
293 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
294 | 294 | break; |
295 | 295 | |
296 | 296 | case 'select' : |
297 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
298 | - foreach ( $value as $key => $val ) { |
|
299 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
297 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
298 | + foreach ($value as $key => $val) { |
|
299 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
301 | 301 | } |
302 | 302 | $fld .= '</select>'; |
303 | 303 | break; |
@@ -309,21 +309,21 @@ discard block |
||
309 | 309 | 'editor_class' => $class, |
310 | 310 | 'tabindex' => $tabindex |
311 | 311 | ); |
312 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
312 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
313 | 313 | ob_start(); |
314 | - wp_editor( $value, $id, $editor_settings ); |
|
314 | + wp_editor($value, $id, $editor_settings); |
|
315 | 315 | $editor = ob_get_contents(); |
316 | 316 | ob_end_clean(); |
317 | 317 | $fld = $editor; |
318 | 318 | break; |
319 | 319 | |
320 | 320 | default : //'text fields' |
321 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
321 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
322 | 322 | $fld .= $extra_desc; |
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
326 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | return $form_fields; |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | */ |
353 | 353 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
354 | 354 | //if $values was submitted in the wrong format, convert it over |
355 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
356 | - $converted_values=array(); |
|
357 | - foreach($values as $id=>$text){ |
|
358 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
355 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
356 | + $converted_values = array(); |
|
357 | + foreach ($values as $id=>$text) { |
|
358 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
359 | 359 | } |
360 | - $values=$converted_values; |
|
360 | + $values = $converted_values; |
|
361 | 361 | } |
362 | 362 | //load formatter helper |
363 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
363 | + EE_Registry::instance()->load_helper('Formatter'); |
|
364 | 364 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
365 | 365 | |
366 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
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 | if ($autosize) { |
372 | 372 | $size = 'med'; |
373 | 373 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -380,21 +380,21 @@ discard block |
||
380 | 380 | $size = ''; |
381 | 381 | } |
382 | 382 | |
383 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
383 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
384 | 384 | |
385 | 385 | if (empty($default) && isset($GLOBALS[$name])) |
386 | 386 | $default = stripslashes($GLOBALS[$name]); |
387 | 387 | |
388 | 388 | |
389 | 389 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
390 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
390 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
391 | 391 | if ($default == $values[$i]['id']) { |
392 | 392 | $field .= ' selected = "selected"'; |
393 | 393 | } |
394 | - if ( isset( $values[$i]['class'] ) ) { |
|
395 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
394 | + if (isset($values[$i]['class'])) { |
|
395 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
396 | 396 | } |
397 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
397 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
398 | 398 | } |
399 | 399 | $field .= '</select>'; |
400 | 400 | |
@@ -412,38 +412,38 @@ discard block |
||
412 | 412 | * @param string $question_groups |
413 | 413 | * @return string HTML |
414 | 414 | */ |
415 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
415 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
416 | 416 | |
417 | 417 | $html = ''; |
418 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
419 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
418 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
419 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
420 | 420 | |
421 | - if ( ! empty( $question_groups )) { |
|
421 | + if ( ! empty($question_groups)) { |
|
422 | 422 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
423 | 423 | // loop thru question groups |
424 | - foreach ( $question_groups as $QSG ) { |
|
424 | + foreach ($question_groups as $QSG) { |
|
425 | 425 | // check that questions exist |
426 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
426 | + if ( ! empty($QSG['QSG_questions'])) { |
|
427 | 427 | // use fieldsets |
428 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
428 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
429 | 429 | // group_name |
430 | - $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>' : ''; |
|
430 | + $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>' : ''; |
|
431 | 431 | // group_desc |
432 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
432 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
433 | 433 | |
434 | 434 | $html .= $before_question_group_questions; |
435 | 435 | // loop thru questions |
436 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
436 | + foreach ($QSG['QSG_questions'] as $question) { |
|
437 | 437 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
438 | 438 | $QFI = new EE_Question_Form_Input( |
439 | 439 | $question['qst_obj'], |
440 | 440 | $question['ans_obj'], |
441 | 441 | $question |
442 | 442 | ); |
443 | - $html .= self::generate_form_input( $QFI ); |
|
443 | + $html .= self::generate_form_input($QFI); |
|
444 | 444 | } |
445 | 445 | $html .= $after_question_group_questions; |
446 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
446 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | } |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | * @param string $group_wrapper |
464 | 464 | * @return string HTML |
465 | 465 | */ |
466 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
466 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
467 | 467 | |
468 | 468 | $html = ''; |
469 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
470 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
469 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
470 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
471 | 471 | |
472 | 472 | $default_q_meta = array( |
473 | 473 | 'att_nmbr' => 1, |
@@ -476,55 +476,55 @@ discard block |
||
476 | 476 | 'input_id' => '', |
477 | 477 | 'input_class' => '' |
478 | 478 | ); |
479 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
479 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
480 | 480 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
481 | 481 | |
482 | - if ( ! empty( $question_groups )) { |
|
482 | + if ( ! empty($question_groups)) { |
|
483 | 483 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
484 | 484 | // loop thru question groups |
485 | - foreach ( $question_groups as $QSG ) { |
|
486 | - if ( $QSG instanceof EE_Question_Group ) { |
|
485 | + foreach ($question_groups as $QSG) { |
|
486 | + if ($QSG instanceof EE_Question_Group) { |
|
487 | 487 | // check that questions exist |
488 | 488 | |
489 | - $where = array( 'QST_deleted' => 0 ); |
|
490 | - if ( ! $from_admin ) { |
|
489 | + $where = array('QST_deleted' => 0); |
|
490 | + if ( ! $from_admin) { |
|
491 | 491 | $where['QST_admin_only'] = 0; |
492 | 492 | } |
493 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
494 | - if ( ! empty( $questions )) { |
|
493 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
494 | + if ( ! empty($questions)) { |
|
495 | 495 | // use fieldsets |
496 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
496 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
497 | 497 | // group_name |
498 | - if ( $QSG->show_group_name() ) { |
|
499 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
498 | + if ($QSG->show_group_name()) { |
|
499 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
500 | 500 | } |
501 | 501 | // group_desc |
502 | - if ( $QSG->show_group_desc() ) { |
|
503 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
502 | + if ($QSG->show_group_desc()) { |
|
503 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | $html .= $before_question_group_questions; |
507 | 507 | // loop thru questions |
508 | - foreach ( $questions as $QST ) { |
|
508 | + foreach ($questions as $QST) { |
|
509 | 509 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
510 | 510 | |
511 | 511 | $answer = NULL; |
512 | 512 | |
513 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
513 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
514 | 514 | // check for answer in $_GET in case we are reprocessing a form after an error |
515 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
516 | - $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 ] ); |
|
515 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
516 | + $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]); |
|
517 | 517 | } |
518 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
518 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
519 | 519 | //attendee data from the session |
520 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
520 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | 524 | |
525 | 525 | $QFI = new EE_Question_Form_Input( |
526 | 526 | $QST, |
527 | - EE_Answer::new_instance ( array( |
|
527 | + EE_Answer::new_instance(array( |
|
528 | 528 | 'ANS_ID'=> 0, |
529 | 529 | 'QST_ID'=> 0, |
530 | 530 | 'REG_ID'=> 0, |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | $q_meta |
534 | 534 | ); |
535 | 535 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
536 | - $html .= self::generate_form_input( $QFI ); |
|
536 | + $html .= self::generate_form_input($QFI); |
|
537 | 537 | } |
538 | 538 | $html .= $after_question_group_questions; |
539 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
539 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
@@ -556,63 +556,63 @@ discard block |
||
556 | 556 | * @param EE_Question_Form_Input $QFI |
557 | 557 | * @return string HTML |
558 | 558 | */ |
559 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
560 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
559 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
560 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
561 | 561 | return ''; |
562 | 562 | } |
563 | 563 | |
564 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
565 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
564 | + $QFI = self::_load_system_dropdowns($QFI); |
|
565 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
566 | 566 | |
567 | 567 | //we also need to verify |
568 | 568 | |
569 | 569 | $display_text = $QFI->get('QST_display_text'); |
570 | 570 | $input_name = $QFI->get('QST_input_name'); |
571 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
571 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
572 | 572 | $input_id = $QFI->get('QST_input_id'); |
573 | 573 | $input_class = $QFI->get('QST_input_class'); |
574 | 574 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
575 | 575 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
576 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
576 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
577 | 577 | $QST_required = $QFI->get('QST_required'); |
578 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
579 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
580 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
581 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
578 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
579 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
580 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
581 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
582 | 582 | $label_class = 'espresso-form-input-lbl'; |
583 | - $QST_options = $QFI->options(true,$answer); |
|
584 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
583 | + $QST_options = $QFI->options(true, $answer); |
|
584 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
585 | 585 | $system_ID = $QFI->get('QST_system'); |
586 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
587 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
586 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
587 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
588 | 588 | |
589 | 589 | |
590 | - switch ( $QFI->get('QST_type') ){ |
|
590 | + switch ($QFI->get('QST_type')) { |
|
591 | 591 | |
592 | 592 | case 'TEXTAREA' : |
593 | - 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 ); |
|
593 | + 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); |
|
594 | 594 | break; |
595 | 595 | |
596 | 596 | case 'DROPDOWN' : |
597 | - 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 ); |
|
597 | + 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); |
|
598 | 598 | break; |
599 | 599 | |
600 | 600 | |
601 | 601 | case 'RADIO_BTN' : |
602 | - 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 ); |
|
602 | + 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); |
|
603 | 603 | break; |
604 | 604 | |
605 | 605 | case 'CHECKBOX' : |
606 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
606 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
607 | 607 | break; |
608 | 608 | |
609 | 609 | case 'DATE' : |
610 | - 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 ); |
|
610 | + 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); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'TEXT' : |
614 | 614 | default: |
615 | - 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 ); |
|
615 | + 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); |
|
616 | 616 | break; |
617 | 617 | |
618 | 618 | } |
@@ -638,31 +638,31 @@ discard block |
||
638 | 638 | * @param string $disabled disabled="disabled" or null |
639 | 639 | * @return string HTML |
640 | 640 | */ |
641 | - 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 ) { |
|
641 | + 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) { |
|
642 | 642 | // need these |
643 | - if ( ! $question || ! $name ) { |
|
643 | + if ( ! $question || ! $name) { |
|
644 | 644 | return NULL; |
645 | 645 | } |
646 | 646 | // prep the answer |
647 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
647 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
648 | 648 | // prep the required array |
649 | - $required = self::prep_required( $required ); |
|
649 | + $required = self::prep_required($required); |
|
650 | 650 | // set disabled tag |
651 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
651 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
652 | 652 | // ya gots ta have style man!!! |
653 | 653 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
654 | - $class = empty( $class ) ? $txt_class : $class; |
|
655 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
656 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
654 | + $class = empty($class) ? $txt_class : $class; |
|
655 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
656 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
657 | 657 | |
658 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
658 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
659 | 659 | // filter label but ensure required text comes before it |
660 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
660 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
661 | 661 | |
662 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
662 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
663 | 663 | |
664 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
665 | - return $label_html . $input_html; |
|
664 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
665 | + return $label_html.$input_html; |
|
666 | 666 | |
667 | 667 | } |
668 | 668 | |
@@ -684,35 +684,35 @@ discard block |
||
684 | 684 | * @param string $disabled disabled="disabled" or null |
685 | 685 | * @return string HTML |
686 | 686 | */ |
687 | - 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 ) { |
|
687 | + 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) { |
|
688 | 688 | // need these |
689 | - if ( ! $question || ! $name ) { |
|
689 | + if ( ! $question || ! $name) { |
|
690 | 690 | return NULL; |
691 | 691 | } |
692 | 692 | // prep the answer |
693 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
693 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
694 | 694 | // prep the required array |
695 | - $required = self::prep_required( $required ); |
|
695 | + $required = self::prep_required($required); |
|
696 | 696 | // make sure $dimensions is an array |
697 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
697 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
698 | 698 | // and set some defaults |
699 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
699 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
700 | 700 | // set disabled tag |
701 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
701 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
702 | 702 | // ya gots ta have style man!!! |
703 | 703 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
704 | - $class = empty( $class ) ? $txt_class : $class; |
|
705 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
706 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
704 | + $class = empty($class) ? $txt_class : $class; |
|
705 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
706 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
707 | 707 | |
708 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
708 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
709 | 709 | // filter label but ensure required text comes before it |
710 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
710 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
711 | 711 | |
712 | - $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>'; |
|
712 | + $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>'; |
|
713 | 713 | |
714 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
715 | - return $label_html . $input_html; |
|
714 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
715 | + return $label_html.$input_html; |
|
716 | 716 | |
717 | 717 | } |
718 | 718 | |
@@ -735,47 +735,47 @@ discard block |
||
735 | 735 | * @param string $disabled disabled="disabled" or null |
736 | 736 | * @return string HTML |
737 | 737 | */ |
738 | - 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 ) { |
|
738 | + 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) { |
|
739 | 739 | |
740 | 740 | // need these |
741 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
741 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
742 | 742 | return NULL; |
743 | 743 | } |
744 | 744 | // prep the answer |
745 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer )) : self::prep_answer( $answer, $use_html_entities ); |
|
745 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer)) : self::prep_answer($answer, $use_html_entities); |
|
746 | 746 | // prep the required array |
747 | - $required = self::prep_required( $required ); |
|
747 | + $required = self::prep_required($required); |
|
748 | 748 | // set disabled tag |
749 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
749 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
750 | 750 | // ya gots ta have style man!!! |
751 | 751 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
752 | - $class = empty( $class ) ? $txt_class : $class; |
|
753 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
754 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
752 | + $class = empty($class) ? $txt_class : $class; |
|
753 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
754 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
755 | 755 | |
756 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
756 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
757 | 757 | // filter label but ensure required text comes before it |
758 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
758 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
759 | 759 | |
760 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
760 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
761 | 761 | // recursively count array elements, to determine total number of options |
762 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
763 | - if ( ! $only_option ) { |
|
762 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
763 | + if ( ! $only_option) { |
|
764 | 764 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
765 | 765 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
766 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
766 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
767 | 767 | } |
768 | - foreach ( $options as $key => $value ) { |
|
768 | + foreach ($options as $key => $value) { |
|
769 | 769 | // if value is an array, then create option groups, else create regular ol' options |
770 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option ); |
|
770 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option); |
|
771 | 771 | } |
772 | 772 | |
773 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
773 | + $input_html .= "\n\t\t\t".'</select>'; |
|
774 | 774 | |
775 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
775 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
776 | 776 | |
777 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
778 | - return $label_html . $input_html; |
|
777 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
778 | + return $label_html.$input_html; |
|
779 | 779 | |
780 | 780 | } |
781 | 781 | |
@@ -792,12 +792,12 @@ discard block |
||
792 | 792 | * @param mixed $answer |
793 | 793 | * @return string |
794 | 794 | */ |
795 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
|
796 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
797 | - foreach ( $QSOs as $QSO ) { |
|
798 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer ); |
|
795 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer) { |
|
796 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
797 | + foreach ($QSOs as $QSO) { |
|
798 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer); |
|
799 | 799 | } |
800 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
800 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
801 | 801 | return $html; |
802 | 802 | } |
803 | 803 | |
@@ -811,12 +811,12 @@ discard block |
||
811 | 811 | * @param int $only_option |
812 | 812 | * @return string |
813 | 813 | */ |
814 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE ){ |
|
815 | - $key = self::prep_answer( $key ); |
|
816 | - $value = self::prep_answer( $value ); |
|
817 | - $value = ! empty( $value ) ? $value : $key; |
|
818 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
819 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
814 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE) { |
|
815 | + $key = self::prep_answer($key); |
|
816 | + $value = self::prep_answer($value); |
|
817 | + $value = ! empty($value) ? $value : $key; |
|
818 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
819 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | |
@@ -840,56 +840,56 @@ discard block |
||
840 | 840 | * @param bool $use_desc_4_label |
841 | 841 | * @return string HTML |
842 | 842 | */ |
843 | - 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 ) { |
|
843 | + 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) { |
|
844 | 844 | // need these |
845 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
845 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
846 | 846 | return NULL; |
847 | 847 | } |
848 | 848 | // prep the answer |
849 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
849 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
850 | 850 | // prep the required array |
851 | - $required = self::prep_required( $required ); |
|
851 | + $required = self::prep_required($required); |
|
852 | 852 | // set disabled tag |
853 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
853 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
854 | 854 | // ya gots ta have style man!!! |
855 | 855 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
856 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
857 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
856 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
857 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
858 | 858 | |
859 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
859 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
860 | 860 | // filter label but ensure required text comes before it |
861 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
861 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
862 | 862 | |
863 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
863 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
864 | 864 | |
865 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
866 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
865 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
866 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
867 | 867 | |
868 | - foreach ( $options as $OPT ) { |
|
869 | - if ( $OPT instanceof EE_Question_Option ) { |
|
870 | - $value = self::prep_option_value( $OPT->value() ); |
|
868 | + foreach ($options as $OPT) { |
|
869 | + if ($OPT instanceof EE_Question_Option) { |
|
870 | + $value = self::prep_option_value($OPT->value()); |
|
871 | 871 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
872 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
873 | - $desc = $OPT->desc();//no self::prep_answer |
|
874 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
875 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
876 | - $opt = '-' . sanitize_key( $value ); |
|
877 | - |
|
878 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
879 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
880 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
881 | - $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 . '/>'; |
|
882 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
883 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
884 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
885 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
872 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
873 | + $desc = $OPT->desc(); //no self::prep_answer |
|
874 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
875 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
876 | + $opt = '-'.sanitize_key($value); |
|
877 | + |
|
878 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
879 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
880 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
881 | + $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.'/>'; |
|
882 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
883 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
884 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
885 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
889 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
890 | 890 | |
891 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
892 | - return $label_html . $input_html; |
|
891 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
892 | + return $label_html.$input_html; |
|
893 | 893 | |
894 | 894 | } |
895 | 895 | |
@@ -912,65 +912,65 @@ discard block |
||
912 | 912 | * @param string $disabled disabled="disabled" or null |
913 | 913 | * @return string HTML |
914 | 914 | */ |
915 | - 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 ) { |
|
915 | + 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) { |
|
916 | 916 | // need these |
917 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
917 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
918 | 918 | return NULL; |
919 | 919 | } |
920 | - $answer = maybe_unserialize( $answer ); |
|
920 | + $answer = maybe_unserialize($answer); |
|
921 | 921 | |
922 | 922 | // prep the answer(s) |
923 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
923 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
924 | 924 | |
925 | - foreach ( $answer as $key => $value ) { |
|
926 | - $key = self::prep_option_value( $key ); |
|
927 | - $answer[$key] = self::prep_answer( $value ); |
|
925 | + foreach ($answer as $key => $value) { |
|
926 | + $key = self::prep_option_value($key); |
|
927 | + $answer[$key] = self::prep_answer($value); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // prep the required array |
931 | - $required = self::prep_required( $required ); |
|
931 | + $required = self::prep_required($required); |
|
932 | 932 | // set disabled tag |
933 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
933 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
934 | 934 | // ya gots ta have style man!!! |
935 | 935 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
936 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
937 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
936 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
937 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
938 | 938 | |
939 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
939 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
940 | 940 | // filter label but ensure required text comes before it |
941 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
942 | - |
|
943 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
944 | - |
|
945 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
946 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
947 | - |
|
948 | - foreach ( $options as $OPT ) { |
|
949 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
950 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
951 | - $text = self::prep_answer( $OPT->value() ); |
|
952 | - $desc = $OPT->desc() ; |
|
953 | - $opt = '-' . sanitize_key( $value ); |
|
954 | - |
|
955 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
956 | - |
|
957 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
958 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
959 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
960 | - $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 . '/>'; |
|
961 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
962 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
963 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
964 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
941 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
942 | + |
|
943 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
944 | + |
|
945 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
946 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
947 | + |
|
948 | + foreach ($options as $OPT) { |
|
949 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
950 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
951 | + $text = self::prep_answer($OPT->value()); |
|
952 | + $desc = $OPT->desc(); |
|
953 | + $opt = '-'.sanitize_key($value); |
|
954 | + |
|
955 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
956 | + |
|
957 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
958 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
959 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
960 | + $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.'/>'; |
|
961 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
962 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
963 | + if ( ! empty($desc) && $desc != $text) { |
|
964 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
965 | 965 | } |
966 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
966 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
967 | 967 | |
968 | 968 | } |
969 | 969 | |
970 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
970 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
971 | 971 | |
972 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
973 | - return $label_html . $input_html; |
|
972 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
973 | + return $label_html.$input_html; |
|
974 | 974 | |
975 | 975 | } |
976 | 976 | |
@@ -992,36 +992,36 @@ discard block |
||
992 | 992 | * @param string $disabled disabled="disabled" or null |
993 | 993 | * @return string HTML |
994 | 994 | */ |
995 | - 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 ) { |
|
995 | + 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) { |
|
996 | 996 | // need these |
997 | - if ( ! $question || ! $name ) { |
|
997 | + if ( ! $question || ! $name) { |
|
998 | 998 | return NULL; |
999 | 999 | } |
1000 | 1000 | // prep the answer |
1001 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1001 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1002 | 1002 | // prep the required array |
1003 | - $required = self::prep_required( $required ); |
|
1003 | + $required = self::prep_required($required); |
|
1004 | 1004 | // set disabled tag |
1005 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1005 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1006 | 1006 | // ya gots ta have style man!!! |
1007 | 1007 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1008 | - $class = empty( $class ) ? $txt_class : $class; |
|
1009 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1010 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1008 | + $class = empty($class) ? $txt_class : $class; |
|
1009 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1010 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1011 | 1011 | |
1012 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1012 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1013 | 1013 | // filter label but ensure required text comes before it |
1014 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1014 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1015 | 1015 | |
1016 | - $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 . '/>'; |
|
1016 | + $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.'/>'; |
|
1017 | 1017 | |
1018 | 1018 | // enqueue scripts |
1019 | - 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 ); |
|
1020 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1021 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1019 | + 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); |
|
1020 | + wp_enqueue_style('espresso-ui-theme'); |
|
1021 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1022 | 1022 | |
1023 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1024 | - return $label_html . $input_html; |
|
1023 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1024 | + return $label_html.$input_html; |
|
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * @access public |
1034 | 1034 | * @return string |
1035 | 1035 | */ |
1036 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1036 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1037 | 1037 | return $required_text; |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1047,9 +1047,9 @@ discard block |
||
1047 | 1047 | * @param string $value |
1048 | 1048 | * @return string HTML |
1049 | 1049 | */ |
1050 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1051 | - $id = ! empty( $id ) ? $id : $name; |
|
1052 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1050 | + static function hidden_input($name, $value, $id = '') { |
|
1051 | + $id = ! empty($id) ? $id : $name; |
|
1052 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * @param string $question |
1062 | 1062 | * @return string |
1063 | 1063 | */ |
1064 | - static function prep_question( $question ){ |
|
1064 | + static function prep_question($question) { |
|
1065 | 1065 | return $question; |
1066 | 1066 | // $link = ''; |
1067 | 1067 | // // does this label have a help link attached ? |
@@ -1084,13 +1084,13 @@ discard block |
||
1084 | 1084 | * @param mixed $answer |
1085 | 1085 | * @return string |
1086 | 1086 | */ |
1087 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1087 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1088 | 1088 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1089 | - if ( is_bool( $answer ) ) { |
|
1089 | + if (is_bool($answer)) { |
|
1090 | 1090 | $answer = $answer ? 1 : 0; |
1091 | 1091 | } |
1092 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1093 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1092 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1093 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | |
@@ -1100,18 +1100,18 @@ discard block |
||
1100 | 1100 | * @param array $QSOs array of EE_Question_Option objects |
1101 | 1101 | * @return array |
1102 | 1102 | */ |
1103 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1103 | + public static function prep_answer_options($QSOs = array()) { |
|
1104 | 1104 | $prepped_answer_options = array(); |
1105 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1106 | - foreach( $QSOs as $key => $QSO ) { |
|
1107 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1108 | - $QSO = EE_Question_Option::new_instance( array( |
|
1109 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1110 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1105 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1106 | + foreach ($QSOs as $key => $QSO) { |
|
1107 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1108 | + $QSO = EE_Question_Option::new_instance(array( |
|
1109 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1110 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1111 | 1111 | )); |
1112 | 1112 | } |
1113 | - if ( $QSO->opt_group() ) { |
|
1114 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1113 | + if ($QSO->opt_group()) { |
|
1114 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1115 | 1115 | } else { |
1116 | 1116 | $prepped_answer_options[] = $QSO; |
1117 | 1117 | } |
@@ -1127,8 +1127,8 @@ discard block |
||
1127 | 1127 | * @param string $option_value |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - static function prep_option_value( $option_value ){ |
|
1131 | - return trim( stripslashes( $option_value )); |
|
1130 | + static function prep_option_value($option_value) { |
|
1131 | + return trim(stripslashes($option_value)); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1139,11 +1139,11 @@ discard block |
||
1139 | 1139 | * @param string|array $required |
1140 | 1140 | * @return array |
1141 | 1141 | */ |
1142 | - static function prep_required( $required = array() ){ |
|
1142 | + static function prep_required($required = array()) { |
|
1143 | 1143 | // make sure required is an array |
1144 | - $required = is_array( $required ) ? $required : array(); |
|
1144 | + $required = is_array($required) ? $required : array(); |
|
1145 | 1145 | // and set some defaults |
1146 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1146 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1147 | 1147 | return $required; |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,30 +1154,30 @@ discard block |
||
1154 | 1154 | * @param string $value |
1155 | 1155 | * @return string |
1156 | 1156 | */ |
1157 | - static function get_label_size_class( $value = FALSE ){ |
|
1158 | - if ( $value === FALSE || $value == '' ) { |
|
1157 | + static function get_label_size_class($value = FALSE) { |
|
1158 | + if ($value === FALSE || $value == '') { |
|
1159 | 1159 | return ' class="medium-lbl"'; |
1160 | 1160 | } |
1161 | 1161 | // determine length of option value |
1162 | - $val_size = strlen( $value ); |
|
1163 | - switch( $val_size ){ |
|
1162 | + $val_size = strlen($value); |
|
1163 | + switch ($val_size) { |
|
1164 | 1164 | case $val_size < 3 : |
1165 | - $size = ' class="nano-lbl"'; |
|
1165 | + $size = ' class="nano-lbl"'; |
|
1166 | 1166 | break; |
1167 | 1167 | case $val_size < 6 : |
1168 | - $size = ' class="micro-lbl"'; |
|
1168 | + $size = ' class="micro-lbl"'; |
|
1169 | 1169 | break; |
1170 | 1170 | case $val_size < 12 : |
1171 | - $size = ' class="tiny-lbl"'; |
|
1171 | + $size = ' class="tiny-lbl"'; |
|
1172 | 1172 | break; |
1173 | 1173 | case $val_size < 25 : |
1174 | - $size = ' class="small-lbl"'; |
|
1174 | + $size = ' class="small-lbl"'; |
|
1175 | 1175 | break; |
1176 | 1176 | case $val_size > 100 : |
1177 | - $size = ' class="big-lbl"'; |
|
1177 | + $size = ' class="big-lbl"'; |
|
1178 | 1178 | break; |
1179 | 1179 | default: |
1180 | - $size = ' class="medium-lbl"'; |
|
1180 | + $size = ' class="medium-lbl"'; |
|
1181 | 1181 | break; |
1182 | 1182 | } |
1183 | 1183 | return $size; |
@@ -1191,20 +1191,20 @@ discard block |
||
1191 | 1191 | * @param array $QFI |
1192 | 1192 | * @return array |
1193 | 1193 | */ |
1194 | - private static function _load_system_dropdowns( $QFI ){ |
|
1194 | + private static function _load_system_dropdowns($QFI) { |
|
1195 | 1195 | $QST_system = $QFI->get('QST_system'); |
1196 | - switch ( $QST_system ) { |
|
1196 | + switch ($QST_system) { |
|
1197 | 1197 | case 'state' : |
1198 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1198 | + $QFI = self::generate_state_dropdown($QFI); |
|
1199 | 1199 | break; |
1200 | 1200 | case 'country' : |
1201 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1201 | + $QFI = self::generate_country_dropdown($QFI); |
|
1202 | 1202 | break; |
1203 | 1203 | case 'admin-state' : |
1204 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1204 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1205 | 1205 | break; |
1206 | 1206 | case 'admin-country' : |
1207 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1207 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1208 | 1208 | break; |
1209 | 1209 | } |
1210 | 1210 | return $QFI; |
@@ -1221,13 +1221,13 @@ discard block |
||
1221 | 1221 | * |
1222 | 1222 | * @return EE_Question_Form_Input |
1223 | 1223 | */ |
1224 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1225 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1224 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1225 | + switch ($QFI->get('QST_type')) { |
|
1226 | 1226 | case 'STATE' : |
1227 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1227 | + $QFI = self::generate_state_dropdown($QFI); |
|
1228 | 1228 | break; |
1229 | 1229 | case 'COUNTRY' : |
1230 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1230 | + $QFI = self::generate_country_dropdown($QFI); |
|
1231 | 1231 | break; |
1232 | 1232 | } |
1233 | 1233 | return $QFI; |
@@ -1241,23 +1241,23 @@ discard block |
||
1241 | 1241 | * @param bool $get_all |
1242 | 1242 | * @return array |
1243 | 1243 | */ |
1244 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1244 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1245 | 1245 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1246 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1247 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1246 | + if ($states && count($states) != count($QST->options())) { |
|
1247 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1248 | 1248 | // if multiple countries, we'll create option groups within the dropdown |
1249 | - foreach ( $states as $state ) { |
|
1250 | - if ( $state instanceof EE_State ) { |
|
1251 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1249 | + foreach ($states as $state) { |
|
1250 | + if ($state instanceof EE_State) { |
|
1251 | + $QSO = EE_Question_Option::new_instance(array( |
|
1252 | 1252 | 'QSO_value' => $state->ID(), |
1253 | 1253 | 'QSO_desc' => $state->name(), |
1254 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1254 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1255 | 1255 | 'QSO_deleted' => FALSE |
1256 | 1256 | )); |
1257 | 1257 | // set option group |
1258 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1258 | + $QSO->set_opt_group($state->country()->name()); |
|
1259 | 1259 | // add option to question |
1260 | - $QST->add_temp_option( $QSO ); |
|
1260 | + $QST->add_temp_option($QSO); |
|
1261 | 1261 | } |
1262 | 1262 | } |
1263 | 1263 | } |
@@ -1273,20 +1273,20 @@ discard block |
||
1273 | 1273 | * @internal param array $question |
1274 | 1274 | * @return array |
1275 | 1275 | */ |
1276 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1276 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1277 | 1277 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1278 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1279 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1278 | + if ($countries && count($countries) != count($QST->options())) { |
|
1279 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1280 | 1280 | // now add countries |
1281 | - foreach ( $countries as $country ) { |
|
1282 | - if ( $country instanceof EE_Country ) { |
|
1283 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1281 | + foreach ($countries as $country) { |
|
1282 | + if ($country instanceof EE_Country) { |
|
1283 | + $QSO = EE_Question_Option::new_instance(array( |
|
1284 | 1284 | 'QSO_value' => $country->ID(), |
1285 | 1285 | 'QSO_desc' => $country->name(), |
1286 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1286 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1287 | 1287 | 'QSO_deleted' => FALSE |
1288 | 1288 | )); |
1289 | - $QST->add_temp_option( $QSO ); |
|
1289 | + $QST->add_temp_option($QSO); |
|
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | } |
@@ -1303,11 +1303,11 @@ discard block |
||
1303 | 1303 | */ |
1304 | 1304 | public static function two_digit_months_dropdown_options() { |
1305 | 1305 | $options = array(); |
1306 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1307 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1308 | - $options[ (string)$mm ] = (string)$mm; |
|
1306 | + for ($x = 1; $x <= 12; $x++) { |
|
1307 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1308 | + $options[(string) $mm] = (string) $mm; |
|
1309 | 1309 | } |
1310 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1310 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
@@ -1322,11 +1322,11 @@ discard block |
||
1322 | 1322 | $options = array(); |
1323 | 1323 | $current_year = date('y'); |
1324 | 1324 | $next_decade = $current_year + 10; |
1325 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1326 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1327 | - $options[ (string)$yy ] = (string)$yy; |
|
1325 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1326 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1327 | + $options[(string) $yy] = (string) $yy; |
|
1328 | 1328 | } |
1329 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1329 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | |
@@ -1340,17 +1340,17 @@ discard block |
||
1340 | 1340 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1341 | 1341 | * @return string html |
1342 | 1342 | */ |
1343 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1343 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1344 | 1344 | $_where = array(); |
1345 | - if ( !empty( $status ) ) { |
|
1345 | + if ( ! empty($status)) { |
|
1346 | 1346 | $_where['STS_ID'] = $status; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ( $evt_category > 0 ) { |
|
1349 | + if ($evt_category > 0) { |
|
1350 | 1350 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1353 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1354 | 1354 | |
1355 | 1355 | //setup vals for select input helper |
1356 | 1356 | $options = array( |
@@ -1360,15 +1360,15 @@ discard block |
||
1360 | 1360 | ) |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - foreach ( $regdtts as $regdtt ) { |
|
1364 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1363 | + foreach ($regdtts as $regdtt) { |
|
1364 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1365 | 1365 | $options[] = array( |
1366 | 1366 | 'text' => $date, |
1367 | 1367 | 'id' => $date |
1368 | 1368 | ); |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1371 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | |
@@ -1382,18 +1382,18 @@ discard block |
||
1382 | 1382 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1383 | 1383 | * @return string html |
1384 | 1384 | */ |
1385 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1385 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1386 | 1386 | //determine what post_status our condition will have for the query. |
1387 | - switch ( $status ) { |
|
1387 | + switch ($status) { |
|
1388 | 1388 | case 'month' : |
1389 | 1389 | case 'today' : |
1390 | 1390 | case NULL : |
1391 | 1391 | case 'all' : |
1392 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1392 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1393 | 1393 | break; |
1394 | 1394 | |
1395 | 1395 | case 'draft' : |
1396 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1396 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1397 | 1397 | |
1398 | 1398 | default : |
1399 | 1399 | $where['Event.status'] = $status; |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | //categories? |
1403 | 1403 | |
1404 | 1404 | |
1405 | - if ( !empty ( $evt_category ) ) { |
|
1405 | + if ( ! empty ($evt_category)) { |
|
1406 | 1406 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1407 | 1407 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1408 | 1408 | } |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | |
1411 | 1411 | // $where['DTT_is_primary'] = 1; |
1412 | 1412 | |
1413 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1413 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1414 | 1414 | |
1415 | 1415 | //let's setup vals for select input helper |
1416 | 1416 | $options = array( |
@@ -1423,9 +1423,9 @@ discard block |
||
1423 | 1423 | //translate month and date |
1424 | 1424 | global $wp_locale; |
1425 | 1425 | |
1426 | - foreach ( $DTTS as $DTT ) { |
|
1427 | - $localized_date = $wp_locale->get_month( date('m', strtotime($DTT->dtt_month)) ) . ' ' . $DTT->dtt_year; |
|
1428 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1426 | + foreach ($DTTS as $DTT) { |
|
1427 | + $localized_date = $wp_locale->get_month(date('m', strtotime($DTT->dtt_month))).' '.$DTT->dtt_year; |
|
1428 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1429 | 1429 | $options[] = array( |
1430 | 1430 | 'text' => $localized_date, |
1431 | 1431 | 'id' => $id |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | |
1436 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1436 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | * @param integer $current_cat currently selected category |
1445 | 1445 | * @return string html for dropdown |
1446 | 1446 | */ |
1447 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1447 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1448 | 1448 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1449 | 1449 | $options = array( |
1450 | 1450 | '0' => array( |
@@ -1454,14 +1454,14 @@ discard block |
||
1454 | 1454 | ); |
1455 | 1455 | |
1456 | 1456 | //setup categories for dropdown |
1457 | - foreach ( $categories as $category ) { |
|
1457 | + foreach ($categories as $category) { |
|
1458 | 1458 | $options[] = array( |
1459 | 1459 | 'text' => $category->get('name'), |
1460 | 1460 | 'id' => $category->ID() |
1461 | 1461 | ); |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1464 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | |
@@ -1480,20 +1480,20 @@ discard block |
||
1480 | 1480 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1481 | 1481 | * @return void |
1482 | 1482 | */ |
1483 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1483 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1484 | 1484 | $btn = ''; |
1485 | - if ( empty( $url ) || empty( $ID )) { |
|
1485 | + if (empty($url) || empty($ID)) { |
|
1486 | 1486 | return $btn; |
1487 | 1487 | } |
1488 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1489 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1490 | - if ( ! $input_only ) { |
|
1491 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1492 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1488 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1489 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1490 | + if ( ! $input_only) { |
|
1491 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1492 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1493 | 1493 | $btn_frm .= $btn; |
1494 | 1494 | $btn_frm .= '</form>'; |
1495 | 1495 | $btn = $btn_frm; |
1496 | - unset ( $btn_frm ); |
|
1496 | + unset ($btn_frm); |
|
1497 | 1497 | } |
1498 | 1498 | return $btn; |
1499 | 1499 | } |
@@ -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++) { |
@@ -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() ) { |
@@ -280,7 +280,7 @@ |
||
280 | 280 | $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
281 | 281 | if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
282 | 282 | $success = $pre_tax_subtotal->add_child_line_item($item); |
283 | - }else{ |
|
283 | + } else{ |
|
284 | 284 | return FALSE; |
285 | 285 | } |
286 | 286 | $total_line_item->recalculate_total_including_taxes(); |
@@ -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 | )); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'FHEE__EEH_Line_Item__add_unrelated_item__line_item', |
59 | 59 | $line_item |
60 | 60 | ); |
61 | - return self::add_item( $parent_line_item, $line_item ); |
|
61 | + return self::add_item($parent_line_item, $line_item); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param boolean $taxable |
80 | 80 | * @return boolean success |
81 | 81 | */ |
82 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
82 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
83 | 83 | $line_item = EE_Line_Item::new_instance(array( |
84 | 84 | 'LIN_name' => $name, |
85 | 85 | 'LIN_desc' => $description, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'LIN_percent' => $percentage_amount, |
88 | 88 | 'LIN_quantity' => NULL, |
89 | 89 | 'LIN_is_taxable' => $taxable, |
90 | - 'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )), |
|
90 | + 'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)), |
|
91 | 91 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
92 | 92 | 'LIN_parent' => $parent_line_item->ID() |
93 | 93 | )); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
96 | 96 | $line_item |
97 | 97 | ); |
98 | - return self::add_item( $parent_line_item, $line_item ); |
|
98 | + return self::add_item($parent_line_item, $line_item); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | * @return \EE_Line_Item |
117 | 117 | * @throws \EE_Error |
118 | 118 | */ |
119 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
120 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
121 | - 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() ) ); |
|
119 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
120 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
121 | + 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())); |
|
122 | 122 | } |
123 | 123 | // either increment the qty for an existing ticket |
124 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
124 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
125 | 125 | // or add a new one |
126 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
127 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
126 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
127 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
128 | 128 | } |
129 | 129 | $total_line_item->recalculate_total_including_taxes(); |
130 | 130 | return $line_item; |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | * @return \EE_Line_Item |
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
143 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
144 | 144 | $line_item = null; |
145 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
146 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
147 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
148 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) { |
|
145 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
146 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
147 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
148 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) { |
|
149 | 149 | $line_item = $ticket_line_item; |
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
154 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
154 | + if ($line_item instanceof EE_Line_Item) { |
|
155 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
156 | 156 | return $line_item; |
157 | 157 | } |
158 | 158 | return null; |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | * @param int $qty |
166 | 166 | * @return void |
167 | 167 | */ |
168 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
169 | - if( ! $line_item->is_percent() ) { |
|
168 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
169 | + if ( ! $line_item->is_percent()) { |
|
170 | 170 | $qty += $line_item->quantity(); |
171 | - $line_item->set_quantity( $qty ); |
|
172 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
171 | + $line_item->set_quantity($qty); |
|
172 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
173 | 173 | } |
174 | - foreach( $line_item->children() as $child ) { |
|
175 | - if( $child->is_sub_line_item() ) { |
|
176 | - EEH_Line_Item::update_quantity( $child, $line_item->quantity() ); |
|
174 | + foreach ($line_item->children() as $child) { |
|
175 | + if ($child->is_sub_line_item()) { |
|
176 | + EEH_Line_Item::update_quantity($child, $line_item->quantity()); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | * @param EE_Line_Item $line_item |
185 | 185 | * @param int $new_quantity |
186 | 186 | */ |
187 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
188 | - if( ! $line_item->is_percent() ) { |
|
189 | - $line_item->set_quantity( $new_quantity ); |
|
190 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
187 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
188 | + if ( ! $line_item->is_percent()) { |
|
189 | + $line_item->set_quantity($new_quantity); |
|
190 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
191 | 191 | } |
192 | - foreach( $line_item->children() as $child ) { |
|
193 | - if( $child->is_sub_line_item() ) { |
|
194 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
192 | + foreach ($line_item->children() as $child) { |
|
193 | + if ($child->is_sub_line_item()) { |
|
194 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
@@ -206,38 +206,38 @@ discard block |
||
206 | 206 | * @return \EE_Line_Item |
207 | 207 | * @throws \EE_Error |
208 | 208 | */ |
209 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
209 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
210 | 210 | $datetimes = $ticket->datetimes(); |
211 | - $event = sprintf( __( '(For %1$s)', 'event_espresso' ), reset( $datetimes )->event()->name() ); |
|
211 | + $event = sprintf(__('(For %1$s)', 'event_espresso'), reset($datetimes)->event()->name()); |
|
212 | 212 | // get event subtotal line |
213 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
214 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
215 | - 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() ) ); |
|
213 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
214 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
215 | + 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())); |
|
216 | 216 | } |
217 | 217 | // add $ticket to cart |
218 | - $line_item = EE_Line_Item::new_instance( array( |
|
218 | + $line_item = EE_Line_Item::new_instance(array( |
|
219 | 219 | 'LIN_name' => $ticket->name(), |
220 | - 'LIN_desc' => $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event, |
|
220 | + 'LIN_desc' => $ticket->description() != '' ? $ticket->description().' '.$event : $event, |
|
221 | 221 | 'LIN_unit_price' => $ticket->price(), |
222 | 222 | 'LIN_quantity' => $qty, |
223 | 223 | 'LIN_is_taxable' => $ticket->taxable(), |
224 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
224 | + 'LIN_order' => count($events_sub_total->children()), |
|
225 | 225 | 'LIN_total' => $ticket->price() * $qty, |
226 | 226 | 'LIN_type' => EEM_Line_Item::type_line_item, |
227 | 227 | 'OBJ_ID' => $ticket->ID(), |
228 | 228 | 'OBJ_type' => 'Ticket' |
229 | - ) ); |
|
229 | + )); |
|
230 | 230 | $line_item = apply_filters( |
231 | 231 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
232 | 232 | $line_item |
233 | 233 | ); |
234 | - $events_sub_total->add_child_line_item( $line_item ); |
|
234 | + $events_sub_total->add_child_line_item($line_item); |
|
235 | 235 | //now add the sub-line items |
236 | 236 | $running_total_for_ticket = 0; |
237 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
237 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
238 | 238 | $sign = $price->is_discount() ? -1 : 1; |
239 | 239 | $price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty; |
240 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
240 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
241 | 241 | 'LIN_name' => $price->name(), |
242 | 242 | 'LIN_desc' => $price->desc(), |
243 | 243 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
248 | 248 | 'OBJ_ID' => $price->ID(), |
249 | 249 | 'OBJ_type' => 'Price' |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | $sub_line_item = apply_filters( |
252 | 252 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
253 | 253 | $sub_line_item |
254 | 254 | ); |
255 | - if ( $price->is_percent() ) { |
|
256 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
255 | + if ($price->is_percent()) { |
|
256 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
257 | 257 | } else { |
258 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
258 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
259 | 259 | } |
260 | 260 | $running_total_for_ticket += $price_total; |
261 | - $line_item->add_child_line_item( $sub_line_item ); |
|
261 | + $line_item->add_child_line_item($sub_line_item); |
|
262 | 262 | } |
263 | 263 | return $line_item; |
264 | 264 | } |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * @param EE_Line_Item $item to be added |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
280 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
281 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
279 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
280 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
281 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
282 | 282 | $success = $pre_tax_subtotal->add_child_line_item($item); |
283 | - }else{ |
|
283 | + } else { |
|
284 | 284 | return FALSE; |
285 | 285 | } |
286 | 286 | $total_line_item->recalculate_total_including_taxes(); |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
295 | 295 | * @return \EE_Line_Item |
296 | 296 | */ |
297 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
298 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
299 | - return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item ); |
|
297 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
298 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
299 | + return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
307 | 307 | * @return \EE_Line_Item |
308 | 308 | */ |
309 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
310 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
311 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
309 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
310 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
311 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | * @param EE_Transaction $transaction |
320 | 320 | * @return void |
321 | 321 | */ |
322 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
323 | - if( $transaction ){ |
|
322 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
323 | + if ($transaction) { |
|
324 | 324 | /** @type EEM_Transaction $EEM_Transaction */ |
325 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
326 | - $transaction = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
327 | - $line_item->set_TXN_ID( $transaction ); |
|
325 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
326 | + $transaction = $EEM_Transaction->ensure_is_ID($transaction); |
|
327 | + $line_item->set_TXN_ID($transaction); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * @param EE_Transaction $transaction |
338 | 338 | * @return \EE_Line_Item of type total |
339 | 339 | */ |
340 | - public static function create_total_line_item( $transaction = NULL ){ |
|
341 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
340 | + public static function create_total_line_item($transaction = NULL) { |
|
341 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
342 | 342 | 'LIN_code' => 'total', |
343 | 343 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
344 | 344 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
349 | 349 | $total_line_item |
350 | 350 | ); |
351 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
352 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
353 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
351 | + self::set_TXN_ID($total_line_item, $transaction); |
|
352 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
353 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
354 | 354 | return $total_line_item; |
355 | 355 | } |
356 | 356 | |
@@ -362,19 +362,19 @@ discard block |
||
362 | 362 | * @param EE_Transaction $transaction |
363 | 363 | * @return EE_Line_Item |
364 | 364 | */ |
365 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
366 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
365 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
366 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
367 | 367 | 'LIN_code' => 'pre-tax-subtotal', |
368 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
368 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
369 | 369 | 'LIN_type' => EEM_Line_Item::type_sub_total |
370 | - ) ); |
|
370 | + )); |
|
371 | 371 | $pre_tax_line_item = apply_filters( |
372 | 372 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
373 | 373 | $pre_tax_line_item |
374 | 374 | ); |
375 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
376 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
377 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
375 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
376 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
377 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
378 | 378 | return $pre_tax_line_item; |
379 | 379 | } |
380 | 380 | |
@@ -387,21 +387,21 @@ discard block |
||
387 | 387 | * @param EE_Transaction $transaction |
388 | 388 | * @return EE_Line_Item |
389 | 389 | */ |
390 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
390 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
391 | 391 | $tax_line_item = EE_Line_Item::new_instance(array( |
392 | 392 | 'LIN_code' => 'taxes', |
393 | 393 | 'LIN_name' => __('Taxes', 'event_espresso'), |
394 | 394 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
395 | - 'LIN_order' => 1000,//this should always come last |
|
395 | + 'LIN_order' => 1000, //this should always come last |
|
396 | 396 | )); |
397 | 397 | $tax_line_item = apply_filters( |
398 | 398 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
399 | 399 | $tax_line_item |
400 | 400 | ); |
401 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
402 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
401 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
402 | + $total_line_item->add_child_line_item($tax_line_item); |
|
403 | 403 | //and lastly, add the actual taxes |
404 | - self::apply_taxes( $total_line_item ); |
|
404 | + self::apply_taxes($total_line_item); |
|
405 | 405 | return $tax_line_item; |
406 | 406 | } |
407 | 407 | |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * @param EE_Event $event |
415 | 415 | * @return EE_Line_Item |
416 | 416 | */ |
417 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
417 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
418 | 418 | $event_line_item = EE_Line_Item::new_instance(array( |
419 | - 'LIN_code' => self::get_event_code( $event ), |
|
420 | - 'LIN_name' => self::get_event_name( $event ), |
|
421 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
419 | + 'LIN_code' => self::get_event_code($event), |
|
420 | + 'LIN_name' => self::get_event_name($event), |
|
421 | + 'LIN_desc' => self::get_event_desc($event), |
|
422 | 422 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
423 | 423 | 'OBJ_type' => 'Event', |
424 | 424 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
428 | 428 | $event_line_item |
429 | 429 | ); |
430 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
431 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
430 | + self::set_TXN_ID($event_line_item, $transaction); |
|
431 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
432 | 432 | return $event_line_item; |
433 | 433 | } |
434 | 434 | |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * @param EE_Event $event |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - public static function get_event_code( $event ) { |
|
441 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
440 | + public static function get_event_code($event) { |
|
441 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | * @param EE_Event $event |
447 | 447 | * @return string |
448 | 448 | */ |
449 | - public static function get_event_name( $event ) { |
|
450 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
449 | + public static function get_event_name($event) { |
|
450 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * @param EE_Event $event |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function get_event_desc( $event ) { |
|
458 | + public static function get_event_desc($event) { |
|
459 | 459 | return $event instanceof EE_Event ? $event->short_description() : ''; |
460 | 460 | } |
461 | 461 | |
@@ -469,37 +469,37 @@ discard block |
||
469 | 469 | * @throws \EE_Error |
470 | 470 | * @return EE_Line_Item |
471 | 471 | */ |
472 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
472 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
473 | 473 | $first_datetime = $ticket->first_datetime(); |
474 | - if( ! $first_datetime instanceof EE_Datetime ){ |
|
475 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) ); |
|
474 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
475 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())); |
|
476 | 476 | } |
477 | 477 | $event = $first_datetime->event(); |
478 | - if ( ! $event instanceof EE_Event ) { |
|
479 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) ); |
|
478 | + if ( ! $event instanceof EE_Event) { |
|
479 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID())); |
|
480 | 480 | } |
481 | 481 | $event_line_item = NULL; |
482 | 482 | $found = false; |
483 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
483 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
484 | 484 | // default event subtotal, we should only ever find this the first time this method is called |
485 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
485 | + if ( ! $event_line_item->OBJ_ID()) { |
|
486 | 486 | // let's use this! but first... set the event details |
487 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
487 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
488 | 488 | $found = true; |
489 | 489 | break; |
490 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
490 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
491 | 491 | // found existing line item for this event in the cart, so break out of loop and use this one |
492 | 492 | $found = true; |
493 | 493 | break; |
494 | 494 | } |
495 | 495 | } |
496 | - if ( ! $found ) { |
|
496 | + if ( ! $found) { |
|
497 | 497 | //there is no event sub-total yet, so add it |
498 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
498 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
499 | 499 | // create a new "event" subtotal below that |
500 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
500 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
501 | 501 | // and set the event details |
502 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
502 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
503 | 503 | } |
504 | 504 | return $event_line_item; |
505 | 505 | } |
@@ -513,14 +513,14 @@ discard block |
||
513 | 513 | * @param EE_Transaction $transaction |
514 | 514 | * @return EE_Line_Item |
515 | 515 | */ |
516 | - public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){ |
|
517 | - if ( $event instanceof EE_Event ) { |
|
518 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
519 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
520 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
521 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
516 | + public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) { |
|
517 | + if ($event instanceof EE_Event) { |
|
518 | + $event_line_item->set_code(self::get_event_code($event)); |
|
519 | + $event_line_item->set_name(self::get_event_name($event)); |
|
520 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
521 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
522 | 522 | } |
523 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
523 | + self::set_TXN_ID($event_line_item, $transaction); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -531,19 +531,19 @@ discard block |
||
531 | 531 | * any old taxes are removed |
532 | 532 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
533 | 533 | */ |
534 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
534 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
535 | 535 | /** @type EEM_Price $EEM_Price */ |
536 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
536 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
537 | 537 | // get array of taxes via Price Model |
538 | 538 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
539 | - ksort( $ordered_taxes ); |
|
540 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
539 | + ksort($ordered_taxes); |
|
540 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
541 | 541 | //just to be safe, remove its old tax line items |
542 | 542 | $taxes_line_item->delete_children_line_items(); |
543 | 543 | //loop thru taxes |
544 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
545 | - foreach ( $taxes as $tax ) { |
|
546 | - if ( $tax instanceof EE_Price ) { |
|
544 | + foreach ($ordered_taxes as $order => $taxes) { |
|
545 | + foreach ($taxes as $tax) { |
|
546 | + if ($tax instanceof EE_Price) { |
|
547 | 547 | $tax_line_item = EE_Line_Item::new_instance( |
548 | 548 | array( |
549 | 549 | 'LIN_name' => $tax->name(), |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
562 | 562 | $tax_line_item |
563 | 563 | ); |
564 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
564 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | } |
@@ -576,10 +576,10 @@ discard block |
||
576 | 576 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
577 | 577 | * @return float |
578 | 578 | */ |
579 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
580 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
581 | - if( ! $taxes_subtotal->children()){ |
|
582 | - self::apply_taxes( $total_line_item ); |
|
579 | + public static function ensure_taxes_applied($total_line_item) { |
|
580 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
581 | + if ( ! $taxes_subtotal->children()) { |
|
582 | + self::apply_taxes($total_line_item); |
|
583 | 583 | } |
584 | 584 | return $taxes_subtotal->total(); |
585 | 585 | } |
@@ -592,16 +592,16 @@ discard block |
||
592 | 592 | * @param EE_Line_Item $parent_line_item |
593 | 593 | * @return bool |
594 | 594 | */ |
595 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
595 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
596 | 596 | $deleted = 0; |
597 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
598 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
599 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
600 | - if ( $child_line_item->ID() ) { |
|
597 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
598 | + if ($child_line_item instanceof EE_Line_Item) { |
|
599 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
600 | + if ($child_line_item->ID()) { |
|
601 | 601 | $child_line_item->delete(); |
602 | - unset( $child_line_item ); |
|
602 | + unset($child_line_item); |
|
603 | 603 | } else { |
604 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
604 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
605 | 605 | } |
606 | 606 | $deleted++; |
607 | 607 | } |
@@ -623,25 +623,25 @@ discard block |
||
623 | 623 | * @param array|bool|string $line_item_codes |
624 | 624 | * @return int number of items successfully removed |
625 | 625 | */ |
626 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
626 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
627 | 627 | |
628 | - if( $total_line_item->type() != EEM_Line_Item::type_total ){ |
|
629 | - 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' ); |
|
628 | + if ($total_line_item->type() != EEM_Line_Item::type_total) { |
|
629 | + 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'); |
|
630 | 630 | } |
631 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
631 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
632 | 632 | |
633 | 633 | // check if only a single line_item_id was passed |
634 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
634 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
635 | 635 | // place single line_item_id in an array to appear as multiple line_item_ids |
636 | - $line_item_codes = array ( $line_item_codes ); |
|
636 | + $line_item_codes = array($line_item_codes); |
|
637 | 637 | } |
638 | 638 | $removals = 0; |
639 | 639 | // cycle thru line_item_ids |
640 | - foreach ( $line_item_codes as $line_item_id ) { |
|
640 | + foreach ($line_item_codes as $line_item_id) { |
|
641 | 641 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
642 | 642 | } |
643 | 643 | |
644 | - if ( $removals > 0 ) { |
|
644 | + if ($removals > 0) { |
|
645 | 645 | $total_line_item->recalculate_taxes_and_tax_total(); |
646 | 646 | return $removals; |
647 | 647 | } else { |
@@ -658,17 +658,17 @@ discard block |
||
658 | 658 | * @param string $description |
659 | 659 | * @return EE_Line_Item the new tax line item created |
660 | 660 | */ |
661 | - public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL ){ |
|
661 | + public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL) { |
|
662 | 662 | //first: remove all tax descendants |
663 | 663 | //add this as a new tax descendant |
664 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
664 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
665 | 665 | $tax_subtotal->delete_children_line_items(); |
666 | 666 | $taxable_total = $total_line_item->taxable_total(); |
667 | 667 | $new_tax_subtotal = EE_Line_Item::new_instance(array( |
668 | 668 | 'TXN_ID' => $total_line_item->TXN_ID(), |
669 | 669 | 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
670 | 670 | 'LIN_desc' => $description ? $description : '', |
671 | - 'LIN_percent' => $taxable_total ? ( $amount / $total_line_item->taxable_total() * 100 ) : 0, |
|
671 | + 'LIN_percent' => $taxable_total ? ($amount / $total_line_item->taxable_total() * 100) : 0, |
|
672 | 672 | 'LIN_total' => $amount, |
673 | 673 | 'LIN_parent' => $tax_subtotal->ID(), |
674 | 674 | 'LIN_type' => EEM_Line_Item::type_tax |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | $new_tax_subtotal |
679 | 679 | ); |
680 | 680 | $new_tax_subtotal->save(); |
681 | - $tax_subtotal->set_total( $amount ); |
|
681 | + $tax_subtotal->set_total($amount); |
|
682 | 682 | $tax_subtotal->save(); |
683 | 683 | $total_line_item->recalculate_total_including_taxes(); |
684 | 684 | return $new_tax_subtotal; |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
694 | 694 | * @return EE_Line_Item[] |
695 | 695 | */ |
696 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
697 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
696 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
697 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | * @param string $obj_type |
708 | 708 | * @return EE_Line_Item[] |
709 | 709 | */ |
710 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
711 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type ); |
|
710 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
711 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
721 | 721 | * @return EE_Line_Item[] |
722 | 722 | */ |
723 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
724 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
723 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
724 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | * @param string $obj_type |
735 | 735 | * @return EE_Line_Item[] |
736 | 736 | */ |
737 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
738 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
737 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
738 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
747 | 747 | * @return EE_Line_Item[] |
748 | 748 | */ |
749 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
750 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
749 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
750 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
759 | 759 | * @return EE_Line_Item[] |
760 | 760 | */ |
761 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
762 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
761 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
762 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | * @param string $line_item_type one of the EEM_Line_Item constants |
773 | 773 | * @return EE_Line_Item[] |
774 | 774 | */ |
775 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
776 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
775 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
776 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | |
@@ -786,15 +786,15 @@ discard block |
||
786 | 786 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
787 | 787 | * @return EE_Line_Item[] |
788 | 788 | */ |
789 | - protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
|
789 | + protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) { |
|
790 | 790 | $objects = array(); |
791 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
792 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
793 | - if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) { |
|
791 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
792 | + if ($child_line_item instanceof EE_Line_Item) { |
|
793 | + if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) { |
|
794 | 794 | $objects[] = $child_line_item; |
795 | 795 | } else { |
796 | 796 | //go-through-all-its children looking for more matches |
797 | - $objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type )); |
|
797 | + $objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type)); |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | } |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | * @param array $OBJ_IDs array of OBJ_IDs |
813 | 813 | * @return EE_Line_Item[] |
814 | 814 | */ |
815 | - public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
|
816 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
815 | + public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) { |
|
816 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -826,15 +826,15 @@ discard block |
||
826 | 826 | * @param array $OBJ_IDs array of OBJ_IDs |
827 | 827 | * @return EE_Line_Item[] |
828 | 828 | */ |
829 | - protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) { |
|
829 | + protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) { |
|
830 | 830 | $objects = array(); |
831 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
832 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
833 | - if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) { |
|
831 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
832 | + if ($child_line_item instanceof EE_Line_Item) { |
|
833 | + if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) { |
|
834 | 834 | $objects[] = $child_line_item; |
835 | 835 | } else { |
836 | 836 | //go-through-all-its children looking for more matches |
837 | - $objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs )); |
|
837 | + $objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs)); |
|
838 | 838 | } |
839 | 839 | } |
840 | 840 | } |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | * @param string $type like one of the EEM_Line_Item::type_* |
853 | 853 | * @return EE_Line_Item |
854 | 854 | */ |
855 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
856 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
855 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
856 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | * @param string $code any value used for LIN_code |
867 | 867 | * @return EE_Line_Item |
868 | 868 | */ |
869 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
870 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
869 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
870 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -880,15 +880,15 @@ discard block |
||
880 | 880 | * @param string $value any value stored in $search_field |
881 | 881 | * @return EE_Line_Item |
882 | 882 | */ |
883 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
884 | - foreach( $parent_line_item->children() as $child ){ |
|
885 | - if ( $child->get( $search_field ) == $value ){ |
|
883 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
884 | + foreach ($parent_line_item->children() as $child) { |
|
885 | + if ($child->get($search_field) == $value) { |
|
886 | 886 | return $child; |
887 | 887 | } |
888 | 888 | } |
889 | - foreach( $parent_line_item->children() as $child ){ |
|
890 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
891 | - if ( $descendant_found ){ |
|
889 | + foreach ($parent_line_item->children() as $child) { |
|
890 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
891 | + if ($descendant_found) { |
|
892 | 892 | return $descendant_found; |
893 | 893 | } |
894 | 894 | } |
@@ -904,22 +904,22 @@ discard block |
||
904 | 904 | * @param int $indentation |
905 | 905 | * @return void |
906 | 906 | */ |
907 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
907 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
908 | 908 | echo "\n<br />"; |
909 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
909 | + for ($i = 0; $i < $indentation; $i++) { |
|
910 | 910 | echo " - "; |
911 | 911 | } |
912 | - if( $line_item->is_percent() ) { |
|
913 | - $breakdown = $line_item->percent() . '%'; |
|
912 | + if ($line_item->is_percent()) { |
|
913 | + $breakdown = $line_item->percent().'%'; |
|
914 | 914 | } else { |
915 | - $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity(); |
|
915 | + $breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity(); |
|
916 | 916 | } |
917 | - echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")"; |
|
918 | - if( $line_item->is_taxable() ){ |
|
917 | + echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")"; |
|
918 | + if ($line_item->is_taxable()) { |
|
919 | 919 | echo " * taxable"; |
920 | 920 | } |
921 | - if( $line_item->children() ){ |
|
922 | - foreach($line_item->children() as $child){ |
|
921 | + if ($line_item->children()) { |
|
922 | + foreach ($line_item->children() as $child) { |
|
923 | 923 | self::visualize($child, $indentation + 1); |
924 | 924 | } |
925 | 925 | } |
@@ -960,88 +960,88 @@ discard block |
||
960 | 960 | * is theirs, which can be done with |
961 | 961 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
962 | 962 | */ |
963 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
963 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
964 | 964 | //init running grand total if not already |
965 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
966 | - $running_totals[ 'total' ] = 0; |
|
965 | + if ( ! isset($running_totals['total'])) { |
|
966 | + $running_totals['total'] = 0; |
|
967 | 967 | } |
968 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
969 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
968 | + if ( ! isset($running_totals['taxable'])) { |
|
969 | + $running_totals['taxable'] = array('total' => 0); |
|
970 | 970 | } |
971 | - foreach ( $line_item->children() as $child_line_item ) { |
|
972 | - switch ( $child_line_item->type() ) { |
|
971 | + foreach ($line_item->children() as $child_line_item) { |
|
972 | + switch ($child_line_item->type()) { |
|
973 | 973 | |
974 | 974 | case EEM_Line_Item::type_sub_total : |
975 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
975 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
976 | 976 | //combine arrays but preserve numeric keys |
977 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
978 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
979 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
977 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
978 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
979 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
980 | 980 | break; |
981 | 981 | |
982 | 982 | case EEM_Line_Item::type_tax_sub_total : |
983 | 983 | |
984 | 984 | //find how much the taxes percentage is |
985 | - if ( $child_line_item->percent() != 0 ) { |
|
985 | + if ($child_line_item->percent() != 0) { |
|
986 | 986 | $tax_percent_decimal = $child_line_item->percent() / 100; |
987 | 987 | } else { |
988 | 988 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
989 | 989 | } |
990 | 990 | //and apply to all the taxable totals, and add to the pretax totals |
991 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
991 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
992 | 992 | //"total" and "taxable" array key is an exception |
993 | - if ( $line_item_id === 'taxable' ) { |
|
993 | + if ($line_item_id === 'taxable') { |
|
994 | 994 | continue; |
995 | 995 | } |
996 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
997 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
996 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
997 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
998 | 998 | } |
999 | 999 | break; |
1000 | 1000 | |
1001 | 1001 | case EEM_Line_Item::type_line_item : |
1002 | 1002 | |
1003 | 1003 | // ticket line items or ???? |
1004 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1004 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1005 | 1005 | // kk it's a ticket |
1006 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1006 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1007 | 1007 | //huh? that shouldn't happen. |
1008 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1008 | + $running_totals['total'] += $child_line_item->total(); |
|
1009 | 1009 | } else { |
1010 | 1010 | //its not in our running totals yet. great. |
1011 | - if ( $child_line_item->is_taxable() ) { |
|
1011 | + if ($child_line_item->is_taxable()) { |
|
1012 | 1012 | $taxable_amount = $child_line_item->unit_price(); |
1013 | 1013 | } else { |
1014 | 1014 | $taxable_amount = 0; |
1015 | 1015 | } |
1016 | 1016 | // are we only calculating totals for some tickets? |
1017 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1018 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1019 | - $running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0; |
|
1020 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0; |
|
1017 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1018 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1019 | + $running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0; |
|
1020 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0; |
|
1021 | 1021 | } else { |
1022 | 1022 | $quantity = $child_line_item->quantity(); |
1023 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1024 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1023 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1024 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1025 | 1025 | } |
1026 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1027 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1026 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1027 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1028 | 1028 | } |
1029 | 1029 | } else { |
1030 | 1030 | // it's some other type of item added to the cart |
1031 | 1031 | // it should affect the running totals |
1032 | 1032 | // basically we want to convert it into a PERCENT modifier. Because |
1033 | 1033 | // more clearly affect all registration's final price equally |
1034 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1; |
|
1035 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1034 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1; |
|
1035 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1036 | 1036 | //the "taxable" array key is an exception |
1037 | - if ( $line_item_id === 'taxable' ) { |
|
1037 | + if ($line_item_id === 'taxable') { |
|
1038 | 1038 | continue; |
1039 | 1039 | } |
1040 | 1040 | // update the running totals |
1041 | 1041 | // yes this actually even works for the running grand total! |
1042 | - $running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total; |
|
1043 | - if ( $child_line_item->is_taxable() ) { |
|
1044 | - $running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1042 | + $running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total; |
|
1043 | + if ($child_line_item->is_taxable()) { |
|
1044 | + $running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1045 | 1045 | } |
1046 | 1046 | } |
1047 | 1047 | } |
@@ -1060,15 +1060,15 @@ discard block |
||
1060 | 1060 | * @param EE_Registration[] $registrations |
1061 | 1061 | * @return \EE_Line_Item |
1062 | 1062 | */ |
1063 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1064 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1065 | - foreach ( $line_item->children() as $child_li ) { |
|
1066 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1063 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1064 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1065 | + foreach ($line_item->children() as $child_li) { |
|
1066 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1067 | 1067 | } |
1068 | 1068 | //if this is the grand total line item, make sure the totals all add up |
1069 | 1069 | //(we could have duplicated this logic AS we copied the line items, but |
1070 | 1070 | //it seems DRYer this way) |
1071 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1071 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1072 | 1072 | $copy_li->recalculate_total_including_taxes(); |
1073 | 1073 | } |
1074 | 1074 | return $copy_li; |
@@ -1083,26 +1083,26 @@ discard block |
||
1083 | 1083 | * @return EE_Line_Item |
1084 | 1084 | * @param EE_Registration[] $registrations |
1085 | 1085 | */ |
1086 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1086 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1087 | 1087 | $new_li_fields = $line_item->model_field_array(); |
1088 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1088 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1089 | 1089 | $line_item->OBJ_type() === 'Ticket' |
1090 | 1090 | ) { |
1091 | 1091 | $count = 0; |
1092 | - foreach ( $registrations as $registration ) { |
|
1093 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1094 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1092 | + foreach ($registrations as $registration) { |
|
1093 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1094 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1095 | 1095 | ) { |
1096 | 1096 | $count++; |
1097 | 1097 | } |
1098 | 1098 | } |
1099 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1099 | + $new_li_fields['LIN_quantity'] = $count; |
|
1100 | 1100 | } |
1101 | 1101 | //don't set the total. We'll leave that up to the code that calculates it |
1102 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1103 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1104 | - unset( $new_li_fields[ 'LIN_total' ] ); |
|
1105 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1102 | + unset($new_li_fields['LIN_ID']); |
|
1103 | + unset($new_li_fields['LIN_parent']); |
|
1104 | + unset($new_li_fields['LIN_total']); |
|
1105 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
@@ -1114,19 +1114,19 @@ discard block |
||
1114 | 1114 | * @param EE_Line_Item $line_item |null |
1115 | 1115 | * @return \EE_Line_Item|null |
1116 | 1116 | */ |
1117 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1118 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1119 | - if ( $copied_li === null ) { |
|
1117 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1118 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1119 | + if ($copied_li === null) { |
|
1120 | 1120 | return null; |
1121 | 1121 | } |
1122 | 1122 | //if this is an event subtotal, we want to only include it if it |
1123 | 1123 | //has a non-zero total and at least one ticket line item child |
1124 | 1124 | $ticket_children = 0; |
1125 | - foreach ( $line_item->children() as $child_li ) { |
|
1126 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1127 | - if ( $child_li_copy !== null ) { |
|
1128 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1129 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1125 | + foreach ($line_item->children() as $child_li) { |
|
1126 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1127 | + if ($child_li_copy !== null) { |
|
1128 | + $copied_li->add_child_line_item($child_li_copy); |
|
1129 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1130 | 1130 | $child_li_copy->OBJ_type() === 'Ticket' |
1131 | 1131 | ) { |
1132 | 1132 | $ticket_children++; |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | } |
1136 | 1136 | //if this is an event subtotal with NO ticket children |
1137 | 1137 | //we basically want to ignore it |
1138 | - if ( $line_item->type() === EEM_Line_Item::type_sub_total && |
|
1138 | + if ($line_item->type() === EEM_Line_Item::type_sub_total && |
|
1139 | 1139 | $line_item->OBJ_type() === 'Event' && |
1140 | 1140 | $ticket_children === 0 && |
1141 | 1141 | $line_item->total() === 0 |
@@ -1153,8 +1153,8 @@ discard block |
||
1153 | 1153 | * @param EE_Line_Item $line_item |
1154 | 1154 | * @return EE_Line_Item |
1155 | 1155 | */ |
1156 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1157 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1156 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1157 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1158 | 1158 | $line_item->OBJ_type() === 'Ticket' && |
1159 | 1159 | $line_item->quantity() == 0 |
1160 | 1160 | ) { |
@@ -1162,9 +1162,9 @@ discard block |
||
1162 | 1162 | } |
1163 | 1163 | $new_li_fields = $line_item->model_field_array(); |
1164 | 1164 | //don't set the total. We'll leave that up to the code that calculates it |
1165 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1166 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1167 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1165 | + unset($new_li_fields['LIN_ID']); |
|
1166 | + unset($new_li_fields['LIN_parent']); |
|
1167 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | |
@@ -1178,9 +1178,9 @@ discard block |
||
1178 | 1178 | * @param EE_Line_Item $total_line_item |
1179 | 1179 | * @return \EE_Line_Item |
1180 | 1180 | */ |
1181 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1182 | - 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' ); |
|
1183 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1181 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1182 | + 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'); |
|
1183 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | |
@@ -1190,9 +1190,9 @@ discard block |
||
1190 | 1190 | * @param EE_Transaction $transaction |
1191 | 1191 | * @return \EE_Line_Item |
1192 | 1192 | */ |
1193 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1194 | - 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' ); |
|
1195 | - return self::create_total_line_item( $transaction ); |
|
1193 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1194 | + 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'); |
|
1195 | + return self::create_total_line_item($transaction); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | |
@@ -1203,9 +1203,9 @@ discard block |
||
1203 | 1203 | * @param EE_Transaction $transaction |
1204 | 1204 | * @return \EE_Line_Item |
1205 | 1205 | */ |
1206 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1207 | - 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' ); |
|
1208 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1206 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1207 | + 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'); |
|
1208 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | |
@@ -1216,9 +1216,9 @@ discard block |
||
1216 | 1216 | * @param EE_Transaction $transaction |
1217 | 1217 | * @return \EE_Line_Item |
1218 | 1218 | */ |
1219 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1220 | - 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' ); |
|
1221 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1219 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1220 | + 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'); |
|
1221 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | |
@@ -1229,9 +1229,9 @@ discard block |
||
1229 | 1229 | * @param EE_Transaction $transaction |
1230 | 1230 | * @return \EE_Line_Item |
1231 | 1231 | */ |
1232 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1233 | - 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' ); |
|
1234 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1232 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1233 | + 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'); |
|
1234 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 |
@@ -467,15 +467,15 @@ |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
470 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
471 | - * line item the ticket's purchase should be added onto |
|
472 | - * |
|
473 | - * @access public |
|
474 | - * @param EE_Line_Item $grand_total the grand total line item |
|
475 | - * @param EE_Ticket $ticket |
|
476 | - * @throws \EE_Error |
|
477 | - * @return EE_Line_Item |
|
478 | - */ |
|
470 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
471 | + * line item the ticket's purchase should be added onto |
|
472 | + * |
|
473 | + * @access public |
|
474 | + * @param EE_Line_Item $grand_total the grand total line item |
|
475 | + * @param EE_Ticket $ticket |
|
476 | + * @throws \EE_Error |
|
477 | + * @return EE_Line_Item |
|
478 | + */ |
|
479 | 479 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
480 | 480 | $first_datetime = $ticket->first_datetime(); |
481 | 481 | if( ! $first_datetime instanceof EE_Datetime ){ |
@@ -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 |
@@ -131,7 +131,7 @@ |
||
131 | 131 | /** |
132 | 132 | * this just returns the properly formatted tab content for our tab box. |
133 | 133 | * @param string $name name of tab (used for selector) |
134 | - * @param string $content content of tab |
|
134 | + * @param string $tab_content content of tab |
|
135 | 135 | * @return string html for content area |
136 | 136 | */ |
137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -43,22 +43,22 @@ discard block |
||
43 | 43 | * @param array $tabs_content an array of the content for each tab [required] |
44 | 44 | * @return string the assembled html string containing the tabbed content for display. |
45 | 45 | */ |
46 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
46 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
47 | 47 | |
48 | 48 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
49 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
50 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
49 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
50 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | //make sure we've got incoming data setup properly |
54 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
55 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
54 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
55 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
56 | 56 | |
57 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
57 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
58 | 58 | $all_tabs_content = ''; |
59 | 59 | |
60 | 60 | $index = 0; |
61 | - foreach ( $tabs as $tab ) { |
|
61 | + foreach ($tabs as $tab) { |
|
62 | 62 | $active = $index === 0 ? true : false; |
63 | 63 | $all_tabs .= self::tab($tab, $active); |
64 | 64 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
77 | 77 | |
78 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
78 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param array $nav_tabs tab array for nav tabs |
99 | 99 | */ |
100 | 100 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
101 | - if ( empty($nav_tabs) ) |
|
102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
101 | + if (empty($nav_tabs)) |
|
102 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
103 | 103 | |
104 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
105 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
104 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
105 | + foreach ($nav_tabs as $slug => $tab) { |
|
106 | 106 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
107 | 107 | } |
108 | 108 | $all_tabs .= '</h2>'; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param bool|string $css If string given then the generated tab will include that as the class. |
119 | 119 | * @return string html for tab |
120 | 120 | */ |
121 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
121 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
122 | 122 | $name = str_replace(' ', '-', $name); |
123 | 123 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
124 | - $class = $css ? $class . ' ' . $css : $class; |
|
125 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
126 | - $url = $url ? $url : '#' . $name; |
|
127 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
124 | + $class = $css ? $class.' '.$css : $class; |
|
125 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
126 | + $url = $url ? $url : '#'.$name; |
|
127 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
128 | 128 | return $tab; |
129 | 129 | } |
130 | 130 | |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
138 | 138 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
139 | - $name = str_replace( ' ', '-', $name); |
|
140 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
141 | - $content .= "\t" . $tab_content . "\n"; |
|
139 | + $name = str_replace(' ', '-', $name); |
|
140 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
141 | + $content .= "\t".$tab_content."\n"; |
|
142 | 142 | $content .= '<div style="clear:both"></div></div>'; |
143 | 143 | return $content; |
144 | 144 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
165 | 165 | * @return string a html snippet of of all the formatted link elements. |
166 | 166 | */ |
167 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
167 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
168 | + if ( ! is_array($item_array) || empty($item_array)) |
|
169 | 169 | return false; //get out we don't have even the basic thing we need! |
170 | 170 | |
171 | 171 | |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
177 | 177 | 'slug' => 'item_slug' |
178 | 178 | ); |
179 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
180 | - $list = '<ul class="' . $container_class . '">'; |
|
179 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
180 | + $list = '<ul class="'.$container_class.'">'; |
|
181 | 181 | |
182 | 182 | $ci = 1; |
183 | - foreach ( $item_array as $item ) { |
|
184 | - $item = wp_parse_args( $item, $defaults ); |
|
185 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
183 | + foreach ($item_array as $item) { |
|
184 | + $item = wp_parse_args($item, $defaults); |
|
185 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
186 | 186 | $list .= self::_text_link_item($item); |
187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
187 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
188 | 188 | $list .= self::_text_link_item($sep); |
189 | 189 | $ci++; |
190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | |
196 | 196 | |
197 | 197 | |
198 | - private static function _text_link_item( $item ) { |
|
198 | + private static function _text_link_item($item) { |
|
199 | 199 | //if this isn't an array then we're doing a separator |
200 | - if ( !is_array( $item ) ) { |
|
200 | + if ( ! is_array($item)) { |
|
201 | 201 | $label = $item; |
202 | 202 | $class = 'ee-text-link-sep'; |
203 | 203 | $href = ''; |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | extract($item); |
207 | 207 | } |
208 | 208 | |
209 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
209 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
210 | 210 | |
211 | - $content = '<li ' . $class . '>'; |
|
212 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
211 | + $content = '<li '.$class.'>'; |
|
212 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
213 | 213 | $content .= $label; |
214 | - $content .= !empty($href) ? '</a>' : ''; |
|
214 | + $content .= ! empty($href) ? '</a>' : ''; |
|
215 | 215 | $content .= '</li>'; |
216 | 216 | return $content; |
217 | 217 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | * @param array $nav_tabs tab array for nav tabs |
99 | 100 | */ |
100 | 101 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
101 | - if ( empty($nav_tabs) ) |
|
102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
102 | + if ( empty($nav_tabs) ) { |
|
103 | + throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
105 | 107 | foreach ( $nav_tabs as $slug => $tab ) { |
@@ -165,8 +167,10 @@ discard block |
||
165 | 167 | * @return string a html snippet of of all the formatted link elements. |
166 | 168 | */ |
167 | 169 | public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
169 | - return false; //get out we don't have even the basic thing we need! |
|
170 | + if ( !is_array($item_array) || empty( $item_array ) ) { |
|
171 | + return false; |
|
172 | + } |
|
173 | + //get out we don't have even the basic thing we need! |
|
170 | 174 | |
171 | 175 | |
172 | 176 | $defaults = array( |
@@ -184,8 +188,9 @@ discard block |
||
184 | 188 | $item = wp_parse_args( $item, $defaults ); |
185 | 189 | $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
186 | 190 | $list .= self::_text_link_item($item); |
187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
188 | - $list .= self::_text_link_item($sep); |
|
191 | + if ( !empty($sep) && $ci != count($item_array) ) { |
|
192 | + $list .= self::_text_link_item($sep); |
|
193 | + } |
|
189 | 194 | $ci++; |
190 | 195 | } |
191 | 196 |
@@ -248,7 +248,7 @@ |
||
248 | 248 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
249 | 249 | * @param array $template_args an array of arguments to be extracted for use in the template |
250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
251 | - * @return mixed string |
|
251 | + * @return string string |
|
252 | 252 | */ |
253 | 253 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | foreach ( (array)$full_template_paths as $full_template_path ) { |
227 | 227 | if ( is_readable( $full_template_path )) { |
228 | 228 | $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
229 | - break; |
|
229 | + break; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -648,9 +648,9 @@ discard block |
||
648 | 648 | ); |
649 | 649 | |
650 | 650 | if ( empty( $items_label ) |
651 | - || ! is_array( $items_label ) |
|
652 | - || ! isset( $items_label['single'] ) |
|
653 | - || ! isset( $items_label['plural'] ) ) { |
|
651 | + || ! is_array( $items_label ) |
|
652 | + || ! isset( $items_label['single'] ) |
|
653 | + || ! isset( $items_label['plural'] ) ) { |
|
654 | 654 | $items_label = array( |
655 | 655 | 'single' => __( '1 item', 'event_espresso' ), |
656 | 656 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -156,26 +156,26 @@ discard block |
||
156 | 156 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
157 | 157 | * @return mixed |
158 | 158 | */ |
159 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
159 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | - $template_path = locate_template( $templates ); |
|
161 | + $template_path = locate_template($templates); |
|
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
163 | + if ($check_if_custom && ! empty($template_path)) |
|
164 | 164 | return TRUE; |
165 | 165 | |
166 | 166 | // not in the theme |
167 | - if ( empty( $template_path )) { |
|
167 | + if (empty($template_path)) { |
|
168 | 168 | // not even a template to look for ? |
169 | - if ( empty( $templates )) { |
|
169 | + if (empty($templates)) { |
|
170 | 170 | // get post_type |
171 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
171 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
172 | 172 | // get array of EE Custom Post Types |
173 | 173 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
174 | 174 | // build template name based on request |
175 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
176 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
177 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
178 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
175 | + if (isset($EE_CPTs[$post_type])) { |
|
176 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
177 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
178 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | // currently active EE template theme |
@@ -184,61 +184,61 @@ discard block |
||
184 | 184 | // array of paths to folders that may contain templates |
185 | 185 | $template_folder_paths = array( |
186 | 186 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
187 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
187 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
188 | 188 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
189 | 189 | EVENT_ESPRESSO_TEMPLATE_DIR |
190 | 190 | ); |
191 | 191 | |
192 | 192 | //add core plugin folders for checking only if we're not $check_if_custom |
193 | - if ( ! $check_if_custom ) { |
|
193 | + if ( ! $check_if_custom) { |
|
194 | 194 | $core_paths = array( |
195 | 195 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
196 | - EE_PUBLIC . $current_theme, |
|
196 | + EE_PUBLIC.$current_theme, |
|
197 | 197 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
198 | - EE_TEMPLATES . $current_theme, |
|
198 | + EE_TEMPLATES.$current_theme, |
|
199 | 199 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
200 | 200 | EE_PLUGIN_DIR_PATH |
201 | 201 | ); |
202 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
202 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // now filter that array |
206 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
206 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
207 | 207 | |
208 | 208 | // array to hold all possible template paths |
209 | 209 | $full_template_paths = array(); |
210 | 210 | |
211 | 211 | // loop through $templates |
212 | - foreach ( (array)$templates as $template ) { |
|
212 | + foreach ((array) $templates as $template) { |
|
213 | 213 | // while looping through all template folder paths |
214 | - foreach ( (array)$template_folder_paths as $template_folder_path ) { |
|
214 | + foreach ((array) $template_folder_paths as $template_folder_path) { |
|
215 | 215 | // build up our template locations array by combining our template folder paths with our templates |
216 | - $full_template_paths[] = rtrim( $template_folder_path, DS ) . DS . $template; |
|
216 | + $full_template_paths[] = rtrim($template_folder_path, DS).DS.$template; |
|
217 | 217 | } |
218 | 218 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
219 | - array_unshift( $full_template_paths, $template ); |
|
219 | + array_unshift($full_template_paths, $template); |
|
220 | 220 | } |
221 | 221 | // filter final array of full template paths |
222 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths ); |
|
222 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); |
|
223 | 223 | |
224 | 224 | |
225 | 225 | // now loop through our final array of template location paths and check each location |
226 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
227 | - if ( is_readable( $full_template_path )) { |
|
228 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
226 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
227 | + if (is_readable($full_template_path)) { |
|
228 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
229 | 229 | break; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
233 | 233 | // if we got it and you want to see it... |
234 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
235 | - if ( $return_string ) { |
|
236 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
234 | + if ($template_path && $load && ! $check_if_custom) { |
|
235 | + if ($return_string) { |
|
236 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
237 | 237 | } else { |
238 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
238 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
239 | 239 | } |
240 | 240 | } |
241 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
241 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
251 | 251 | * @return mixed string |
252 | 252 | */ |
253 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
253 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
255 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
255 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -263,26 +263,26 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @since 4.6.0 |
265 | 265 | */ |
266 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
267 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
266 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
267 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
268 | 268 | |
269 | 269 | // you gimme nuttin - YOU GET NUTTIN !! |
270 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
270 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
271 | 271 | return ''; |
272 | 272 | } |
273 | 273 | // if $template_args are not in an array, then make it so |
274 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
275 | - $template_args = array( $template_args ); |
|
274 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
275 | + $template_args = array($template_args); |
|
276 | 276 | } |
277 | - extract( (array) $template_args); |
|
277 | + extract((array) $template_args); |
|
278 | 278 | |
279 | - if ( $return_string ) { |
|
279 | + if ($return_string) { |
|
280 | 280 | // because we want to return a string, we are going to capture the output |
281 | 281 | ob_start(); |
282 | - include( $template_path ); |
|
282 | + include($template_path); |
|
283 | 283 | return ob_get_clean(); |
284 | 284 | } else { |
285 | - include( $template_path ); |
|
285 | + include($template_path); |
|
286 | 286 | } |
287 | 287 | return ''; |
288 | 288 | } |
@@ -300,27 +300,27 @@ discard block |
||
300 | 300 | * @param string $suffix added to the end of the generated class |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
303 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
304 | 304 | // in the beginning... |
305 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
305 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
306 | 306 | // da muddle |
307 | 307 | $class = ''; |
308 | 308 | // the end |
309 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
309 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
310 | 310 | // is the passed object an EE object ? |
311 | - if ( $object instanceof EE_Base_Class ) { |
|
311 | + if ($object instanceof EE_Base_Class) { |
|
312 | 312 | // grab the exact type of object |
313 | - $obj_class = get_class( $object ); |
|
313 | + $obj_class = get_class($object); |
|
314 | 314 | // depending on the type of object... |
315 | - switch ( $obj_class ) { |
|
315 | + switch ($obj_class) { |
|
316 | 316 | // no specifics just yet... |
317 | 317 | default : |
318 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
319 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
318 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
319 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | } |
323 | - return $prefix . $class . $suffix; |
|
323 | + return $prefix.$class.$suffix; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -336,50 +336,50 @@ discard block |
||
336 | 336 | * @param string $cur_code_span_class |
337 | 337 | * @return string the html output for the formatted money value |
338 | 338 | */ |
339 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
339 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
340 | 340 | // ensure amount was received |
341 | - if ( is_null( $amount ) ) { |
|
342 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
343 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
341 | + if (is_null($amount)) { |
|
342 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
343 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
344 | 344 | return ''; |
345 | 345 | } |
346 | 346 | //ensure amount is float |
347 | 347 | $amount = (float) $amount; |
348 | 348 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
349 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
349 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
350 | 350 | // still a number or was amount converted to a string like "free" ? |
351 | - if ( is_float( $amount_formatted )) { |
|
351 | + if (is_float($amount_formatted)) { |
|
352 | 352 | // was a country ISO code passed ? if so generate currency config object for that country |
353 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
353 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
354 | 354 | // verify results |
355 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
355 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
356 | 356 | // set default config country currency settings |
357 | 357 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
358 | 358 | } |
359 | 359 | // format float |
360 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
360 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
361 | 361 | // add formatting ? |
362 | - if ( ! $return_raw ) { |
|
362 | + if ( ! $return_raw) { |
|
363 | 363 | // add currency sign |
364 | - if( $mny->sign_b4 ){ |
|
365 | - if( $amount >= 0 ){ |
|
366 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
367 | - }else{ |
|
368 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
364 | + if ($mny->sign_b4) { |
|
365 | + if ($amount >= 0) { |
|
366 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
367 | + } else { |
|
368 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
369 | 369 | } |
370 | 370 | |
371 | - }else{ |
|
372 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
371 | + } else { |
|
372 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // add currency code ? |
376 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
376 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
377 | 377 | } |
378 | 378 | // filter results |
379 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
379 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
380 | 380 | } |
381 | 381 | // clean up vars |
382 | - unset( $mny ); |
|
382 | + unset($mny); |
|
383 | 383 | // return formatted currency amount |
384 | 384 | return $amount_formatted; |
385 | 385 | } |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
395 | 395 | * @return string The localized label for the status id. |
396 | 396 | */ |
397 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
397 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
398 | 398 | /** @type EEM_Status $EEM_Status */ |
399 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
400 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
401 | - return $status[ $status_id ]; |
|
399 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
400 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
401 | + return $status[$status_id]; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * @param string $icon |
412 | 412 | * @return string the html output for the button |
413 | 413 | */ |
414 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
415 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
416 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
414 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
415 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
416 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
417 | 417 | return $button; |
418 | 418 | } |
419 | 419 | |
@@ -430,21 +430,21 @@ discard block |
||
430 | 430 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
431 | 431 | * @return string generated link |
432 | 432 | */ |
433 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
433 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
434 | 434 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
435 | + if ( ! $page) |
|
436 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
437 | 437 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
438 | + if ( ! $action) |
|
439 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
440 | 440 | |
441 | 441 | $action = empty($action) ? 'default' : $action; |
442 | 442 | |
443 | 443 | |
444 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
445 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
446 | - $help_text = !$help_text ? '' : $help_text; |
|
447 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
444 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
445 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
446 | + $help_text = ! $help_text ? '' : $help_text; |
|
447 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -456,31 +456,31 @@ discard block |
||
456 | 456 | * @param EE_Help_Tour |
457 | 457 | * @return string html |
458 | 458 | */ |
459 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
459 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
460 | 460 | $id = $tour->get_slug(); |
461 | 461 | $stops = $tour->get_stops(); |
462 | 462 | |
463 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
463 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
464 | 464 | |
465 | - foreach ( $stops as $stop ) { |
|
466 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
467 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
465 | + foreach ($stops as $stop) { |
|
466 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
467 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
468 | 468 | |
469 | 469 | //if container is set to modal then let's make sure we set the options accordingly |
470 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
470 | + if (empty($data_id) && empty($data_class)) { |
|
471 | 471 | $stop['options']['modal'] = true; |
472 | 472 | $stop['options']['expose'] = true; |
473 | 473 | } |
474 | 474 | |
475 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
476 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
475 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
476 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
477 | 477 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
478 | 478 | |
479 | 479 | //options |
480 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
480 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
481 | 481 | $options = ' data-options="'; |
482 | - foreach ( $stop['options'] as $option => $value ) { |
|
483 | - $options .= $option . ':' . $value . ';'; |
|
482 | + foreach ($stop['options'] as $option => $value) { |
|
483 | + $options .= $option.':'.$value.';'; |
|
484 | 484 | } |
485 | 485 | $options .= '"'; |
486 | 486 | } else { |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | //let's put all together |
491 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
491 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | $content .= '</ol>'; |
@@ -509,31 +509,31 @@ discard block |
||
509 | 509 | * @throws EE_Error |
510 | 510 | * @return string html structure for status. |
511 | 511 | */ |
512 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
512 | + public static function status_legend($status_array, $active_status = '') { |
|
513 | + if ( ! is_array($status_array)) |
|
514 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
515 | 515 | |
516 | 516 | $setup_array = array(); |
517 | - foreach ( $status_array as $item => $status ) { |
|
517 | + foreach ($status_array as $item => $status) { |
|
518 | 518 | $setup_array[$item] = array( |
519 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
520 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
519 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
520 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
521 | 521 | 'status' => $status |
522 | 522 | ); |
523 | 523 | } |
524 | 524 | |
525 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
526 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
527 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
528 | - foreach ( $setup_array as $item => $details ) { |
|
525 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
526 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
527 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
528 | + foreach ($setup_array as $item => $details) { |
|
529 | 529 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
530 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
531 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
532 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
533 | - $content .= '</dt>' . "\n"; |
|
530 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
531 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
532 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
533 | + $content .= '</dt>'."\n"; |
|
534 | 534 | } |
535 | - $content .= '</dl>' . "\n"; |
|
536 | - $content .= '</div>' . "\n"; |
|
535 | + $content .= '</dl>'."\n"; |
|
536 | + $content .= '</div>'."\n"; |
|
537 | 537 | return $content; |
538 | 538 | } |
539 | 539 | |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | * @return string |
547 | 547 | */ |
548 | 548 | public static function layout_array_as_table($data) { |
549 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
550 | - $data = (array)$data; |
|
549 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
550 | + $data = (array) $data; |
|
551 | 551 | } |
552 | 552 | EE_Registry::instance()->load_helper('Array'); |
553 | 553 | ob_start(); |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | ?> |
562 | 562 | <tr> |
563 | 563 | <td> |
564 | - <?php echo $data_key;?> |
|
564 | + <?php echo $data_key; ?> |
|
565 | 565 | </td> |
566 | 566 | <td> |
567 | - <?php echo self::layout_array_as_table($data_values);?> |
|
567 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
568 | 568 | </td> |
569 | 569 | </tr> |
570 | 570 | <?php |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | <ul> |
579 | 579 | <?php |
580 | 580 | foreach ($data as $datum) { |
581 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
581 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
582 | 582 | }?> |
583 | 583 | </ul> |
584 | 584 | <?php |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return string |
610 | 610 | */ |
611 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
612 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
611 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
612 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | |
@@ -633,13 +633,13 @@ discard block |
||
633 | 633 | * ) |
634 | 634 | * @return string |
635 | 635 | */ |
636 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
636 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
637 | 637 | $page_links = array(); |
638 | 638 | $disable_first = $disable_last = ''; |
639 | 639 | $total_items = (int) $total_items; |
640 | 640 | $per_page = (int) $per_page; |
641 | 641 | $current = (int) $current; |
642 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
642 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
643 | 643 | |
644 | 644 | //filter items_label |
645 | 645 | $items_label = apply_filters( |
@@ -647,68 +647,68 @@ discard block |
||
647 | 647 | $items_label |
648 | 648 | ); |
649 | 649 | |
650 | - if ( empty( $items_label ) |
|
651 | - || ! is_array( $items_label ) |
|
652 | - || ! isset( $items_label['single'] ) |
|
653 | - || ! isset( $items_label['plural'] ) ) { |
|
650 | + if (empty($items_label) |
|
651 | + || ! is_array($items_label) |
|
652 | + || ! isset($items_label['single']) |
|
653 | + || ! isset($items_label['plural'])) { |
|
654 | 654 | $items_label = array( |
655 | - 'single' => __( '1 item', 'event_espresso' ), |
|
656 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
655 | + 'single' => __('1 item', 'event_espresso'), |
|
656 | + 'plural' => __('%s items', 'event_espresso') |
|
657 | 657 | ); |
658 | 658 | } else { |
659 | 659 | $items_label = array( |
660 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
661 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
660 | + 'single' => '1 '.esc_html($items_label['single']), |
|
661 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
662 | 662 | ); |
663 | 663 | } |
664 | 664 | |
665 | - $total_pages = ceil( $total_items / $per_page ); |
|
665 | + $total_pages = ceil($total_items / $per_page); |
|
666 | 666 | |
667 | - if ( $total_pages <= 1 ) |
|
667 | + if ($total_pages <= 1) |
|
668 | 668 | return ''; |
669 | 669 | |
670 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
670 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
671 | 671 | |
672 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
672 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
673 | 673 | |
674 | - if ( $current === 1 ) { |
|
674 | + if ($current === 1) { |
|
675 | 675 | $disable_first = ' disabled'; |
676 | 676 | } |
677 | - if ( $current == $total_pages ) { |
|
677 | + if ($current == $total_pages) { |
|
678 | 678 | $disable_last = ' disabled'; |
679 | 679 | } |
680 | 680 | |
681 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
682 | - 'first-page' . $disable_first, |
|
683 | - esc_attr__( 'Go to the first page' ), |
|
684 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
681 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
682 | + 'first-page'.$disable_first, |
|
683 | + esc_attr__('Go to the first page'), |
|
684 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
685 | 685 | '«' |
686 | 686 | ); |
687 | 687 | |
688 | 688 | $page_links[] = sprintf( |
689 | 689 | '<a class="%s" title="%s" href="%s">%s</a>', |
690 | - 'prev-page' . $disable_first, |
|
691 | - esc_attr__( 'Go to the previous page' ), |
|
692 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
690 | + 'prev-page'.$disable_first, |
|
691 | + esc_attr__('Go to the previous page'), |
|
692 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
693 | 693 | '‹' |
694 | 694 | ); |
695 | 695 | |
696 | - if ( ! $show_num_field ) { |
|
696 | + if ( ! $show_num_field) { |
|
697 | 697 | $html_current_page = $current; |
698 | 698 | } else { |
699 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
700 | - esc_attr__( 'Current page' ), |
|
699 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
700 | + esc_attr__('Current page'), |
|
701 | 701 | $current, |
702 | - strlen( $total_pages ) |
|
702 | + strlen($total_pages) |
|
703 | 703 | ); |
704 | 704 | } |
705 | 705 | |
706 | 706 | $html_total_pages = sprintf( |
707 | 707 | '<span class="total-pages">%s</span>', |
708 | - number_format_i18n( $total_pages ) |
|
708 | + number_format_i18n($total_pages) |
|
709 | 709 | ); |
710 | 710 | $page_links[] = sprintf( |
711 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
711 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
712 | 712 | $html_current_page, |
713 | 713 | $html_total_pages, |
714 | 714 | '<span class="paging-input">', |
@@ -717,29 +717,29 @@ discard block |
||
717 | 717 | |
718 | 718 | $page_links[] = sprintf( |
719 | 719 | '<a class="%s" title="%s" href="%s">%s</a>', |
720 | - 'next-page' . $disable_last, |
|
721 | - esc_attr__( 'Go to the next page' ), |
|
722 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
720 | + 'next-page'.$disable_last, |
|
721 | + esc_attr__('Go to the next page'), |
|
722 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
723 | 723 | '›' |
724 | 724 | ); |
725 | 725 | |
726 | 726 | $page_links[] = sprintf( |
727 | 727 | '<a class="%s" title="%s" href="%s">%s</a>', |
728 | - 'last-page' . $disable_last, |
|
729 | - esc_attr__( 'Go to the last page' ), |
|
730 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
728 | + 'last-page'.$disable_last, |
|
729 | + esc_attr__('Go to the last page'), |
|
730 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
731 | 731 | '»' |
732 | 732 | ); |
733 | 733 | |
734 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
734 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
735 | 735 | // set page class |
736 | - if ( $total_pages ) { |
|
736 | + if ($total_pages) { |
|
737 | 737 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
738 | 738 | } else { |
739 | 739 | $page_class = ' no-pages'; |
740 | 740 | } |
741 | 741 | |
742 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
742 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
743 | 743 | } |
744 | 744 | |
745 | 745 |
@@ -160,8 +160,9 @@ discard block |
||
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | 161 | $template_path = locate_template( $templates ); |
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
164 | - return TRUE; |
|
163 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
164 | + return TRUE; |
|
165 | + } |
|
165 | 166 | |
166 | 167 | // not in the theme |
167 | 168 | if ( empty( $template_path )) { |
@@ -364,11 +365,11 @@ discard block |
||
364 | 365 | if( $mny->sign_b4 ){ |
365 | 366 | if( $amount >= 0 ){ |
366 | 367 | $amount_formatted = $mny->sign . $amount_formatted; |
367 | - }else{ |
|
368 | + } else{ |
|
368 | 369 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
369 | 370 | } |
370 | 371 | |
371 | - }else{ |
|
372 | + } else{ |
|
372 | 373 | $amount_formatted = $amount_formatted . $mny->sign; |
373 | 374 | } |
374 | 375 | |
@@ -432,11 +433,13 @@ discard block |
||
432 | 433 | */ |
433 | 434 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
434 | 435 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
436 | + if ( ! $page ) { |
|
437 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
438 | + } |
|
437 | 439 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
440 | + if ( ! $action ) { |
|
441 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
442 | + } |
|
440 | 443 | |
441 | 444 | $action = empty($action) ? 'default' : $action; |
442 | 445 | |
@@ -510,8 +513,9 @@ discard block |
||
510 | 513 | * @return string html structure for status. |
511 | 514 | */ |
512 | 515 | public static function status_legend( $status_array, $active_status = '' ) { |
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
516 | + if ( !is_array( $status_array ) ) { |
|
517 | + throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
518 | + } |
|
515 | 519 | |
516 | 520 | $setup_array = array(); |
517 | 521 | foreach ( $status_array as $item => $status ) { |
@@ -572,8 +576,7 @@ discard block |
||
572 | 576 | </tbody> |
573 | 577 | </table> |
574 | 578 | <?php |
575 | - } |
|
576 | - else { |
|
579 | + } else { |
|
577 | 580 | ?> |
578 | 581 | <ul> |
579 | 582 | <?php |
@@ -583,8 +586,7 @@ discard block |
||
583 | 586 | </ul> |
584 | 587 | <?php |
585 | 588 | } |
586 | - } |
|
587 | - else { |
|
589 | + } else { |
|
588 | 590 | //simple value |
589 | 591 | echo $data; |
590 | 592 | } |
@@ -664,8 +666,9 @@ discard block |
||
664 | 666 | |
665 | 667 | $total_pages = ceil( $total_items / $per_page ); |
666 | 668 | |
667 | - if ( $total_pages <= 1 ) |
|
668 | - return ''; |
|
669 | + if ( $total_pages <= 1 ) { |
|
670 | + return ''; |
|
671 | + } |
|
669 | 672 | |
670 | 673 | $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
671 | 674 |