@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | //namespace EventEspresso\core\libraries\templates; |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -70,23 +70,23 @@ discard block |
||
| 70 | 70 | * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
| 71 | 71 | * @param int $priority - order in which template parts should be applied |
| 72 | 72 | */ |
| 73 | - public function add_template_part( $name, $label, $template, $priority ) { |
|
| 73 | + public function add_template_part($name, $label, $template, $priority) { |
|
| 74 | 74 | // SplPriorityQueue doesn't play nice with multiple items having the same priority |
| 75 | 75 | // so if the incoming priority is already occupied, then let's increment it by one, |
| 76 | 76 | // and then pass everything back into this method and try again with the new priority |
| 77 | - if ( isset( $this->priorities[ $priority ] ) ) { |
|
| 77 | + if (isset($this->priorities[$priority])) { |
|
| 78 | 78 | $priority++; |
| 79 | - $this->add_template_part( $name, $label, $template, $priority ); |
|
| 79 | + $this->add_template_part($name, $label, $template, $priority); |
|
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | // kk now we can mark this priority as being occupied |
| 83 | - $this->priorities[ $priority ] = true; |
|
| 83 | + $this->priorities[$priority] = true; |
|
| 84 | 84 | // create the template part and add to the queue |
| 85 | 85 | $this->template_parts->insert( |
| 86 | - new EE_Template_Part( $name, $label, $template, $priority ), |
|
| 86 | + new EE_Template_Part($name, $label, $template, $priority), |
|
| 87 | 87 | $priority |
| 88 | 88 | ); |
| 89 | - if ( $name == 'event' ) { |
|
| 89 | + if ($name == 'event') { |
|
| 90 | 90 | $this->event_desc_priority = $priority; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | * @param string $content |
| 104 | 104 | * @return string |
| 105 | 105 | */ |
| 106 | - public function apply_template_part_filters( $content = '' ) { |
|
| 106 | + public function apply_template_part_filters($content = '') { |
|
| 107 | 107 | $this->template_parts->rewind(); |
| 108 | 108 | // loop through template parts and position content |
| 109 | - while ( $this->template_parts->valid() ) { |
|
| 109 | + while ($this->template_parts->valid()) { |
|
| 110 | 110 | $this->_position_template_part( |
| 111 | 111 | $content, |
| 112 | 112 | $this->template_parts->current()->template(), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $this->template_parts->next(); |
| 116 | 116 | } |
| 117 | 117 | // now simply add our three strings of content together |
| 118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
| 118 | + return $this->before_event_content.$this->event_content.$this->after_event_content; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -136,16 +136,16 @@ discard block |
||
| 136 | 136 | * @param int $priority |
| 137 | 137 | * @return string |
| 138 | 138 | */ |
| 139 | - protected function _position_template_part( $content, $template, $priority ) { |
|
| 139 | + protected function _position_template_part($content, $template, $priority) { |
|
| 140 | 140 | // Event Description content is the actual incoming content itself |
| 141 | - if ( $priority === $this->event_desc_priority ) { |
|
| 141 | + if ($priority === $this->event_desc_priority) { |
|
| 142 | 142 | $this->event_content = $content; |
| 143 | - } else if ( $priority < $this->event_desc_priority ) { |
|
| 143 | + } else if ($priority < $this->event_desc_priority) { |
|
| 144 | 144 | // everything BEFORE the Event Description |
| 145 | - $this->before_event_content .= EEH_Template::locate_template( $template ); |
|
| 146 | - } else if ( $priority > $this->event_desc_priority ) { |
|
| 145 | + $this->before_event_content .= EEH_Template::locate_template($template); |
|
| 146 | + } else if ($priority > $this->event_desc_priority) { |
|
| 147 | 147 | // everything AFTER the Event Description |
| 148 | - $this->after_event_content .= EEH_Template::locate_template( $template ); |
|
| 148 | + $this->after_event_content .= EEH_Template::locate_template($template); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -170,15 +170,15 @@ discard block |
||
| 170 | 170 | $list_item_css_class = '', |
| 171 | 171 | $list_item_css_id_prefix = '' |
| 172 | 172 | ) { |
| 173 | - $event_archive_display_order = EEH_HTML::ul( $list_css_id, $list_css_class ); |
|
| 173 | + $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
| 174 | 174 | $this->template_parts->rewind(); |
| 175 | 175 | // loop through template parts and add template content |
| 176 | - while ( $this->template_parts->valid() ) { |
|
| 176 | + while ($this->template_parts->valid()) { |
|
| 177 | 177 | $event_archive_display_order .= EEH_HTML::li( |
| 178 | - EEH_HTML::span( '', '', 'dashicons dashicons-arrow-up-alt2' ) . |
|
| 179 | - EEH_HTML::span( '', '', 'dashicons dashicons-arrow-down-alt2' ) . |
|
| 178 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2'). |
|
| 179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2'). |
|
| 180 | 180 | $this->template_parts->current()->label(), |
| 181 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
| 181 | + $list_item_css_id_prefix.$this->template_parts->current()->name(), |
|
| 182 | 182 | $list_item_css_class |
| 183 | 183 | ); |
| 184 | 184 | $this->template_parts->next(); |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | 200 | public function display_template_parts() { |
| 201 | - if ( WP_DEBUG ) { |
|
| 201 | + if (WP_DEBUG) { |
|
| 202 | 202 | $this->template_parts->rewind(); |
| 203 | - while ( $this->template_parts->valid() ) { |
|
| 204 | - EEH_Debug_Tools::printr( $this->template_parts->current(), 'template_part', __FILE__, __LINE__ ); |
|
| 203 | + while ($this->template_parts->valid()) { |
|
| 204 | + EEH_Debug_Tools::printr($this->template_parts->current(), 'template_part', __FILE__, __LINE__); |
|
| 205 | 205 | $this->template_parts->next(); |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function instance() { |
| 130 | 130 | // check if class object is instantiated, and instantiated properly |
| 131 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
| 131 | + if ( ! self::$_instance instanceof EE_Config) { |
|
| 132 | 132 | self::$_instance = new self(); |
| 133 | 133 | } |
| 134 | 134 | return self::$_instance; |
@@ -145,22 +145,22 @@ discard block |
||
| 145 | 145 | * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode) |
| 146 | 146 | * @return EE_Config |
| 147 | 147 | */ |
| 148 | - public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){ |
|
| 149 | - if ( $hard_reset ) { |
|
| 148 | + public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) { |
|
| 149 | + if ($hard_reset) { |
|
| 150 | 150 | self::$_instance->_config_option_names = array(); |
| 151 | 151 | self::$_instance->_initialize_config(); |
| 152 | 152 | self::$_instance->update_espresso_config(); |
| 153 | 153 | } |
| 154 | - if( self::$_instance instanceof EE_Config ){ |
|
| 154 | + if (self::$_instance instanceof EE_Config) { |
|
| 155 | 155 | self::$_instance->shutdown(); |
| 156 | 156 | } |
| 157 | 157 | self::$_instance = NULL; |
| 158 | 158 | //we don't need to reset the static properties imo because those should |
| 159 | 159 | //only change when a module is added or removed. Currently we don't |
| 160 | 160 | //support removing a module during a request when it previously existed |
| 161 | - if( $reinstantiate ){ |
|
| 161 | + if ($reinstantiate) { |
|
| 162 | 162 | return self::instance(); |
| 163 | - }else{ |
|
| 163 | + } else { |
|
| 164 | 164 | return NULL; |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * @return \EE_Config |
| 175 | 175 | */ |
| 176 | 176 | private function __construct() { |
| 177 | - do_action( 'AHEE__EE_Config__construct__begin',$this ); |
|
| 178 | - $this->_config_option_names = get_option( 'ee_config_option_names', array() ); |
|
| 177 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 178 | + $this->_config_option_names = get_option('ee_config_option_names', array()); |
|
| 179 | 179 | // setup empty config classes |
| 180 | 180 | $this->_initialize_config(); |
| 181 | 181 | // load existing EE site settings |
@@ -183,15 +183,15 @@ discard block |
||
| 183 | 183 | // confirm everything loaded correctly and set filtered defaults if not |
| 184 | 184 | $this->_verify_config(); |
| 185 | 185 | // register shortcodes and modules |
| 186 | - add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 ); |
|
| 186 | + add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999); |
|
| 187 | 187 | // initialize shortcodes and modules |
| 188 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' )); |
|
| 188 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 189 | 189 | // register widgets |
| 190 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
| 190 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 191 | 191 | // shutdown |
| 192 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
| 192 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 193 | 193 | // construct__end hook |
| 194 | - do_action( 'AHEE__EE_Config__construct__end',$this ); |
|
| 194 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
| 195 | 195 | // hardcoded hack |
| 196 | 196 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
| 197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return string current theme set. |
| 205 | 205 | */ |
| 206 | 206 | public static function get_current_theme() { |
| 207 | - return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 207 | + return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | |
@@ -238,27 +238,27 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | private function _load_core_config() { |
| 240 | 240 | // load_core_config__start hook |
| 241 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
| 241 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 242 | 242 | $espresso_config = $this->get_espresso_config(); |
| 243 | - foreach ( $espresso_config as $config => $settings ) { |
|
| 243 | + foreach ($espresso_config as $config => $settings) { |
|
| 244 | 244 | // load_core_config__start hook |
| 245 | - $settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this ); |
|
| 246 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
| 247 | - $this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
| 245 | + $settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this); |
|
| 246 | + if (is_object($settings) && property_exists($this, $config)) { |
|
| 247 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
| 248 | 248 | //call configs populate method to ensure any defaults are set for empty values. |
| 249 | - if ( method_exists( $settings, 'populate' ) ) { |
|
| 249 | + if (method_exists($settings, 'populate')) { |
|
| 250 | 250 | $this->{$config}->populate(); |
| 251 | 251 | } |
| 252 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
| 252 | + if (method_exists($settings, 'do_hooks')) { |
|
| 253 | 253 | $this->{$config}->do_hooks(); |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) { |
|
| 257 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) { |
|
| 258 | 258 | $this->update_espresso_config(); |
| 259 | 259 | } |
| 260 | 260 | // load_core_config__end hook |
| 261 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
| 261 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
@@ -272,40 +272,40 @@ discard block |
||
| 272 | 272 | protected function _verify_config() { |
| 273 | 273 | |
| 274 | 274 | $this->core = $this->core instanceof EE_Core_Config |
| 275 | - ? $this->core : new EE_Core_Config(); |
|
| 276 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
| 275 | + ? $this->core : new EE_Core_Config(); |
|
| 276 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 277 | 277 | |
| 278 | 278 | $this->organization = $this->organization instanceof EE_Organization_Config |
| 279 | - ? $this->organization : new EE_Organization_Config(); |
|
| 280 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
| 279 | + ? $this->organization : new EE_Organization_Config(); |
|
| 280 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
| 281 | 281 | |
| 282 | 282 | $this->currency = $this->currency instanceof EE_Currency_Config |
| 283 | 283 | ? $this->currency : new EE_Currency_Config(); |
| 284 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
| 284 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 285 | 285 | |
| 286 | 286 | $this->registration = $this->registration instanceof EE_Registration_Config |
| 287 | 287 | ? $this->registration : new EE_Registration_Config(); |
| 288 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
| 288 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
| 289 | 289 | |
| 290 | 290 | $this->admin = $this->admin instanceof EE_Admin_Config |
| 291 | 291 | ? $this->admin : new EE_Admin_Config(); |
| 292 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
| 292 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 293 | 293 | |
| 294 | 294 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
| 295 | 295 | ? $this->template_settings : new EE_Template_Config(); |
| 296 | - $this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings ); |
|
| 296 | + $this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings); |
|
| 297 | 297 | |
| 298 | 298 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
| 299 | 299 | ? $this->map_settings : new EE_Map_Config(); |
| 300 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
| 300 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
| 301 | 301 | |
| 302 | 302 | $this->environment = $this->environment instanceof EE_Environment_Config |
| 303 | 303 | ? $this->environment : new EE_Environment_Config(); |
| 304 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
| 304 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
| 305 | 305 | |
| 306 | 306 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
| 307 | 307 | ? $this->gateway : new EE_Gateway_Config(); |
| 308 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
| 308 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 309 | 309 | |
| 310 | 310 | } |
| 311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | public function get_espresso_config() { |
| 321 | 321 | // grab espresso configuration |
| 322 | - return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() )); |
|
| 322 | + return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array())); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -332,12 +332,12 @@ discard block |
||
| 332 | 332 | * @param $old_value |
| 333 | 333 | * @param $value |
| 334 | 334 | */ |
| 335 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
| 335 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
| 336 | 336 | // make sure we're checking the ee config |
| 337 | - if ( $option == 'ee_config' ) { |
|
| 337 | + if ($option == 'ee_config') { |
|
| 338 | 338 | // run a loose comparison of the old value against the new value for type and properties, |
| 339 | 339 | // but NOT exact instance like WP update_option does |
| 340 | - if ( $value != $old_value ) { |
|
| 340 | + if ($value != $old_value) { |
|
| 341 | 341 | // if they are NOT the same, then remove the hook, |
| 342 | 342 | // which means the subsequent update results will be based solely on the update query results |
| 343 | 343 | // the reason we do this is because, as stated above, |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | // the string it sees in the db looks the same as the new one it has been passed!!! |
| 353 | 353 | // This results in the query returning an "affected rows" value of ZERO, |
| 354 | 354 | // which gets returned immediately by WP update_option and looks like an error. |
| 355 | - remove_action( 'update_option', array( $this, 'check_config_updated' )); |
|
| 355 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -367,11 +367,11 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | protected function _reset_espresso_addon_config() { |
| 369 | 369 | $this->_config_option_names = array(); |
| 370 | - foreach( $this->addons as $addon_name => $addon_config_obj ) { |
|
| 371 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
| 372 | - $config_class = get_class( $addon_config_obj ); |
|
| 373 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
| 374 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE ); |
|
| 370 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 371 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 372 | + $config_class = get_class($addon_config_obj); |
|
| 373 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
| 374 | + $this->update_config('addons', $addon_name, $addon_config_obj, FALSE); |
|
| 375 | 375 | } |
| 376 | 376 | $this->addons->{$addon_name} = NULL; |
| 377 | 377 | } |
@@ -387,17 +387,17 @@ discard block |
||
| 387 | 387 | * @param bool $add_error |
| 388 | 388 | * @return bool |
| 389 | 389 | */ |
| 390 | - public function update_espresso_config( $add_success = FALSE, $add_error = TRUE ) { |
|
| 390 | + public function update_espresso_config($add_success = FALSE, $add_error = TRUE) { |
|
| 391 | 391 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
| 392 | 392 | //$clone = clone( self::$_instance ); |
| 393 | 393 | //self::$_instance = NULL; |
| 394 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this ); |
|
| 394 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 395 | 395 | $this->_reset_espresso_addon_config(); |
| 396 | 396 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
| 397 | 397 | // but BEFORE the actual update occurs |
| 398 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
| 398 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 399 | 399 | // now update "ee_config" |
| 400 | - $saved = update_option( 'ee_config', $this ); |
|
| 400 | + $saved = update_option('ee_config', $this); |
|
| 401 | 401 | // if not saved... check if the hook we just added still exists; |
| 402 | 402 | // if it does, it means one of two things: |
| 403 | 403 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -408,25 +408,25 @@ discard block |
||
| 408 | 408 | // but just means no update occurred, so don't display an error to the user. |
| 409 | 409 | // BUT... if update_option returns FALSE, AND the hook is missing, |
| 410 | 410 | // then it means that something truly went wrong |
| 411 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved; |
|
| 411 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 412 | 412 | // remove our action since we don't want it in the system anymore |
| 413 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
| 414 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
| 413 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 414 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 415 | 415 | //self::$_instance = $clone; |
| 416 | 416 | //unset( $clone ); |
| 417 | 417 | // if config remains the same or was updated successfully |
| 418 | - if ( $saved ) { |
|
| 419 | - if ( $add_success ) { |
|
| 418 | + if ($saved) { |
|
| 419 | + if ($add_success) { |
|
| 420 | 420 | EE_Error::add_success( |
| 421 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
| 421 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 422 | 422 | __FILE__, __FUNCTION__, __LINE__ |
| 423 | 423 | ); |
| 424 | 424 | } |
| 425 | 425 | return TRUE; |
| 426 | 426 | } else { |
| 427 | - if ( $add_error ) { |
|
| 427 | + if ($add_error) { |
|
| 428 | 428 | EE_Error::add_error( |
| 429 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
| 429 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 430 | 430 | __FILE__, __FUNCTION__, __LINE__ |
| 431 | 431 | ); |
| 432 | 432 | } |
@@ -452,20 +452,20 @@ discard block |
||
| 452 | 452 | $name = '', |
| 453 | 453 | $config_class = '', |
| 454 | 454 | $config_obj = NULL, |
| 455 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
| 455 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 456 | 456 | $display_errors = TRUE |
| 457 | 457 | ) { |
| 458 | 458 | try { |
| 459 | - foreach ( $tests_to_run as $test ) { |
|
| 460 | - switch ( $test ) { |
|
| 459 | + foreach ($tests_to_run as $test) { |
|
| 460 | + switch ($test) { |
|
| 461 | 461 | |
| 462 | 462 | // TEST #1 : check that section was set |
| 463 | 463 | case 1 : |
| 464 | - if ( empty( $section ) ) { |
|
| 465 | - if ( $display_errors ) { |
|
| 464 | + if (empty($section)) { |
|
| 465 | + if ($display_errors) { |
|
| 466 | 466 | throw new EE_Error( |
| 467 | 467 | sprintf( |
| 468 | - __( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ), |
|
| 468 | + __('No configuration section has been provided while attempting to save "%s".', 'event_espresso'), |
|
| 469 | 469 | $config_class |
| 470 | 470 | ) |
| 471 | 471 | ); |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | |
| 477 | 477 | // TEST #2 : check that settings section exists |
| 478 | 478 | case 2 : |
| 479 | - if ( ! isset( $this->{$section} ) ) { |
|
| 480 | - if ( $display_errors ) { |
|
| 479 | + if ( ! isset($this->{$section} )) { |
|
| 480 | + if ($display_errors) { |
|
| 481 | 481 | throw new EE_Error( |
| 482 | - sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
| 483 | - $section ) |
|
| 482 | + sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 483 | + $section) |
|
| 484 | 484 | ); |
| 485 | 485 | } |
| 486 | 486 | return false; |
@@ -490,12 +490,12 @@ discard block |
||
| 490 | 490 | // TEST #3 : check that section is the proper format |
| 491 | 491 | case 3 : |
| 492 | 492 | if ( |
| 493 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
| 493 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 494 | 494 | ) { |
| 495 | - if ( $display_errors ) { |
|
| 495 | + if ($display_errors) { |
|
| 496 | 496 | throw new EE_Error( |
| 497 | 497 | sprintf( |
| 498 | - __( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ), |
|
| 498 | + __('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'), |
|
| 499 | 499 | $section |
| 500 | 500 | ) |
| 501 | 501 | ); |
@@ -506,10 +506,10 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | // TEST #4 : check that config section name has been set |
| 508 | 508 | case 4 : |
| 509 | - if ( empty( $name ) ) { |
|
| 510 | - if ( $display_errors ) { |
|
| 509 | + if (empty($name)) { |
|
| 510 | + if ($display_errors) { |
|
| 511 | 511 | throw new EE_Error( |
| 512 | - __( 'No name has been provided for the specific configuration section.', 'event_espresso' ) |
|
| 512 | + __('No name has been provided for the specific configuration section.', 'event_espresso') |
|
| 513 | 513 | ); |
| 514 | 514 | } |
| 515 | 515 | return false; |
@@ -518,10 +518,10 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | // TEST #5 : check that a config class name has been set |
| 520 | 520 | case 5 : |
| 521 | - if ( empty( $config_class ) ) { |
|
| 522 | - if ( $display_errors ) { |
|
| 521 | + if (empty($config_class)) { |
|
| 522 | + if ($display_errors) { |
|
| 523 | 523 | throw new EE_Error( |
| 524 | - __( 'No class name has been provided for the specific configuration section.', 'event_espresso' ) |
|
| 524 | + __('No class name has been provided for the specific configuration section.', 'event_espresso') |
|
| 525 | 525 | ); |
| 526 | 526 | } |
| 527 | 527 | return false; |
@@ -530,11 +530,11 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | // TEST #6 : verify config class is accessible |
| 532 | 532 | case 6 : |
| 533 | - if ( ! class_exists( $config_class ) ) { |
|
| 534 | - if ( $display_errors ) { |
|
| 533 | + if ( ! class_exists($config_class)) { |
|
| 534 | + if ($display_errors) { |
|
| 535 | 535 | throw new EE_Error( |
| 536 | 536 | sprintf( |
| 537 | - __( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ), |
|
| 537 | + __('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'), |
|
| 538 | 538 | $config_class |
| 539 | 539 | ) |
| 540 | 540 | ); |
@@ -545,11 +545,11 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | // TEST #7 : check that config has even been set |
| 547 | 547 | case 7 : |
| 548 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
| 549 | - if ( $display_errors ) { |
|
| 548 | + if ( ! isset($this->{$section}->{$name} )) { |
|
| 549 | + if ($display_errors) { |
|
| 550 | 550 | throw new EE_Error( |
| 551 | 551 | sprintf( |
| 552 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
| 552 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 553 | 553 | $section, |
| 554 | 554 | $name |
| 555 | 555 | ) |
@@ -558,17 +558,17 @@ discard block |
||
| 558 | 558 | return false; |
| 559 | 559 | } else { |
| 560 | 560 | // and make sure it's not serialized |
| 561 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
| 561 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
| 562 | 562 | } |
| 563 | 563 | break; |
| 564 | 564 | |
| 565 | 565 | // TEST #8 : check that config is the requested type |
| 566 | 566 | case 8 : |
| 567 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
| 568 | - if ( $display_errors ) { |
|
| 567 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
| 568 | + if ($display_errors) { |
|
| 569 | 569 | throw new EE_Error( |
| 570 | 570 | sprintf( |
| 571 | - __( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ), |
|
| 571 | + __('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'), |
|
| 572 | 572 | $section, |
| 573 | 573 | $name, |
| 574 | 574 | $config_class |
@@ -581,12 +581,12 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | // TEST #9 : verify config object |
| 583 | 583 | case 9 : |
| 584 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
| 585 | - if ( $display_errors ) { |
|
| 584 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
| 585 | + if ($display_errors) { |
|
| 586 | 586 | throw new EE_Error( |
| 587 | 587 | sprintf( |
| 588 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
| 589 | - print_r( $config_obj, true ) |
|
| 588 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 589 | + print_r($config_obj, true) |
|
| 590 | 590 | ) |
| 591 | 591 | ); |
| 592 | 592 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - } catch( EE_Error $e ) { |
|
| 600 | + } catch (EE_Error $e) { |
|
| 601 | 601 | $e->get_error(); |
| 602 | 602 | } |
| 603 | 603 | // you have successfully run the gauntlet |
@@ -614,8 +614,8 @@ discard block |
||
| 614 | 614 | * @param string $name |
| 615 | 615 | * @return string |
| 616 | 616 | */ |
| 617 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
| 618 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
| 617 | + private function _generate_config_option_name($section = '', $name = '') { |
|
| 618 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | |
@@ -629,10 +629,10 @@ discard block |
||
| 629 | 629 | * @param string $name |
| 630 | 630 | * @return string |
| 631 | 631 | */ |
| 632 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
| 633 | - return ! empty( $config_class ) |
|
| 632 | + private function _set_config_class($config_class = '', $name = '') { |
|
| 633 | + return ! empty($config_class) |
|
| 634 | 634 | ? $config_class |
| 635 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
| 635 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
@@ -646,34 +646,34 @@ discard block |
||
| 646 | 646 | * @param EE_Config_Base $config_obj |
| 647 | 647 | * @return EE_Config_Base |
| 648 | 648 | */ |
| 649 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
| 649 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
| 650 | 650 | // ensure config class is set to something |
| 651 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
| 651 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 652 | 652 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
| 653 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) { |
|
| 653 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 654 | 654 | return null; |
| 655 | 655 | } |
| 656 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
| 656 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 657 | 657 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
| 658 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
| 659 | - $this->_config_option_names[ $config_option_name ] = $config_class; |
|
| 658 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
| 659 | + $this->_config_option_names[$config_option_name] = $config_class; |
|
| 660 | 660 | } |
| 661 | 661 | // verify the incoming config object but suppress errors |
| 662 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) { |
|
| 662 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 663 | 663 | $config_obj = new $config_class(); |
| 664 | 664 | } |
| 665 | - if ( get_option( $config_option_name ) ) { |
|
| 666 | - update_option( $config_option_name, $config_obj ); |
|
| 665 | + if (get_option($config_option_name)) { |
|
| 666 | + update_option($config_option_name, $config_obj); |
|
| 667 | 667 | $this->{$section}->{$name} = $config_obj; |
| 668 | 668 | return $this->{$section}->{$name}; |
| 669 | 669 | } else { |
| 670 | 670 | // create a wp-option for this config |
| 671 | - if ( add_option( $config_option_name, $config_obj, '', 'no' )) { |
|
| 672 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
| 671 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 672 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 673 | 673 | return $this->{$section}->{$name}; |
| 674 | 674 | } else { |
| 675 | 675 | EE_Error::add_error( |
| 676 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
| 676 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 677 | 677 | __FILE__, __FUNCTION__, __LINE__ |
| 678 | 678 | ); |
| 679 | 679 | return null; |
@@ -694,37 +694,37 @@ discard block |
||
| 694 | 694 | * @param bool $throw_errors |
| 695 | 695 | * @return bool |
| 696 | 696 | */ |
| 697 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
| 698 | - $config_obj = maybe_unserialize( $config_obj ); |
|
| 697 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
| 698 | + $config_obj = maybe_unserialize($config_obj); |
|
| 699 | 699 | // get class name of the incoming object |
| 700 | - $config_class = get_class( $config_obj ); |
|
| 700 | + $config_class = get_class($config_obj); |
|
| 701 | 701 | // run tests 1-5 and 9 to verify config |
| 702 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) { |
|
| 702 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) { |
|
| 703 | 703 | return false; |
| 704 | 704 | } |
| 705 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
| 705 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 706 | 706 | // check if config object has been added to db by seeing if config option name is in $this->_config_option_names array |
| 707 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
| 707 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
| 708 | 708 | // save new config to db |
| 709 | - return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
| 709 | + return $this->set_config($section, $name, $config_class, $config_obj); |
|
| 710 | 710 | } else { |
| 711 | 711 | // first check if the record already exists |
| 712 | - $existing_config = get_option( $config_option_name ); |
|
| 713 | - $config_obj = serialize( $config_obj ); |
|
| 712 | + $existing_config = get_option($config_option_name); |
|
| 713 | + $config_obj = serialize($config_obj); |
|
| 714 | 714 | // just return if db record is already up to date |
| 715 | - if ( $existing_config == $config_obj ) { |
|
| 715 | + if ($existing_config == $config_obj) { |
|
| 716 | 716 | $this->{$section}->{$name} = $config_obj; |
| 717 | 717 | return true; |
| 718 | - } else if ( update_option( $config_option_name, $config_obj )) { |
|
| 718 | + } else if (update_option($config_option_name, $config_obj)) { |
|
| 719 | 719 | // update wp-option for this config class |
| 720 | 720 | $this->{$section}->{$name} = $config_obj; |
| 721 | 721 | return true; |
| 722 | - } elseif ( $throw_errors ) { |
|
| 722 | + } elseif ($throw_errors) { |
|
| 723 | 723 | EE_Error::add_error( |
| 724 | 724 | sprintf( |
| 725 | - __( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ), |
|
| 725 | + __('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'), |
|
| 726 | 726 | $config_class, |
| 727 | - 'EE_Config->' . $section . '->' . $name |
|
| 727 | + 'EE_Config->'.$section.'->'.$name |
|
| 728 | 728 | ), |
| 729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
| 730 | 730 | ); |
@@ -744,34 +744,34 @@ discard block |
||
| 744 | 744 | * @param string $config_class |
| 745 | 745 | * @return mixed EE_Config_Base | NULL |
| 746 | 746 | */ |
| 747 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
| 747 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
| 748 | 748 | // ensure config class is set to something |
| 749 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
| 749 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 750 | 750 | // run tests 1-4, 6 and 7 to verify that all params have been set |
| 751 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) { |
|
| 751 | + if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) { |
|
| 752 | 752 | return NULL; |
| 753 | 753 | } |
| 754 | 754 | // now test if the requested config object exists, but suppress errors |
| 755 | - if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) { |
|
| 755 | + if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) { |
|
| 756 | 756 | // config already exists, so pass it back |
| 757 | 757 | return $this->{$section}->{$name}; |
| 758 | 758 | } |
| 759 | 759 | // load config option from db if it exists |
| 760 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name )); |
|
| 760 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 761 | 761 | // verify the newly retrieved config object, but suppress errors |
| 762 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) { |
|
| 762 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) { |
|
| 763 | 763 | // config is good, so set it and pass it back |
| 764 | 764 | $this->{$section}->{$name} = $config_obj; |
| 765 | 765 | return $this->{$section}->{$name}; |
| 766 | 766 | } |
| 767 | 767 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
| 768 | - $config_obj =$this->set_config( $section, $name, $config_class ); |
|
| 768 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
| 769 | 769 | // verify the newly created config object |
| 770 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) { |
|
| 770 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 771 | 771 | return $this->{$section}->{$name}; |
| 772 | 772 | } else { |
| 773 | 773 | EE_Error::add_error( |
| 774 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
| 774 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 775 | 775 | __FILE__, __FUNCTION__, __LINE__ |
| 776 | 776 | ); |
| 777 | 777 | } |
@@ -786,9 +786,9 @@ discard block |
||
| 786 | 786 | * @param string $config_option_name |
| 787 | 787 | * @return mixed EE_Config_Base | FALSE |
| 788 | 788 | */ |
| 789 | - public function get_config_option( $config_option_name = '' ) { |
|
| 789 | + public function get_config_option($config_option_name = '') { |
|
| 790 | 790 | // retrieve the wp-option for this config class. |
| 791 | - return maybe_unserialize( get_option( $config_option_name )); |
|
| 791 | + return maybe_unserialize(get_option($config_option_name)); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | |
@@ -801,45 +801,45 @@ discard block |
||
| 801 | 801 | * @param $page_for_posts |
| 802 | 802 | * @return void |
| 803 | 803 | */ |
| 804 | - public function update_post_shortcodes( $page_for_posts = '' ) { |
|
| 804 | + public function update_post_shortcodes($page_for_posts = '') { |
|
| 805 | 805 | // make sure page_for_posts is set |
| 806 | - $page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
| 806 | + $page_for_posts = ! empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
| 807 | 807 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
| 808 | 808 | $critical_shortcodes = $this->core->get_critical_pages_shortcodes_array(); |
| 809 | 809 | // allow others to mess stuff up :D |
| 810 | - do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts ); |
|
| 810 | + do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts); |
|
| 811 | 811 | // verify that post_shortcodes is set |
| 812 | - $this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array(); |
|
| 812 | + $this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array(); |
|
| 813 | 813 | // cycle thru post_shortcodes |
| 814 | - foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){ |
|
| 814 | + foreach ($this->core->post_shortcodes as $post_name => $shortcodes) { |
|
| 815 | 815 | // are there any shortcodes to track ? |
| 816 | - if ( ! empty( $shortcodes )) { |
|
| 816 | + if ( ! empty($shortcodes)) { |
|
| 817 | 817 | // loop thru list of tracked shortcodes |
| 818 | - foreach( $shortcodes as $shortcode => $post_id ) { |
|
| 818 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
| 819 | 819 | // if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode |
| 820 | - if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) { |
|
| 820 | + if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) { |
|
| 821 | 821 | // then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog) |
| 822 | - unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] ); |
|
| 822 | + unset($this->core->post_shortcodes[$post_name][$shortcode]); |
|
| 823 | 823 | } |
| 824 | 824 | // skip the posts page, because we want all shortcodes registered for it |
| 825 | - if ( $post_name == $page_for_posts ) { |
|
| 825 | + if ($post_name == $page_for_posts) { |
|
| 826 | 826 | continue; |
| 827 | 827 | } |
| 828 | 828 | // make sure post still exists |
| 829 | - $post = get_post( $post_id ); |
|
| 830 | - if ( $post ) { |
|
| 829 | + $post = get_post($post_id); |
|
| 830 | + if ($post) { |
|
| 831 | 831 | // check that the post name matches what we have saved |
| 832 | - if ( $post->post_name == $post_name ) { |
|
| 832 | + if ($post->post_name == $post_name) { |
|
| 833 | 833 | // if so, then break before hitting the unset below |
| 834 | 834 | continue; |
| 835 | 835 | } |
| 836 | 836 | } |
| 837 | 837 | // we don't like missing posts around here >:( |
| 838 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
| 838 | + unset($this->core->post_shortcodes[$post_name]); |
|
| 839 | 839 | } |
| 840 | 840 | } else { |
| 841 | 841 | // you got no shortcodes to keep track of ! |
| 842 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
| 842 | + unset($this->core->post_shortcodes[$post_name]); |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | //only show errors |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | * @return string |
| 859 | 859 | */ |
| 860 | 860 | public static function get_page_for_posts() { |
| 861 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
| 862 | - if ( ! $page_for_posts ) { |
|
| 861 | + $page_for_posts = get_option('page_for_posts'); |
|
| 862 | + if ( ! $page_for_posts) { |
|
| 863 | 863 | return 'posts'; |
| 864 | 864 | } |
| 865 | 865 | /** @type WPDB $wpdb */ |
| 866 | 866 | global $wpdb; |
| 867 | 867 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
| 868 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts )); |
|
| 868 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | */ |
| 883 | 883 | public function register_shortcodes_and_modules() { |
| 884 | 884 | // allow shortcodes to register with WP and to set hooks for the rest of the system |
| 885 | - EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
|
| 885 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
| 886 | 886 | // allow modules to set hooks for the rest of the system |
| 887 | 887 | EE_Registry::instance()->modules = $this->_register_modules(); |
| 888 | 888 | } |
@@ -914,21 +914,21 @@ discard block |
||
| 914 | 914 | public function widgets_init() { |
| 915 | 915 | //only init widgets on admin pages when not in complete maintenance, and |
| 916 | 916 | //on frontend when not in any maintenance mode |
| 917 | - if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
|
| 917 | + if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) { |
|
| 918 | 918 | // grab list of installed widgets |
| 919 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
| 919 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
| 920 | 920 | // filter list of modules to register |
| 921 | - $widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
|
| 921 | + $widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register); |
|
| 922 | 922 | |
| 923 | - if ( ! empty( $widgets_to_register ) ) { |
|
| 923 | + if ( ! empty($widgets_to_register)) { |
|
| 924 | 924 | // cycle thru widget folders |
| 925 | - foreach ( $widgets_to_register as $widget_path ) { |
|
| 925 | + foreach ($widgets_to_register as $widget_path) { |
|
| 926 | 926 | // add to list of installed widget modules |
| 927 | - EE_Config::register_ee_widget( $widget_path ); |
|
| 927 | + EE_Config::register_ee_widget($widget_path); |
|
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | // filter list of installed modules |
| 931 | - EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
|
| 931 | + EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets); |
|
| 932 | 932 | } |
| 933 | 933 | } |
| 934 | 934 | |
@@ -941,54 +941,54 @@ discard block |
||
| 941 | 941 | * @param string $widget_path - full path up to and including widget folder |
| 942 | 942 | * @return void |
| 943 | 943 | */ |
| 944 | - public static function register_ee_widget( $widget_path = NULL ) { |
|
| 945 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
| 944 | + public static function register_ee_widget($widget_path = NULL) { |
|
| 945 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 946 | 946 | $widget_ext = '.widget.php'; |
| 947 | 947 | // make all separators match |
| 948 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
| 948 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 949 | 949 | // does the file path INCLUDE the actual file name as part of the path ? |
| 950 | - if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
|
| 950 | + if (strpos($widget_path, $widget_ext) !== FALSE) { |
|
| 951 | 951 | // grab and shortcode file name from directory name and break apart at dots |
| 952 | - $file_name = explode( '.', basename( $widget_path )); |
|
| 952 | + $file_name = explode('.', basename($widget_path)); |
|
| 953 | 953 | // take first segment from file name pieces and remove class prefix if it exists |
| 954 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
| 954 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 955 | 955 | // sanitize shortcode directory name |
| 956 | - $widget = sanitize_key( $widget ); |
|
| 956 | + $widget = sanitize_key($widget); |
|
| 957 | 957 | // now we need to rebuild the shortcode path |
| 958 | - $widget_path = explode( DS, $widget_path ); |
|
| 958 | + $widget_path = explode(DS, $widget_path); |
|
| 959 | 959 | // remove last segment |
| 960 | - array_pop( $widget_path ); |
|
| 960 | + array_pop($widget_path); |
|
| 961 | 961 | // glue it back together |
| 962 | - $widget_path = implode( DS, $widget_path ); |
|
| 962 | + $widget_path = implode(DS, $widget_path); |
|
| 963 | 963 | } else { |
| 964 | 964 | // grab and sanitize widget directory name |
| 965 | - $widget = sanitize_key( basename( $widget_path )); |
|
| 965 | + $widget = sanitize_key(basename($widget_path)); |
|
| 966 | 966 | } |
| 967 | 967 | // create classname from widget directory name |
| 968 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
|
| 968 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 969 | 969 | // add class prefix |
| 970 | - $widget_class = 'EEW_' . $widget; |
|
| 970 | + $widget_class = 'EEW_'.$widget; |
|
| 971 | 971 | // does the widget exist ? |
| 972 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
| 972 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
| 973 | 973 | $msg = sprintf( |
| 974 | - __( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ), |
|
| 974 | + __('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), |
|
| 975 | 975 | $widget_class, |
| 976 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 976 | + $widget_path.DS.$widget_class.$widget_ext |
|
| 977 | 977 | ); |
| 978 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 978 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 979 | 979 | return; |
| 980 | 980 | } |
| 981 | 981 | // load the widget class file |
| 982 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
| 982 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
| 983 | 983 | // verify that class exists |
| 984 | - if ( ! class_exists( $widget_class )) { |
|
| 985 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
| 986 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 984 | + if ( ! class_exists($widget_class)) { |
|
| 985 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 986 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 987 | 987 | return; |
| 988 | 988 | } |
| 989 | - register_widget( $widget_class ); |
|
| 989 | + register_widget($widget_class); |
|
| 990 | 990 | // add to array of registered widgets |
| 991 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 991 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | |
@@ -1001,18 +1001,18 @@ discard block |
||
| 1001 | 1001 | */ |
| 1002 | 1002 | private function _register_shortcodes() { |
| 1003 | 1003 | // grab list of installed shortcodes |
| 1004 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
| 1004 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
| 1005 | 1005 | // filter list of modules to register |
| 1006 | - $shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
|
| 1007 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
| 1006 | + $shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register); |
|
| 1007 | + if ( ! empty($shortcodes_to_register)) { |
|
| 1008 | 1008 | // cycle thru shortcode folders |
| 1009 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
| 1009 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
| 1010 | 1010 | // add to list of installed shortcode modules |
| 1011 | - EE_Config::register_shortcode( $shortcode_path ); |
|
| 1011 | + EE_Config::register_shortcode($shortcode_path); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | } |
| 1014 | 1014 | // filter list of installed modules |
| 1015 | - return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
|
| 1015 | + return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | |
@@ -1024,56 +1024,56 @@ discard block |
||
| 1024 | 1024 | * @param string $shortcode_path - full path up to and including shortcode folder |
| 1025 | 1025 | * @return bool |
| 1026 | 1026 | */ |
| 1027 | - public static function register_shortcode( $shortcode_path = NULL ) { |
|
| 1028 | - do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
|
| 1027 | + public static function register_shortcode($shortcode_path = NULL) { |
|
| 1028 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
| 1029 | 1029 | $shortcode_ext = '.shortcode.php'; |
| 1030 | 1030 | // make all separators match |
| 1031 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
| 1031 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
| 1032 | 1032 | // does the file path INCLUDE the actual file name as part of the path ? |
| 1033 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
|
| 1033 | + if (strpos($shortcode_path, $shortcode_ext) !== FALSE) { |
|
| 1034 | 1034 | // grab shortcode file name from directory name and break apart at dots |
| 1035 | - $shortcode_file = explode( '.', basename( $shortcode_path )); |
|
| 1035 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
| 1036 | 1036 | // take first segment from file name pieces and remove class prefix if it exists |
| 1037 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
|
| 1037 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0]; |
|
| 1038 | 1038 | // sanitize shortcode directory name |
| 1039 | - $shortcode = sanitize_key( $shortcode ); |
|
| 1039 | + $shortcode = sanitize_key($shortcode); |
|
| 1040 | 1040 | // now we need to rebuild the shortcode path |
| 1041 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
| 1041 | + $shortcode_path = explode(DS, $shortcode_path); |
|
| 1042 | 1042 | // remove last segment |
| 1043 | - array_pop( $shortcode_path ); |
|
| 1043 | + array_pop($shortcode_path); |
|
| 1044 | 1044 | // glue it back together |
| 1045 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
| 1045 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
| 1046 | 1046 | } else { |
| 1047 | 1047 | // we need to generate the filename based off of the folder name |
| 1048 | 1048 | // grab and sanitize shortcode directory name |
| 1049 | - $shortcode = sanitize_key( basename( $shortcode_path )); |
|
| 1050 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
| 1049 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
| 1050 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | // create classname from shortcode directory or file name |
| 1053 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
|
| 1053 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
| 1054 | 1054 | // add class prefix |
| 1055 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1055 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 1056 | 1056 | // does the shortcode exist ? |
| 1057 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
| 1057 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
| 1058 | 1058 | $msg = sprintf( |
| 1059 | - __( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
|
| 1059 | + __('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'), |
|
| 1060 | 1060 | $shortcode_class, |
| 1061 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 1061 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
| 1062 | 1062 | ); |
| 1063 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1063 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1064 | 1064 | return FALSE; |
| 1065 | 1065 | } |
| 1066 | 1066 | // load the shortcode class file |
| 1067 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
| 1067 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
| 1068 | 1068 | // verify that class exists |
| 1069 | - if ( ! class_exists( $shortcode_class )) { |
|
| 1070 | - $msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
|
| 1071 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1069 | + if ( ! class_exists($shortcode_class)) { |
|
| 1070 | + $msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class); |
|
| 1071 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1072 | 1072 | return FALSE; |
| 1073 | 1073 | } |
| 1074 | - $shortcode = strtoupper( $shortcode ); |
|
| 1074 | + $shortcode = strtoupper($shortcode); |
|
| 1075 | 1075 | // add to array of registered shortcodes |
| 1076 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 1076 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
| 1077 | 1077 | return TRUE; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
@@ -1088,23 +1088,23 @@ discard block |
||
| 1088 | 1088 | */ |
| 1089 | 1089 | private function _register_modules() { |
| 1090 | 1090 | // grab list of installed modules |
| 1091 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
| 1091 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
| 1092 | 1092 | // filter list of modules to register |
| 1093 | - $modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
|
| 1093 | + $modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register); |
|
| 1094 | 1094 | |
| 1095 | 1095 | |
| 1096 | - if ( ! empty( $modules_to_register ) ) { |
|
| 1096 | + if ( ! empty($modules_to_register)) { |
|
| 1097 | 1097 | // loop through folders |
| 1098 | - foreach ( $modules_to_register as $module_path ) { |
|
| 1098 | + foreach ($modules_to_register as $module_path) { |
|
| 1099 | 1099 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
| 1100 | - if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
|
| 1100 | + if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') { |
|
| 1101 | 1101 | // add to list of installed modules |
| 1102 | - EE_Config::register_module( $module_path ); |
|
| 1102 | + EE_Config::register_module($module_path); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | // filter list of installed modules |
| 1107 | - return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
|
| 1107 | + return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | |
@@ -1117,54 +1117,54 @@ discard block |
||
| 1117 | 1117 | * @param string $module_path - full path up to and including module folder |
| 1118 | 1118 | * @return bool |
| 1119 | 1119 | */ |
| 1120 | - public static function register_module( $module_path = NULL ) { |
|
| 1121 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
| 1120 | + public static function register_module($module_path = NULL) { |
|
| 1121 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1122 | 1122 | $module_ext = '.module.php'; |
| 1123 | 1123 | // make all separators match |
| 1124 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
| 1124 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1125 | 1125 | // does the file path INCLUDE the actual file name as part of the path ? |
| 1126 | - if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
|
| 1126 | + if (strpos($module_path, $module_ext) !== FALSE) { |
|
| 1127 | 1127 | // grab and shortcode file name from directory name and break apart at dots |
| 1128 | - $module_file = explode( '.', basename( $module_path )); |
|
| 1128 | + $module_file = explode('.', basename($module_path)); |
|
| 1129 | 1129 | // now we need to rebuild the shortcode path |
| 1130 | - $module_path = explode( DS, $module_path ); |
|
| 1130 | + $module_path = explode(DS, $module_path); |
|
| 1131 | 1131 | // remove last segment |
| 1132 | - array_pop( $module_path ); |
|
| 1132 | + array_pop($module_path); |
|
| 1133 | 1133 | // glue it back together |
| 1134 | - $module_path = implode( DS, $module_path ) . DS; |
|
| 1134 | + $module_path = implode(DS, $module_path).DS; |
|
| 1135 | 1135 | // take first segment from file name pieces and sanitize it |
| 1136 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
| 1136 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1137 | 1137 | // ensure class prefix is added |
| 1138 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
| 1138 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
| 1139 | 1139 | } else { |
| 1140 | 1140 | // we need to generate the filename based off of the folder name |
| 1141 | 1141 | // grab and sanitize module name |
| 1142 | - $module = strtolower( basename( $module_path )); |
|
| 1143 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
|
| 1142 | + $module = strtolower(basename($module_path)); |
|
| 1143 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1144 | 1144 | // like trailingslashit() |
| 1145 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
| 1145 | + $module_path = rtrim($module_path, DS).DS; |
|
| 1146 | 1146 | // create classname from module directory name |
| 1147 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
|
| 1147 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1148 | 1148 | // add class prefix |
| 1149 | - $module_class = 'EED_' . $module; |
|
| 1149 | + $module_class = 'EED_'.$module; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | // does the module exist ? |
| 1152 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
| 1153 | - $msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
| 1154 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1152 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
| 1153 | + $msg = sprintf(__('The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
| 1154 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1155 | 1155 | return FALSE; |
| 1156 | 1156 | } |
| 1157 | 1157 | // load the module class file |
| 1158 | - require_once( $module_path . $module_class . $module_ext ); |
|
| 1158 | + require_once($module_path.$module_class.$module_ext); |
|
| 1159 | 1159 | // verify that class exists |
| 1160 | - if ( ! class_exists( $module_class )) { |
|
| 1161 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
| 1162 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1160 | + if ( ! class_exists($module_class)) { |
|
| 1161 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1162 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1163 | 1163 | return FALSE; |
| 1164 | 1164 | } |
| 1165 | 1165 | // add to array of registered modules |
| 1166 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1167 | - do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
| 1166 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
| 1167 | + do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
| 1168 | 1168 | return TRUE; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1178,23 +1178,23 @@ discard block |
||
| 1178 | 1178 | */ |
| 1179 | 1179 | private function _initialize_shortcodes() { |
| 1180 | 1180 | // cycle thru shortcode folders |
| 1181 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
| 1181 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
| 1182 | 1182 | // add class prefix |
| 1183 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1183 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 1184 | 1184 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
| 1185 | 1185 | // which set hooks ? |
| 1186 | - if ( is_admin() ) { |
|
| 1186 | + if (is_admin()) { |
|
| 1187 | 1187 | // fire immediately |
| 1188 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
|
| 1188 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
| 1189 | 1189 | } else { |
| 1190 | 1190 | // delay until other systems are online |
| 1191 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
|
| 1191 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks')); |
|
| 1192 | 1192 | // convert classname to UPPERCASE and create WP shortcode. |
| 1193 | - $shortcode_tag = strtoupper( $shortcode ); |
|
| 1193 | + $shortcode_tag = strtoupper($shortcode); |
|
| 1194 | 1194 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
| 1195 | - if ( ! shortcode_exists( $shortcode_tag )) { |
|
| 1195 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
| 1196 | 1196 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
| 1197 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
|
| 1197 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | } |
| 1200 | 1200 | } |
@@ -1211,15 +1211,15 @@ discard block |
||
| 1211 | 1211 | */ |
| 1212 | 1212 | private function _initialize_modules() { |
| 1213 | 1213 | // cycle thru shortcode folders |
| 1214 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
| 1214 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1215 | 1215 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
| 1216 | 1216 | // which set hooks ? |
| 1217 | - if ( is_admin() ) { |
|
| 1217 | + if (is_admin()) { |
|
| 1218 | 1218 | // fire immediately |
| 1219 | - call_user_func( array( $module_class, 'set_hooks_admin' )); |
|
| 1219 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1220 | 1220 | } else { |
| 1221 | 1221 | // delay until other systems are online |
| 1222 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
|
| 1222 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks')); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | } |
| 1225 | 1225 | } |
@@ -1237,26 +1237,26 @@ discard block |
||
| 1237 | 1237 | * @param string $key - url param key indicating a route is being called |
| 1238 | 1238 | * @return bool |
| 1239 | 1239 | */ |
| 1240 | - public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
|
| 1241 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
| 1242 | - $module = str_replace( 'EED_', '', $module ); |
|
| 1243 | - $module_class = 'EED_' . $module; |
|
| 1244 | - if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) { |
|
| 1245 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
| 1246 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1240 | + public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') { |
|
| 1241 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1242 | + $module = str_replace('EED_', '', $module); |
|
| 1243 | + $module_class = 'EED_'.$module; |
|
| 1244 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) { |
|
| 1245 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1246 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1247 | 1247 | return FALSE; |
| 1248 | 1248 | } |
| 1249 | - if ( empty( $route )) { |
|
| 1250 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
| 1251 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1249 | + if (empty($route)) { |
|
| 1250 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1251 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1252 | 1252 | return FALSE; |
| 1253 | 1253 | } |
| 1254 | - if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
| 1255 | - $msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
|
| 1256 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1254 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
| 1255 | + $msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route); |
|
| 1256 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1257 | 1257 | return FALSE; |
| 1258 | 1258 | } |
| 1259 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
| 1259 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
| 1260 | 1260 | return TRUE; |
| 1261 | 1261 | } |
| 1262 | 1262 | |
@@ -1270,11 +1270,11 @@ discard block |
||
| 1270 | 1270 | * @param string $key - url param key indicating a route is being called |
| 1271 | 1271 | * @return string |
| 1272 | 1272 | */ |
| 1273 | - public static function get_route( $route = NULL, $key = 'ee' ) { |
|
| 1274 | - do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
|
| 1275 | - $route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
|
| 1276 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
|
| 1277 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
| 1273 | + public static function get_route($route = NULL, $key = 'ee') { |
|
| 1274 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1275 | + $route = apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1276 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1277 | + return EE_Config::$_module_route_map[$key][$route]; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | return NULL; |
| 1280 | 1280 | } |
@@ -1303,35 +1303,35 @@ discard block |
||
| 1303 | 1303 | * @param string $key - url param key indicating a route is being called |
| 1304 | 1304 | * @return bool |
| 1305 | 1305 | */ |
| 1306 | - public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
|
| 1307 | - do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
|
| 1308 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
| 1309 | - $msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
|
| 1310 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1306 | + public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') { |
|
| 1307 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1308 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1309 | + $msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route); |
|
| 1310 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1311 | 1311 | return FALSE; |
| 1312 | 1312 | } |
| 1313 | - if ( empty( $forward )) { |
|
| 1314 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
| 1315 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1313 | + if (empty($forward)) { |
|
| 1314 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1315 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1316 | 1316 | return FALSE; |
| 1317 | 1317 | } |
| 1318 | - if ( is_array( $forward )) { |
|
| 1319 | - if ( ! isset( $forward[1] )) { |
|
| 1320 | - $msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
|
| 1321 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1318 | + if (is_array($forward)) { |
|
| 1319 | + if ( ! isset($forward[1])) { |
|
| 1320 | + $msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route); |
|
| 1321 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1322 | 1322 | return FALSE; |
| 1323 | 1323 | } |
| 1324 | - if ( ! method_exists( $forward[0], $forward[1] )) { |
|
| 1325 | - $msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
|
| 1326 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1324 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
| 1325 | + $msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route); |
|
| 1326 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1327 | 1327 | return FALSE; |
| 1328 | 1328 | } |
| 1329 | - } else if ( ! function_exists( $forward )) { |
|
| 1330 | - $msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
|
| 1331 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1329 | + } else if ( ! function_exists($forward)) { |
|
| 1330 | + $msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route); |
|
| 1331 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1332 | 1332 | return FALSE; |
| 1333 | 1333 | } |
| 1334 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
| 1334 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1335 | 1335 | return TRUE; |
| 1336 | 1336 | } |
| 1337 | 1337 | |
@@ -1346,10 +1346,10 @@ discard block |
||
| 1346 | 1346 | * @param string $key - url param key indicating a route is being called |
| 1347 | 1347 | * @return string |
| 1348 | 1348 | */ |
| 1349 | - public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
| 1350 | - do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
|
| 1351 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
|
| 1352 | - return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
|
| 1349 | + public static function get_forward($route = NULL, $status = 0, $key = 'ee') { |
|
| 1350 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1351 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1352 | + return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status); |
|
| 1353 | 1353 | } |
| 1354 | 1354 | return NULL; |
| 1355 | 1355 | } |
@@ -1366,19 +1366,19 @@ discard block |
||
| 1366 | 1366 | * @param string $key - url param key indicating a route is being called |
| 1367 | 1367 | * @return bool |
| 1368 | 1368 | */ |
| 1369 | - public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
|
| 1370 | - do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
|
| 1371 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
| 1372 | - $msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
|
| 1373 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1369 | + public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') { |
|
| 1370 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1371 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1372 | + $msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route); |
|
| 1373 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1374 | 1374 | return FALSE; |
| 1375 | 1375 | } |
| 1376 | - if ( ! is_readable( $view )) { |
|
| 1377 | - $msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
|
| 1378 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1376 | + if ( ! is_readable($view)) { |
|
| 1377 | + $msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view); |
|
| 1378 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1379 | 1379 | return FALSE; |
| 1380 | 1380 | } |
| 1381 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
| 1381 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1382 | 1382 | return TRUE; |
| 1383 | 1383 | } |
| 1384 | 1384 | |
@@ -1395,10 +1395,10 @@ discard block |
||
| 1395 | 1395 | * @param string $key - url param key indicating a route is being called |
| 1396 | 1396 | * @return string |
| 1397 | 1397 | */ |
| 1398 | - public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
| 1399 | - do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
|
| 1400 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
|
| 1401 | - return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
|
| 1398 | + public static function get_view($route = NULL, $status = 0, $key = 'ee') { |
|
| 1399 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1400 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1401 | + return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | return NULL; |
| 1404 | 1404 | } |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | |
| 1407 | 1407 | |
| 1408 | 1408 | public function shutdown() { |
| 1409 | - update_option( 'ee_config_option_names', $this->_config_option_names ); |
|
| 1409 | + update_option('ee_config_option_names', $this->_config_option_names); |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | * magic functions in use, except we'll allow them to magically set and get stuff... |
| 1423 | 1423 | * basically, they should just be well-defined stdClasses |
| 1424 | 1424 | */ |
| 1425 | -class EE_Config_Base{ |
|
| 1425 | +class EE_Config_Base { |
|
| 1426 | 1426 | |
| 1427 | 1427 | /** |
| 1428 | 1428 | * Utility function for escaping the value of a property and returning. |
@@ -1431,13 +1431,13 @@ discard block |
||
| 1431 | 1431 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
| 1432 | 1432 | * @throws \EE_Error |
| 1433 | 1433 | */ |
| 1434 | - public function get_pretty( $property ) { |
|
| 1435 | - if ( ! property_exists( $this, $property ) ) { |
|
| 1436 | - throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) ); |
|
| 1434 | + public function get_pretty($property) { |
|
| 1435 | + if ( ! property_exists($this, $property)) { |
|
| 1436 | + throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property)); |
|
| 1437 | 1437 | } |
| 1438 | 1438 | //just handling escaping of strings for now. |
| 1439 | - if ( is_string( $this->{$property} ) ) { |
|
| 1440 | - return stripslashes( $this->{$property} ); |
|
| 1439 | + if (is_string($this->{$property} )) { |
|
| 1440 | + return stripslashes($this->{$property} ); |
|
| 1441 | 1441 | } |
| 1442 | 1442 | return $this->{$property}; |
| 1443 | 1443 | } |
@@ -1446,19 +1446,19 @@ discard block |
||
| 1446 | 1446 | |
| 1447 | 1447 | public function populate() { |
| 1448 | 1448 | //grab defaults via a new instance of this class. |
| 1449 | - $class_name = get_class( $this ); |
|
| 1449 | + $class_name = get_class($this); |
|
| 1450 | 1450 | $defaults = new $class_name; |
| 1451 | 1451 | |
| 1452 | 1452 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
| 1453 | 1453 | //default from our $defaults object. |
| 1454 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
| 1455 | - if ( is_null( $this->{$property} ) ) { |
|
| 1454 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1455 | + if (is_null($this->{$property} )) { |
|
| 1456 | 1456 | $this->{$property} = $value; |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | //cleanup |
| 1461 | - unset( $defaults ); |
|
| 1461 | + unset($defaults); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | |
@@ -1550,12 +1550,12 @@ discard block |
||
| 1550 | 1550 | */ |
| 1551 | 1551 | public function __construct() { |
| 1552 | 1552 | $current_network_main_site = is_multisite() ? get_current_site() : NULL; |
| 1553 | - $current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
| 1553 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1554 | 1554 | // set default organization settings |
| 1555 | 1555 | $this->current_blog_id = get_current_blog_id(); |
| 1556 | 1556 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
| 1557 | - $this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
|
| 1558 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
|
| 1557 | + $this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE); |
|
| 1558 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE; |
|
| 1559 | 1559 | $this->post_shortcodes = array(); |
| 1560 | 1560 | $this->module_route_map = array(); |
| 1561 | 1561 | $this->module_forward_map = array(); |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | $this->event_cpt_slug = __('events', 'event_espresso'); |
| 1575 | 1575 | |
| 1576 | 1576 | //ueip constant check |
| 1577 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
| 1577 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1578 | 1578 | $this->ee_ueip_optin = FALSE; |
| 1579 | 1579 | $this->ee_ueip_has_notified = TRUE; |
| 1580 | 1580 | } |
@@ -1614,8 +1614,8 @@ discard block |
||
| 1614 | 1614 | * @return string |
| 1615 | 1615 | */ |
| 1616 | 1616 | public function reg_page_url() { |
| 1617 | - if ( ! $this->reg_page_url ) { |
|
| 1618 | - $this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
| 1617 | + if ( ! $this->reg_page_url) { |
|
| 1618 | + $this->reg_page_url = get_permalink($this->reg_page_id).'#checkout'; |
|
| 1619 | 1619 | } |
| 1620 | 1620 | return $this->reg_page_url; |
| 1621 | 1621 | } |
@@ -1628,12 +1628,12 @@ discard block |
||
| 1628 | 1628 | * @return string |
| 1629 | 1629 | */ |
| 1630 | 1630 | public function txn_page_url($query_args = array()) { |
| 1631 | - if ( ! $this->txn_page_url ) { |
|
| 1632 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
| 1631 | + if ( ! $this->txn_page_url) { |
|
| 1632 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1633 | 1633 | } |
| 1634 | - if($query_args){ |
|
| 1635 | - return add_query_arg($query_args,$this->txn_page_url); |
|
| 1636 | - }else{ |
|
| 1634 | + if ($query_args) { |
|
| 1635 | + return add_query_arg($query_args, $this->txn_page_url); |
|
| 1636 | + } else { |
|
| 1637 | 1637 | return $this->txn_page_url; |
| 1638 | 1638 | } |
| 1639 | 1639 | } |
@@ -1645,12 +1645,12 @@ discard block |
||
| 1645 | 1645 | * @return string |
| 1646 | 1646 | */ |
| 1647 | 1647 | public function thank_you_page_url($query_args = array()) { |
| 1648 | - if ( ! $this->thank_you_page_url ) { |
|
| 1649 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
| 1648 | + if ( ! $this->thank_you_page_url) { |
|
| 1649 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1650 | 1650 | } |
| 1651 | - if($query_args){ |
|
| 1652 | - return add_query_arg($query_args,$this->thank_you_page_url); |
|
| 1653 | - }else{ |
|
| 1651 | + if ($query_args) { |
|
| 1652 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1653 | + } else { |
|
| 1654 | 1654 | return $this->thank_you_page_url; |
| 1655 | 1655 | } |
| 1656 | 1656 | } |
@@ -1661,8 +1661,8 @@ discard block |
||
| 1661 | 1661 | * @return string |
| 1662 | 1662 | */ |
| 1663 | 1663 | public function cancel_page_url() { |
| 1664 | - if ( ! $this->cancel_page_url ) { |
|
| 1665 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
| 1664 | + if ( ! $this->cancel_page_url) { |
|
| 1665 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1666 | 1666 | } |
| 1667 | 1667 | return $this->cancel_page_url; |
| 1668 | 1668 | } |
@@ -1690,7 +1690,7 @@ discard block |
||
| 1690 | 1690 | //reset all url properties |
| 1691 | 1691 | $this->_reset_urls(); |
| 1692 | 1692 | //return what to save to db |
| 1693 | - return array_keys( get_object_vars( $this ) ); |
|
| 1693 | + return array_keys(get_object_vars($this)); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | } |
@@ -1922,38 +1922,38 @@ discard block |
||
| 1922 | 1922 | * @param null $CNT_ISO |
| 1923 | 1923 | * @return \EE_Currency_Config |
| 1924 | 1924 | */ |
| 1925 | - public function __construct( $CNT_ISO = NULL ) { |
|
| 1925 | + public function __construct($CNT_ISO = NULL) { |
|
| 1926 | 1926 | |
| 1927 | 1927 | // get country code from organization settings or use default |
| 1928 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
| 1928 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
| 1929 | 1929 | // but override if requested |
| 1930 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
| 1930 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 1931 | 1931 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
| 1932 | - if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
| 1932 | + if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) { |
|
| 1933 | 1933 | // retrieve the country settings from the db, just in case they have been customized |
| 1934 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
| 1935 | - if ( $country instanceof EE_Country ) { |
|
| 1936 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 1937 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 1938 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 1939 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 1940 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 1941 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 1942 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 1943 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 1934 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 1935 | + if ($country instanceof EE_Country) { |
|
| 1936 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 1937 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 1938 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 1939 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 1940 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 1941 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 1942 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 1943 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 1944 | 1944 | } |
| 1945 | 1945 | } |
| 1946 | 1946 | // fallback to hardcoded defaults, in case the above failed |
| 1947 | - if ( empty( $this->code )) { |
|
| 1947 | + if (empty($this->code)) { |
|
| 1948 | 1948 | // set default currency settings |
| 1949 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 1950 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
| 1951 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
| 1952 | - $this->sign = '$'; // currency sign: $ |
|
| 1953 | - $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
| 1954 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 1955 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 1956 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 1949 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 1950 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 1951 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 1952 | + $this->sign = '$'; // currency sign: $ |
|
| 1953 | + $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
| 1954 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 1955 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 1956 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 1957 | 1957 | } |
| 1958 | 1958 | } |
| 1959 | 1959 | } |
@@ -2102,7 +2102,7 @@ discard block |
||
| 2102 | 2102 | * @since 4.8.8.rc.019 |
| 2103 | 2103 | */ |
| 2104 | 2104 | public function do_hooks() { |
| 2105 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
|
| 2105 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | 2108 | |
@@ -2110,7 +2110,7 @@ discard block |
||
| 2110 | 2110 | * @return void |
| 2111 | 2111 | */ |
| 2112 | 2112 | public function set_default_reg_status_on_EEM_Event() { |
| 2113 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
| 2113 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | 2116 | |
@@ -2215,10 +2215,10 @@ discard block |
||
| 2215 | 2215 | * @param bool $reset |
| 2216 | 2216 | * @return string |
| 2217 | 2217 | */ |
| 2218 | - public function log_file_name( $reset = FALSE ) { |
|
| 2219 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
| 2220 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
| 2221 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
| 2218 | + public function log_file_name($reset = FALSE) { |
|
| 2219 | + if (empty($this->log_file_name) || $reset) { |
|
| 2220 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt'; |
|
| 2221 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
| 2222 | 2222 | } |
| 2223 | 2223 | return $this->log_file_name; |
| 2224 | 2224 | } |
@@ -2230,10 +2230,10 @@ discard block |
||
| 2230 | 2230 | * @param bool $reset |
| 2231 | 2231 | * @return string |
| 2232 | 2232 | */ |
| 2233 | - public function debug_file_name( $reset = FALSE ) { |
|
| 2234 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
| 2235 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
| 2236 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
| 2233 | + public function debug_file_name($reset = FALSE) { |
|
| 2234 | + if (empty($this->debug_file_name) || $reset) { |
|
| 2235 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt'; |
|
| 2236 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
| 2237 | 2237 | } |
| 2238 | 2238 | return $this->debug_file_name; |
| 2239 | 2239 | } |
@@ -2406,21 +2406,21 @@ discard block |
||
| 2406 | 2406 | // set default map settings |
| 2407 | 2407 | $this->use_google_maps = TRUE; |
| 2408 | 2408 | // for event details pages (reg page) |
| 2409 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2410 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2411 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2412 | - $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
| 2413 | - $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
| 2414 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2415 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2409 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2410 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2411 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2412 | + $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
| 2413 | + $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
| 2414 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2415 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2416 | 2416 | // for event list pages |
| 2417 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2418 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2419 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2420 | - $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
| 2421 | - $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
| 2422 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2423 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2417 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2418 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2419 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2420 | + $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
| 2421 | + $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
| 2422 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2423 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | 2426 | } |
@@ -2431,7 +2431,7 @@ discard block |
||
| 2431 | 2431 | /** |
| 2432 | 2432 | * stores Events_Archive settings |
| 2433 | 2433 | */ |
| 2434 | -class EE_Events_Archive_Config extends EE_Config_Base{ |
|
| 2434 | +class EE_Events_Archive_Config extends EE_Config_Base { |
|
| 2435 | 2435 | |
| 2436 | 2436 | public $display_status_banner; |
| 2437 | 2437 | public $display_description; |
@@ -2450,7 +2450,7 @@ discard block |
||
| 2450 | 2450 | /** |
| 2451 | 2451 | * class constructor |
| 2452 | 2452 | */ |
| 2453 | - public function __construct(){ |
|
| 2453 | + public function __construct() { |
|
| 2454 | 2454 | $this->display_status_banner = 0; |
| 2455 | 2455 | $this->display_description = 1; |
| 2456 | 2456 | $this->display_ticket_selector = 0; |
@@ -2470,7 +2470,7 @@ discard block |
||
| 2470 | 2470 | /** |
| 2471 | 2471 | * Stores Event_Single_Config settings |
| 2472 | 2472 | */ |
| 2473 | -class EE_Event_Single_Config extends EE_Config_Base{ |
|
| 2473 | +class EE_Event_Single_Config extends EE_Config_Base { |
|
| 2474 | 2474 | |
| 2475 | 2475 | public $display_status_banner_single; |
| 2476 | 2476 | public $display_venue; |
@@ -2499,7 +2499,7 @@ discard block |
||
| 2499 | 2499 | /** |
| 2500 | 2500 | * Stores Ticket_Selector_Config settings |
| 2501 | 2501 | */ |
| 2502 | -class EE_Ticket_Selector_Config extends EE_Config_Base{ |
|
| 2502 | +class EE_Ticket_Selector_Config extends EE_Config_Base { |
|
| 2503 | 2503 | public $show_ticket_sale_columns; |
| 2504 | 2504 | public $show_ticket_details; |
| 2505 | 2505 | public $show_expired_tickets; |
@@ -2553,7 +2553,7 @@ discard block |
||
| 2553 | 2553 | * @return void |
| 2554 | 2554 | */ |
| 2555 | 2555 | protected function _set_php_values() { |
| 2556 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
| 2556 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 2557 | 2557 | $this->php->version = phpversion(); |
| 2558 | 2558 | } |
| 2559 | 2559 | |
@@ -2572,9 +2572,9 @@ discard block |
||
| 2572 | 2572 | * @type string $msg Any message to be displayed. |
| 2573 | 2573 | * } |
| 2574 | 2574 | */ |
| 2575 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
| 2576 | - if ( ! empty( $this->php->max_input_vars ) && ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
|
| 2577 | - return sprintf( __('The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars); |
|
| 2575 | + public function max_input_vars_limit_check($input_count = 0) { |
|
| 2576 | + if ( ! empty($this->php->max_input_vars) && ($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) { |
|
| 2577 | + return sprintf(__('The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars); |
|
| 2578 | 2578 | } else { |
| 2579 | 2579 | return ''; |
| 2580 | 2580 | } |
@@ -2609,7 +2609,7 @@ discard block |
||
| 2609 | 2609 | * stores payment gateway info |
| 2610 | 2610 | * @deprecated |
| 2611 | 2611 | */ |
| 2612 | -class EE_Gateway_Config extends EE_Config_Base{ |
|
| 2612 | +class EE_Gateway_Config extends EE_Config_Base { |
|
| 2613 | 2613 | |
| 2614 | 2614 | /** |
| 2615 | 2615 | * Array with keys that are payment gateways slugs, and values are arrays |
@@ -2631,9 +2631,9 @@ discard block |
||
| 2631 | 2631 | * class constructor |
| 2632 | 2632 | * @deprecated |
| 2633 | 2633 | */ |
| 2634 | - public function __construct(){ |
|
| 2634 | + public function __construct() { |
|
| 2635 | 2635 | $this->payment_settings = array(); |
| 2636 | - $this->active_gateways = array( 'Invoice' => FALSE ); |
|
| 2636 | + $this->active_gateways = array('Invoice' => FALSE); |
|
| 2637 | 2637 | } |
| 2638 | 2638 | } |
| 2639 | 2639 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public static function instance() { |
| 63 | 63 | // check if class object is instantiated, and instantiated properly |
| 64 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Front_Controller )) { |
|
| 64 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Front_Controller)) { |
|
| 65 | 65 | self::$_instance = new self(); |
| 66 | 66 | } |
| 67 | 67 | return self::$_instance; |
@@ -79,37 +79,37 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | private function __construct() { |
| 81 | 81 | // make sure template tags are loaded immediately so that themes don't break |
| 82 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'load_espresso_template_tags' ), 10 ); |
|
| 82 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
| 83 | 83 | // determine how to integrate WP_Query with the EE models |
| 84 | - add_action( 'AHEE__EE_System__initialize', array( $this, 'employ_CPT_Strategy' )); |
|
| 84 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 85 | 85 | // load other resources and begin to actually run shortcodes and modules |
| 86 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 5 ); |
|
| 86 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 87 | 87 | // analyse the incoming WP request |
| 88 | - add_action( 'parse_request', array( $this, 'get_request' ), 1, 1 ); |
|
| 88 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 89 | 89 | // process any content shortcodes |
| 90 | - add_action( 'parse_request', array( $this, '_initialize_shortcodes' ), 5 ); |
|
| 90 | + add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
| 91 | 91 | // process request with module factory |
| 92 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10, 1 ); |
|
| 92 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 93 | 93 | // before headers sent |
| 94 | - add_action( 'wp', array( $this, 'wp' ), 5 ); |
|
| 94 | + add_action('wp', array($this, 'wp'), 5); |
|
| 95 | 95 | // load css and js |
| 96 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 1 ); |
|
| 96 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
| 97 | 97 | // header |
| 98 | - add_action('wp_head', array( $this, 'header_meta_tag' ), 5 ); |
|
| 99 | - add_filter( 'template_include', array( $this, 'template_include' ), 1 ); |
|
| 98 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 99 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
| 100 | 100 | // display errors |
| 101 | - add_action('loop_start', array( $this, 'display_errors' ), 2 ); |
|
| 101 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 102 | 102 | // the content |
| 103 | - add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 103 | + add_filter('the_content', array($this, 'the_content'), 5, 1); |
|
| 104 | 104 | //exclude our private cpt comments |
| 105 | - add_filter( 'comments_clauses', array( $this, 'filter_wp_comments'), 10, 1 ); |
|
| 105 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 106 | 106 | //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
| 107 | - add_filter( 'admin_url', array( $this, 'maybe_force_admin_ajax_ssl' ), 200, 1 ); |
|
| 107 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 108 | 108 | // action hook EE |
| 109 | - do_action( 'AHEE__EE_Front_Controller__construct__done',$this ); |
|
| 109 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 110 | 110 | // for checking that browser cookies are enabled |
| 111 | - if ( apply_filters( 'FHEE__EE_Front_Controller____construct__set_test_cookie', true )) { |
|
| 112 | - setcookie( 'ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/' ); |
|
| 111 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 112 | + setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * @return void |
| 130 | 130 | */ |
| 131 | 131 | public function load_espresso_template_tags() { |
| 132 | - if ( is_readable( EE_PUBLIC . 'template_tags.php' )) { |
|
| 133 | - require_once( EE_PUBLIC . 'template_tags.php' ); |
|
| 132 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
| 133 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
| 146 | 146 | * @return array array of comment clauses with modifications. |
| 147 | 147 | */ |
| 148 | - public function filter_wp_comments( $clauses ) { |
|
| 148 | + public function filter_wp_comments($clauses) { |
|
| 149 | 149 | global $wpdb; |
| 150 | - if ( strpos( $clauses['join'], $wpdb->posts ) !== FALSE ) { |
|
| 150 | + if (strpos($clauses['join'], $wpdb->posts) !== FALSE) { |
|
| 151 | 151 | $cpts = EE_Register_CPTs::get_private_CPTs(); |
| 152 | - foreach ( $cpts as $cpt => $details ) { |
|
| 153 | - $clauses['where'] .= $wpdb->prepare( " AND $wpdb->posts.post_type != %s", $cpt ); |
|
| 152 | + foreach ($cpts as $cpt => $details) { |
|
| 153 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | return $clauses; |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | 169 | public function employ_CPT_Strategy() { |
| 170 | - if ( apply_filters( 'FHEE__EE_Front_Controller__employ_CPT_Strategy',true) ){ |
|
| 171 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
| 170 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 171 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * @param string $url incoming url |
| 181 | 181 | * @return string final assembled url |
| 182 | 182 | */ |
| 183 | - public function maybe_force_admin_ajax_ssl( $url ) { |
|
| 184 | - if ( is_ssl() && preg_match( '/admin-ajax.php/', $url )) { |
|
| 185 | - $url = str_replace( 'http://', 'https://', $url ); |
|
| 183 | + public function maybe_force_admin_ajax_ssl($url) { |
|
| 184 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 185 | + $url = str_replace('http://', 'https://', $url); |
|
| 186 | 186 | } |
| 187 | 187 | return $url; |
| 188 | 188 | } |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | * @param WP $WP |
| 220 | 220 | * @return void |
| 221 | 221 | */ |
| 222 | - public function get_request( WP $WP ) { |
|
| 223 | - do_action( 'AHEE__EE_Front_Controller__get_request__start' ); |
|
| 222 | + public function get_request(WP $WP) { |
|
| 223 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 224 | 224 | /** @var EE_Request_Handler $Request_Handler */ |
| 225 | - $Request_Handler = EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 226 | - $Request_Handler->parse_request( $WP ); |
|
| 227 | - do_action( 'AHEE__EE_Front_Controller__get_request__complete' ); |
|
| 225 | + $Request_Handler = EE_Registry::instance()->load_core('Request_Handler'); |
|
| 226 | + $Request_Handler->parse_request($WP); |
|
| 227 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -236,22 +236,22 @@ discard block |
||
| 236 | 236 | * @param WP $WP |
| 237 | 237 | * @return void |
| 238 | 238 | */ |
| 239 | - public function _initialize_shortcodes( WP $WP ) { |
|
| 240 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this ); |
|
| 239 | + public function _initialize_shortcodes(WP $WP) { |
|
| 240 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
| 241 | 241 | // grab post_name from request |
| 242 | - $current_post = apply_filters( 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', EE_Registry::instance()->REQ->get( 'post_name' )); |
|
| 242 | + $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', EE_Registry::instance()->REQ->get('post_name')); |
|
| 243 | 243 | // if it's not set, then check if frontpage is blog |
| 244 | - if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'posts' ) { |
|
| 244 | + if (empty($current_post) && get_option('show_on_front') == 'posts') { |
|
| 245 | 245 | // yup.. this is the posts page, prepare to load all shortcode modules |
| 246 | 246 | $current_post = 'posts'; |
| 247 | - } else if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'page' ) { |
|
| 247 | + } else if (empty($current_post) && get_option('show_on_front') == 'page') { |
|
| 248 | 248 | // some other page is set as the homepage |
| 249 | - $page_on_front = get_option( 'page_on_front' ); |
|
| 250 | - if ( $page_on_front ) { |
|
| 249 | + $page_on_front = get_option('page_on_front'); |
|
| 250 | + if ($page_on_front) { |
|
| 251 | 251 | // k now we need to find the post_name for this page |
| 252 | 252 | global $wpdb; |
| 253 | 253 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d"; |
| 254 | - $page_on_front = $wpdb->get_var( $wpdb->prepare( $SQL, $page_on_front )); |
|
| 254 | + $page_on_front = $wpdb->get_var($wpdb->prepare($SQL, $page_on_front)); |
|
| 255 | 255 | // set the current post slug to what it actually is |
| 256 | 256 | $current_post = $page_on_front ? $page_on_front : $current_post; |
| 257 | 257 | } |
@@ -259,58 +259,58 @@ discard block |
||
| 259 | 259 | // where are posts being displayed ? |
| 260 | 260 | $page_for_posts = EE_Config::get_page_for_posts(); |
| 261 | 261 | // in case $current_post is hierarchical like: /parent-page/current-page |
| 262 | - $current_post = basename( $current_post ); |
|
| 262 | + $current_post = basename($current_post); |
|
| 263 | 263 | // are we on a category page? |
| 264 | - $term_exists = is_array( term_exists( $current_post, 'category' )) || array_key_exists( 'category_name', $WP->query_vars ); |
|
| 264 | + $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', $WP->query_vars); |
|
| 265 | 265 | // make sure shortcodes are set |
| 266 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes )) { |
|
| 266 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes)) { |
|
| 267 | 267 | // d( EE_Registry::instance()->CFG->core->post_shortcodes ); |
| 268 | 268 | // cycle thru all posts with shortcodes set |
| 269 | - foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
| 269 | + foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
| 270 | 270 | // filter shortcodes so |
| 271 | - $post_shortcodes = apply_filters( 'FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes ); |
|
| 271 | + $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes); |
|
| 272 | 272 | // now cycle thru shortcodes |
| 273 | - foreach ( $post_shortcodes as $shortcode_class => $post_id ) { |
|
| 273 | + foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
| 274 | 274 | // are we on this page, or on the blog page, or an EE CPT category page ? |
| 275 | - if ( $current_post == $post_name || $term_exists ) { |
|
| 275 | + if ($current_post == $post_name || $term_exists) { |
|
| 276 | 276 | // verify shortcode is in list of registered shortcodes |
| 277 | - if ( ! isset( EE_Registry::instance()->shortcodes->{$shortcode_class} )) { |
|
| 278 | - if ( $current_post != $page_for_posts && current_user_can( 'edit_post', $post_id )) { |
|
| 279 | - $msg = sprintf( __( 'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso' ), $shortcode_class ); |
|
| 280 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 281 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 277 | + if ( ! isset(EE_Registry::instance()->shortcodes->{$shortcode_class} )) { |
|
| 278 | + if ($current_post != $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
| 279 | + $msg = sprintf(__('The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso'), $shortcode_class); |
|
| 280 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 281 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 282 | 282 | } |
| 283 | - add_shortcode( $shortcode_class, array( 'EES_Shortcode', 'invalid_shortcode_processor' )); |
|
| 283 | + add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
| 284 | 284 | continue; |
| 285 | 285 | } |
| 286 | 286 | // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
| 287 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $current_post ] ) || $term_exists || $current_post == $page_for_posts ) { |
|
| 287 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$current_post]) || $term_exists || $current_post == $page_for_posts) { |
|
| 288 | 288 | // let's pause to reflect on this... |
| 289 | - $sc_reflector = new ReflectionClass( 'EES_' . $shortcode_class ); |
|
| 289 | + $sc_reflector = new ReflectionClass('EES_'.$shortcode_class); |
|
| 290 | 290 | // ensure that class is actually a shortcode |
| 291 | - if ( ! $sc_reflector->isSubclassOf( 'EES_Shortcode' ) && defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE ) { |
|
| 292 | - $msg = sprintf( __( 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso' ), $shortcode_class ); |
|
| 293 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 294 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 291 | + if ( ! $sc_reflector->isSubclassOf('EES_Shortcode') && defined('WP_DEBUG') && WP_DEBUG === TRUE) { |
|
| 292 | + $msg = sprintf(__('The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso'), $shortcode_class); |
|
| 293 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 294 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 295 | 295 | continue; |
| 296 | 296 | } |
| 297 | 297 | // and pass the request object to the run method |
| 298 | 298 | EE_Registry::instance()->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
| 299 | 299 | // fire the shortcode class's run method, so that it can activate resources |
| 300 | - EE_Registry::instance()->shortcodes->{$shortcode_class}->run( $WP ); |
|
| 300 | + EE_Registry::instance()->shortcodes->{$shortcode_class}->run($WP); |
|
| 301 | 301 | } |
| 302 | 302 | // if this is NOT the "Posts page" and we have a valid entry for the "Posts page" in our tracked post_shortcodes array |
| 303 | - } else if ( $post_name != $page_for_posts && isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] )) { |
|
| 303 | + } else if ($post_name != $page_for_posts && isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) { |
|
| 304 | 304 | // and the shortcode is not being tracked for this page |
| 305 | - if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] )) { |
|
| 305 | + if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
| 306 | 306 | // then remove the "fallback" shortcode processor |
| 307 | - remove_shortcode( $shortcode_class ); |
|
| 307 | + remove_shortcode($shortcode_class); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__end', $this ); |
|
| 313 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
@@ -322,20 +322,20 @@ discard block |
||
| 322 | 322 | * @param WP_Query $WP_Query |
| 323 | 323 | * @return void |
| 324 | 324 | */ |
| 325 | - public function pre_get_posts( $WP_Query ) { |
|
| 325 | + public function pre_get_posts($WP_Query) { |
|
| 326 | 326 | // only load Module_Request_Router if this is the main query |
| 327 | - if ( $WP_Query->is_main_query() ) { |
|
| 327 | + if ($WP_Query->is_main_query()) { |
|
| 328 | 328 | // load module request router |
| 329 | - $Module_Request_Router = EE_Registry::instance()->load_core( 'Module_Request_Router' ); |
|
| 329 | + $Module_Request_Router = EE_Registry::instance()->load_core('Module_Request_Router'); |
|
| 330 | 330 | // verify object |
| 331 | - if ( $Module_Request_Router instanceof EE_Module_Request_Router ) { |
|
| 331 | + if ($Module_Request_Router instanceof EE_Module_Request_Router) { |
|
| 332 | 332 | // cycle thru module routes |
| 333 | - while ( $route = $Module_Request_Router->get_route( $WP_Query )) { |
|
| 333 | + while ($route = $Module_Request_Router->get_route($WP_Query)) { |
|
| 334 | 334 | // determine module and method for route |
| 335 | - $module = $Module_Request_Router->resolve_route( $route[0], $route[1] ); |
|
| 336 | - if( $module instanceof EED_Module ) { |
|
| 335 | + $module = $Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 336 | + if ($module instanceof EED_Module) { |
|
| 337 | 337 | // get registered view for route |
| 338 | - $this->_template_path = $Module_Request_Router->get_view( $route ); |
|
| 338 | + $this->_template_path = $Module_Request_Router->get_view($route); |
|
| 339 | 339 | // grab module name |
| 340 | 340 | $module_name = $module->module_name(); |
| 341 | 341 | // map the module to the module objects |
@@ -379,29 +379,29 @@ discard block |
||
| 379 | 379 | public function wp_enqueue_scripts() { |
| 380 | 380 | |
| 381 | 381 | // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
| 382 | - if ( apply_filters( 'FHEE_load_css', TRUE ) ) { |
|
| 382 | + if (apply_filters('FHEE_load_css', TRUE)) { |
|
| 383 | 383 | |
| 384 | 384 | EE_Registry::instance()->CFG->template_settings->enable_default_style = TRUE; |
| 385 | 385 | //Load the ThemeRoller styles if enabled |
| 386 | - if ( isset( EE_Registry::instance()->CFG->template_settings->enable_default_style ) && EE_Registry::instance()->CFG->template_settings->enable_default_style ) { |
|
| 386 | + if (isset(EE_Registry::instance()->CFG->template_settings->enable_default_style) && EE_Registry::instance()->CFG->template_settings->enable_default_style) { |
|
| 387 | 387 | |
| 388 | 388 | //Load custom style sheet if available |
| 389 | - if ( isset( EE_Registry::instance()->CFG->template_settings->custom_style_sheet )) { |
|
| 390 | - wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . EE_Registry::instance()->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION ); |
|
| 389 | + if (isset(EE_Registry::instance()->CFG->template_settings->custom_style_sheet)) { |
|
| 390 | + wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL.'css/'.EE_Registry::instance()->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION); |
|
| 391 | 391 | wp_enqueue_style('espresso_custom_css'); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if ( is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )) { |
|
| 395 | - wp_register_style( 'espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
| 394 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
| 395 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
| 396 | 396 | } else { |
| 397 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
| 397 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
| 398 | 398 | } |
| 399 | 399 | wp_enqueue_style('espresso_default'); |
| 400 | 400 | |
| 401 | - if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css' )) { |
|
| 402 | - wp_register_style( 'espresso_style', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 401 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
| 402 | + wp_register_style('espresso_style', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 403 | 403 | } else { |
| 404 | - wp_register_style( 'espresso_style', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 404 | + wp_register_style('espresso_style', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | } |
@@ -409,40 +409,40 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
| 412 | - if ( apply_filters( 'FHEE_load_js', TRUE ) ) { |
|
| 412 | + if (apply_filters('FHEE_load_js', TRUE)) { |
|
| 413 | 413 | |
| 414 | - wp_enqueue_script( 'jquery' ); |
|
| 414 | + wp_enqueue_script('jquery'); |
|
| 415 | 415 | //let's make sure that all required scripts have been setup |
| 416 | - if ( function_exists( 'wp_script_is' )) { |
|
| 417 | - if ( ! wp_script_is( 'jquery' )) { |
|
| 416 | + if (function_exists('wp_script_is')) { |
|
| 417 | + if ( ! wp_script_is('jquery')) { |
|
| 418 | 418 | $msg = sprintf( |
| 419 | - __( '%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso' ), |
|
| 419 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso'), |
|
| 420 | 420 | '<em><br />', |
| 421 | 421 | '</em>' |
| 422 | 422 | ); |
| 423 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 423 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | // load core js |
| 427 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 428 | - wp_enqueue_script( 'espresso_core' ); |
|
| 429 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
| 427 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 428 | + wp_enqueue_script('espresso_core'); |
|
| 429 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
| 430 | 430 | |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
| 434 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
| 434 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
| 435 | 435 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | //accounting.js library |
| 440 | 440 | // @link http://josscrowcroft.github.io/accounting.js/ |
| 441 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
| 442 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
| 443 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 444 | - wp_register_script( 'ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE ); |
|
| 445 | - wp_enqueue_script( 'ee-accounting' ); |
|
| 441 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
| 442 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
| 443 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 444 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE); |
|
| 445 | + wp_enqueue_script('ee-accounting'); |
|
| 446 | 446 | |
| 447 | 447 | $currency_config = array( |
| 448 | 448 | 'currency' => array( |
@@ -465,21 +465,21 @@ discard block |
||
| 465 | 465 | wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( ! function_exists( 'wp_head' )) { |
|
| 468 | + if ( ! function_exists('wp_head')) { |
|
| 469 | 469 | $msg = sprintf( |
| 470 | - __( '%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
| 470 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
| 471 | 471 | '<em><br />', |
| 472 | 472 | '</em>' |
| 473 | 473 | ); |
| 474 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 474 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 475 | 475 | } |
| 476 | - if ( ! function_exists( 'wp_footer' )) { |
|
| 476 | + if ( ! function_exists('wp_footer')) { |
|
| 477 | 477 | $msg = sprintf( |
| 478 | - __( '%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
| 478 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
| 479 | 479 | '<em><br />', |
| 480 | 480 | '</em>' |
| 481 | 481 | ); |
| 482 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 482 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @return void |
| 494 | 494 | */ |
| 495 | 495 | public function header_meta_tag() { |
| 496 | - print( apply_filters("FHEE__EE_Front_Controller__header_meta_tag","<meta name='generator' content='Event Espresso Version " . EVENT_ESPRESSO_VERSION . "' />")); |
|
| 496 | + print(apply_filters("FHEE__EE_Front_Controller__header_meta_tag", "<meta name='generator' content='Event Espresso Version ".EVENT_ESPRESSO_VERSION."' />")); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | * @param $the_content |
| 508 | 508 | * @return string |
| 509 | 509 | */ |
| 510 | - public function the_content( $the_content ) { |
|
| 510 | + public function the_content($the_content) { |
|
| 511 | 511 | // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
| 512 | - if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 512 | + if (apply_filters('FHEE_run_EE_the_content', FALSE)) { |
|
| 513 | 513 | } |
| 514 | 514 | return $the_content; |
| 515 | 515 | } |
@@ -534,9 +534,9 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | public function display_errors() { |
| 536 | 536 | static $shown_already = FALSE; |
| 537 | - do_action( 'AHEE__EE_Front_Controller__display_errors__begin' ); |
|
| 537 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 538 | 538 | if ( |
| 539 | - apply_filters( 'FHEE__EE_Front_Controller__display_errors', TRUE ) |
|
| 539 | + apply_filters('FHEE__EE_Front_Controller__display_errors', TRUE) |
|
| 540 | 540 | && ! $shown_already |
| 541 | 541 | && is_main_query() |
| 542 | 542 | && ! is_feed() |
@@ -545,9 +545,9 @@ discard block |
||
| 545 | 545 | ) { |
| 546 | 546 | echo EE_Error::get_notices(); |
| 547 | 547 | $shown_already = TRUE; |
| 548 | - EEH_Template::display_template( EE_TEMPLATES . 'espresso-ajax-notices.template.php' ); |
|
| 548 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
| 549 | 549 | } |
| 550 | - do_action( 'AHEE__EE_Front_Controller__display_errors__end' ); |
|
| 550 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | * @param string $template_include_path |
| 563 | 563 | * @return string |
| 564 | 564 | */ |
| 565 | - public function template_include( $template_include_path = NULL ) { |
|
| 566 | - if ( EE_Registry::instance()->REQ->is_espresso_page() ) { |
|
| 567 | - $this->_template_path = ! empty( $this->_template_path ) ? basename( $this->_template_path ) : basename( $template_include_path ); |
|
| 568 | - $template_path = EEH_Template::locate_template( $this->_template_path, array(), false ); |
|
| 569 | - $this->_template_path = ! empty( $template_path ) ? $template_path : $template_include_path; |
|
| 570 | - $this->_template = basename( $this->_template_path ); |
|
| 565 | + public function template_include($template_include_path = NULL) { |
|
| 566 | + if (EE_Registry::instance()->REQ->is_espresso_page()) { |
|
| 567 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 568 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 569 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 570 | + $this->_template = basename($this->_template_path); |
|
| 571 | 571 | return $this->_template_path; |
| 572 | 572 | } |
| 573 | 573 | return $template_include_path; |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @param bool $with_path |
| 583 | 583 | * @return string |
| 584 | 584 | */ |
| 585 | - public function get_selected_template( $with_path = FALSE ) { |
|
| 585 | + public function get_selected_template($with_path = FALSE) { |
|
| 586 | 586 | return $with_path ? $this->_template_path : $this->_template; |
| 587 | 587 | } |
| 588 | 588 | |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
| 2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
| 3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
| 4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
| 5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
| 3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
| 4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
| 5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
| 6 | 6 | } |
| 7 | 7 | /** |
| 8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @access private |
| 65 | 65 | * @var boolean |
| 66 | 66 | */ |
| 67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
| 67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @access public |
| 76 | 76 | * @echo string |
| 77 | 77 | */ |
| 78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
| 79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
| 80 | - parent::__construct( $message, $code ); |
|
| 78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
| 79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
| 80 | + parent::__construct($message, $code); |
|
| 81 | 81 | } else { |
| 82 | - parent::__construct( $message, $code, $previous ); |
|
| 82 | + parent::__construct($message, $code, $previous); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * @param $line |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
| 98 | - $type = EE_Error::error_type( $code ); |
|
| 97 | + public static function error_handler($code, $message, $file, $line) { |
|
| 98 | + $type = EE_Error::error_type($code); |
|
| 99 | 99 | $site = site_url(); |
| 100 | - switch ( $site ) { |
|
| 100 | + switch ($site) { |
|
| 101 | 101 | case 'http://ee4.eventespresso.com/' : |
| 102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
| 103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | $to = '[email protected]'; |
| 111 | 111 | break; |
| 112 | 112 | default : |
| 113 | - $to = get_option( 'admin_email' ); |
|
| 113 | + $to = get_option('admin_email'); |
|
| 114 | 114 | } |
| 115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
| 116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
| 117 | - if ( function_exists( 'wp_mail' )) { |
|
| 118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
| 119 | - wp_mail( $to, $subject, $msg ); |
|
| 115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
| 116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
| 117 | + if (function_exists('wp_mail')) { |
|
| 118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
| 119 | + wp_mail($to, $subject, $msg); |
|
| 120 | 120 | } |
| 121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
| 122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
| 122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
| 123 | 123 | echo '<br /></p></div>'; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * @param $code |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public static function error_type( $code ) { |
|
| 136 | - switch( $code ) { |
|
| 135 | + public static function error_type($code) { |
|
| 136 | + switch ($code) { |
|
| 137 | 137 | case E_ERROR: // 1 // |
| 138 | 138 | return 'E_ERROR'; |
| 139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public static function fatal_error_handler() { |
| 181 | 181 | $last_error = error_get_last(); |
| 182 | - if ( $last_error['type'] === E_ERROR ) { |
|
| 183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
| 182 | + if ($last_error['type'] === E_ERROR) { |
|
| 183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param $line |
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
| 198 | + private static function _format_error($code, $message, $file, $line) { |
|
| 199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
| 200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
| 201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @param $content_type |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | - public static function set_content_type( $content_type ) { |
|
| 216 | + public static function set_content_type($content_type) { |
|
| 217 | 217 | return 'text/html'; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function get_error() { |
| 229 | 229 | |
| 230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
| 230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
| 231 | 231 | throw $this; |
| 232 | 232 | } |
| 233 | 233 | // get separate user and developer messages if they exist |
| 234 | - $msg = explode( '||', $this->getMessage() ); |
|
| 234 | + $msg = explode('||', $this->getMessage()); |
|
| 235 | 235 | $user_msg = $msg[0]; |
| 236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
| 236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
| 238 | 238 | |
| 239 | 239 | // add details to _all_exceptions array |
| 240 | 240 | $x_time = time(); |
| 241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
| 242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
| 243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
| 244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
| 245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
| 246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
| 247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
| 241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
| 242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
| 243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
| 244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
| 245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
| 246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
| 247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
| 248 | 248 | self::$_error_count++; |
| 249 | 249 | |
| 250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @access public |
| 260 | 260 | * @return boolean |
| 261 | 261 | */ |
| 262 | - public static function has_error(){ |
|
| 262 | + public static function has_error() { |
|
| 263 | 263 | return self::$_error_count ? TRUE : FALSE; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @access public |
| 271 | 271 | * @echo string |
| 272 | 272 | */ |
| 273 | - public function display_errors(){ |
|
| 273 | + public function display_errors() { |
|
| 274 | 274 | |
| 275 | 275 | $trace_details = ''; |
| 276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
| 331 | 331 | </style> |
| 332 | 332 | <div id="ee-error-message" class="error">'; |
| 333 | 333 | |
| 334 | - if ( ! WP_DEBUG ) { |
|
| 334 | + if ( ! WP_DEBUG) { |
|
| 335 | 335 | $output .= ' |
| 336 | 336 | <p>'; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // cycle thru errors |
| 340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
| 340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
| 341 | 341 | |
| 342 | 342 | // process trace info |
| 343 | - if ( empty( $ex['trace'] )) { |
|
| 343 | + if (empty($ex['trace'])) { |
|
| 344 | 344 | |
| 345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
| 345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
| 346 | 346 | |
| 347 | 347 | } else { |
| 348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
| 357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
| 358 | 358 | </tr>'; |
| 359 | 359 | |
| 360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
| 360 | + $last_on_stack = count($ex['trace']) - 1; |
|
| 361 | 361 | // reverse array so that stack is in proper chronological order |
| 362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
| 362 | + $sorted_trace = array_reverse($ex['trace']); |
|
| 363 | 363 | |
| 364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
| 364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
| 365 | 365 | |
| 366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
| 367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
| 368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
| 369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
| 370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
| 371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
| 366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
| 367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
| 368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
| 369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
| 370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
| 371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
| 372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
| 373 | 373 | |
| 374 | - if ( empty( $file ) && ! empty( $class )) { |
|
| 375 | - $a = new ReflectionClass( $class ); |
|
| 374 | + if (empty($file) && ! empty($class)) { |
|
| 375 | + $a = new ReflectionClass($class); |
|
| 376 | 376 | $file = $a->getFileName(); |
| 377 | - if ( empty( $line ) && ! empty( $function )) { |
|
| 378 | - $b = new ReflectionMethod( $class, $function ); |
|
| 377 | + if (empty($line) && ! empty($function)) { |
|
| 378 | + $b = new ReflectionMethod($class, $function); |
|
| 379 | 379 | $line = $b->getStartLine(); |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( $nmbr == $last_on_stack ) { |
|
| 383 | + if ($nmbr == $last_on_stack) { |
|
| 384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
| 385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
| 386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
| 386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
| 390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
| 391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
| 392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
| 393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
| 394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
| 395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
| 389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
| 390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
| 391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
| 392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
| 393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
| 394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
| 395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
| 396 | 396 | |
| 397 | 397 | $trace_details .= ' |
| 398 | 398 | <tr> |
| 399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
| 400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
| 401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
| 402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
| 403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
| 399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
| 400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
| 401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
| 402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
| 403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
| 404 | 404 | </tr>'; |
| 405 | 405 | |
| 406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
| 416 | 416 | |
| 417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
| 418 | - if ( ! WP_DEBUG ) { |
|
| 418 | + if ( ! WP_DEBUG) { |
|
| 419 | 419 | |
| 420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
| 420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
| 421 | 421 | |
| 422 | 422 | } else { |
| 423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
| 425 | 425 | $output .= ' |
| 426 | 426 | <div class="ee-error-dev-msg-dv"> |
| 427 | 427 | <p class="ee-error-dev-msg-pg"> |
| 428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
| 429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
| 430 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
| 431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
| 428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
| 429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
| 430 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
| 431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
| 432 | 432 | </a><br /> |
| 433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
| 434 | 434 | </p> |
| 435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 436 | 436 | ' . $trace_details; |
| 437 | 437 | |
| 438 | - if ( ! empty( $class )) { |
|
| 438 | + if ( ! empty($class)) { |
|
| 439 | 439 | $output .= ' |
| 440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
| 441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
| 442 | 442 | <h3>Class Details</h3>'; |
| 443 | - $a = new ReflectionClass( $class ); |
|
| 443 | + $a = new ReflectionClass($class); |
|
| 444 | 444 | $output .= ' |
| 445 | - <pre>' . $a . '</pre> |
|
| 445 | + <pre>' . $a.'</pre> |
|
| 446 | 446 | </div> |
| 447 | 447 | </div>'; |
| 448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $this->write_to_error_log( $time, $ex ); |
|
| 457 | + $this->write_to_error_log($time, $ex); |
|
| 458 | 458 | |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // remove last linebreak |
| 462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
| 462 | + $output = substr($output, 0, (count($output) - 7)); |
|
| 463 | 463 | |
| 464 | - if ( ! WP_DEBUG ) { |
|
| 464 | + if ( ! WP_DEBUG) { |
|
| 465 | 465 | $output .= ' |
| 466 | 466 | </p>'; |
| 467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
| 469 | 469 | $output .= ' |
| 470 | 470 | </div>'; |
| 471 | 471 | |
| 472 | - $output .= self::_print_scripts( TRUE ); |
|
| 472 | + $output .= self::_print_scripts(TRUE); |
|
| 473 | 473 | |
| 474 | - if ( defined( 'DOING_AJAX' )) { |
|
| 475 | - echo json_encode( array( 'error' => $output )); |
|
| 474 | + if (defined('DOING_AJAX')) { |
|
| 475 | + echo json_encode(array('error' => $output)); |
|
| 476 | 476 | exit(); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
| 492 | 492 | * @ param array $arguments |
| 493 | 493 | * @ return string |
| 494 | 494 | */ |
| 495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
| 495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
| 496 | 496 | |
| 497 | 497 | $arg_string = ''; |
| 498 | - if ( ! empty( $arguments )) { |
|
| 498 | + if ( ! empty($arguments)) { |
|
| 499 | 499 | |
| 500 | 500 | $args = array(); |
| 501 | 501 | |
| 502 | - foreach ( $arguments as $arg ) { |
|
| 502 | + foreach ($arguments as $arg) { |
|
| 503 | 503 | |
| 504 | - if ( ! empty( $arg )) { |
|
| 504 | + if ( ! empty($arg)) { |
|
| 505 | 505 | |
| 506 | - if ( is_string( $arg )) { |
|
| 507 | - $args[] = " '" . $arg . "'"; |
|
| 508 | - } elseif ( is_array( $arg )) { |
|
| 509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
| 510 | - } elseif ( is_null( $arg )) { |
|
| 506 | + if (is_string($arg)) { |
|
| 507 | + $args[] = " '".$arg."'"; |
|
| 508 | + } elseif (is_array($arg)) { |
|
| 509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
| 510 | + } elseif (is_null($arg)) { |
|
| 511 | 511 | $args[] = ' NULL'; |
| 512 | - } elseif ( is_bool( $arg )) { |
|
| 513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
| 514 | - } elseif ( is_object( $arg )) { |
|
| 515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
| 516 | - } elseif ( is_resource( $arg )) { |
|
| 517 | - $args[] = get_resource_type( $arg ); |
|
| 512 | + } elseif (is_bool($arg)) { |
|
| 513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
| 514 | + } elseif (is_object($arg)) { |
|
| 515 | + $args[] = ' OBJECT '.get_class($arg); |
|
| 516 | + } elseif (is_resource($arg)) { |
|
| 517 | + $args[] = get_resource_type($arg); |
|
| 518 | 518 | } else { |
| 519 | 519 | $args[] = $arg; |
| 520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
| 525 | - $arg_string = implode( ', ', $args ); |
|
| 525 | + $arg_string = implode(', ', $args); |
|
| 526 | 526 | } |
| 527 | - if ( $array ) { |
|
| 527 | + if ($array) { |
|
| 528 | 528 | $arg_string .= ' )'; |
| 529 | 529 | } |
| 530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 545 | 545 | * @return void |
| 546 | 546 | */ |
| 547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
| 547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
| 549 | 549 | self::$_error_count++; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 564 | 564 | * @return void |
| 565 | 565 | */ |
| 566 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 567 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
| 566 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 567 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 582 | 582 | * @return void |
| 583 | 583 | */ |
| 584 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 585 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
| 584 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 585 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
@@ -600,12 +600,12 @@ discard block |
||
| 600 | 600 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 601 | 601 | * @return void |
| 602 | 602 | */ |
| 603 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 604 | - if ( empty( $msg )) { |
|
| 603 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 604 | + if (empty($msg)) { |
|
| 605 | 605 | EE_Error::doing_it_wrong( |
| 606 | - 'EE_Error::add_' . $type . '()', |
|
| 606 | + 'EE_Error::add_'.$type.'()', |
|
| 607 | 607 | sprintf( |
| 608 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
| 608 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
| 609 | 609 | $type, |
| 610 | 610 | $file, |
| 611 | 611 | $line |
@@ -613,32 +613,32 @@ discard block |
||
| 613 | 613 | EVENT_ESPRESSO_VERSION |
| 614 | 614 | ); |
| 615 | 615 | } |
| 616 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
| 616 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
| 617 | 617 | EE_Error::doing_it_wrong( |
| 618 | 618 | 'EE_Error::add_error()', |
| 619 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
| 619 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
| 620 | 620 | EVENT_ESPRESSO_VERSION |
| 621 | 621 | ); |
| 622 | 622 | } |
| 623 | 623 | // get separate user and developer messages if they exist |
| 624 | - $msg = explode( '||', $msg ); |
|
| 624 | + $msg = explode('||', $msg); |
|
| 625 | 625 | $user_msg = $msg[0]; |
| 626 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
| 626 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 627 | 627 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
| 628 | 628 | // add notice if message exists |
| 629 | - if ( ! empty( $msg )) { |
|
| 629 | + if ( ! empty($msg)) { |
|
| 630 | 630 | // get error code |
| 631 | - $notice_code = EE_Error::generate_error_code( $file, $func, $line ); |
|
| 632 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
| 633 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
| 631 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
| 632 | + if (WP_DEBUG && $type == 'errors') { |
|
| 633 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
| 634 | 634 | } |
| 635 | 635 | // add notice. Index by code if it's not blank |
| 636 | - if( $notice_code ) { |
|
| 637 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
| 636 | + if ($notice_code) { |
|
| 637 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
| 638 | 638 | } else { |
| 639 | - self::$_espresso_notices[ $type ][] = $msg; |
|
| 639 | + self::$_espresso_notices[$type][] = $msg; |
|
| 640 | 640 | } |
| 641 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
| 641 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | } |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | * @access private |
| 693 | 693 | * @return void |
| 694 | 694 | */ |
| 695 | - public static function reset_notices(){ |
|
| 695 | + public static function reset_notices() { |
|
| 696 | 696 | self::$_espresso_notices['success'] = FALSE; |
| 697 | 697 | self::$_espresso_notices['attention'] = FALSE; |
| 698 | 698 | self::$_espresso_notices['errors'] = FALSE; |
@@ -705,14 +705,14 @@ discard block |
||
| 705 | 705 | * @access public |
| 706 | 706 | * @return int |
| 707 | 707 | */ |
| 708 | - public static function has_notices(){ |
|
| 708 | + public static function has_notices() { |
|
| 709 | 709 | $has_notices = 0; |
| 710 | 710 | // check for success messages |
| 711 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
| 711 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
| 712 | 712 | // check for attention messages |
| 713 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
| 713 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
| 714 | 714 | // check for error messages |
| 715 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
| 715 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
| 716 | 716 | return $has_notices; |
| 717 | 717 | } |
| 718 | 718 | |
@@ -728,8 +728,8 @@ discard block |
||
| 728 | 728 | * @param boolean $remove_empty whether or not to unset empty messages |
| 729 | 729 | * @return array |
| 730 | 730 | */ |
| 731 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
| 732 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 731 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
| 732 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 733 | 733 | |
| 734 | 734 | $success_messages = ''; |
| 735 | 735 | $attention_messages = ''; |
@@ -739,44 +739,44 @@ discard block |
||
| 739 | 739 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 740 | 740 | |
| 741 | 741 | // either save notices to the db |
| 742 | - if ( $save_to_transient ) { |
|
| 743 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
| 742 | + if ($save_to_transient) { |
|
| 743 | + update_option('ee_notices', self::$_espresso_notices); |
|
| 744 | 744 | return; |
| 745 | 745 | } |
| 746 | 746 | // grab any notices that have been previously saved |
| 747 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
| 748 | - foreach ( $notices as $type => $notice ) { |
|
| 749 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
| 747 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
| 748 | + foreach ($notices as $type => $notice) { |
|
| 749 | + if (is_array($notice) && ! empty($notice)) { |
|
| 750 | 750 | // make sure that existsing notice type is an array |
| 751 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
| 751 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
| 752 | 752 | // merge stored notices with any newly created ones |
| 753 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
| 753 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
| 754 | 754 | $print_scripts = TRUE; |
| 755 | 755 | } |
| 756 | 756 | } |
| 757 | 757 | // now clear any stored notices |
| 758 | - update_option( 'ee_notices', FALSE ); |
|
| 758 | + update_option('ee_notices', FALSE); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | // check for success messages |
| 762 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
| 762 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
| 763 | 763 | // combine messages |
| 764 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
| 764 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
| 765 | 765 | $print_scripts = TRUE; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | // check for attention messages |
| 769 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
| 769 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
| 770 | 770 | // combine messages |
| 771 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
| 771 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
| 772 | 772 | $print_scripts = TRUE; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | // check for error messages |
| 776 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
| 777 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
| 776 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
| 777 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
| 778 | 778 | // combine messages |
| 779 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
| 779 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
| 780 | 780 | $print_scripts = TRUE; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -790,21 +790,21 @@ discard block |
||
| 790 | 790 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
| 791 | 791 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
| 792 | 792 | //showMessage( $success_messages ); |
| 793 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
| 793 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | if ($attention_messages != '') { |
| 797 | 797 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
| 798 | 798 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
| 799 | 799 | //showMessage( $error_messages, TRUE ); |
| 800 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
| 800 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | if ($error_messages != '') { |
| 804 | 804 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
| 805 | 805 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
| 806 | 806 | //showMessage( $error_messages, TRUE ); |
| 807 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
| 807 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | $notices .= '</div>'; |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | 'errors' => $error_messages |
| 818 | 818 | ); |
| 819 | 819 | |
| 820 | - if ( $remove_empty ) { |
|
| 820 | + if ($remove_empty) { |
|
| 821 | 821 | // remove empty notices |
| 822 | 822 | foreach ($notices as $type => $notice) { |
| 823 | 823 | if (empty($notice)) { |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if ( $print_scripts ) { |
|
| 830 | + if ($print_scripts) { |
|
| 831 | 831 | self::_print_scripts(); |
| 832 | 832 | } |
| 833 | 833 | |
@@ -847,17 +847,17 @@ discard block |
||
| 847 | 847 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
| 848 | 848 | * @return void |
| 849 | 849 | */ |
| 850 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
| 851 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
| 852 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
| 850 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
| 851 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
| 852 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
| 853 | 853 | //maybe initialize persistent_admin_notices |
| 854 | - if ( empty( $persistent_admin_notices )) { |
|
| 855 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
| 854 | + if (empty($persistent_admin_notices)) { |
|
| 855 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
| 856 | 856 | } |
| 857 | - $pan_name = sanitize_key( $pan_name ); |
|
| 858 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
| 859 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
| 860 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
| 857 | + $pan_name = sanitize_key($pan_name); |
|
| 858 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
| 859 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
| 860 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | 863 | } |
@@ -873,34 +873,34 @@ discard block |
||
| 873 | 873 | * @param bool $return_immediately |
| 874 | 874 | * @return void |
| 875 | 875 | */ |
| 876 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
| 877 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
| 878 | - if ( ! empty( $pan_name )) { |
|
| 879 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
| 876 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
| 877 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
| 878 | + if ( ! empty($pan_name)) { |
|
| 879 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
| 880 | 880 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
| 881 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
| 881 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
| 882 | 882 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
| 883 | - if ( $purge ) { |
|
| 884 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
| 883 | + if ($purge) { |
|
| 884 | + unset($persistent_admin_notices[$pan_name]); |
|
| 885 | 885 | } else { |
| 886 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
| 886 | + $persistent_admin_notices[$pan_name] = NULL; |
|
| 887 | 887 | } |
| 888 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
| 889 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 888 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
| 889 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | - if ( $return_immediately ) { |
|
| 893 | + if ($return_immediately) { |
|
| 894 | 894 | return; |
| 895 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 895 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
| 896 | 896 | // grab any notices and concatenate into string |
| 897 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
| 897 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
| 898 | 898 | exit(); |
| 899 | 899 | } else { |
| 900 | 900 | // save errors to a transient to be displayed on next request (after redirect) |
| 901 | - EE_Error::get_notices( FALSE, TRUE ); |
|
| 902 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
| 903 | - wp_safe_redirect( urldecode( $return_url )); |
|
| 901 | + EE_Error::get_notices(FALSE, TRUE); |
|
| 902 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
| 903 | + wp_safe_redirect(urldecode($return_url)); |
|
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | |
@@ -915,20 +915,20 @@ discard block |
||
| 915 | 915 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
| 916 | 916 | * @return string |
| 917 | 917 | */ |
| 918 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
| 919 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
| 918 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
| 919 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
| 920 | 920 | $args = array( |
| 921 | 921 | 'nag_notice' => $pan_name, |
| 922 | - 'return_url' => urlencode( $return_url ), |
|
| 922 | + 'return_url' => urlencode($return_url), |
|
| 923 | 923 | 'ajax_url' => WP_AJAX_URL, |
| 924 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
| 924 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
| 925 | 925 | ); |
| 926 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
| 926 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
| 927 | 927 | return ' |
| 928 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
| 929 | - <p>' . $pan_message . '</p> |
|
| 930 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
| 931 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
| 928 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
| 929 | + <p>' . $pan_message.'</p> |
|
| 930 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
| 931 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
| 932 | 932 | </a> |
| 933 | 933 | <div style="clear:both;"></div> |
| 934 | 934 | </div>'; |
@@ -944,24 +944,24 @@ discard block |
||
| 944 | 944 | * @param string $return_url |
| 945 | 945 | * @return array |
| 946 | 946 | */ |
| 947 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
| 947 | + public static function get_persistent_admin_notices($return_url = '') { |
|
| 948 | 948 | $notices = ''; |
| 949 | 949 | // check for persistent admin notices |
| 950 | 950 | //filter the list though so plugins can notify the admin in a different way if they want |
| 951 | 951 | $persistent_admin_notices = apply_filters( |
| 952 | 952 | 'FHEE__EE_Error__get_persistent_admin_notices', |
| 953 | - get_option( 'ee_pers_admin_notices', FALSE ), |
|
| 953 | + get_option('ee_pers_admin_notices', FALSE), |
|
| 954 | 954 | 'ee_pers_admin_notices', |
| 955 | 955 | $return_url |
| 956 | 956 | ); |
| 957 | - if ( $persistent_admin_notices ) { |
|
| 957 | + if ($persistent_admin_notices) { |
|
| 958 | 958 | // load scripts |
| 959 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 960 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 961 | - wp_enqueue_script( 'ee_error_js' ); |
|
| 959 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 960 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 961 | + wp_enqueue_script('ee_error_js'); |
|
| 962 | 962 | // and display notices |
| 963 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
| 964 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
| 963 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
| 964 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | return $notices; |
@@ -976,26 +976,26 @@ discard block |
||
| 976 | 976 | * @param bool $force_print |
| 977 | 977 | * @return void |
| 978 | 978 | */ |
| 979 | - private static function _print_scripts( $force_print = FALSE ) { |
|
| 980 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
| 981 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
| 979 | + private static function _print_scripts($force_print = FALSE) { |
|
| 980 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
| 981 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
| 982 | 982 | return; |
| 983 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
| 984 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
| 985 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
| 986 | - wp_enqueue_script( 'ee_error_js' ); |
|
| 987 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
| 983 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
| 984 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 985 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 986 | + wp_enqueue_script('ee_error_js'); |
|
| 987 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
| 988 | 988 | } |
| 989 | 989 | } else { |
| 990 | 990 | return ' |
| 991 | 991 | <script> |
| 992 | 992 | /* <![CDATA[ */ |
| 993 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
| 993 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
| 994 | 994 | /* ]]> */ |
| 995 | 995 | </script> |
| 996 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 997 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 998 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 996 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 997 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 998 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 999 | 999 | '; |
| 1000 | 1000 | |
| 1001 | 1001 | } |
@@ -1029,11 +1029,11 @@ discard block |
||
| 1029 | 1029 | * @ param string $line |
| 1030 | 1030 | * @ return string |
| 1031 | 1031 | */ |
| 1032 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
| 1033 | - $file = explode( '.', basename( $file )); |
|
| 1034 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
| 1035 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
| 1036 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
| 1032 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
| 1033 | + $file = explode('.', basename($file)); |
|
| 1034 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
| 1035 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
| 1036 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
| 1037 | 1037 | return $error_code; |
| 1038 | 1038 | } |
| 1039 | 1039 | |
@@ -1049,36 +1049,36 @@ discard block |
||
| 1049 | 1049 | * @ param object $ex |
| 1050 | 1050 | * @ return void |
| 1051 | 1051 | */ |
| 1052 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
| 1052 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
| 1053 | 1053 | |
| 1054 | - if ( ! $ex ) { |
|
| 1054 | + if ( ! $ex) { |
|
| 1055 | 1055 | return; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - if ( ! $time ) { |
|
| 1058 | + if ( ! $time) { |
|
| 1059 | 1059 | $time = time(); |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 1063 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
| 1064 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
| 1065 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
| 1066 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
| 1067 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
| 1068 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
| 1069 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
| 1070 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 1062 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
| 1063 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
| 1064 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
| 1065 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
| 1066 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
| 1067 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
| 1068 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
| 1069 | + $exception_log .= $ex['string'].PHP_EOL; |
|
| 1070 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
| 1071 | 1071 | |
| 1072 | 1072 | try { |
| 1073 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
| 1074 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
| 1075 | - if ( ! $clear ) { |
|
| 1073 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
| 1074 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
| 1075 | + if ( ! $clear) { |
|
| 1076 | 1076 | //get existing log file and append new log info |
| 1077 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
| 1077 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
| 1078 | 1078 | } |
| 1079 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
| 1080 | - } catch( EE_Error $e ){ |
|
| 1081 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
| 1079 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
| 1080 | + } catch (EE_Error $e) { |
|
| 1081 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
| 1082 | 1082 | return; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
@@ -1102,9 +1102,9 @@ discard block |
||
| 1102 | 1102 | * @param int $error_type |
| 1103 | 1103 | * @return void |
| 1104 | 1104 | */ |
| 1105 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
| 1106 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
| 1107 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
| 1105 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
| 1106 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 1107 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | } |
| 1110 | 1110 | |
@@ -1136,13 +1136,13 @@ discard block |
||
| 1136 | 1136 | */ |
| 1137 | 1137 | function espresso_error_enqueue_scripts() { |
| 1138 | 1138 | // js for error handling |
| 1139 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
| 1140 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
| 1139 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
| 1140 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
| 1141 | 1141 | } |
| 1142 | -if ( is_admin() ) { |
|
| 1143 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
| 1142 | +if (is_admin()) { |
|
| 1143 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
| 1144 | 1144 | } else { |
| 1145 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
| 1145 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | |
@@ -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 | /** |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * @return \EEH_Autoloader |
| 51 | 51 | */ |
| 52 | 52 | private function __construct() { |
| 53 | - if ( self::$_autoloaders === null ) { |
|
| 53 | + if (self::$_autoloaders === null) { |
|
| 54 | 54 | self::$_autoloaders = array(); |
| 55 | 55 | $this->_register_custom_autoloaders(); |
| 56 | - spl_autoload_register( array( $this, 'espresso_autoloader' ) ); |
|
| 56 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public static function instance() { |
| 67 | 67 | // check if class object is instantiated |
| 68 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
| 68 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
| 69 | 69 | self::$_instance = new self(); |
| 70 | 70 | } |
| 71 | 71 | return self::$_instance; |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | * @internal param string $class_name - simple class name ie: session |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | - public static function espresso_autoloader( $class_name ) { |
|
| 86 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
| 87 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
| 85 | + public static function espresso_autoloader($class_name) { |
|
| 86 | + if (isset(self::$_autoloaders[$class_name])) { |
|
| 87 | + require_once(self::$_autoloaders[$class_name]); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
@@ -99,26 +99,26 @@ discard block |
||
| 99 | 99 | * @return void |
| 100 | 100 | * @throws \EE_Error |
| 101 | 101 | */ |
| 102 | - public static function register_autoloader( $class_paths, $read_check = true ) { |
|
| 103 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
| 104 | - foreach ( $class_paths as $class => $path ) { |
|
| 102 | + public static function register_autoloader($class_paths, $read_check = true) { |
|
| 103 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
| 104 | + foreach ($class_paths as $class => $path) { |
|
| 105 | 105 | // don't give up! you gotta... |
| 106 | 106 | // get some class |
| 107 | - if ( empty( $class )) { |
|
| 108 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
| 107 | + if (empty($class)) { |
|
| 108 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
| 109 | 109 | } |
| 110 | 110 | // one day you will find the path young grasshopper |
| 111 | - if ( empty( $path )) { |
|
| 112 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
| 111 | + if (empty($path)) { |
|
| 112 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
| 113 | 113 | } |
| 114 | 114 | // is file readable ? |
| 115 | - if ( $read_check && ! is_readable( $path )) { |
|
| 116 | - throw new EE_Error ( sprintf( __( 'The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s','event_espresso' ), $class, $path )); |
|
| 115 | + if ($read_check && ! is_readable($path)) { |
|
| 116 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
| 117 | 117 | } |
| 118 | - if ( ! isset( self::$_autoloaders[ $class ] )) { |
|
| 119 | - self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path ); |
|
| 120 | - if ( EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' ) ) { |
|
| 121 | - EEH_Debug_Tools::printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ ); |
|
| 118 | + if ( ! isset(self::$_autoloaders[$class])) { |
|
| 119 | + self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path); |
|
| 120 | + if (EE_DEBUG && (EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all')) { |
|
| 121 | + EEH_Debug_Tools::printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | private function _register_custom_autoloaders() { |
| 150 | 150 | EEH_Autoloader::$debug = ''; |
| 151 | 151 | \EEH_Autoloader::register_helpers_autoloaders(); |
| 152 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' ); |
|
| 153 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
| 154 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true ); |
|
| 155 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true ); |
|
| 156 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
| 157 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
| 158 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' ) { |
|
| 152 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
| 153 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
| 154 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
| 155 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
| 156 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
| 157 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
| 158 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 159 | 159 | EEH_Debug_Tools::instance()->show_times(); |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @access public |
| 169 | 169 | */ |
| 170 | 170 | public static function register_helpers_autoloaders() { |
| 171 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
| 171 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @return void |
| 195 | 195 | */ |
| 196 | 196 | public static function register_line_item_display_autoloaders() { |
| 197 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , true ); |
|
| 197 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @return void |
| 208 | 208 | */ |
| 209 | 209 | public static function register_line_item_filter_autoloaders() { |
| 210 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_filters' , true ); |
|
| 210 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return void |
| 221 | 221 | */ |
| 222 | 222 | public static function register_template_part_autoloaders() { |
| 223 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'template_parts', true ); |
|
| 223 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -237,35 +237,35 @@ discard block |
||
| 237 | 237 | * @return void |
| 238 | 238 | * @throws \EE_Error |
| 239 | 239 | */ |
| 240 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false){ |
|
| 241 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' ) { |
|
| 242 | - EEH_Debug_Tools::instance()->start_timer( basename( $folder ) ); |
|
| 240 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false) { |
|
| 241 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 242 | + EEH_Debug_Tools::instance()->start_timer(basename($folder)); |
|
| 243 | 243 | } |
| 244 | 244 | // make sure last char is a / |
| 245 | - $folder .= $folder[strlen($folder)-1] !== DS ? DS : ''; |
|
| 245 | + $folder .= $folder[strlen($folder) - 1] !== DS ? DS : ''; |
|
| 246 | 246 | $class_to_filepath_map = array(); |
| 247 | - $exclude = array( 'index' ); |
|
| 247 | + $exclude = array('index'); |
|
| 248 | 248 | //get all the files in that folder that end in php |
| 249 | - $filepaths = glob( $folder.'*'); |
|
| 249 | + $filepaths = glob($folder.'*'); |
|
| 250 | 250 | |
| 251 | - if ( empty( $filepaths ) ) { |
|
| 251 | + if (empty($filepaths)) { |
|
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - foreach( $filepaths as $filepath ) { |
|
| 256 | - if ( substr( $filepath, -4, 4 ) === '.php' ) { |
|
| 257 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
| 258 | - if ( ! in_array( $class_name, $exclude )) { |
|
| 259 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
| 255 | + foreach ($filepaths as $filepath) { |
|
| 256 | + if (substr($filepath, -4, 4) === '.php') { |
|
| 257 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
| 258 | + if ( ! in_array($class_name, $exclude)) { |
|
| 259 | + $class_to_filepath_map [$class_name] = $filepath; |
|
| 260 | 260 | } |
| 261 | - } else if ( $recursive ) { |
|
| 262 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive ); |
|
| 261 | + } else if ($recursive) { |
|
| 262 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
| 266 | - self::register_autoloader( $class_to_filepath_map, false ); |
|
| 267 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' ) { |
|
| 268 | - EEH_Debug_Tools::instance()->stop_timer( basename( $folder ) ); |
|
| 266 | + self::register_autoloader($class_to_filepath_map, false); |
|
| 267 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 268 | + EEH_Debug_Tools::instance()->stop_timer(basename($folder)); |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
@@ -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 | |
@@ -182,26 +182,26 @@ discard block |
||
| 182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
| 183 | 183 | * @return mixed |
| 184 | 184 | */ |
| 185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
| 185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
| 186 | 186 | // first use WP locate_template to check for template in the current theme folder |
| 187 | - $template_path = locate_template( $templates ); |
|
| 187 | + $template_path = locate_template($templates); |
|
| 188 | 188 | |
| 189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
| 189 | + if ($check_if_custom && ! empty($template_path)) |
|
| 190 | 190 | return TRUE; |
| 191 | 191 | |
| 192 | 192 | // not in the theme |
| 193 | - if ( empty( $template_path )) { |
|
| 193 | + if (empty($template_path)) { |
|
| 194 | 194 | // not even a template to look for ? |
| 195 | - if ( empty( $templates )) { |
|
| 195 | + if (empty($templates)) { |
|
| 196 | 196 | // get post_type |
| 197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
| 197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
| 198 | 198 | // get array of EE Custom Post Types |
| 199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
| 200 | 200 | // build template name based on request |
| 201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
| 202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
| 201 | + if (isset($EE_CPTs[$post_type])) { |
|
| 202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | // currently active EE template theme |
@@ -210,79 +210,79 @@ discard block |
||
| 210 | 210 | // array of paths to folders that may contain templates |
| 211 | 211 | $template_folder_paths = array( |
| 212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
| 213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
| 213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
| 214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
| 215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
| 219 | - if ( ! $check_if_custom ) { |
|
| 219 | + if ( ! $check_if_custom) { |
|
| 220 | 220 | $core_paths = array( |
| 221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
| 222 | - EE_PUBLIC . $current_theme, |
|
| 222 | + EE_PUBLIC.$current_theme, |
|
| 223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
| 224 | - EE_TEMPLATES . $current_theme, |
|
| 224 | + EE_TEMPLATES.$current_theme, |
|
| 225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
| 226 | 226 | EE_PLUGIN_DIR_PATH |
| 227 | 227 | ); |
| 228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
| 228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // now filter that array |
| 232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
| 233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
| 234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
| 232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
| 233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
| 234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
| 235 | 235 | // array to hold all possible template paths |
| 236 | 236 | $full_template_paths = array(); |
| 237 | 237 | |
| 238 | 238 | // loop through $templates |
| 239 | - foreach ( $templates as $template ) { |
|
| 239 | + foreach ($templates as $template) { |
|
| 240 | 240 | // normalize directory separators |
| 241 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
| 242 | - $file_name = basename( $template ); |
|
| 243 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
| 241 | + $template = EEH_File::standardise_directory_separators($template); |
|
| 242 | + $file_name = basename($template); |
|
| 243 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
| 244 | 244 | // while looping through all template folder paths |
| 245 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
| 245 | + foreach ($template_folder_paths as $template_folder_path) { |
|
| 246 | 246 | // normalize directory separators |
| 247 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
| 247 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
| 248 | 248 | // determine if any common base path exists between the two paths |
| 249 | 249 | $common_base_path = EEH_Template::_find_common_base_path( |
| 250 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
| 250 | + array($template_folder_path, $template_path_minus_file_name) |
|
| 251 | 251 | ); |
| 252 | - if ( $common_base_path !== '' ) { |
|
| 252 | + if ($common_base_path !== '') { |
|
| 253 | 253 | // both paths have a common base, so just tack the filename onto our search path |
| 254 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
| 254 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
| 255 | 255 | } else { |
| 256 | 256 | // no common base path, so let's just concatenate |
| 257 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
| 257 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
| 258 | 258 | } |
| 259 | 259 | // build up our template locations array by adding our resolved paths |
| 260 | 260 | $full_template_paths[] = $resolved_path; |
| 261 | 261 | } |
| 262 | 262 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
| 263 | - array_unshift( $full_template_paths, $template ); |
|
| 263 | + array_unshift($full_template_paths, $template); |
|
| 264 | 264 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
| 265 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
| 265 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
| 266 | 266 | } |
| 267 | 267 | // filter final array of full template paths |
| 268 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
| 268 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
| 269 | 269 | // now loop through our final array of template location paths and check each location |
| 270 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
| 271 | - if ( is_readable( $full_template_path )) { |
|
| 272 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
| 270 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
| 271 | + if (is_readable($full_template_path)) { |
|
| 272 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
| 273 | 273 | break; |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | // if we got it and you want to see it... |
| 278 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
| 279 | - if ( $return_string ) { |
|
| 280 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 278 | + if ($template_path && $load && ! $check_if_custom) { |
|
| 279 | + if ($return_string) { |
|
| 280 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 281 | 281 | } else { |
| 282 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
| 282 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
| 285 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | |
@@ -295,21 +295,21 @@ discard block |
||
| 295 | 295 | * @param array $paths |
| 296 | 296 | * @return string |
| 297 | 297 | */ |
| 298 | - protected static function _find_common_base_path( $paths ) { |
|
| 298 | + protected static function _find_common_base_path($paths) { |
|
| 299 | 299 | $last_offset = 0; |
| 300 | 300 | $common_base_path = ''; |
| 301 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
| 301 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
| 302 | 302 | $dir_length = $index - $last_offset + 1; |
| 303 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
| 304 | - foreach ( $paths as $path ) { |
|
| 305 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
| 303 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
| 304 | + foreach ($paths as $path) { |
|
| 305 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
| 306 | 306 | return $common_base_path; |
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | $common_base_path .= $directory; |
| 310 | 310 | $last_offset = $index + 1; |
| 311 | 311 | } |
| 312 | - return substr( $common_base_path, 0, -1 ); |
|
| 312 | + return substr($common_base_path, 0, -1); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 322 | 322 | * @return mixed string |
| 323 | 323 | */ |
| 324 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
| 324 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -332,26 +332,26 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @since 4.6.0 |
| 334 | 334 | */ |
| 335 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
| 336 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
| 335 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
| 336 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
| 337 | 337 | |
| 338 | 338 | // you gimme nuttin - YOU GET NUTTIN !! |
| 339 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
| 339 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
| 340 | 340 | return ''; |
| 341 | 341 | } |
| 342 | 342 | // if $template_args are not in an array, then make it so |
| 343 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
| 344 | - $template_args = array( $template_args ); |
|
| 343 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
| 344 | + $template_args = array($template_args); |
|
| 345 | 345 | } |
| 346 | - extract( (array) $template_args); |
|
| 346 | + extract((array) $template_args); |
|
| 347 | 347 | |
| 348 | - if ( $return_string ) { |
|
| 348 | + if ($return_string) { |
|
| 349 | 349 | // because we want to return a string, we are going to capture the output |
| 350 | 350 | ob_start(); |
| 351 | - include( $template_path ); |
|
| 351 | + include($template_path); |
|
| 352 | 352 | return ob_get_clean(); |
| 353 | 353 | } else { |
| 354 | - include( $template_path ); |
|
| 354 | + include($template_path); |
|
| 355 | 355 | } |
| 356 | 356 | return ''; |
| 357 | 357 | } |
@@ -369,27 +369,27 @@ discard block |
||
| 369 | 369 | * @param string $suffix added to the end of the generated class |
| 370 | 370 | * @return string |
| 371 | 371 | */ |
| 372 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 372 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 373 | 373 | // in the beginning... |
| 374 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
| 374 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
| 375 | 375 | // da muddle |
| 376 | 376 | $class = ''; |
| 377 | 377 | // the end |
| 378 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
| 378 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
| 379 | 379 | // is the passed object an EE object ? |
| 380 | - if ( $object instanceof EE_Base_Class ) { |
|
| 380 | + if ($object instanceof EE_Base_Class) { |
|
| 381 | 381 | // grab the exact type of object |
| 382 | - $obj_class = get_class( $object ); |
|
| 382 | + $obj_class = get_class($object); |
|
| 383 | 383 | // depending on the type of object... |
| 384 | - switch ( $obj_class ) { |
|
| 384 | + switch ($obj_class) { |
|
| 385 | 385 | // no specifics just yet... |
| 386 | 386 | default : |
| 387 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
| 388 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
| 387 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
| 388 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
| 389 | 389 | |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | - return $prefix . $class . $suffix; |
|
| 392 | + return $prefix.$class.$suffix; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -405,50 +405,50 @@ discard block |
||
| 405 | 405 | * @param string $cur_code_span_class |
| 406 | 406 | * @return string the html output for the formatted money value |
| 407 | 407 | */ |
| 408 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
| 408 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
| 409 | 409 | // ensure amount was received |
| 410 | - if ( is_null( $amount ) ) { |
|
| 411 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
| 412 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 410 | + if (is_null($amount)) { |
|
| 411 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
| 412 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 413 | 413 | return ''; |
| 414 | 414 | } |
| 415 | 415 | //ensure amount is float |
| 416 | 416 | $amount = (float) $amount; |
| 417 | 417 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
| 418 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
| 418 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
| 419 | 419 | // still a number or was amount converted to a string like "free" ? |
| 420 | - if ( is_float( $amount_formatted )) { |
|
| 420 | + if (is_float($amount_formatted)) { |
|
| 421 | 421 | // was a country ISO code passed ? if so generate currency config object for that country |
| 422 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
| 422 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
| 423 | 423 | // verify results |
| 424 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
| 424 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
| 425 | 425 | // set default config country currency settings |
| 426 | 426 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
| 427 | 427 | } |
| 428 | 428 | // format float |
| 429 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
| 429 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
| 430 | 430 | // add formatting ? |
| 431 | - if ( ! $return_raw ) { |
|
| 431 | + if ( ! $return_raw) { |
|
| 432 | 432 | // add currency sign |
| 433 | - if( $mny->sign_b4 ){ |
|
| 434 | - if( $amount >= 0 ){ |
|
| 435 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
| 436 | - }else{ |
|
| 437 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
| 433 | + if ($mny->sign_b4) { |
|
| 434 | + if ($amount >= 0) { |
|
| 435 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
| 436 | + } else { |
|
| 437 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - }else{ |
|
| 441 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
| 440 | + } else { |
|
| 441 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // add currency code ? |
| 445 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
| 445 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
| 446 | 446 | } |
| 447 | 447 | // filter results |
| 448 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
| 448 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
| 449 | 449 | } |
| 450 | 450 | // clean up vars |
| 451 | - unset( $mny ); |
|
| 451 | + unset($mny); |
|
| 452 | 452 | // return formatted currency amount |
| 453 | 453 | return $amount_formatted; |
| 454 | 454 | } |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
| 464 | 464 | * @return string The localized label for the status id. |
| 465 | 465 | */ |
| 466 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
| 466 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
| 467 | 467 | /** @type EEM_Status $EEM_Status */ |
| 468 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
| 469 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
| 470 | - return $status[ $status_id ]; |
|
| 468 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
| 469 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
| 470 | + return $status[$status_id]; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | |
@@ -480,9 +480,9 @@ discard block |
||
| 480 | 480 | * @param string $icon |
| 481 | 481 | * @return string the html output for the button |
| 482 | 482 | */ |
| 483 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
| 484 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
| 485 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
| 483 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
| 484 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
| 485 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
| 486 | 486 | return $button; |
| 487 | 487 | } |
| 488 | 488 | |
@@ -499,21 +499,21 @@ discard block |
||
| 499 | 499 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
| 500 | 500 | * @return string generated link |
| 501 | 501 | */ |
| 502 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 502 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
| 503 | 503 | |
| 504 | - if ( ! $page ) |
|
| 505 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 504 | + if ( ! $page) |
|
| 505 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
| 506 | 506 | |
| 507 | - if ( ! $action ) |
|
| 508 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 507 | + if ( ! $action) |
|
| 508 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
| 509 | 509 | |
| 510 | 510 | $action = empty($action) ? 'default' : $action; |
| 511 | 511 | |
| 512 | 512 | |
| 513 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
| 514 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 515 | - $help_text = !$help_text ? '' : $help_text; |
|
| 516 | - 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>'; |
|
| 513 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
| 514 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 515 | + $help_text = ! $help_text ? '' : $help_text; |
|
| 516 | + 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>'; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | |
@@ -525,31 +525,31 @@ discard block |
||
| 525 | 525 | * @param EE_Help_Tour |
| 526 | 526 | * @return string html |
| 527 | 527 | */ |
| 528 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
| 528 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
| 529 | 529 | $id = $tour->get_slug(); |
| 530 | 530 | $stops = $tour->get_stops(); |
| 531 | 531 | |
| 532 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
| 532 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
| 533 | 533 | |
| 534 | - foreach ( $stops as $stop ) { |
|
| 535 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
| 536 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
| 534 | + foreach ($stops as $stop) { |
|
| 535 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
| 536 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
| 537 | 537 | |
| 538 | 538 | //if container is set to modal then let's make sure we set the options accordingly |
| 539 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
| 539 | + if (empty($data_id) && empty($data_class)) { |
|
| 540 | 540 | $stop['options']['modal'] = true; |
| 541 | 541 | $stop['options']['expose'] = true; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
| 545 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
| 544 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
| 545 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
| 546 | 546 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
| 547 | 547 | |
| 548 | 548 | //options |
| 549 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
| 549 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
| 550 | 550 | $options = ' data-options="'; |
| 551 | - foreach ( $stop['options'] as $option => $value ) { |
|
| 552 | - $options .= $option . ':' . $value . ';'; |
|
| 551 | + foreach ($stop['options'] as $option => $value) { |
|
| 552 | + $options .= $option.':'.$value.';'; |
|
| 553 | 553 | } |
| 554 | 554 | $options .= '"'; |
| 555 | 555 | } else { |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | //let's put all together |
| 560 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
| 560 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | $content .= '</ol>'; |
@@ -578,31 +578,31 @@ discard block |
||
| 578 | 578 | * @throws EE_Error |
| 579 | 579 | * @return string html structure for status. |
| 580 | 580 | */ |
| 581 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
| 582 | - if ( !is_array( $status_array ) ) |
|
| 583 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 581 | + public static function status_legend($status_array, $active_status = '') { |
|
| 582 | + if ( ! is_array($status_array)) |
|
| 583 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
| 584 | 584 | |
| 585 | 585 | $setup_array = array(); |
| 586 | - foreach ( $status_array as $item => $status ) { |
|
| 586 | + foreach ($status_array as $item => $status) { |
|
| 587 | 587 | $setup_array[$item] = array( |
| 588 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
| 589 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
| 588 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
| 589 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
| 590 | 590 | 'status' => $status |
| 591 | 591 | ); |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
| 595 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
| 596 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
| 597 | - foreach ( $setup_array as $item => $details ) { |
|
| 594 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
| 595 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
| 596 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
| 597 | + foreach ($setup_array as $item => $details) { |
|
| 598 | 598 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
| 599 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
| 600 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
| 601 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
| 602 | - $content .= '</dt>' . "\n"; |
|
| 599 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
| 600 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
| 601 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
| 602 | + $content .= '</dt>'."\n"; |
|
| 603 | 603 | } |
| 604 | - $content .= '</dl>' . "\n"; |
|
| 605 | - $content .= '</div>' . "\n"; |
|
| 604 | + $content .= '</dl>'."\n"; |
|
| 605 | + $content .= '</div>'."\n"; |
|
| 606 | 606 | return $content; |
| 607 | 607 | } |
| 608 | 608 | |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | * @return string |
| 616 | 616 | */ |
| 617 | 617 | public static function layout_array_as_table($data) { |
| 618 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
| 619 | - $data = (array)$data; |
|
| 618 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 619 | + $data = (array) $data; |
|
| 620 | 620 | } |
| 621 | 621 | ob_start(); |
| 622 | 622 | if (is_array($data)) { |
@@ -629,10 +629,10 @@ discard block |
||
| 629 | 629 | ?> |
| 630 | 630 | <tr> |
| 631 | 631 | <td> |
| 632 | - <?php echo $data_key;?> |
|
| 632 | + <?php echo $data_key; ?> |
|
| 633 | 633 | </td> |
| 634 | 634 | <td> |
| 635 | - <?php echo self::layout_array_as_table($data_values);?> |
|
| 635 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
| 636 | 636 | </td> |
| 637 | 637 | </tr> |
| 638 | 638 | <?php |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | <ul> |
| 647 | 647 | <?php |
| 648 | 648 | foreach ($data as $datum) { |
| 649 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
| 649 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
| 650 | 650 | }?> |
| 651 | 651 | </ul> |
| 652 | 652 | <?php |
@@ -676,8 +676,8 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return string |
| 678 | 678 | */ |
| 679 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 680 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
| 679 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 680 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | |
@@ -701,13 +701,13 @@ discard block |
||
| 701 | 701 | * ) |
| 702 | 702 | * @return string |
| 703 | 703 | */ |
| 704 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 704 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 705 | 705 | $page_links = array(); |
| 706 | 706 | $disable_first = $disable_last = ''; |
| 707 | 707 | $total_items = (int) $total_items; |
| 708 | 708 | $per_page = (int) $per_page; |
| 709 | 709 | $current = (int) $current; |
| 710 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
| 710 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
| 711 | 711 | |
| 712 | 712 | //filter items_label |
| 713 | 713 | $items_label = apply_filters( |
@@ -715,68 +715,68 @@ discard block |
||
| 715 | 715 | $items_label |
| 716 | 716 | ); |
| 717 | 717 | |
| 718 | - if ( empty( $items_label ) |
|
| 719 | - || ! is_array( $items_label ) |
|
| 720 | - || ! isset( $items_label['single'] ) |
|
| 721 | - || ! isset( $items_label['plural'] ) ) { |
|
| 718 | + if (empty($items_label) |
|
| 719 | + || ! is_array($items_label) |
|
| 720 | + || ! isset($items_label['single']) |
|
| 721 | + || ! isset($items_label['plural'])) { |
|
| 722 | 722 | $items_label = array( |
| 723 | - 'single' => __( '1 item', 'event_espresso' ), |
|
| 724 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
| 723 | + 'single' => __('1 item', 'event_espresso'), |
|
| 724 | + 'plural' => __('%s items', 'event_espresso') |
|
| 725 | 725 | ); |
| 726 | 726 | } else { |
| 727 | 727 | $items_label = array( |
| 728 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
| 729 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
| 728 | + 'single' => '1 '.esc_html($items_label['single']), |
|
| 729 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
| 730 | 730 | ); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 733 | + $total_pages = ceil($total_items / $per_page); |
|
| 734 | 734 | |
| 735 | - if ( $total_pages <= 1 ) |
|
| 735 | + if ($total_pages <= 1) |
|
| 736 | 736 | return ''; |
| 737 | 737 | |
| 738 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
| 738 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
| 739 | 739 | |
| 740 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
| 740 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
| 741 | 741 | |
| 742 | - if ( $current === 1 ) { |
|
| 742 | + if ($current === 1) { |
|
| 743 | 743 | $disable_first = ' disabled'; |
| 744 | 744 | } |
| 745 | - if ( $current == $total_pages ) { |
|
| 745 | + if ($current == $total_pages) { |
|
| 746 | 746 | $disable_last = ' disabled'; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 750 | - 'first-page' . $disable_first, |
|
| 751 | - esc_attr__( 'Go to the first page' ), |
|
| 752 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
| 749 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 750 | + 'first-page'.$disable_first, |
|
| 751 | + esc_attr__('Go to the first page'), |
|
| 752 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
| 753 | 753 | '«' |
| 754 | 754 | ); |
| 755 | 755 | |
| 756 | 756 | $page_links[] = sprintf( |
| 757 | 757 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 758 | - 'prev-page' . $disable_first, |
|
| 759 | - esc_attr__( 'Go to the previous page' ), |
|
| 760 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
| 758 | + 'prev-page'.$disable_first, |
|
| 759 | + esc_attr__('Go to the previous page'), |
|
| 760 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
| 761 | 761 | '‹' |
| 762 | 762 | ); |
| 763 | 763 | |
| 764 | - if ( ! $show_num_field ) { |
|
| 764 | + if ( ! $show_num_field) { |
|
| 765 | 765 | $html_current_page = $current; |
| 766 | 766 | } else { |
| 767 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 768 | - esc_attr__( 'Current page' ), |
|
| 767 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 768 | + esc_attr__('Current page'), |
|
| 769 | 769 | $current, |
| 770 | - strlen( $total_pages ) |
|
| 770 | + strlen($total_pages) |
|
| 771 | 771 | ); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | $html_total_pages = sprintf( |
| 775 | 775 | '<span class="total-pages">%s</span>', |
| 776 | - number_format_i18n( $total_pages ) |
|
| 776 | + number_format_i18n($total_pages) |
|
| 777 | 777 | ); |
| 778 | 778 | $page_links[] = sprintf( |
| 779 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
| 779 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
| 780 | 780 | $html_current_page, |
| 781 | 781 | $html_total_pages, |
| 782 | 782 | '<span class="paging-input">', |
@@ -785,29 +785,29 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | $page_links[] = sprintf( |
| 787 | 787 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 788 | - 'next-page' . $disable_last, |
|
| 789 | - esc_attr__( 'Go to the next page' ), |
|
| 790 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
| 788 | + 'next-page'.$disable_last, |
|
| 789 | + esc_attr__('Go to the next page'), |
|
| 790 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
| 791 | 791 | '›' |
| 792 | 792 | ); |
| 793 | 793 | |
| 794 | 794 | $page_links[] = sprintf( |
| 795 | 795 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 796 | - 'last-page' . $disable_last, |
|
| 797 | - esc_attr__( 'Go to the last page' ), |
|
| 798 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
| 796 | + 'last-page'.$disable_last, |
|
| 797 | + esc_attr__('Go to the last page'), |
|
| 798 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
| 799 | 799 | '»' |
| 800 | 800 | ); |
| 801 | 801 | |
| 802 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
| 802 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
| 803 | 803 | // set page class |
| 804 | - if ( $total_pages ) { |
|
| 804 | + if ($total_pages) { |
|
| 805 | 805 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 806 | 806 | } else { |
| 807 | 807 | $page_class = ' no-pages'; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
| 810 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
| 824 | 824 | |
| 825 | 825 | |
| 826 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
| 826 | +if ( ! function_exists('espresso_pagination')) { |
|
| 827 | 827 | /** |
| 828 | 828 | * espresso_pagination |
| 829 | 829 | * |
@@ -835,21 +835,21 @@ discard block |
||
| 835 | 835 | $big = 999999999; // need an unlikely integer |
| 836 | 836 | $pagination = paginate_links( |
| 837 | 837 | array( |
| 838 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 838 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 839 | 839 | 'format' => '?paged=%#%', |
| 840 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 840 | + 'current' => max(1, get_query_var('paged')), |
|
| 841 | 841 | 'total' => $wp_query->max_num_pages, |
| 842 | 842 | 'show_all' => true, |
| 843 | 843 | 'end_size' => 10, |
| 844 | 844 | 'mid_size' => 6, |
| 845 | 845 | 'prev_next' => true, |
| 846 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
| 847 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
| 846 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
| 847 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
| 848 | 848 | 'type' => 'plain', |
| 849 | 849 | 'add_args' => false, |
| 850 | 850 | 'add_fragment' => '' |
| 851 | 851 | ) |
| 852 | 852 | ); |
| 853 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
| 853 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -35,24 +35,24 @@ discard block |
||
| 35 | 35 | $add_wrapper = true |
| 36 | 36 | ) { |
| 37 | 37 | // check that incoming object implements the EEI_Address interface |
| 38 | - if ( ! $obj_with_address instanceof EEI_Address ) { |
|
| 39 | - $msg = __( 'The address could not be formatted.', 'event_espresso' ); |
|
| 38 | + if ( ! $obj_with_address instanceof EEI_Address) { |
|
| 39 | + $msg = __('The address could not be formatted.', 'event_espresso'); |
|
| 40 | 40 | $dev_msg = __( |
| 41 | 41 | 'The Address Formatter requires passed objects to implement the EEI_Address interface.', |
| 42 | 42 | 'event_espresso' |
| 43 | 43 | ); |
| 44 | - EE_Error::add_error( $msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 44 | + EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 45 | 45 | return null; |
| 46 | 46 | } |
| 47 | 47 | // obtain an address formatter |
| 48 | - $formatter = EEH_Address::_get_formatter( $type ); |
|
| 48 | + $formatter = EEH_Address::_get_formatter($type); |
|
| 49 | 49 | // apply schema.org formatting ? |
| 50 | 50 | $use_schema = ! is_admin() ? $use_schema : false; |
| 51 | 51 | $formatted_address = $use_schema |
| 52 | - ? EEH_Address::_schema_formatting( $formatter, $obj_with_address ) |
|
| 53 | - : EEH_Address::_regular_formatting( $formatter, $obj_with_address, $add_wrapper ); |
|
| 52 | + ? EEH_Address::_schema_formatting($formatter, $obj_with_address) |
|
| 53 | + : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); |
|
| 54 | 54 | $formatted_address = $add_wrapper && ! $use_schema |
| 55 | - ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' |
|
| 55 | + ? '<div class="espresso-address-dv">'.$formatted_address.'</div>' |
|
| 56 | 56 | : $formatted_address; |
| 57 | 57 | // return the formatted address |
| 58 | 58 | return $formatted_address; |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
| 68 | 68 | * @return EEI_Address_Formatter |
| 69 | 69 | */ |
| 70 | - private static function _get_formatter( $type ) { |
|
| 71 | - switch ( $type ) { |
|
| 70 | + private static function _get_formatter($type) { |
|
| 71 | + switch ($type) { |
|
| 72 | 72 | case 'multiline' : |
| 73 | 73 | return new EventEspresso\core\services\address\formatters\MultiLineAddressFormatter(); |
| 74 | 74 | case 'inline' : |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * @param object EEI_Address $obj_with_address |
| 122 | 122 | * @return string |
| 123 | 123 | */ |
| 124 | - private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ) { |
|
| 124 | + private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) { |
|
| 125 | 125 | $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; |
| 126 | 126 | $formatted_address .= $formatter->format( |
| 127 | - EEH_Schema::streetAddress( $obj_with_address ), |
|
| 128 | - EEH_Schema::postOfficeBoxNumber( $obj_with_address ), |
|
| 129 | - EEH_Schema::addressLocality( $obj_with_address ), |
|
| 130 | - EEH_Schema::addressRegion( $obj_with_address ), |
|
| 131 | - EEH_Schema::postalCode( $obj_with_address ), |
|
| 132 | - EEH_Schema::addressCountry( $obj_with_address ), |
|
| 127 | + EEH_Schema::streetAddress($obj_with_address), |
|
| 128 | + EEH_Schema::postOfficeBoxNumber($obj_with_address), |
|
| 129 | + EEH_Schema::addressLocality($obj_with_address), |
|
| 130 | + EEH_Schema::addressRegion($obj_with_address), |
|
| 131 | + EEH_Schema::postalCode($obj_with_address), |
|
| 132 | + EEH_Schema::addressCountry($obj_with_address), |
|
| 133 | 133 | $obj_with_address->country_ID() |
| 134 | 134 | ); |
| 135 | 135 | $formatted_address .= '</div>'; |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | * regardless of access. |
| 45 | 45 | * @return EE_Venue | null |
| 46 | 46 | */ |
| 47 | - public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true ) { |
|
| 48 | - $VNU_ID = absint( $VNU_ID ); |
|
| 47 | + public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true) { |
|
| 48 | + $VNU_ID = absint($VNU_ID); |
|
| 49 | 49 | // do we already have the Venue you are looking for? |
| 50 | - if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID ) { |
|
| 51 | - return EEH_Venue_View::_get_venue( $privacy_check ); |
|
| 50 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID) { |
|
| 51 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
| 52 | 52 | } |
| 53 | 53 | // international newspaper? |
| 54 | 54 | global $post; |
| 55 | - if ( $post instanceof WP_Post ) { |
|
| 56 | - switch ( $post->post_type ) { |
|
| 55 | + if ($post instanceof WP_Post) { |
|
| 56 | + switch ($post->post_type) { |
|
| 57 | 57 | // if this is being called from an EE_Venue post, |
| 58 | 58 | // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
| 59 | 59 | // then we can try to just grab the attached EE_Venue object |
@@ -61,31 +61,31 @@ discard block |
||
| 61 | 61 | // the post already contains the related EE_Venue object AND one of the following is TRUE: |
| 62 | 62 | // the requested Venue ID matches the post ID OR... |
| 63 | 63 | // there was no specific Venue ID requested |
| 64 | - if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) { |
|
| 64 | + if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) { |
|
| 65 | 65 | // use existing related EE_Venue object |
| 66 | - EEH_Venue_View::$_venue = $post->EE_Venue; |
|
| 67 | - } else if ( $VNU_ID ) { |
|
| 66 | + EEH_Venue_View::$_venue = $post->EE_Venue; |
|
| 67 | + } else if ($VNU_ID) { |
|
| 68 | 68 | // there WAS a specific Venue ID requested, but it's NOT the current post object |
| 69 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
| 69 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
| 70 | 70 | } else { |
| 71 | 71 | // no specific Venue ID requested, so use post ID to generate EE_Venue object |
| 72 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID ); |
|
| 72 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
| 73 | 73 | } |
| 74 | 74 | break; |
| 75 | 75 | |
| 76 | 76 | case 'espresso_events': |
| 77 | - if ( $look_in_event ) { |
|
| 77 | + if ($look_in_event) { |
|
| 78 | 78 | // grab the events related venues |
| 79 | 79 | $venues = EEH_Venue_View::get_event_venues(); |
| 80 | 80 | // make sure the result is an array |
| 81 | - $venues = is_array( $venues ) ? $venues : array(); |
|
| 81 | + $venues = is_array($venues) ? $venues : array(); |
|
| 82 | 82 | // do we have an ID for a specific venue? |
| 83 | - if ( $VNU_ID ) { |
|
| 83 | + if ($VNU_ID) { |
|
| 84 | 84 | // loop thru the related venues |
| 85 | - foreach( $venues as $venue ) { |
|
| 86 | - if ( $venue instanceof EE_Venue ) { |
|
| 85 | + foreach ($venues as $venue) { |
|
| 86 | + if ($venue instanceof EE_Venue) { |
|
| 87 | 87 | // until we find the venue we're looking for |
| 88 | - if ( $venue->ID() == $VNU_ID ) { |
|
| 88 | + if ($venue->ID() == $VNU_ID) { |
|
| 89 | 89 | EEH_Venue_View::$_venue = $venue; |
| 90 | 90 | break; |
| 91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // then the global post is an events post and this function was called with no argument |
| 98 | 98 | } else { |
| 99 | 99 | // just grab the first related event venue |
| 100 | - EEH_Venue_View::$_venue = reset( $venues ); |
|
| 100 | + EEH_Venue_View::$_venue = reset($venues); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | break; |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
| 108 | - if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) { |
|
| 108 | + if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
| 109 | 109 | // sigh... pull it from the db |
| 110 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
| 110 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
| 111 | 111 | } |
| 112 | - return EEH_Venue_View::_get_venue( $privacy_check ); |
|
| 112 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * regardless of access. |
| 122 | 122 | * @return EE_Venue |
| 123 | 123 | */ |
| 124 | - protected static function _get_venue( $privacy_check = true ) { |
|
| 124 | + protected static function _get_venue($privacy_check = true) { |
|
| 125 | 125 | // check for private venues. |
| 126 | - if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) { |
|
| 126 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
| 127 | 127 | return null; |
| 128 | 128 | } |
| 129 | 129 | return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public static function get_event_venues() { |
| 141 | 141 | global $post; |
| 142 | - if ( $post->post_type == 'espresso_events' ) { |
|
| 143 | - if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) { |
|
| 142 | + if ($post->post_type == 'espresso_events') { |
|
| 143 | + if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
| 144 | 144 | return $post->EE_Event->venues(); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @return bool|null |
| 162 | 162 | */ |
| 163 | - public static function is_venue_private( $VNU_ID = false ) { |
|
| 164 | - $venue = EEH_Venue_View::get_venue( $VNU_ID, true, true ); |
|
| 165 | - if ( ! $venue instanceof EE_Venue ) { |
|
| 163 | + public static function is_venue_private($VNU_ID = false) { |
|
| 164 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true); |
|
| 165 | + if ( ! $venue instanceof EE_Venue) { |
|
| 166 | 166 | return null; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * @param int $VNU_ID |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - public static function venue_description( $VNU_ID = 0 ) { |
|
| 182 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 183 | - if ( $venue instanceof EE_Venue ) { |
|
| 181 | + public static function venue_description($VNU_ID = 0) { |
|
| 182 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 183 | + if ($venue instanceof EE_Venue) { |
|
| 184 | 184 | return$venue->description(); |
| 185 | 185 | } |
| 186 | 186 | return ''; |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | * @param int $VNU_ID |
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | - public static function venue_excerpt( $VNU_ID = 0 ) { |
|
| 199 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 200 | - if ( $venue instanceof EE_Venue ) { |
|
| 198 | + public static function venue_excerpt($VNU_ID = 0) { |
|
| 199 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 200 | + if ($venue instanceof EE_Venue) { |
|
| 201 | 201 | $excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
| 202 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '…' ); |
|
| 203 | - return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : ''; |
|
| 202 | + $venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'…'); |
|
| 203 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : ''; |
|
| 204 | 204 | } |
| 205 | 205 | return ''; |
| 206 | 206 | } |
@@ -215,22 +215,22 @@ discard block |
||
| 215 | 215 | * @param bool $hide_uncategorized |
| 216 | 216 | * @return string |
| 217 | 217 | */ |
| 218 | - public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) { |
|
| 218 | + public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) { |
|
| 219 | 219 | $category_links = array(); |
| 220 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 221 | - if ( $venue instanceof EE_Venue ) { |
|
| 220 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 221 | + if ($venue instanceof EE_Venue) { |
|
| 222 | 222 | // get category terms |
| 223 | - if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) { |
|
| 223 | + if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
| 224 | 224 | // loop thru terms and create links |
| 225 | - foreach ( $venue_categories as $term ) { |
|
| 226 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
| 227 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
| 228 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> '; |
|
| 225 | + foreach ($venue_categories as $term) { |
|
| 226 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
| 227 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
| 228 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> '; |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | - return implode( ', ', $category_links ); |
|
| 233 | + return implode(', ', $category_links); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | * @param bool $add_wrapper |
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | - public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) { |
|
| 249 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 250 | - if ( $venue instanceof EE_Venue ) { |
|
| 251 | - return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper ); |
|
| 248 | + public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) { |
|
| 249 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 250 | + if ($venue instanceof EE_Venue) { |
|
| 251 | + return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
| 252 | 252 | } |
| 253 | 253 | return ''; |
| 254 | 254 | } |
@@ -262,10 +262,10 @@ discard block |
||
| 262 | 262 | * @param int $VNU_ID |
| 263 | 263 | * @return bool|string |
| 264 | 264 | */ |
| 265 | - public static function venue_has_address( $VNU_ID = 0 ) { |
|
| 266 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 267 | - if ( $venue instanceof EE_Venue ) { |
|
| 268 | - return EEH_Address::format( $venue, 'inline', FALSE, FALSE ); |
|
| 265 | + public static function venue_has_address($VNU_ID = 0) { |
|
| 266 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 267 | + if ($venue instanceof EE_Venue) { |
|
| 268 | + return EEH_Address::format($venue, 'inline', FALSE, FALSE); |
|
| 269 | 269 | } |
| 270 | 270 | return false; |
| 271 | 271 | } |
@@ -280,30 +280,30 @@ discard block |
||
| 280 | 280 | * @param int $VNU_ID |
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | - public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) { |
|
| 284 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 285 | - if ( $venue instanceof EE_Venue ) { |
|
| 283 | + public static function venue_name($link_to = 'details', $VNU_ID = 0) { |
|
| 284 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 285 | + if ($venue instanceof EE_Venue) { |
|
| 286 | 286 | $venue_name = apply_filters( |
| 287 | 287 | 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
| 288 | 288 | EEH_Venue_View::is_venue_private() |
| 289 | - ? EEH_Venue_View::$_venue->name() . " " . __( '(Private)', 'event_espresso' ) |
|
| 289 | + ? EEH_Venue_View::$_venue->name()." ".__('(Private)', 'event_espresso') |
|
| 290 | 290 | : EEH_Venue_View::$_venue->name(), |
| 291 | 291 | EEH_Venue_View::$_venue |
| 292 | 292 | ); |
| 293 | - $venue_name = EEH_Schema::name( $venue_name ); |
|
| 293 | + $venue_name = EEH_Schema::name($venue_name); |
|
| 294 | 294 | |
| 295 | 295 | //if venue is trashed then ignore the "link to" setting because the venue is trashed. |
| 296 | - if ( $venue->get('status') == 'trash' ) { |
|
| 296 | + if ($venue->get('status') == 'trash') { |
|
| 297 | 297 | $link_to = ''; |
| 298 | 298 | } |
| 299 | - switch( $link_to ) { |
|
| 299 | + switch ($link_to) { |
|
| 300 | 300 | |
| 301 | 301 | case 'details' : |
| 302 | - return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name ); |
|
| 302 | + return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
| 303 | 303 | break; |
| 304 | 304 | |
| 305 | 305 | case 'website' : |
| 306 | - return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name ); |
|
| 306 | + return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
| 307 | 307 | break; |
| 308 | 308 | |
| 309 | 309 | default : |
@@ -323,10 +323,10 @@ discard block |
||
| 323 | 323 | * @param string $text |
| 324 | 324 | * @return string |
| 325 | 325 | */ |
| 326 | - public static function venue_details_link( $VNU_ID = 0, $text = '' ) { |
|
| 327 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 328 | - if ( $venue instanceof EE_Venue ) { |
|
| 329 | - return EEH_Schema::url( get_permalink( $venue->ID() ), $text ); |
|
| 326 | + public static function venue_details_link($VNU_ID = 0, $text = '') { |
|
| 327 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 328 | + if ($venue instanceof EE_Venue) { |
|
| 329 | + return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
| 330 | 330 | } |
| 331 | 331 | return ''; |
| 332 | 332 | } |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | * @param string $text |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | - public static function venue_website_link( $VNU_ID = 0, $text = '' ) { |
|
| 345 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 346 | - if ( $venue instanceof EE_Venue ) { |
|
| 344 | + public static function venue_website_link($VNU_ID = 0, $text = '') { |
|
| 345 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 346 | + if ($venue instanceof EE_Venue) { |
|
| 347 | 347 | $url = $venue->venue_url(); |
| 348 | - $text = ! empty( $text ) ? $text : $url; |
|
| 349 | - return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : ''; |
|
| 348 | + $text = ! empty($text) ? $text : $url; |
|
| 349 | + return ! empty($url) ? EEH_Schema::url($url, $text) : ''; |
|
| 350 | 350 | } |
| 351 | 351 | return ''; |
| 352 | 352 | } |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | * @param int $VNU_ID |
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | - public static function venue_phone( $VNU_ID = 0) { |
|
| 364 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 365 | - if ( $venue instanceof EE_Venue ) { |
|
| 366 | - return EEH_Schema::telephone( $venue->phone() ); |
|
| 363 | + public static function venue_phone($VNU_ID = 0) { |
|
| 364 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 365 | + if ($venue instanceof EE_Venue) { |
|
| 366 | + return EEH_Schema::telephone($venue->phone()); |
|
| 367 | 367 | } |
| 368 | 368 | return ''; |
| 369 | 369 | } |
@@ -379,48 +379,48 @@ discard block |
||
| 379 | 379 | * @param array $gmap map options |
| 380 | 380 | * @return string |
| 381 | 381 | */ |
| 382 | - public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) { |
|
| 382 | + public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) { |
|
| 383 | 383 | |
| 384 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 385 | - if ( $venue instanceof EE_Venue ) { |
|
| 384 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 385 | + if ($venue instanceof EE_Venue) { |
|
| 386 | 386 | // check for global espresso_events post and use it's ID if no map_ID is set |
| 387 | 387 | global $post; |
| 388 | - $map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
| 388 | + $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
| 389 | 389 | // grab map settings |
| 390 | 390 | $map_cfg = EE_Registry::instance()->CFG->map_settings; |
| 391 | 391 | // are maps enabled ? |
| 392 | - if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) { |
|
| 392 | + if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
| 393 | 393 | |
| 394 | 394 | $details_page = is_single(); |
| 395 | 395 | $options = array(); |
| 396 | - $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
| 396 | + $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
| 397 | 397 | |
| 398 | - $options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE ); |
|
| 398 | + $options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE); |
|
| 399 | 399 | |
| 400 | 400 | $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width; |
| 401 | - $options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
| 401 | + $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
| 402 | 402 | |
| 403 | 403 | $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height; |
| 404 | - $options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
| 404 | + $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
| 405 | 405 | |
| 406 | 406 | $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom; |
| 407 | - $options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
| 407 | + $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
| 408 | 408 | |
| 409 | 409 | $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav; |
| 410 | - $options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];; |
|
| 410 | + $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ; |
|
| 411 | 411 | |
| 412 | 412 | $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size; |
| 413 | - $options['ee_map_nav_size'] = isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
| 413 | + $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
| 414 | 414 | |
| 415 | 415 | $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type; |
| 416 | - $options['ee_map_type_control'] = isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
| 416 | + $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
| 417 | 417 | |
| 418 | 418 | $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align; |
| 419 | - $options['ee_map_align'] = isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
| 419 | + $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
| 420 | 420 | |
| 421 | - $options['ee_static_url'] = isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link(); |
|
| 421 | + $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
| 422 | 422 | |
| 423 | - return EEH_Maps::google_map( $options ); |
|
| 423 | + return EEH_Maps::google_map($options); |
|
| 424 | 424 | |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @param array $atts like EEH_Maps::google_map_link |
| 436 | 436 | * @return string |
| 437 | 437 | */ |
| 438 | - public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){ |
|
| 438 | + public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) { |
|
| 439 | 439 | $state = $venue->state_obj(); |
| 440 | 440 | $country = $venue->country_obj(); |
| 441 | 441 | $atts = shortcode_atts( |
@@ -466,23 +466,23 @@ discard block |
||
| 466 | 466 | * @param string $after |
| 467 | 467 | * @return string |
| 468 | 468 | */ |
| 469 | - public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) { |
|
| 470 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
| 471 | - if ( $venue instanceof EE_Venue ) { |
|
| 469 | + public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') { |
|
| 470 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
| 471 | + if ($venue instanceof EE_Venue) { |
|
| 472 | 472 | // can the user edit this post ? |
| 473 | - if ( current_user_can( 'edit_post', $venue->ID() )) { |
|
| 473 | + if (current_user_can('edit_post', $venue->ID())) { |
|
| 474 | 474 | // set link text |
| 475 | - $link = ! empty( $link ) ? $link : __('edit this venue'); |
|
| 475 | + $link = ! empty($link) ? $link : __('edit this venue'); |
|
| 476 | 476 | // generate nonce |
| 477 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
| 477 | + $nonce = wp_create_nonce('edit_nonce'); |
|
| 478 | 478 | // generate url to venue editor for this venue |
| 479 | - $url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) ); |
|
| 479 | + $url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php')); |
|
| 480 | 480 | // get edit CPT text |
| 481 | - $post_type_obj = get_post_type_object( 'espresso_venues' ); |
|
| 481 | + $post_type_obj = get_post_type_object('espresso_venues'); |
|
| 482 | 482 | // build final link html |
| 483 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
| 483 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
| 484 | 484 | // put it all together |
| 485 | - return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after; |
|
| 485 | + return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after; |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | return ''; |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | * @return string |
| 70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
| 71 | 71 | */ |
| 72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
| 72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
| 73 | 73 | |
| 74 | - if ( empty($input_vars) ) { |
|
| 75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 74 | + if (empty($input_vars)) { |
|
| 75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 76 | 76 | return FALSE; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
| 98 | 98 | 'append_content' => '' |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
| 101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
| 102 | 102 | |
| 103 | 103 | // required fields get a * |
| 104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
| 105 | 105 | // and the css class "required" |
| 106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
| 107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
| 106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
| 107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
| 108 | 108 | |
| 109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
| 110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
| 109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
| 110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
| 111 | 111 | |
| 112 | 112 | //rows or cols? |
| 113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
| 114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
| 113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
| 114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
| 115 | 115 | |
| 116 | 116 | //any content? |
| 117 | 117 | $append_content = $input_value['append_content']; |
| 118 | 118 | |
| 119 | - $output .= (!$close) ? '<ul>' : ''; |
|
| 119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
| 120 | 120 | $output .= '<li>'; |
| 121 | 121 | |
| 122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | // text inputs |
| 126 | 126 | case 'text' : |
| 127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
| 128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
| 127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
| 128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
| 129 | 129 | break; |
| 130 | 130 | |
| 131 | 131 | // dropdowns |
| 132 | 132 | case 'select' : |
| 133 | 133 | |
| 134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
| 135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
| 134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
| 135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
| 136 | 136 | |
| 137 | 137 | if (is_array($input_value['options'])) { |
| 138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | foreach ($options as $key => $value) { |
| 144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
| 144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
| 145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
| 146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
| 146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
| 147 | 147 | } |
| 148 | - $output .= "\n\t\t\t" . '</select>'; |
|
| 148 | + $output .= "\n\t\t\t".'</select>'; |
|
| 149 | 149 | |
| 150 | 150 | break; |
| 151 | 151 | |
| 152 | 152 | case 'textarea' : |
| 153 | 153 | |
| 154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
| 155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
| 154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
| 155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
| 156 | 156 | break; |
| 157 | 157 | |
| 158 | 158 | case 'hidden' : |
| 159 | 159 | $close = false; |
| 160 | 160 | $output .= "</li></ul>"; |
| 161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
| 161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
| 162 | 162 | break; |
| 163 | 163 | |
| 164 | 164 | case 'checkbox' : |
| 165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
| 166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
| 167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
| 165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
| 166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
| 167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
| 168 | 168 | break; |
| 169 | 169 | |
| 170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
| 177 | 177 | ); |
| 178 | 178 | $output .= '</li>'; |
| 179 | 179 | $output .= '</ul>'; |
| 180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
| 181 | - if ( $append_content ) { |
|
| 180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
| 181 | + if ($append_content) { |
|
| 182 | 182 | $output .= $append_content; |
| 183 | 183 | } |
| 184 | 184 | ob_start(); |
| 185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
| 185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
| 186 | 186 | $editor = ob_get_contents(); |
| 187 | 187 | ob_end_clean(); |
| 188 | 188 | $output .= $editor; |
| 189 | 189 | break; |
| 190 | 190 | |
| 191 | 191 | } |
| 192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
| 192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
| 193 | 193 | $output .= $append_content; |
| 194 | 194 | } |
| 195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $form_fields = array(); |
| 231 | 231 | $fields = (array) $fields; |
| 232 | 232 | |
| 233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
| 233 | + foreach ($fields as $field_name => $field_atts) { |
|
| 234 | 234 | //defaults: |
| 235 | 235 | $defaults = array( |
| 236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
| 248 | 248 | 'wpeditor_args' => array() |
| 249 | 249 | ); |
| 250 | 250 | // merge defaults with passed arguments |
| 251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
| 252 | - extract( $_fields ); |
|
| 251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
| 252 | + extract($_fields); |
|
| 253 | 253 | // generate label |
| 254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
| 254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
| 255 | 255 | // generate field name |
| 256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
| 256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
| 257 | 257 | |
| 258 | 258 | //tabindex |
| 259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
| 259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
| 260 | 260 | |
| 261 | 261 | //we determine what we're building based on the type |
| 262 | - switch ( $type ) { |
|
| 262 | + switch ($type) { |
|
| 263 | 263 | |
| 264 | 264 | case 'textarea' : |
| 265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
| 265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
| 266 | 266 | $fld .= $extra_desc; |
| 267 | 267 | break; |
| 268 | 268 | |
| 269 | 269 | case 'checkbox' : |
| 270 | 270 | $c_input = ''; |
| 271 | - if ( is_array($value) ) { |
|
| 272 | - foreach ( $value as $key => $val ) { |
|
| 273 | - $c_id = $field_name . '_' . $value; |
|
| 274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
| 275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
| 276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
| 277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
| 271 | + if (is_array($value)) { |
|
| 272 | + foreach ($value as $key => $val) { |
|
| 273 | + $c_id = $field_name.'_'.$value; |
|
| 274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
| 275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
| 276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
| 277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
| 278 | 278 | } |
| 279 | 279 | $fld = $c_input; |
| 280 | 280 | } else { |
| 281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
| 282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
| 281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
| 282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
| 283 | 283 | } |
| 284 | 284 | break; |
| 285 | 285 | |
| 286 | 286 | case 'radio' : |
| 287 | 287 | $c_input = ''; |
| 288 | - if ( is_array($value) ) { |
|
| 289 | - foreach ( $value as $key => $val ) { |
|
| 290 | - $c_id = $field_name . '_' . $value; |
|
| 291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
| 292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
| 293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
| 294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
| 288 | + if (is_array($value)) { |
|
| 289 | + foreach ($value as $key => $val) { |
|
| 290 | + $c_id = $field_name.'_'.$value; |
|
| 291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
| 292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
| 293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
| 294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
| 295 | 295 | } |
| 296 | 296 | $fld = $c_input; |
| 297 | 297 | } else { |
| 298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
| 299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
| 298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
| 299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
| 300 | 300 | } |
| 301 | 301 | break; |
| 302 | 302 | |
| 303 | 303 | case 'hidden' : |
| 304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
| 304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
| 305 | 305 | break; |
| 306 | 306 | |
| 307 | 307 | case 'select' : |
| 308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
| 309 | - foreach ( $value as $key => $val ) { |
|
| 310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
| 311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
| 308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
| 309 | + foreach ($value as $key => $val) { |
|
| 310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
| 311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
| 312 | 312 | } |
| 313 | 313 | $fld .= '</select>'; |
| 314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
| 320 | 320 | 'editor_class' => $class, |
| 321 | 321 | 'tabindex' => $tabindex |
| 322 | 322 | ); |
| 323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
| 323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
| 324 | 324 | ob_start(); |
| 325 | - wp_editor( $value, $id, $editor_settings ); |
|
| 325 | + wp_editor($value, $id, $editor_settings); |
|
| 326 | 326 | $editor = ob_get_contents(); |
| 327 | 327 | ob_end_clean(); |
| 328 | 328 | $fld = $editor; |
| 329 | 329 | break; |
| 330 | 330 | |
| 331 | 331 | default : //'text fields' |
| 332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
| 332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
| 333 | 333 | $fld .= $extra_desc; |
| 334 | 334 | |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
| 337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return $form_fields; |
@@ -363,19 +363,19 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
| 365 | 365 | //if $values was submitted in the wrong format, convert it over |
| 366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
| 367 | - $converted_values=array(); |
|
| 368 | - foreach($values as $id=>$text){ |
|
| 369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
| 366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
| 367 | + $converted_values = array(); |
|
| 368 | + foreach ($values as $id=>$text) { |
|
| 369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
| 370 | 370 | } |
| 371 | - $values=$converted_values; |
|
| 371 | + $values = $converted_values; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
| 374 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
| 375 | 375 | //Debug |
| 376 | 376 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 377 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
| 378 | - $field .= ' ' . $parameters; |
|
| 377 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
| 378 | + $field .= ' '.$parameters; |
|
| 379 | 379 | if ($autosize) { |
| 380 | 380 | $size = 'med'; |
| 381 | 381 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -388,21 +388,21 @@ discard block |
||
| 388 | 388 | $size = ''; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
| 391 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
| 392 | 392 | |
| 393 | 393 | if (empty($default) && isset($GLOBALS[$name])) |
| 394 | 394 | $default = stripslashes($GLOBALS[$name]); |
| 395 | 395 | |
| 396 | 396 | |
| 397 | 397 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
| 398 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
| 398 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
| 399 | 399 | if ($default == $values[$i]['id']) { |
| 400 | 400 | $field .= ' selected = "selected"'; |
| 401 | 401 | } |
| 402 | - if ( isset( $values[$i]['class'] ) ) { |
|
| 403 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
| 402 | + if (isset($values[$i]['class'])) { |
|
| 403 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
| 404 | 404 | } |
| 405 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
| 405 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
| 406 | 406 | } |
| 407 | 407 | $field .= '</select>'; |
| 408 | 408 | |
@@ -420,38 +420,38 @@ discard block |
||
| 420 | 420 | * @param string $question_groups |
| 421 | 421 | * @return string HTML |
| 422 | 422 | */ |
| 423 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
| 423 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
| 424 | 424 | |
| 425 | 425 | $html = ''; |
| 426 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
| 427 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
| 426 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
| 427 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
| 428 | 428 | |
| 429 | - if ( ! empty( $question_groups )) { |
|
| 429 | + if ( ! empty($question_groups)) { |
|
| 430 | 430 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 431 | 431 | // loop thru question groups |
| 432 | - foreach ( $question_groups as $QSG ) { |
|
| 432 | + foreach ($question_groups as $QSG) { |
|
| 433 | 433 | // check that questions exist |
| 434 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
| 434 | + if ( ! empty($QSG['QSG_questions'])) { |
|
| 435 | 435 | // use fieldsets |
| 436 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
| 436 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
| 437 | 437 | // group_name |
| 438 | - $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>' : ''; |
|
| 438 | + $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>' : ''; |
|
| 439 | 439 | // group_desc |
| 440 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
| 440 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
| 441 | 441 | |
| 442 | 442 | $html .= $before_question_group_questions; |
| 443 | 443 | // loop thru questions |
| 444 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
| 444 | + foreach ($QSG['QSG_questions'] as $question) { |
|
| 445 | 445 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 446 | 446 | $QFI = new EE_Question_Form_Input( |
| 447 | 447 | $question['qst_obj'], |
| 448 | 448 | $question['ans_obj'], |
| 449 | 449 | $question |
| 450 | 450 | ); |
| 451 | - $html .= self::generate_form_input( $QFI ); |
|
| 451 | + $html .= self::generate_form_input($QFI); |
|
| 452 | 452 | } |
| 453 | 453 | $html .= $after_question_group_questions; |
| 454 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
| 454 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
@@ -471,11 +471,11 @@ discard block |
||
| 471 | 471 | * @param string $group_wrapper |
| 472 | 472 | * @return string HTML |
| 473 | 473 | */ |
| 474 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
| 474 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
| 475 | 475 | |
| 476 | 476 | $html = ''; |
| 477 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
| 478 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
| 477 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
| 478 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
| 479 | 479 | |
| 480 | 480 | $default_q_meta = array( |
| 481 | 481 | 'att_nmbr' => 1, |
@@ -484,55 +484,55 @@ discard block |
||
| 484 | 484 | 'input_id' => '', |
| 485 | 485 | 'input_class' => '' |
| 486 | 486 | ); |
| 487 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
| 487 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
| 488 | 488 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 489 | 489 | |
| 490 | - if ( ! empty( $question_groups )) { |
|
| 490 | + if ( ! empty($question_groups)) { |
|
| 491 | 491 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 492 | 492 | // loop thru question groups |
| 493 | - foreach ( $question_groups as $QSG ) { |
|
| 494 | - if ( $QSG instanceof EE_Question_Group ) { |
|
| 493 | + foreach ($question_groups as $QSG) { |
|
| 494 | + if ($QSG instanceof EE_Question_Group) { |
|
| 495 | 495 | // check that questions exist |
| 496 | 496 | |
| 497 | - $where = array( 'QST_deleted' => 0 ); |
|
| 498 | - if ( ! $from_admin ) { |
|
| 497 | + $where = array('QST_deleted' => 0); |
|
| 498 | + if ( ! $from_admin) { |
|
| 499 | 499 | $where['QST_admin_only'] = 0; |
| 500 | 500 | } |
| 501 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
| 502 | - if ( ! empty( $questions )) { |
|
| 501 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
| 502 | + if ( ! empty($questions)) { |
|
| 503 | 503 | // use fieldsets |
| 504 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
| 504 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
| 505 | 505 | // group_name |
| 506 | - if ( $QSG->show_group_name() ) { |
|
| 507 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
| 506 | + if ($QSG->show_group_name()) { |
|
| 507 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
| 508 | 508 | } |
| 509 | 509 | // group_desc |
| 510 | - if ( $QSG->show_group_desc() ) { |
|
| 511 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
| 510 | + if ($QSG->show_group_desc()) { |
|
| 511 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | $html .= $before_question_group_questions; |
| 515 | 515 | // loop thru questions |
| 516 | - foreach ( $questions as $QST ) { |
|
| 516 | + foreach ($questions as $QST) { |
|
| 517 | 517 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
| 518 | 518 | |
| 519 | 519 | $answer = NULL; |
| 520 | 520 | |
| 521 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
| 521 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
| 522 | 522 | // check for answer in $_GET in case we are reprocessing a form after an error |
| 523 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
| 524 | - $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 ] ); |
|
| 523 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
| 524 | + $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]); |
|
| 525 | 525 | } |
| 526 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
| 526 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
| 527 | 527 | //attendee data from the session |
| 528 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
| 528 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | $QFI = new EE_Question_Form_Input( |
| 534 | 534 | $QST, |
| 535 | - EE_Answer::new_instance ( array( |
|
| 535 | + EE_Answer::new_instance(array( |
|
| 536 | 536 | 'ANS_ID'=> 0, |
| 537 | 537 | 'QST_ID'=> 0, |
| 538 | 538 | 'REG_ID'=> 0, |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | $q_meta |
| 542 | 542 | ); |
| 543 | 543 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 544 | - $html .= self::generate_form_input( $QFI ); |
|
| 544 | + $html .= self::generate_form_input($QFI); |
|
| 545 | 545 | } |
| 546 | 546 | $html .= $after_question_group_questions; |
| 547 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
| 547 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | } |
@@ -564,63 +564,63 @@ discard block |
||
| 564 | 564 | * @param EE_Question_Form_Input $QFI |
| 565 | 565 | * @return string HTML |
| 566 | 566 | */ |
| 567 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
| 568 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
| 567 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
| 568 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
| 569 | 569 | return ''; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
| 573 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
| 572 | + $QFI = self::_load_system_dropdowns($QFI); |
|
| 573 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
| 574 | 574 | |
| 575 | 575 | //we also need to verify |
| 576 | 576 | |
| 577 | 577 | $display_text = $QFI->get('QST_display_text'); |
| 578 | 578 | $input_name = $QFI->get('QST_input_name'); |
| 579 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
| 579 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
| 580 | 580 | $input_id = $QFI->get('QST_input_id'); |
| 581 | 581 | $input_class = $QFI->get('QST_input_class'); |
| 582 | 582 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
| 583 | 583 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
| 584 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
| 584 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
| 585 | 585 | $QST_required = $QFI->get('QST_required'); |
| 586 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
| 587 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
| 588 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
| 589 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
| 586 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
| 587 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
| 588 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
| 589 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
| 590 | 590 | $label_class = 'espresso-form-input-lbl'; |
| 591 | - $QST_options = $QFI->options(true,$answer); |
|
| 592 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
| 591 | + $QST_options = $QFI->options(true, $answer); |
|
| 592 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
| 593 | 593 | $system_ID = $QFI->get('QST_system'); |
| 594 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
| 595 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
| 594 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
| 595 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
| 596 | 596 | |
| 597 | 597 | |
| 598 | - switch ( $QFI->get('QST_type') ){ |
|
| 598 | + switch ($QFI->get('QST_type')) { |
|
| 599 | 599 | |
| 600 | 600 | case 'TEXTAREA' : |
| 601 | - 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 ); |
|
| 601 | + 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); |
|
| 602 | 602 | break; |
| 603 | 603 | |
| 604 | 604 | case 'DROPDOWN' : |
| 605 | - 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 ); |
|
| 605 | + 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); |
|
| 606 | 606 | break; |
| 607 | 607 | |
| 608 | 608 | |
| 609 | 609 | case 'RADIO_BTN' : |
| 610 | - 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 ); |
|
| 610 | + 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); |
|
| 611 | 611 | break; |
| 612 | 612 | |
| 613 | 613 | case 'CHECKBOX' : |
| 614 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
| 614 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
| 615 | 615 | break; |
| 616 | 616 | |
| 617 | 617 | case 'DATE' : |
| 618 | - 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 ); |
|
| 618 | + 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); |
|
| 619 | 619 | break; |
| 620 | 620 | |
| 621 | 621 | case 'TEXT' : |
| 622 | 622 | default: |
| 623 | - 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 ); |
|
| 623 | + 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); |
|
| 624 | 624 | break; |
| 625 | 625 | |
| 626 | 626 | } |
@@ -646,31 +646,31 @@ discard block |
||
| 646 | 646 | * @param string $disabled disabled="disabled" or null |
| 647 | 647 | * @return string HTML |
| 648 | 648 | */ |
| 649 | - 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 ) { |
|
| 649 | + 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) { |
|
| 650 | 650 | // need these |
| 651 | - if ( ! $question || ! $name ) { |
|
| 651 | + if ( ! $question || ! $name) { |
|
| 652 | 652 | return NULL; |
| 653 | 653 | } |
| 654 | 654 | // prep the answer |
| 655 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
| 655 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
| 656 | 656 | // prep the required array |
| 657 | - $required = self::prep_required( $required ); |
|
| 657 | + $required = self::prep_required($required); |
|
| 658 | 658 | // set disabled tag |
| 659 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 659 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 660 | 660 | // ya gots ta have style man!!! |
| 661 | 661 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
| 662 | - $class = empty( $class ) ? $txt_class : $class; |
|
| 663 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 664 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 662 | + $class = empty($class) ? $txt_class : $class; |
|
| 663 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 664 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 665 | 665 | |
| 666 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
| 666 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
| 667 | 667 | // filter label but ensure required text comes before it |
| 668 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 668 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 669 | 669 | |
| 670 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
| 670 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
| 671 | 671 | |
| 672 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 673 | - return $label_html . $input_html; |
|
| 672 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 673 | + return $label_html.$input_html; |
|
| 674 | 674 | |
| 675 | 675 | } |
| 676 | 676 | |
@@ -692,35 +692,35 @@ discard block |
||
| 692 | 692 | * @param string $disabled disabled="disabled" or null |
| 693 | 693 | * @return string HTML |
| 694 | 694 | */ |
| 695 | - 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 ) { |
|
| 695 | + 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) { |
|
| 696 | 696 | // need these |
| 697 | - if ( ! $question || ! $name ) { |
|
| 697 | + if ( ! $question || ! $name) { |
|
| 698 | 698 | return NULL; |
| 699 | 699 | } |
| 700 | 700 | // prep the answer |
| 701 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
| 701 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
| 702 | 702 | // prep the required array |
| 703 | - $required = self::prep_required( $required ); |
|
| 703 | + $required = self::prep_required($required); |
|
| 704 | 704 | // make sure $dimensions is an array |
| 705 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
| 705 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
| 706 | 706 | // and set some defaults |
| 707 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
| 707 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
| 708 | 708 | // set disabled tag |
| 709 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 709 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 710 | 710 | // ya gots ta have style man!!! |
| 711 | 711 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
| 712 | - $class = empty( $class ) ? $txt_class : $class; |
|
| 713 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 714 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 712 | + $class = empty($class) ? $txt_class : $class; |
|
| 713 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 714 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 715 | 715 | |
| 716 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
| 716 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
| 717 | 717 | // filter label but ensure required text comes before it |
| 718 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 718 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 719 | 719 | |
| 720 | - $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>'; |
|
| 720 | + $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>'; |
|
| 721 | 721 | |
| 722 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 723 | - return $label_html . $input_html; |
|
| 722 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 723 | + return $label_html.$input_html; |
|
| 724 | 724 | |
| 725 | 725 | } |
| 726 | 726 | |
@@ -743,47 +743,47 @@ discard block |
||
| 743 | 743 | * @param string $disabled disabled="disabled" or null |
| 744 | 744 | * @return string HTML |
| 745 | 745 | */ |
| 746 | - 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 ) { |
|
| 746 | + 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) { |
|
| 747 | 747 | |
| 748 | 748 | // need these |
| 749 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
| 749 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
| 750 | 750 | return NULL; |
| 751 | 751 | } |
| 752 | 752 | // prep the answer |
| 753 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
| 753 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
| 754 | 754 | // prep the required array |
| 755 | - $required = self::prep_required( $required ); |
|
| 755 | + $required = self::prep_required($required); |
|
| 756 | 756 | // set disabled tag |
| 757 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 757 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 758 | 758 | // ya gots ta have style man!!! |
| 759 | 759 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
| 760 | - $class = empty( $class ) ? $txt_class : $class; |
|
| 761 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 762 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 760 | + $class = empty($class) ? $txt_class : $class; |
|
| 761 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 762 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 763 | 763 | |
| 764 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
| 764 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
| 765 | 765 | // filter label but ensure required text comes before it |
| 766 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 766 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 767 | 767 | |
| 768 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
| 768 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
| 769 | 769 | // recursively count array elements, to determine total number of options |
| 770 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
| 771 | - if ( ! $only_option ) { |
|
| 770 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
| 771 | + if ( ! $only_option) { |
|
| 772 | 772 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
| 773 | 773 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
| 774 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
| 774 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
| 775 | 775 | } |
| 776 | - foreach ( $options as $key => $value ) { |
|
| 776 | + foreach ($options as $key => $value) { |
|
| 777 | 777 | // if value is an array, then create option groups, else create regular ol' options |
| 778 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
| 778 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
| 781 | + $input_html .= "\n\t\t\t".'</select>'; |
|
| 782 | 782 | |
| 783 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
| 783 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
| 784 | 784 | |
| 785 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 786 | - return $label_html . $input_html; |
|
| 785 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 786 | + return $label_html.$input_html; |
|
| 787 | 787 | |
| 788 | 788 | } |
| 789 | 789 | |
@@ -801,12 +801,12 @@ discard block |
||
| 801 | 801 | * @param boolean $use_html_entities |
| 802 | 802 | * @return string |
| 803 | 803 | */ |
| 804 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
| 805 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
| 806 | - foreach ( $QSOs as $QSO ) { |
|
| 807 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
| 804 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
| 805 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
| 806 | + foreach ($QSOs as $QSO) { |
|
| 807 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
| 808 | 808 | } |
| 809 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
| 809 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
| 810 | 810 | return $html; |
| 811 | 811 | } |
| 812 | 812 | |
@@ -821,12 +821,12 @@ discard block |
||
| 821 | 821 | * @param boolean $use_html_entities |
| 822 | 822 | * @return string |
| 823 | 823 | */ |
| 824 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
| 825 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
| 826 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
| 827 | - $value = ! empty( $value ) ? $value : $key; |
|
| 828 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
| 829 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
| 824 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
| 825 | + $key = self::prep_answer($key, $use_html_entities); |
|
| 826 | + $value = self::prep_answer($value, $use_html_entities); |
|
| 827 | + $value = ! empty($value) ? $value : $key; |
|
| 828 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
| 829 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | |
@@ -850,56 +850,56 @@ discard block |
||
| 850 | 850 | * @param bool $use_desc_4_label |
| 851 | 851 | * @return string HTML |
| 852 | 852 | */ |
| 853 | - 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 ) { |
|
| 853 | + 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) { |
|
| 854 | 854 | // need these |
| 855 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
| 855 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
| 856 | 856 | return NULL; |
| 857 | 857 | } |
| 858 | 858 | // prep the answer |
| 859 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
| 859 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
| 860 | 860 | // prep the required array |
| 861 | - $required = self::prep_required( $required ); |
|
| 861 | + $required = self::prep_required($required); |
|
| 862 | 862 | // set disabled tag |
| 863 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 863 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 864 | 864 | // ya gots ta have style man!!! |
| 865 | 865 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
| 866 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
| 867 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 866 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
| 867 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 868 | 868 | |
| 869 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
| 869 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
| 870 | 870 | // filter label but ensure required text comes before it |
| 871 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 871 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 872 | 872 | |
| 873 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
| 873 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
| 874 | 874 | |
| 875 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 876 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
| 875 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 876 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
| 877 | 877 | |
| 878 | - foreach ( $options as $OPT ) { |
|
| 879 | - if ( $OPT instanceof EE_Question_Option ) { |
|
| 880 | - $value = self::prep_option_value( $OPT->value() ); |
|
| 878 | + foreach ($options as $OPT) { |
|
| 879 | + if ($OPT instanceof EE_Question_Option) { |
|
| 880 | + $value = self::prep_option_value($OPT->value()); |
|
| 881 | 881 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
| 882 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
| 883 | - $desc = $OPT->desc();//no self::prep_answer |
|
| 884 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
| 885 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
| 886 | - $opt = '-' . sanitize_key( $value ); |
|
| 887 | - |
|
| 888 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
| 889 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
| 890 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
| 891 | - $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 . '/>'; |
|
| 892 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
| 893 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
| 894 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
| 895 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
| 882 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
| 883 | + $desc = $OPT->desc(); //no self::prep_answer |
|
| 884 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
| 885 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
| 886 | + $opt = '-'.sanitize_key($value); |
|
| 887 | + |
|
| 888 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
| 889 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
| 890 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
| 891 | + $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.'/>'; |
|
| 892 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
| 893 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
| 894 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
| 895 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
| 899 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
| 900 | 900 | |
| 901 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 902 | - return $label_html . $input_html; |
|
| 901 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 902 | + return $label_html.$input_html; |
|
| 903 | 903 | |
| 904 | 904 | } |
| 905 | 905 | |
@@ -922,65 +922,65 @@ discard block |
||
| 922 | 922 | * @param string $disabled disabled="disabled" or null |
| 923 | 923 | * @return string HTML |
| 924 | 924 | */ |
| 925 | - 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 ) { |
|
| 925 | + 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) { |
|
| 926 | 926 | // need these |
| 927 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
| 927 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
| 928 | 928 | return NULL; |
| 929 | 929 | } |
| 930 | - $answer = maybe_unserialize( $answer ); |
|
| 930 | + $answer = maybe_unserialize($answer); |
|
| 931 | 931 | |
| 932 | 932 | // prep the answer(s) |
| 933 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
| 933 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
| 934 | 934 | |
| 935 | - foreach ( $answer as $key => $value ) { |
|
| 936 | - $key = self::prep_option_value( $key ); |
|
| 937 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
| 935 | + foreach ($answer as $key => $value) { |
|
| 936 | + $key = self::prep_option_value($key); |
|
| 937 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | // prep the required array |
| 941 | - $required = self::prep_required( $required ); |
|
| 941 | + $required = self::prep_required($required); |
|
| 942 | 942 | // set disabled tag |
| 943 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 943 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 944 | 944 | // ya gots ta have style man!!! |
| 945 | 945 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
| 946 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
| 947 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 946 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
| 947 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 948 | 948 | |
| 949 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
| 949 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
| 950 | 950 | // filter label but ensure required text comes before it |
| 951 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 952 | - |
|
| 953 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
| 954 | - |
|
| 955 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 956 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
| 957 | - |
|
| 958 | - foreach ( $options as $OPT ) { |
|
| 959 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
| 960 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
| 961 | - $text = self::prep_answer( $OPT->value() ); |
|
| 962 | - $desc = $OPT->desc() ; |
|
| 963 | - $opt = '-' . sanitize_key( $value ); |
|
| 964 | - |
|
| 965 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
| 966 | - |
|
| 967 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
| 968 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
| 969 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
| 970 | - $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 . '/>'; |
|
| 971 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
| 972 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
| 973 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
| 974 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
| 951 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 952 | + |
|
| 953 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
| 954 | + |
|
| 955 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 956 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
| 957 | + |
|
| 958 | + foreach ($options as $OPT) { |
|
| 959 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
| 960 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
| 961 | + $text = self::prep_answer($OPT->value()); |
|
| 962 | + $desc = $OPT->desc(); |
|
| 963 | + $opt = '-'.sanitize_key($value); |
|
| 964 | + |
|
| 965 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
| 966 | + |
|
| 967 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
| 968 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
| 969 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
| 970 | + $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.'/>'; |
|
| 971 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
| 972 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
| 973 | + if ( ! empty($desc) && $desc != $text) { |
|
| 974 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
| 975 | 975 | } |
| 976 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
| 976 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
| 977 | 977 | |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
| 980 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
| 981 | 981 | |
| 982 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 983 | - return $label_html . $input_html; |
|
| 982 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 983 | + return $label_html.$input_html; |
|
| 984 | 984 | |
| 985 | 985 | } |
| 986 | 986 | |
@@ -1002,36 +1002,36 @@ discard block |
||
| 1002 | 1002 | * @param string $disabled disabled="disabled" or null |
| 1003 | 1003 | * @return string HTML |
| 1004 | 1004 | */ |
| 1005 | - 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 ) { |
|
| 1005 | + 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) { |
|
| 1006 | 1006 | // need these |
| 1007 | - if ( ! $question || ! $name ) { |
|
| 1007 | + if ( ! $question || ! $name) { |
|
| 1008 | 1008 | return NULL; |
| 1009 | 1009 | } |
| 1010 | 1010 | // prep the answer |
| 1011 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
| 1011 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
| 1012 | 1012 | // prep the required array |
| 1013 | - $required = self::prep_required( $required ); |
|
| 1013 | + $required = self::prep_required($required); |
|
| 1014 | 1014 | // set disabled tag |
| 1015 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 1015 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
| 1016 | 1016 | // ya gots ta have style man!!! |
| 1017 | 1017 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
| 1018 | - $class = empty( $class ) ? $txt_class : $class; |
|
| 1019 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
| 1020 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
| 1018 | + $class = empty($class) ? $txt_class : $class; |
|
| 1019 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
| 1020 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
| 1021 | 1021 | |
| 1022 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
| 1022 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
| 1023 | 1023 | // filter label but ensure required text comes before it |
| 1024 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
| 1024 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
| 1025 | 1025 | |
| 1026 | - $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 . '/>'; |
|
| 1026 | + $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.'/>'; |
|
| 1027 | 1027 | |
| 1028 | 1028 | // enqueue scripts |
| 1029 | - 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 ); |
|
| 1030 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
| 1031 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1029 | + 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); |
|
| 1030 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 1031 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 1032 | 1032 | |
| 1033 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
| 1034 | - return $label_html . $input_html; |
|
| 1033 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
| 1034 | + return $label_html.$input_html; |
|
| 1035 | 1035 | |
| 1036 | 1036 | } |
| 1037 | 1037 | |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | * @access public |
| 1044 | 1044 | * @return string |
| 1045 | 1045 | */ |
| 1046 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
| 1046 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
| 1047 | 1047 | return $required_text; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1057,9 +1057,9 @@ discard block |
||
| 1057 | 1057 | * @param string $value |
| 1058 | 1058 | * @return string HTML |
| 1059 | 1059 | */ |
| 1060 | - static function hidden_input( $name, $value, $id = '' ){ |
|
| 1061 | - $id = ! empty( $id ) ? $id : $name; |
|
| 1062 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
| 1060 | + static function hidden_input($name, $value, $id = '') { |
|
| 1061 | + $id = ! empty($id) ? $id : $name; |
|
| 1062 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | * @param string $question |
| 1072 | 1072 | * @return string |
| 1073 | 1073 | */ |
| 1074 | - static function prep_question( $question ){ |
|
| 1074 | + static function prep_question($question) { |
|
| 1075 | 1075 | return $question; |
| 1076 | 1076 | // $link = ''; |
| 1077 | 1077 | // // does this label have a help link attached ? |
@@ -1094,13 +1094,13 @@ discard block |
||
| 1094 | 1094 | * @param mixed $answer |
| 1095 | 1095 | * @return string |
| 1096 | 1096 | */ |
| 1097 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
| 1097 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
| 1098 | 1098 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
| 1099 | - if ( is_bool( $answer ) ) { |
|
| 1099 | + if (is_bool($answer)) { |
|
| 1100 | 1100 | $answer = $answer ? 1 : 0; |
| 1101 | 1101 | } |
| 1102 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
| 1103 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
| 1102 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
| 1103 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | |
@@ -1110,18 +1110,18 @@ discard block |
||
| 1110 | 1110 | * @param array $QSOs array of EE_Question_Option objects |
| 1111 | 1111 | * @return array |
| 1112 | 1112 | */ |
| 1113 | - public static function prep_answer_options( $QSOs = array() ){ |
|
| 1113 | + public static function prep_answer_options($QSOs = array()) { |
|
| 1114 | 1114 | $prepped_answer_options = array(); |
| 1115 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
| 1116 | - foreach( $QSOs as $key => $QSO ) { |
|
| 1117 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
| 1118 | - $QSO = EE_Question_Option::new_instance( array( |
|
| 1119 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
| 1120 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
| 1115 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
| 1116 | + foreach ($QSOs as $key => $QSO) { |
|
| 1117 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
| 1118 | + $QSO = EE_Question_Option::new_instance(array( |
|
| 1119 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
| 1120 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
| 1121 | 1121 | )); |
| 1122 | 1122 | } |
| 1123 | - if ( $QSO->opt_group() ) { |
|
| 1124 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
| 1123 | + if ($QSO->opt_group()) { |
|
| 1124 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
| 1125 | 1125 | } else { |
| 1126 | 1126 | $prepped_answer_options[] = $QSO; |
| 1127 | 1127 | } |
@@ -1137,8 +1137,8 @@ discard block |
||
| 1137 | 1137 | * @param string $option_value |
| 1138 | 1138 | * @return string |
| 1139 | 1139 | */ |
| 1140 | - static function prep_option_value( $option_value ){ |
|
| 1141 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
| 1140 | + static function prep_option_value($option_value) { |
|
| 1141 | + return esc_attr(trim(stripslashes($option_value))); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | |
@@ -1149,11 +1149,11 @@ discard block |
||
| 1149 | 1149 | * @param string|array $required |
| 1150 | 1150 | * @return array |
| 1151 | 1151 | */ |
| 1152 | - static function prep_required( $required = array() ){ |
|
| 1152 | + static function prep_required($required = array()) { |
|
| 1153 | 1153 | // make sure required is an array |
| 1154 | - $required = is_array( $required ) ? $required : array(); |
|
| 1154 | + $required = is_array($required) ? $required : array(); |
|
| 1155 | 1155 | // and set some defaults |
| 1156 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
| 1156 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
| 1157 | 1157 | return $required; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
@@ -1164,30 +1164,30 @@ discard block |
||
| 1164 | 1164 | * @param string $value |
| 1165 | 1165 | * @return string |
| 1166 | 1166 | */ |
| 1167 | - static function get_label_size_class( $value = FALSE ){ |
|
| 1168 | - if ( $value === FALSE || $value == '' ) { |
|
| 1167 | + static function get_label_size_class($value = FALSE) { |
|
| 1168 | + if ($value === FALSE || $value == '') { |
|
| 1169 | 1169 | return ' class="medium-lbl"'; |
| 1170 | 1170 | } |
| 1171 | 1171 | // determine length of option value |
| 1172 | - $val_size = strlen( $value ); |
|
| 1173 | - switch( $val_size ){ |
|
| 1172 | + $val_size = strlen($value); |
|
| 1173 | + switch ($val_size) { |
|
| 1174 | 1174 | case $val_size < 3 : |
| 1175 | - $size = ' class="nano-lbl"'; |
|
| 1175 | + $size = ' class="nano-lbl"'; |
|
| 1176 | 1176 | break; |
| 1177 | 1177 | case $val_size < 6 : |
| 1178 | - $size = ' class="micro-lbl"'; |
|
| 1178 | + $size = ' class="micro-lbl"'; |
|
| 1179 | 1179 | break; |
| 1180 | 1180 | case $val_size < 12 : |
| 1181 | - $size = ' class="tiny-lbl"'; |
|
| 1181 | + $size = ' class="tiny-lbl"'; |
|
| 1182 | 1182 | break; |
| 1183 | 1183 | case $val_size < 25 : |
| 1184 | - $size = ' class="small-lbl"'; |
|
| 1184 | + $size = ' class="small-lbl"'; |
|
| 1185 | 1185 | break; |
| 1186 | 1186 | case $val_size > 100 : |
| 1187 | - $size = ' class="big-lbl"'; |
|
| 1187 | + $size = ' class="big-lbl"'; |
|
| 1188 | 1188 | break; |
| 1189 | 1189 | default: |
| 1190 | - $size = ' class="medium-lbl"'; |
|
| 1190 | + $size = ' class="medium-lbl"'; |
|
| 1191 | 1191 | break; |
| 1192 | 1192 | } |
| 1193 | 1193 | return $size; |
@@ -1201,20 +1201,20 @@ discard block |
||
| 1201 | 1201 | * @param array $QFI |
| 1202 | 1202 | * @return array |
| 1203 | 1203 | */ |
| 1204 | - private static function _load_system_dropdowns( $QFI ){ |
|
| 1204 | + private static function _load_system_dropdowns($QFI) { |
|
| 1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
| 1206 | - switch ( $QST_system ) { |
|
| 1206 | + switch ($QST_system) { |
|
| 1207 | 1207 | case 'state' : |
| 1208 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
| 1208 | + $QFI = self::generate_state_dropdown($QFI); |
|
| 1209 | 1209 | break; |
| 1210 | 1210 | case 'country' : |
| 1211 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
| 1211 | + $QFI = self::generate_country_dropdown($QFI); |
|
| 1212 | 1212 | break; |
| 1213 | 1213 | case 'admin-state' : |
| 1214 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
| 1214 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
| 1215 | 1215 | break; |
| 1216 | 1216 | case 'admin-country' : |
| 1217 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
| 1217 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
| 1218 | 1218 | break; |
| 1219 | 1219 | } |
| 1220 | 1220 | return $QFI; |
@@ -1231,13 +1231,13 @@ discard block |
||
| 1231 | 1231 | * |
| 1232 | 1232 | * @return EE_Question_Form_Input |
| 1233 | 1233 | */ |
| 1234 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
| 1235 | - switch( $QFI->get( 'QST_type' ) ) { |
|
| 1234 | + protected static function _load_specialized_dropdowns($QFI) { |
|
| 1235 | + switch ($QFI->get('QST_type')) { |
|
| 1236 | 1236 | case 'STATE' : |
| 1237 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
| 1237 | + $QFI = self::generate_state_dropdown($QFI); |
|
| 1238 | 1238 | break; |
| 1239 | 1239 | case 'COUNTRY' : |
| 1240 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
| 1240 | + $QFI = self::generate_country_dropdown($QFI); |
|
| 1241 | 1241 | break; |
| 1242 | 1242 | } |
| 1243 | 1243 | return $QFI; |
@@ -1251,23 +1251,23 @@ discard block |
||
| 1251 | 1251 | * @param bool $get_all |
| 1252 | 1252 | * @return array |
| 1253 | 1253 | */ |
| 1254 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
| 1254 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
| 1255 | 1255 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
| 1256 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
| 1257 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
| 1256 | + if ($states && count($states) != count($QST->options())) { |
|
| 1257 | + $QST->set('QST_type', 'DROPDOWN'); |
|
| 1258 | 1258 | // if multiple countries, we'll create option groups within the dropdown |
| 1259 | - foreach ( $states as $state ) { |
|
| 1260 | - if ( $state instanceof EE_State ) { |
|
| 1261 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
| 1259 | + foreach ($states as $state) { |
|
| 1260 | + if ($state instanceof EE_State) { |
|
| 1261 | + $QSO = EE_Question_Option::new_instance(array( |
|
| 1262 | 1262 | 'QSO_value' => $state->ID(), |
| 1263 | 1263 | 'QSO_desc' => $state->name(), |
| 1264 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
| 1264 | + 'QST_ID' => $QST->get('QST_ID'), |
|
| 1265 | 1265 | 'QSO_deleted' => FALSE |
| 1266 | 1266 | )); |
| 1267 | 1267 | // set option group |
| 1268 | - $QSO->set_opt_group( $state->country()->name() ); |
|
| 1268 | + $QSO->set_opt_group($state->country()->name()); |
|
| 1269 | 1269 | // add option to question |
| 1270 | - $QST->add_temp_option( $QSO ); |
|
| 1270 | + $QST->add_temp_option($QSO); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | 1273 | } |
@@ -1283,20 +1283,20 @@ discard block |
||
| 1283 | 1283 | * @internal param array $question |
| 1284 | 1284 | * @return array |
| 1285 | 1285 | */ |
| 1286 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
| 1286 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
| 1287 | 1287 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
| 1288 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
| 1289 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
| 1288 | + if ($countries && count($countries) != count($QST->options())) { |
|
| 1289 | + $QST->set('QST_type', 'DROPDOWN'); |
|
| 1290 | 1290 | // now add countries |
| 1291 | - foreach ( $countries as $country ) { |
|
| 1292 | - if ( $country instanceof EE_Country ) { |
|
| 1293 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
| 1291 | + foreach ($countries as $country) { |
|
| 1292 | + if ($country instanceof EE_Country) { |
|
| 1293 | + $QSO = EE_Question_Option::new_instance(array( |
|
| 1294 | 1294 | 'QSO_value' => $country->ID(), |
| 1295 | 1295 | 'QSO_desc' => $country->name(), |
| 1296 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
| 1296 | + 'QST_ID' => $QST->get('QST_ID'), |
|
| 1297 | 1297 | 'QSO_deleted' => FALSE |
| 1298 | 1298 | )); |
| 1299 | - $QST->add_temp_option( $QSO ); |
|
| 1299 | + $QST->add_temp_option($QSO); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | } |
| 1302 | 1302 | } |
@@ -1313,11 +1313,11 @@ discard block |
||
| 1313 | 1313 | */ |
| 1314 | 1314 | public static function two_digit_months_dropdown_options() { |
| 1315 | 1315 | $options = array(); |
| 1316 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
| 1317 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
| 1318 | - $options[ (string)$mm ] = (string)$mm; |
|
| 1316 | + for ($x = 1; $x <= 12; $x++) { |
|
| 1317 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
| 1318 | + $options[(string) $mm] = (string) $mm; |
|
| 1319 | 1319 | } |
| 1320 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
| 1320 | + return EEH_Form_Fields::prep_answer_options($options); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | |
@@ -1332,11 +1332,11 @@ discard block |
||
| 1332 | 1332 | $options = array(); |
| 1333 | 1333 | $current_year = date('y'); |
| 1334 | 1334 | $next_decade = $current_year + 10; |
| 1335 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
| 1336 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
| 1337 | - $options[ (string)$yy ] = (string)$yy; |
|
| 1335 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
| 1336 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
| 1337 | + $options[(string) $yy] = (string) $yy; |
|
| 1338 | 1338 | } |
| 1339 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
| 1339 | + return EEH_Form_Fields::prep_answer_options($options); |
|
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | |
@@ -1350,17 +1350,17 @@ discard block |
||
| 1350 | 1350 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
| 1351 | 1351 | * @return string html |
| 1352 | 1352 | */ |
| 1353 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
| 1353 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
| 1354 | 1354 | $_where = array(); |
| 1355 | - if ( !empty( $status ) ) { |
|
| 1355 | + if ( ! empty($status)) { |
|
| 1356 | 1356 | $_where['STS_ID'] = $status; |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - if ( $evt_category > 0 ) { |
|
| 1359 | + if ($evt_category > 0) { |
|
| 1360 | 1360 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
| 1363 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
| 1364 | 1364 | |
| 1365 | 1365 | //setup vals for select input helper |
| 1366 | 1366 | $options = array( |
@@ -1370,15 +1370,15 @@ discard block |
||
| 1370 | 1370 | ) |
| 1371 | 1371 | ); |
| 1372 | 1372 | |
| 1373 | - foreach ( $regdtts as $regdtt ) { |
|
| 1374 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
| 1373 | + foreach ($regdtts as $regdtt) { |
|
| 1374 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
| 1375 | 1375 | $options[] = array( |
| 1376 | 1376 | 'text' => $date, |
| 1377 | 1377 | 'id' => $date |
| 1378 | 1378 | ); |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
| 1381 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | |
@@ -1392,18 +1392,18 @@ discard block |
||
| 1392 | 1392 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
| 1393 | 1393 | * @return string html |
| 1394 | 1394 | */ |
| 1395 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
| 1395 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
| 1396 | 1396 | //determine what post_status our condition will have for the query. |
| 1397 | - switch ( $status ) { |
|
| 1397 | + switch ($status) { |
|
| 1398 | 1398 | case 'month' : |
| 1399 | 1399 | case 'today' : |
| 1400 | 1400 | case NULL : |
| 1401 | 1401 | case 'all' : |
| 1402 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
| 1402 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
| 1403 | 1403 | break; |
| 1404 | 1404 | |
| 1405 | 1405 | case 'draft' : |
| 1406 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
| 1406 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
| 1407 | 1407 | |
| 1408 | 1408 | default : |
| 1409 | 1409 | $where['Event.status'] = $status; |
@@ -1412,7 +1412,7 @@ discard block |
||
| 1412 | 1412 | //categories? |
| 1413 | 1413 | |
| 1414 | 1414 | |
| 1415 | - if ( !empty ( $evt_category ) ) { |
|
| 1415 | + if ( ! empty ($evt_category)) { |
|
| 1416 | 1416 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
| 1417 | 1417 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
| 1418 | 1418 | } |
@@ -1420,7 +1420,7 @@ discard block |
||
| 1420 | 1420 | |
| 1421 | 1421 | // $where['DTT_is_primary'] = 1; |
| 1422 | 1422 | |
| 1423 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
| 1423 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
| 1424 | 1424 | |
| 1425 | 1425 | //let's setup vals for select input helper |
| 1426 | 1426 | $options = array( |
@@ -1435,9 +1435,9 @@ discard block |
||
| 1435 | 1435 | //translate month and date |
| 1436 | 1436 | global $wp_locale; |
| 1437 | 1437 | |
| 1438 | - foreach ( $DTTS as $DTT ) { |
|
| 1439 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
| 1440 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
| 1438 | + foreach ($DTTS as $DTT) { |
|
| 1439 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
| 1440 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
| 1441 | 1441 | $options[] = array( |
| 1442 | 1442 | 'text' => $localized_date, |
| 1443 | 1443 | 'id' => $id |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | 1447 | |
| 1448 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
| 1448 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | * @param integer $current_cat currently selected category |
| 1457 | 1457 | * @return string html for dropdown |
| 1458 | 1458 | */ |
| 1459 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
| 1459 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
| 1460 | 1460 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
| 1461 | 1461 | $options = array( |
| 1462 | 1462 | '0' => array( |
@@ -1466,14 +1466,14 @@ discard block |
||
| 1466 | 1466 | ); |
| 1467 | 1467 | |
| 1468 | 1468 | //setup categories for dropdown |
| 1469 | - foreach ( $categories as $category ) { |
|
| 1469 | + foreach ($categories as $category) { |
|
| 1470 | 1470 | $options[] = array( |
| 1471 | 1471 | 'text' => $category->get('name'), |
| 1472 | 1472 | 'id' => $category->ID() |
| 1473 | 1473 | ); |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
| 1476 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | |
@@ -1492,20 +1492,20 @@ discard block |
||
| 1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
| 1493 | 1493 | * @return void |
| 1494 | 1494 | */ |
| 1495 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
| 1495 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
| 1496 | 1496 | $btn = ''; |
| 1497 | - if ( empty( $url ) || empty( $ID )) { |
|
| 1497 | + if (empty($url) || empty($ID)) { |
|
| 1498 | 1498 | return $btn; |
| 1499 | 1499 | } |
| 1500 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
| 1501 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
| 1502 | - if ( ! $input_only ) { |
|
| 1503 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
| 1504 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
| 1500 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
| 1501 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
| 1502 | + if ( ! $input_only) { |
|
| 1503 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
| 1504 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
| 1505 | 1505 | $btn_frm .= $btn; |
| 1506 | 1506 | $btn_frm .= '</form>'; |
| 1507 | 1507 | $btn = $btn_frm; |
| 1508 | - unset ( $btn_frm ); |
|
| 1508 | + unset ($btn_frm); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | return $btn; |
| 1511 | 1511 | } |