@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @since 4.6.0 |
601 | 601 | * @global WPDB $wpdb |
602 | 602 | * |
603 | - * @return mixed null|int WP_user ID or NULL |
|
603 | + * @return integer|null null|int WP_user ID or NULL |
|
604 | 604 | */ |
605 | 605 | public static function get_default_creator_id() { |
606 | 606 | global $wpdb; |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @static |
760 | 760 | * @deprecated instead use TableManager::dropTable() |
761 | 761 | * @param string $table_name |
762 | - * @return bool | int |
|
762 | + * @return integer | int |
|
763 | 763 | */ |
764 | 764 | public static function delete_unused_db_table( $table_name ) { |
765 | 765 | return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | * @deprecated instead use TableManager::dropIndex() |
776 | 776 | * @param string $table_name |
777 | 777 | * @param string $index_name |
778 | - * @return bool | int |
|
778 | + * @return integer | int |
|
779 | 779 | */ |
780 | 780 | public static function drop_index( $table_name, $index_name ) { |
781 | 781 | return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if ( is_array( $hooks_to_fire_at_time ) ) { |
252 | 252 | foreach ( (array) $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
253 | 253 | if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | + && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
255 | 255 | ) { |
256 | 256 | unset( $crons[ $timestamp ][ $hook_name ] ); |
257 | 257 | } |
@@ -738,13 +738,13 @@ discard block |
||
738 | 738 | |
739 | 739 | |
740 | 740 | /** |
741 | - * delete_db_table_if_empty |
|
742 | - * |
|
743 | - * @access public |
|
744 | - * @static |
|
745 | - * @param string $table_name |
|
746 | - * @return bool | int |
|
747 | - */ |
|
741 | + * delete_db_table_if_empty |
|
742 | + * |
|
743 | + * @access public |
|
744 | + * @static |
|
745 | + * @param string $table_name |
|
746 | + * @return bool | int |
|
747 | + */ |
|
748 | 748 | public static function delete_db_table_if_empty( $table_name ) { |
749 | 749 | if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
750 | 750 | return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
@@ -1759,8 +1759,8 @@ discard block |
||
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | } |
1762 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1763 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1762 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1763 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1764 | 1764 | |
1765 | 1765 | if ( $remove_all && $espresso_db_update = (array) get_option( 'espresso_db_update' )) { |
1766 | 1766 | $db_update_sans_ee4 = array(); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EEH_Activation Helper |
4 | 4 | * |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return \EventEspresso\core\services\database\TableAnalysis |
55 | 55 | */ |
56 | 56 | public static function getTableAnalysis() { |
57 | - if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis ) { |
|
58 | - self::$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
57 | + if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
58 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
59 | 59 | } |
60 | 60 | return self::$table_analysis; |
61 | 61 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return \EventEspresso\core\services\database\TableManager |
67 | 67 | */ |
68 | 68 | public static function getTableManager() { |
69 | - if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager ) { |
|
70 | - self::$table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
69 | + if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
70 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
71 | 71 | } |
72 | 72 | return self::$table_manager; |
73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param $table_name |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
86 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
85 | + public static function ensure_table_name_has_prefix($table_name) { |
|
86 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return boolean success, whether the database and folders are setup properly |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public static function initialize_db_and_folders(){ |
|
114 | + public static function initialize_db_and_folders() { |
|
115 | 115 | $good_filesystem = EEH_Activation::create_upload_directories(); |
116 | 116 | $good_db = EEH_Activation::create_database_tables(); |
117 | 117 | return $good_filesystem && $good_db; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | - public static function initialize_db_content(){ |
|
130 | + public static function initialize_db_content() { |
|
131 | 131 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
132 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
132 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | EEH_Activation::remove_cron_tasks(); |
147 | 147 | EEH_Activation::create_cron_tasks(); |
148 | 148 | // remove all TXN locks since that is being done via extra meta now |
149 | - delete_option( 'ee_locked_transactions' ); |
|
149 | + delete_option('ee_locked_transactions'); |
|
150 | 150 | //also, check for CAF default db content |
151 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
151 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
152 | 152 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
153 | 153 | //which users really won't care about on initial activation |
154 | 154 | EE_Error::overwrite_success(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return array |
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | - public static function get_cron_tasks( $which_to_include ) { |
|
171 | + public static function get_cron_tasks($which_to_include) { |
|
172 | 172 | $cron_tasks = apply_filters( |
173 | 173 | 'FHEE__EEH_Activation__get_cron_tasks', |
174 | 174 | array( |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
178 | 178 | ) |
179 | 179 | ); |
180 | - if ( $which_to_include === 'old' ) { |
|
180 | + if ($which_to_include === 'old') { |
|
181 | 181 | $cron_tasks = array_filter( |
182 | 182 | $cron_tasks, |
183 | - function ( $value ) { |
|
183 | + function($value) { |
|
184 | 184 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
185 | 185 | } |
186 | 186 | ); |
187 | - } elseif ( $which_to_include === 'current' ) { |
|
188 | - $cron_tasks = array_filter( $cron_tasks ); |
|
189 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
187 | + } elseif ($which_to_include === 'current') { |
|
188 | + $cron_tasks = array_filter($cron_tasks); |
|
189 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
190 | 190 | throw new EE_Error( |
191 | 191 | sprintf( |
192 | 192 | __( |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function create_cron_tasks() { |
211 | 211 | |
212 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
213 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
214 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
212 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
213 | + if ( ! wp_next_scheduled($hook_name)) { |
|
214 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
226 | 226 | * @throws \EE_Error |
227 | 227 | */ |
228 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
228 | + public static function remove_cron_tasks($remove_all = true) { |
|
229 | 229 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
230 | 230 | $crons = _get_cron_array(); |
231 | - $crons = is_array( $crons ) ? $crons : array(); |
|
231 | + $crons = is_array($crons) ? $crons : array(); |
|
232 | 232 | /* reminder of what $crons look like: |
233 | 233 | * Top-level keys are timestamps, and their values are arrays. |
234 | 234 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -246,23 +246,23 @@ discard block |
||
246 | 246 | * ... |
247 | 247 | * ... |
248 | 248 | */ |
249 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
250 | - foreach ( (array) $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
251 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
252 | - foreach ( (array) $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
253 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
249 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
250 | + foreach ((array) $crons as $timestamp => $hooks_to_fire_at_time) { |
|
251 | + if (is_array($hooks_to_fire_at_time)) { |
|
252 | + foreach ((array) $hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
253 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
254 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
255 | 255 | ) { |
256 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
256 | + unset($crons[$timestamp][$hook_name]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | //also take care of any empty cron timestamps. |
260 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
261 | - unset( $crons[ $timestamp ] ); |
|
260 | + if (empty($hooks_to_fire_at_time)) { |
|
261 | + unset($crons[$timestamp]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | - _set_cron_array( $crons ); |
|
265 | + _set_cron_array($crons); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function CPT_initialization() { |
279 | 279 | // register Custom Post Types |
280 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
280 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
281 | 281 | flush_rewrite_rules(); |
282 | 282 | } |
283 | 283 | |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @return void |
296 | 296 | */ |
297 | 297 | public static function reset_and_update_config() { |
298 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
299 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
298 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
299 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
300 | 300 | //EE_Config::reset(); |
301 | 301 | } |
302 | 302 | |
@@ -309,28 +309,28 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public static function load_calendar_config() { |
311 | 311 | // grab array of all plugin folders and loop thru it |
312 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
313 | - if ( empty( $plugins ) ) { |
|
312 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
313 | + if (empty($plugins)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | - foreach ( $plugins as $plugin_path ) { |
|
316 | + foreach ($plugins as $plugin_path) { |
|
317 | 317 | // grab plugin folder name from path |
318 | - $plugin = basename( $plugin_path ); |
|
318 | + $plugin = basename($plugin_path); |
|
319 | 319 | // drill down to Espresso plugins |
320 | 320 | // then to calendar related plugins |
321 | 321 | if ( |
322 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
323 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
324 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
325 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
326 | - || strpos( $plugin, 'calendar' ) !== false |
|
322 | + strpos($plugin, 'espresso') !== FALSE |
|
323 | + || strpos($plugin, 'Espresso') !== FALSE |
|
324 | + || strpos($plugin, 'ee4') !== FALSE |
|
325 | + || strpos($plugin, 'EE4') !== FALSE |
|
326 | + || strpos($plugin, 'calendar') !== false |
|
327 | 327 | ) { |
328 | 328 | // this is what we are looking for |
329 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
329 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
330 | 330 | // does it exist in this folder ? |
331 | - if ( is_readable( $calendar_config )) { |
|
331 | + if (is_readable($calendar_config)) { |
|
332 | 332 | // YEAH! let's load it |
333 | - require_once( $calendar_config ); |
|
333 | + require_once($calendar_config); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | * @param \EE_Config $EE_Config |
347 | 347 | * @return \stdClass |
348 | 348 | */ |
349 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
350 | - $convert_from_array = array( 'addons' ); |
|
349 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
350 | + $convert_from_array = array('addons'); |
|
351 | 351 | // in case old settings were saved as an array |
352 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
352 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
353 | 353 | // convert existing settings to an object |
354 | 354 | $config_array = $settings; |
355 | 355 | $settings = new stdClass(); |
356 | - foreach ( (array) $config_array as $key => $value ){ |
|
357 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
358 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
356 | + foreach ((array) $config_array as $key => $value) { |
|
357 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
358 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
359 | 359 | } else { |
360 | 360 | $settings->{$key} = $value; |
361 | 361 | } |
362 | 362 | } |
363 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
363 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
364 | 364 | } |
365 | 365 | return $settings; |
366 | 366 | } |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public static function deactivate_event_espresso() { |
378 | 378 | // check permissions |
379 | - if ( current_user_can( 'activate_plugins' )) { |
|
380 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
379 | + if (current_user_can('activate_plugins')) { |
|
380 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | $critical_pages = array( |
400 | 400 | array( |
401 | 401 | 'id' =>'reg_page_id', |
402 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
402 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
403 | 403 | 'post' => NULL, |
404 | 404 | 'code' => 'ESPRESSO_CHECKOUT' |
405 | 405 | ), |
406 | 406 | array( |
407 | 407 | 'id' => 'txn_page_id', |
408 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
408 | + 'name' => __('Transactions', 'event_espresso'), |
|
409 | 409 | 'post' => NULL, |
410 | 410 | 'code' => 'ESPRESSO_TXN_PAGE' |
411 | 411 | ), |
412 | 412 | array( |
413 | 413 | 'id' => 'thank_you_page_id', |
414 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
414 | + 'name' => __('Thank You', 'event_espresso'), |
|
415 | 415 | 'post' => NULL, |
416 | 416 | 'code' => 'ESPRESSO_THANK_YOU' |
417 | 417 | ), |
418 | 418 | array( |
419 | 419 | 'id' => 'cancel_page_id', |
420 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
420 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
421 | 421 | 'post' => NULL, |
422 | 422 | 'code' => 'ESPRESSO_CANCELLED' |
423 | 423 | ), |
@@ -425,62 +425,62 @@ discard block |
||
425 | 425 | |
426 | 426 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
427 | 427 | |
428 | - foreach ( $critical_pages as $critical_page ) { |
|
428 | + foreach ($critical_pages as $critical_page) { |
|
429 | 429 | // is critical page ID set in config ? |
430 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
430 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
431 | 431 | // attempt to find post by ID |
432 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
432 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
433 | 433 | } |
434 | 434 | // no dice? |
435 | - if ( $critical_page['post'] === null ) { |
|
435 | + if ($critical_page['post'] === null) { |
|
436 | 436 | // attempt to find post by title |
437 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
437 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
438 | 438 | // still nothing? |
439 | - if ( $critical_page['post'] === null ) { |
|
440 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
439 | + if ($critical_page['post'] === null) { |
|
440 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
441 | 441 | // REALLY? Still nothing ??!?!? |
442 | - if ( $critical_page['post'] === null ) { |
|
443 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
444 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
442 | + if ($critical_page['post'] === null) { |
|
443 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
444 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
445 | 445 | break; |
446 | 446 | } |
447 | 447 | } |
448 | 448 | } |
449 | 449 | // track post_shortcodes |
450 | - if ( $critical_page['post'] ) { |
|
451 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
450 | + if ($critical_page['post']) { |
|
451 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
452 | 452 | } |
453 | 453 | // check that Post ID matches critical page ID in config |
454 | 454 | if ( |
455 | - isset( $critical_page['post']->ID ) |
|
456 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
455 | + isset($critical_page['post']->ID) |
|
456 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
457 | 457 | ) { |
458 | 458 | //update Config with post ID |
459 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
460 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
461 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
462 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
459 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
460 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
461 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
462 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | 466 | $critical_page_problem = |
467 | - ! isset( $critical_page['post']->post_status ) |
|
467 | + ! isset($critical_page['post']->post_status) |
|
468 | 468 | || $critical_page['post']->post_status !== 'publish' |
469 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
469 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
470 | 470 | ? TRUE |
471 | 471 | : $critical_page_problem; |
472 | 472 | |
473 | 473 | } |
474 | 474 | |
475 | - if ( $critical_page_problem ) { |
|
475 | + if ($critical_page_problem) { |
|
476 | 476 | $msg = sprintf( |
477 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
478 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
477 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
478 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
479 | 479 | ); |
480 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
480 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
481 | 481 | } |
482 | - if ( EE_Error::has_notices() ) { |
|
483 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
482 | + if (EE_Error::has_notices()) { |
|
483 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -492,13 +492,13 @@ discard block |
||
492 | 492 | * parameter to the shortcode |
493 | 493 | * @return WP_Post or NULl |
494 | 494 | */ |
495 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
495 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
496 | 496 | global $wpdb; |
497 | 497 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
498 | 498 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
499 | - if($post_id){ |
|
499 | + if ($post_id) { |
|
500 | 500 | return get_post($post_id); |
501 | - }else{ |
|
501 | + } else { |
|
502 | 502 | return NULL; |
503 | 503 | } |
504 | 504 | |
@@ -515,32 +515,32 @@ discard block |
||
515 | 515 | * @param array $critical_page |
516 | 516 | * @return array |
517 | 517 | */ |
518 | - public static function create_critical_page( $critical_page ) { |
|
518 | + public static function create_critical_page($critical_page) { |
|
519 | 519 | |
520 | 520 | $post_args = array( |
521 | 521 | 'post_title' => $critical_page['name'], |
522 | 522 | 'post_status' => 'publish', |
523 | 523 | 'post_type' => 'page', |
524 | 524 | 'comment_status' => 'closed', |
525 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
525 | + 'post_content' => '['.$critical_page['code'].']' |
|
526 | 526 | ); |
527 | 527 | |
528 | - $post_id = wp_insert_post( $post_args ); |
|
529 | - if ( ! $post_id ) { |
|
528 | + $post_id = wp_insert_post($post_args); |
|
529 | + if ( ! $post_id) { |
|
530 | 530 | $msg = sprintf( |
531 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
531 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
532 | 532 | $critical_page['name'] |
533 | 533 | ); |
534 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
534 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
535 | 535 | return $critical_page; |
536 | 536 | } |
537 | 537 | // get newly created post's details |
538 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
538 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
539 | 539 | $msg = sprintf( |
540 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
540 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
541 | 541 | $critical_page['name'] |
542 | 542 | ); |
543 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
543 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | return $critical_page; |
@@ -559,35 +559,35 @@ discard block |
||
559 | 559 | * @param array $critical_page |
560 | 560 | * @return void |
561 | 561 | */ |
562 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
562 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
563 | 563 | // check the goods |
564 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
564 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
565 | 565 | $msg = sprintf( |
566 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
566 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
567 | 567 | $critical_page['name'] |
568 | 568 | ); |
569 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
569 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
570 | 570 | return; |
571 | 571 | } |
572 | 572 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
573 | 573 | // map shortcode to post |
574 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
574 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
575 | 575 | // and make sure it's NOT added to the WP "Posts Page" |
576 | 576 | // name of the WP Posts Page |
577 | 577 | $posts_page = EE_Config::get_page_for_posts(); |
578 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
579 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
578 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
579 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
580 | 580 | } |
581 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
582 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
581 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
582 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
583 | 583 | } |
584 | 584 | // update post_shortcode CFG |
585 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
585 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
586 | 586 | $msg = sprintf( |
587 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
587 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
588 | 588 | $critical_page['name'] |
589 | 589 | ); |
590 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
590 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
@@ -605,24 +605,24 @@ discard block |
||
605 | 605 | public static function get_default_creator_id() { |
606 | 606 | global $wpdb; |
607 | 607 | |
608 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
608 | + if ( ! empty(self::$_default_creator_id)) { |
|
609 | 609 | return self::$_default_creator_id; |
610 | 610 | }/**/ |
611 | 611 | |
612 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
612 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
613 | 613 | |
614 | 614 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
615 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
616 | - if ( $pre_filtered_id !== false ) { |
|
615 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
616 | + if ($pre_filtered_id !== false) { |
|
617 | 617 | return (int) $pre_filtered_id; |
618 | 618 | } |
619 | 619 | |
620 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'capabilities' ); |
|
621 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
622 | - $user_id = $wpdb->get_var( $query ); |
|
623 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
624 | - if ( $user_id && (int)$user_id ) { |
|
625 | - self::$_default_creator_id = (int)$user_id; |
|
620 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
621 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
622 | + $user_id = $wpdb->get_var($query); |
|
623 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
624 | + if ($user_id && (int) $user_id) { |
|
625 | + self::$_default_creator_id = (int) $user_id; |
|
626 | 626 | return self::$_default_creator_id; |
627 | 627 | } else { |
628 | 628 | return NULL; |
@@ -651,28 +651,28 @@ discard block |
||
651 | 651 | * @return void |
652 | 652 | * @throws EE_Error if there are database errors |
653 | 653 | */ |
654 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
655 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
654 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
655 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
659 | - if ( ! function_exists( 'dbDelta' )) { |
|
660 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
658 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
659 | + if ( ! function_exists('dbDelta')) { |
|
660 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
661 | 661 | } |
662 | 662 | $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
663 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix( $table_name ); |
|
663 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
664 | 664 | // do we need to first delete an existing version of this table ? |
665 | - if ( $drop_pre_existing_table && $tableAnalysis->tableExists( $wp_table_name ) ){ |
|
665 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
666 | 666 | // ok, delete the table... but ONLY if it's empty |
667 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
667 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
668 | 668 | // table is NOT empty, are you SURE you want to delete this table ??? |
669 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
670 | - \EEH_Activation::getTableManager()->dropTable( $wp_table_name ); |
|
671 | - } else if ( ! $deleted_safely ) { |
|
669 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
670 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
671 | + } else if ( ! $deleted_safely) { |
|
672 | 672 | // so we should be more cautious rather than just dropping tables so easily |
673 | 673 | EE_Error::add_persistent_admin_notice( |
674 | - 'bad_table_' . $wp_table_name . '_detected', |
|
675 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
674 | + 'bad_table_'.$wp_table_name.'_detected', |
|
675 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
676 | 676 | $wp_table_name, |
677 | 677 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
678 | 678 | '<b>wp-config.php</b>', |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | TRUE ); |
681 | 681 | } |
682 | 682 | } |
683 | - $engine = str_replace( 'ENGINE=', '', $engine ); |
|
684 | - \EEH_Activation::getTableManager()->createTable( $table_name, $sql, $engine ); |
|
683 | + $engine = str_replace('ENGINE=', '', $engine); |
|
684 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | * 'VARCHAR(10)' |
700 | 700 | * @return bool|int |
701 | 701 | */ |
702 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
703 | - return \EEH_Activation::getTableManager()->addColumn( $table_name, $column_name, $column_info ); |
|
702 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
703 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @param string $table_name, without prefixed $wpdb->prefix |
717 | 717 | * @return array of database column names |
718 | 718 | */ |
719 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
720 | - return \EEH_Activation::getTableManager()->getTableColumns( $table_name ); |
|
719 | + public static function get_fields_on_table($table_name = NULL) { |
|
720 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | * @param string $table_name |
732 | 732 | * @return bool |
733 | 733 | */ |
734 | - public static function db_table_is_empty( $table_name ) { |
|
735 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ); |
|
734 | + public static function db_table_is_empty($table_name) { |
|
735 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | * @param string $table_name |
746 | 746 | * @return bool | int |
747 | 747 | */ |
748 | - public static function delete_db_table_if_empty( $table_name ) { |
|
749 | - if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
|
750 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
748 | + public static function delete_db_table_if_empty($table_name) { |
|
749 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
750 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
751 | 751 | } |
752 | 752 | return false; |
753 | 753 | } |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | * @param string $table_name |
764 | 764 | * @return bool | int |
765 | 765 | */ |
766 | - public static function delete_unused_db_table( $table_name ) { |
|
767 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
766 | + public static function delete_unused_db_table($table_name) { |
|
767 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | * @param string $index_name |
780 | 780 | * @return bool | int |
781 | 781 | */ |
782 | - public static function drop_index( $table_name, $index_name ) { |
|
783 | - return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
|
782 | + public static function drop_index($table_name, $index_name) { |
|
783 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -794,27 +794,27 @@ discard block |
||
794 | 794 | * @return boolean success (whether database is setup properly or not) |
795 | 795 | */ |
796 | 796 | public static function create_database_tables() { |
797 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
797 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
798 | 798 | //find the migration script that sets the database to be compatible with the code |
799 | 799 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
800 | - if( $dms_name ){ |
|
801 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
802 | - $current_data_migration_script->set_migrating( false ); |
|
800 | + if ($dms_name) { |
|
801 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
802 | + $current_data_migration_script->set_migrating(false); |
|
803 | 803 | $current_data_migration_script->schema_changes_before_migration(); |
804 | 804 | $current_data_migration_script->schema_changes_after_migration(); |
805 | - if( $current_data_migration_script->get_errors() ){ |
|
806 | - if( WP_DEBUG ){ |
|
807 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
808 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
805 | + if ($current_data_migration_script->get_errors()) { |
|
806 | + if (WP_DEBUG) { |
|
807 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
808 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
809 | 809 | } |
810 | - }else{ |
|
811 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
810 | + } else { |
|
811 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
812 | 812 | } |
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
816 | - }else{ |
|
817 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
816 | + } else { |
|
817 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
818 | 818 | return false; |
819 | 819 | } |
820 | 820 | return true; |
@@ -834,36 +834,36 @@ discard block |
||
834 | 834 | public static function initialize_system_questions() { |
835 | 835 | // QUESTION GROUPS |
836 | 836 | global $wpdb; |
837 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group' ); |
|
837 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
838 | 838 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
839 | 839 | // what we have |
840 | - $question_groups = $wpdb->get_col( $SQL ); |
|
840 | + $question_groups = $wpdb->get_col($SQL); |
|
841 | 841 | // check the response |
842 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
842 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
843 | 843 | // what we should have |
844 | - $QSG_systems = array( 1, 2 ); |
|
844 | + $QSG_systems = array(1, 2); |
|
845 | 845 | $QSG_IDs = array(); |
846 | 846 | $timestamp = time(); |
847 | 847 | // loop thru what we should have and compare to what we have |
848 | - foreach ( $QSG_systems as $QSG_system ) { |
|
848 | + foreach ($QSG_systems as $QSG_system) { |
|
849 | 849 | // reset values array |
850 | 850 | $QSG_values = array(); |
851 | 851 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
852 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
852 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
853 | 853 | // add it |
854 | - switch ( $QSG_system ) { |
|
854 | + switch ($QSG_system) { |
|
855 | 855 | |
856 | 856 | case 1: |
857 | 857 | $QSG_values = array( |
858 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
859 | - 'QSG_identifier' => 'personal-information-' . $timestamp, |
|
858 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
859 | + 'QSG_identifier' => 'personal-information-'.$timestamp, |
|
860 | 860 | 'QSG_desc' => __( |
861 | 861 | 'Questions for gathering critical details like "Name" and "Email Address"', |
862 | 862 | 'event_espresso' |
863 | 863 | ), |
864 | 864 | 'QSG_parent' => null, |
865 | - 'QSG_html_name' => 'personal-information-' . $timestamp, |
|
866 | - 'QSG_html_id' => 'personal-information-' . $timestamp, |
|
865 | + 'QSG_html_name' => 'personal-information-'.$timestamp, |
|
866 | + 'QSG_html_id' => 'personal-information-'.$timestamp, |
|
867 | 867 | 'QSG_order' => 1, |
868 | 868 | 'QSG_wp_user' => self::get_default_creator_id(), |
869 | 869 | 'QSG_system' => EEM_Question_Group::system_personal, |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | |
874 | 874 | case 2: |
875 | 875 | $QSG_values = array( |
876 | - 'QSG_name' => __( 'Address Information', 'event_espresso' ), |
|
877 | - 'QSG_identifier' => 'address-information-' . $timestamp, |
|
876 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
877 | + 'QSG_identifier' => 'address-information-'.$timestamp, |
|
878 | 878 | 'QSG_desc' => __( |
879 | 879 | 'Questions for gathering mailing address details', |
880 | 880 | 'event_espresso' |
881 | 881 | ), |
882 | 882 | 'QSG_parent' => null, |
883 | - 'QSG_html_name' => 'address-information-' . $timestamp, |
|
884 | - 'QSG_html_id' => 'address-information-' . $timestamp, |
|
883 | + 'QSG_html_name' => 'address-information-'.$timestamp, |
|
884 | + 'QSG_html_id' => 'address-information-'.$timestamp, |
|
885 | 885 | 'QSG_order' => 2, |
886 | 886 | 'QSG_wp_user' => self::get_default_creator_id(), |
887 | 887 | 'QSG_system' => EEM_Question_Group::system_address, |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | |
892 | 892 | } |
893 | 893 | // make sure we have some values before inserting them |
894 | - if ( ! empty( $QSG_values )) { |
|
894 | + if ( ! empty($QSG_values)) { |
|
895 | 895 | // insert system question |
896 | 896 | $wpdb->insert( |
897 | 897 | $table_name, |
898 | 898 | $QSG_values, |
899 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
899 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
900 | 900 | ); |
901 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
901 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | } |
@@ -907,10 +907,10 @@ discard block |
||
907 | 907 | |
908 | 908 | // QUESTIONS |
909 | 909 | global $wpdb; |
910 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question' ); |
|
910 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
911 | 911 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
912 | 912 | // what we have |
913 | - $questions = $wpdb->get_col( $SQL ); |
|
913 | + $questions = $wpdb->get_col($SQL); |
|
914 | 914 | // what we should have |
915 | 915 | $QST_systems = array( |
916 | 916 | 'fname', |
@@ -925,32 +925,32 @@ discard block |
||
925 | 925 | 'phone' |
926 | 926 | ); |
927 | 927 | // loop thru what we should have and compare to what we have |
928 | - foreach ( $QST_systems as $QST_system ) { |
|
928 | + foreach ($QST_systems as $QST_system) { |
|
929 | 929 | // reset values array |
930 | 930 | $QST_values = array(); |
931 | 931 | // if we don't have what we should have |
932 | - if ( ! in_array( $QST_system, $questions )) { |
|
932 | + if ( ! in_array($QST_system, $questions)) { |
|
933 | 933 | // add it |
934 | - switch ( $QST_system ) { |
|
934 | + switch ($QST_system) { |
|
935 | 935 | |
936 | 936 | case 'fname': |
937 | 937 | $QST_values = array( |
938 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_personal ], |
|
939 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
940 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
941 | - 'QST_identifier' => 'fname-' . $timestamp, |
|
938 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_personal], |
|
939 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
940 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
941 | + 'QST_identifier' => 'fname-'.$timestamp, |
|
942 | 942 | 'QST_system' => 'fname', |
943 | 943 | 'QST_type' => 'TEXT', |
944 | 944 | 'QST_required' => 1, |
945 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
945 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
946 | 946 | 'QST_desc' => 'The registrant\'s given name', |
947 | - 'QST_html_name' => 'fname-' . $timestamp, |
|
948 | - 'QST_html_id' => 'fname-' . $timestamp, |
|
947 | + 'QST_html_name' => 'fname-'.$timestamp, |
|
948 | + 'QST_html_id' => 'fname-'.$timestamp, |
|
949 | 949 | 'QST_html_class' => 'fname', |
950 | - 'QST_html_label_id' => 'fname-' . $timestamp . '-lbl', |
|
950 | + 'QST_html_label_id' => 'fname-'.$timestamp.'-lbl', |
|
951 | 951 | 'QST_html_label_class' => 'fname-lbl', |
952 | 952 | 'QST_default_value' => '', |
953 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
953 | + 'QST_validation_strategies' => array('required' => ''), |
|
954 | 954 | 'QST_validation_message' => '', |
955 | 955 | 'QST_order' => 1, |
956 | 956 | 'QST_admin_only' => 0, |
@@ -964,19 +964,19 @@ discard block |
||
964 | 964 | |
965 | 965 | case 'lname': |
966 | 966 | $QST_values = array( |
967 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_personal ], |
|
968 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
969 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
970 | - 'QST_identifier' => 'lname-' . $timestamp, |
|
967 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_personal], |
|
968 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
969 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
970 | + 'QST_identifier' => 'lname-'.$timestamp, |
|
971 | 971 | 'QST_system' => 'lname', |
972 | 972 | 'QST_type' => 'TEXT', |
973 | 973 | 'QST_required' => 1, |
974 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
974 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
975 | 975 | 'QST_desc' => 'The registrant\'s family name', |
976 | - 'QST_html_name' => 'lname-' . $timestamp, |
|
977 | - 'QST_html_id' => 'lname-' . $timestamp, |
|
976 | + 'QST_html_name' => 'lname-'.$timestamp, |
|
977 | + 'QST_html_id' => 'lname-'.$timestamp, |
|
978 | 978 | 'QST_html_class' => 'lname', |
979 | - 'QST_html_label_id' => 'lname-' . $timestamp . '-lbl', |
|
979 | + 'QST_html_label_id' => 'lname-'.$timestamp.'-lbl', |
|
980 | 980 | 'QST_html_label_class' => 'lname-lbl', |
981 | 981 | 'QST_default_value' => '', |
982 | 982 | 'QST_validation_strategies' => array(), |
@@ -993,22 +993,22 @@ discard block |
||
993 | 993 | |
994 | 994 | case 'email': |
995 | 995 | $QST_values = array( |
996 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_personal ], |
|
997 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
998 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
999 | - 'QST_identifier' => 'email-' . $timestamp, |
|
996 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_personal], |
|
997 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
998 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
999 | + 'QST_identifier' => 'email-'.$timestamp, |
|
1000 | 1000 | 'QST_system' => 'email', |
1001 | 1001 | 'QST_type' => 'EMAIL', |
1002 | 1002 | 'QST_required' => 1, |
1003 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1003 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1004 | 1004 | 'QST_desc' => 'The registrant\'s email address', |
1005 | - 'QST_html_name' => 'email-' . $timestamp, |
|
1006 | - 'QST_html_id' => 'email-' . $timestamp, |
|
1005 | + 'QST_html_name' => 'email-'.$timestamp, |
|
1006 | + 'QST_html_id' => 'email-'.$timestamp, |
|
1007 | 1007 | 'QST_html_class' => 'email', |
1008 | - 'QST_html_label_id' => 'email-' . $timestamp . '-lbl', |
|
1008 | + 'QST_html_label_id' => 'email-'.$timestamp.'-lbl', |
|
1009 | 1009 | 'QST_html_label_class' => 'email-lbl', |
1010 | 1010 | 'QST_default_value' => '', |
1011 | - 'QST_validation_strategies' => array( 'required' => '', 'email' => '', ), |
|
1011 | + 'QST_validation_strategies' => array('required' => '', 'email' => '',), |
|
1012 | 1012 | 'QST_validation_message' => '', |
1013 | 1013 | 'QST_order' => 3, |
1014 | 1014 | 'QST_admin_only' => 0, |
@@ -1022,22 +1022,22 @@ discard block |
||
1022 | 1022 | |
1023 | 1023 | case 'address': |
1024 | 1024 | $QST_values = array( |
1025 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1026 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
1027 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
1028 | - 'QST_identifier' => 'address-' . $timestamp, |
|
1025 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1026 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
1027 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
1028 | + 'QST_identifier' => 'address-'.$timestamp, |
|
1029 | 1029 | 'QST_system' => 'address', |
1030 | 1030 | 'QST_type' => 'TEXT', |
1031 | 1031 | 'QST_required' => 0, |
1032 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1032 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1033 | 1033 | 'QST_desc' => 'The registrant\'s street address', |
1034 | - 'QST_html_name' => 'address-' . $timestamp, |
|
1035 | - 'QST_html_id' => 'address-' . $timestamp, |
|
1034 | + 'QST_html_name' => 'address-'.$timestamp, |
|
1035 | + 'QST_html_id' => 'address-'.$timestamp, |
|
1036 | 1036 | 'QST_html_class' => 'address', |
1037 | - 'QST_html_label_id' => 'address-' . $timestamp . '-lbl', |
|
1037 | + 'QST_html_label_id' => 'address-'.$timestamp.'-lbl', |
|
1038 | 1038 | 'QST_html_label_class' => 'address-lbl', |
1039 | 1039 | 'QST_default_value' => '', |
1040 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1040 | + 'QST_validation_strategies' => array('required' => ''), |
|
1041 | 1041 | 'QST_validation_message' => '', |
1042 | 1042 | 'QST_order' => 4, |
1043 | 1043 | 'QST_admin_only' => 0, |
@@ -1051,22 +1051,22 @@ discard block |
||
1051 | 1051 | |
1052 | 1052 | case 'address2': |
1053 | 1053 | $QST_values = array( |
1054 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1055 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
1056 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
1057 | - 'QST_identifier' => 'address2-' . $timestamp, |
|
1054 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1055 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1056 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1057 | + 'QST_identifier' => 'address2-'.$timestamp, |
|
1058 | 1058 | 'QST_system' => 'address2', |
1059 | 1059 | 'QST_type' => 'TEXT', |
1060 | 1060 | 'QST_required' => 0, |
1061 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1061 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1062 | 1062 | 'QST_desc' => 'The registrant\'s street address (additional info)', |
1063 | - 'QST_html_name' => 'address2-' . $timestamp, |
|
1064 | - 'QST_html_id' => 'address2-' . $timestamp, |
|
1063 | + 'QST_html_name' => 'address2-'.$timestamp, |
|
1064 | + 'QST_html_id' => 'address2-'.$timestamp, |
|
1065 | 1065 | 'QST_html_class' => 'address2', |
1066 | - 'QST_html_label_id' => 'address2-' . $timestamp . '-lbl', |
|
1066 | + 'QST_html_label_id' => 'address2-'.$timestamp.'-lbl', |
|
1067 | 1067 | 'QST_html_label_class' => 'address2-lbl', |
1068 | 1068 | 'QST_default_value' => '', |
1069 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1069 | + 'QST_validation_strategies' => array('required' => ''), |
|
1070 | 1070 | 'QST_validation_message' => '', |
1071 | 1071 | 'QST_order' => 5, |
1072 | 1072 | 'QST_admin_only' => 0, |
@@ -1080,22 +1080,22 @@ discard block |
||
1080 | 1080 | |
1081 | 1081 | case 'city': |
1082 | 1082 | $QST_values = array( |
1083 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1084 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1085 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1086 | - 'QST_identifier' => 'city-' . $timestamp, |
|
1083 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1084 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1085 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1086 | + 'QST_identifier' => 'city-'.$timestamp, |
|
1087 | 1087 | 'QST_system' => 'city', |
1088 | 1088 | 'QST_type' => 'TEXT', |
1089 | 1089 | 'QST_required' => 0, |
1090 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1090 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1091 | 1091 | 'QST_desc' => 'The registrant\'s city', |
1092 | - 'QST_html_name' => 'city-' . $timestamp, |
|
1093 | - 'QST_html_id' => 'city-' . $timestamp, |
|
1092 | + 'QST_html_name' => 'city-'.$timestamp, |
|
1093 | + 'QST_html_id' => 'city-'.$timestamp, |
|
1094 | 1094 | 'QST_html_class' => 'city', |
1095 | - 'QST_html_label_id' => 'city-' . $timestamp . '-lbl', |
|
1095 | + 'QST_html_label_id' => 'city-'.$timestamp.'-lbl', |
|
1096 | 1096 | 'QST_html_label_class' => 'city-lbl', |
1097 | 1097 | 'QST_default_value' => '', |
1098 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1098 | + 'QST_validation_strategies' => array('required' => ''), |
|
1099 | 1099 | 'QST_validation_message' => '', |
1100 | 1100 | 'QST_order' => 6, |
1101 | 1101 | 'QST_admin_only' => 0, |
@@ -1109,22 +1109,22 @@ discard block |
||
1109 | 1109 | |
1110 | 1110 | case 'state': |
1111 | 1111 | $QST_values = array( |
1112 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1113 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1114 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1115 | - 'QST_identifier' => 'state-' . $timestamp, |
|
1112 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1113 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1114 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1115 | + 'QST_identifier' => 'state-'.$timestamp, |
|
1116 | 1116 | 'QST_system' => 'state', |
1117 | 1117 | 'QST_type' => 'STATE', |
1118 | 1118 | 'QST_required' => 0, |
1119 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1119 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1120 | 1120 | 'QST_desc' => 'The registrant\'s state/province', |
1121 | - 'QST_html_name' => 'state-' . $timestamp, |
|
1122 | - 'QST_html_id' => 'state-' . $timestamp, |
|
1121 | + 'QST_html_name' => 'state-'.$timestamp, |
|
1122 | + 'QST_html_id' => 'state-'.$timestamp, |
|
1123 | 1123 | 'QST_html_class' => 'state', |
1124 | - 'QST_html_label_id' => 'state-' . $timestamp . '-lbl', |
|
1124 | + 'QST_html_label_id' => 'state-'.$timestamp.'-lbl', |
|
1125 | 1125 | 'QST_html_label_class' => 'state-lbl', |
1126 | 1126 | 'QST_default_value' => '', |
1127 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1127 | + 'QST_validation_strategies' => array('required' => ''), |
|
1128 | 1128 | 'QST_validation_message' => '', |
1129 | 1129 | 'QST_order' => 7, |
1130 | 1130 | 'QST_admin_only' => 0, |
@@ -1135,22 +1135,22 @@ discard block |
||
1135 | 1135 | |
1136 | 1136 | case 'country' : |
1137 | 1137 | $QST_values = array( |
1138 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1139 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1140 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1141 | - 'QST_identifier' => 'country-' . $timestamp, |
|
1138 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1139 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1140 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1141 | + 'QST_identifier' => 'country-'.$timestamp, |
|
1142 | 1142 | 'QST_system' => 'country', |
1143 | 1143 | 'QST_type' => 'COUNTRY', |
1144 | 1144 | 'QST_required' => 0, |
1145 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1145 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1146 | 1146 | 'QST_desc' => 'The registrant\'s country', |
1147 | - 'QST_html_name' => 'country-' . $timestamp, |
|
1148 | - 'QST_html_id' => 'country-' . $timestamp, |
|
1147 | + 'QST_html_name' => 'country-'.$timestamp, |
|
1148 | + 'QST_html_id' => 'country-'.$timestamp, |
|
1149 | 1149 | 'QST_html_class' => 'country', |
1150 | - 'QST_html_label_id' => 'country-' . $timestamp . '-lbl', |
|
1150 | + 'QST_html_label_id' => 'country-'.$timestamp.'-lbl', |
|
1151 | 1151 | 'QST_html_label_class' => 'country-lbl', |
1152 | 1152 | 'QST_default_value' => '', |
1153 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1153 | + 'QST_validation_strategies' => array('required' => ''), |
|
1154 | 1154 | 'QST_validation_message' => '', |
1155 | 1155 | 'QST_order' => 8, |
1156 | 1156 | 'QST_admin_only' => 0, |
@@ -1161,22 +1161,22 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | case 'zip': |
1163 | 1163 | $QST_values = array( |
1164 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1165 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1166 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1167 | - 'QST_identifier' => 'zip-' . $timestamp, |
|
1164 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1165 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1166 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1167 | + 'QST_identifier' => 'zip-'.$timestamp, |
|
1168 | 1168 | 'QST_system' => 'zip', |
1169 | 1169 | 'QST_type' => 'TEXT', |
1170 | 1170 | 'QST_required' => 0, |
1171 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1171 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1172 | 1172 | 'QST_desc' => 'The registrant\'s zip/postal code', |
1173 | - 'QST_html_name' => 'zip-' . $timestamp, |
|
1174 | - 'QST_html_id' => 'zip-' . $timestamp, |
|
1173 | + 'QST_html_name' => 'zip-'.$timestamp, |
|
1174 | + 'QST_html_id' => 'zip-'.$timestamp, |
|
1175 | 1175 | 'QST_html_class' => 'zip', |
1176 | - 'QST_html_label_id' => 'zip-' . $timestamp . '-lbl', |
|
1176 | + 'QST_html_label_id' => 'zip-'.$timestamp.'-lbl', |
|
1177 | 1177 | 'QST_html_label_class' => 'zip-lbl', |
1178 | 1178 | 'QST_default_value' => '', |
1179 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1179 | + 'QST_validation_strategies' => array('required' => ''), |
|
1180 | 1180 | 'QST_validation_message' => '', |
1181 | 1181 | 'QST_order' => 9, |
1182 | 1182 | 'QST_admin_only' => 0, |
@@ -1190,22 +1190,22 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | case 'phone': |
1192 | 1192 | $QST_values = array( |
1193 | - 'QSG_ID' => $QSG_IDs[ EEM_Question_Group::system_address ], |
|
1194 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1195 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1196 | - 'QST_identifier' => 'phone-' . $timestamp, |
|
1193 | + 'QSG_ID' => $QSG_IDs[EEM_Question_Group::system_address], |
|
1194 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1195 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1196 | + 'QST_identifier' => 'phone-'.$timestamp, |
|
1197 | 1197 | 'QST_system' => 'phone', |
1198 | 1198 | 'QST_type' => 'TEXT', |
1199 | 1199 | 'QST_required' => 0, |
1200 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1200 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1201 | 1201 | 'QST_desc' => 'The registrant\'s phone number', |
1202 | - 'QST_html_name' => 'phone-' . $timestamp, |
|
1203 | - 'QST_html_id' => 'phone-' . $timestamp, |
|
1202 | + 'QST_html_name' => 'phone-'.$timestamp, |
|
1203 | + 'QST_html_id' => 'phone-'.$timestamp, |
|
1204 | 1204 | 'QST_html_class' => 'phone', |
1205 | - 'QST_html_label_id' => 'phone-' . $timestamp . '-lbl', |
|
1205 | + 'QST_html_label_id' => 'phone-'.$timestamp.'-lbl', |
|
1206 | 1206 | 'QST_html_label_class' => 'phone-lbl', |
1207 | 1207 | 'QST_default_value' => '', |
1208 | - 'QST_validation_strategies' => array( 'required' => '' ), |
|
1208 | + 'QST_validation_strategies' => array('required' => ''), |
|
1209 | 1209 | 'QST_validation_message' => '', |
1210 | 1210 | 'QST_order' => 10, |
1211 | 1211 | 'QST_admin_only' => 0, |
@@ -1218,12 +1218,12 @@ discard block |
||
1218 | 1218 | break; |
1219 | 1219 | |
1220 | 1220 | } |
1221 | - if ( ! empty( $QST_values )) { |
|
1221 | + if ( ! empty($QST_values)) { |
|
1222 | 1222 | // insert system question |
1223 | 1223 | $wpdb->insert( |
1224 | 1224 | $table_name, |
1225 | 1225 | $QST_values, |
1226 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1226 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1227 | 1227 | ); |
1228 | 1228 | } |
1229 | 1229 | } |
@@ -1237,11 +1237,11 @@ discard block |
||
1237 | 1237 | * |
1238 | 1238 | * @throws \EE_Error |
1239 | 1239 | */ |
1240 | - public static function insert_default_payment_methods(){ |
|
1241 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1242 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1243 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1244 | - }else{ |
|
1240 | + public static function insert_default_payment_methods() { |
|
1241 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1242 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1243 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1244 | + } else { |
|
1245 | 1245 | EEM_Payment_Method::instance()->verify_button_urls(); |
1246 | 1246 | } |
1247 | 1247 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | |
1258 | 1258 | global $wpdb; |
1259 | 1259 | |
1260 | - if ( \EEH_Activation::getTableAnalysis()->tableExists( EEM_Status::instance()->table() ) ) { |
|
1260 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1261 | 1261 | |
1262 | 1262 | $table_name = EEM_Status::instance()->table(); |
1263 | 1263 | |
@@ -1333,33 +1333,33 @@ discard block |
||
1333 | 1333 | $folders = array( |
1334 | 1334 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1335 | 1335 | EVENT_ESPRESSO_GATEWAY_DIR, |
1336 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1337 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1338 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1336 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1337 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1338 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1339 | 1339 | ); |
1340 | - foreach ( $folders as $folder ) { |
|
1340 | + foreach ($folders as $folder) { |
|
1341 | 1341 | try { |
1342 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1343 | - @ chmod( $folder, 0755 ); |
|
1344 | - } catch( EE_Error $e ){ |
|
1342 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1343 | + @ chmod($folder, 0755); |
|
1344 | + } catch (EE_Error $e) { |
|
1345 | 1345 | EE_Error::add_error( |
1346 | 1346 | sprintf( |
1347 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1347 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1348 | 1348 | $folder, |
1349 | - '<br />' . $e->getMessage() |
|
1349 | + '<br />'.$e->getMessage() |
|
1350 | 1350 | ), |
1351 | 1351 | __FILE__, __FUNCTION__, __LINE__ |
1352 | 1352 | ); |
1353 | 1353 | //indicate we'll need to fix this later |
1354 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1354 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1355 | 1355 | return FALSE; |
1356 | 1356 | } |
1357 | 1357 | } |
1358 | 1358 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1359 | 1359 | //is disabled, there might be activation errors recorded in there |
1360 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1360 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1361 | 1361 | //remember EE's folders are all good |
1362 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1362 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1363 | 1363 | return TRUE; |
1364 | 1364 | } |
1365 | 1365 | |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | * @return boolean |
1373 | 1373 | */ |
1374 | 1374 | public static function upload_directories_incomplete() { |
1375 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1375 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | */ |
1390 | 1390 | public static function generate_default_message_templates() { |
1391 | 1391 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1392 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1392 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1393 | 1393 | /* |
1394 | 1394 | * This first method is taking care of ensuring any default messengers |
1395 | 1395 | * that should be made active and have templates generated are done. |
@@ -1425,22 +1425,22 @@ discard block |
||
1425 | 1425 | $active_messengers = $message_resource_manager->active_messengers(); |
1426 | 1426 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1427 | 1427 | $templates_created = false; |
1428 | - foreach ( $active_messengers as $active_messenger ) { |
|
1428 | + foreach ($active_messengers as $active_messenger) { |
|
1429 | 1429 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1430 | 1430 | $default_message_type_names_to_activate = array(); |
1431 | 1431 | // looping through each default message type reported by the messenger |
1432 | 1432 | // and setup the actual message types to activate. |
1433 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1433 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1434 | 1434 | // if already active or has already been activated before we skip |
1435 | 1435 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1436 | 1436 | // we also skip if the message type is not installed. |
1437 | 1437 | if ( |
1438 | - $message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name ) |
|
1438 | + $message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name) |
|
1439 | 1439 | || $message_resource_manager->is_message_type_active_for_messenger( |
1440 | 1440 | $active_messenger->name, |
1441 | 1441 | $default_message_type_name_for_messenger |
1442 | 1442 | ) |
1443 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1443 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1444 | 1444 | ) { |
1445 | 1445 | continue; |
1446 | 1446 | } |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | false |
1454 | 1454 | ); |
1455 | 1455 | //activate the templates for these message types |
1456 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1456 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1457 | 1457 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1458 | 1458 | $active_messenger->name, |
1459 | 1459 | $default_message_type_names_for_messenger, |
@@ -1480,18 +1480,18 @@ discard block |
||
1480 | 1480 | EE_Message_Resource_Manager $message_resource_manager |
1481 | 1481 | ) { |
1482 | 1482 | /** @type EE_messenger[] $messengers_to_generate */ |
1483 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1483 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1484 | 1484 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1485 | 1485 | $templates_generated = false; |
1486 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1486 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1487 | 1487 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1488 | 1488 | //verify the default message types match an installed message type. |
1489 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1489 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1490 | 1490 | if ( |
1491 | - ! isset( $installed_message_types[ $name ] ) |
|
1492 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name ) |
|
1491 | + ! isset($installed_message_types[$name]) |
|
1492 | + || $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name) |
|
1493 | 1493 | ) { |
1494 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1494 | + unset($default_message_type_names_for_messenger[$key]); |
|
1495 | 1495 | } |
1496 | 1496 | } |
1497 | 1497 | // in previous iterations, the active_messengers option in the db |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | false |
1506 | 1506 | ); |
1507 | 1507 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1508 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1508 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1509 | 1509 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1510 | 1510 | $messenger_to_generate->name, |
1511 | 1511 | $default_message_type_names_for_messenger, |
@@ -1537,18 +1537,18 @@ discard block |
||
1537 | 1537 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1538 | 1538 | |
1539 | 1539 | $messengers_to_generate = array(); |
1540 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1540 | + foreach ($installed_messengers as $installed_messenger) { |
|
1541 | 1541 | //if installed messenger is a messenger that should be activated on install |
1542 | 1542 | //and is not already active |
1543 | 1543 | //and has never been activated |
1544 | 1544 | if ( |
1545 | 1545 | ! $installed_messenger->activate_on_install |
1546 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1547 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1546 | + || isset($active_messengers[$installed_messenger->name]) |
|
1547 | + || isset($has_activated[$installed_messenger->name]) |
|
1548 | 1548 | ) { |
1549 | 1549 | continue; |
1550 | 1550 | } |
1551 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1551 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1552 | 1552 | } |
1553 | 1553 | return $messengers_to_generate; |
1554 | 1554 | } |
@@ -1573,9 +1573,9 @@ discard block |
||
1573 | 1573 | */ |
1574 | 1574 | public static function validate_messages_system() { |
1575 | 1575 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1576 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1576 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1577 | 1577 | $message_resource_manager->validate_active_message_types_are_installed(); |
1578 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1578 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | |
@@ -1588,12 +1588,12 @@ discard block |
||
1588 | 1588 | * @static |
1589 | 1589 | * @return void |
1590 | 1590 | */ |
1591 | - public static function create_no_ticket_prices_array(){ |
|
1591 | + public static function create_no_ticket_prices_array() { |
|
1592 | 1592 | // this creates an array for tracking events that have no active ticket prices created |
1593 | 1593 | // this allows us to warn admins of the situation so that it can be corrected |
1594 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1595 | - if ( ! $espresso_no_ticket_prices ) { |
|
1596 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1594 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1595 | + if ( ! $espresso_no_ticket_prices) { |
|
1596 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1597 | 1597 | } |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1618,24 +1618,24 @@ discard block |
||
1618 | 1618 | * @global wpdb $wpdb |
1619 | 1619 | * @throws \EE_Error |
1620 | 1620 | */ |
1621 | - public static function delete_all_espresso_cpt_data(){ |
|
1621 | + public static function delete_all_espresso_cpt_data() { |
|
1622 | 1622 | global $wpdb; |
1623 | 1623 | //get all the CPT post_types |
1624 | 1624 | $ee_post_types = array(); |
1625 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1626 | - if ( method_exists( $model_name, 'instance' )) { |
|
1627 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1628 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1629 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1625 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1626 | + if (method_exists($model_name, 'instance')) { |
|
1627 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1628 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1629 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1630 | 1630 | } |
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | //get all our CPTs |
1634 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1634 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1635 | 1635 | $cpt_ids = $wpdb->get_col($query); |
1636 | 1636 | //delete each post meta and term relations too |
1637 | - foreach($cpt_ids as $post_id){ |
|
1638 | - wp_delete_post($post_id,true); |
|
1637 | + foreach ($cpt_ids as $post_id) { |
|
1638 | + wp_delete_post($post_id, true); |
|
1639 | 1639 | } |
1640 | 1640 | } |
1641 | 1641 | |
@@ -1647,12 +1647,12 @@ discard block |
||
1647 | 1647 | public static function drop_espresso_tables() { |
1648 | 1648 | $tables = array(); |
1649 | 1649 | // load registry |
1650 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1651 | - if ( method_exists( $model_name, 'instance' )) { |
|
1652 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1653 | - if ( $model_obj instanceof EEM_Base ) { |
|
1654 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1655 | - if ( strpos( $table->get_table_name(), 'esp_' ) |
|
1650 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1651 | + if (method_exists($model_name, 'instance')) { |
|
1652 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1653 | + if ($model_obj instanceof EEM_Base) { |
|
1654 | + foreach ($model_obj->get_tables() as $table) { |
|
1655 | + if (strpos($table->get_table_name(), 'esp_') |
|
1656 | 1656 | && |
1657 | 1657 | ( |
1658 | 1658 | is_main_site()//main site? nuke them all |
@@ -1675,10 +1675,10 @@ discard block |
||
1675 | 1675 | 'esp_promotion_rule', |
1676 | 1676 | 'esp_rule' |
1677 | 1677 | ); |
1678 | - foreach( $tables_without_models as $table ){ |
|
1678 | + foreach ($tables_without_models as $table) { |
|
1679 | 1679 | $tables[] = $table; |
1680 | 1680 | } |
1681 | - return \EEH_Activation::getTableManager()->dropTables( $tables ); |
|
1681 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | /** |
@@ -1690,8 +1690,8 @@ discard block |
||
1690 | 1690 | * @param array $table_names |
1691 | 1691 | * @return array of table names which we deleted |
1692 | 1692 | */ |
1693 | - public static function drop_tables( $table_names ) { |
|
1694 | - return \EEH_Activation::getTableManager()->dropTables( $table_names ); |
|
1693 | + public static function drop_tables($table_names) { |
|
1694 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1695 | 1695 | } |
1696 | 1696 | /** |
1697 | 1697 | * plugin_uninstall |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | * @param bool $remove_all |
1702 | 1702 | * @return void |
1703 | 1703 | */ |
1704 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1704 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1705 | 1705 | global $wpdb; |
1706 | 1706 | self::drop_espresso_tables(); |
1707 | 1707 | |
@@ -1739,50 +1739,50 @@ discard block |
||
1739 | 1739 | 'ee_job_parameters_' => false, |
1740 | 1740 | 'ee_upload_directories_incomplete' => true, |
1741 | 1741 | ); |
1742 | - if( is_main_site() ) { |
|
1743 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1742 | + if (is_main_site()) { |
|
1743 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | $undeleted_options = array(); |
1747 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1747 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1748 | 1748 | |
1749 | - if( $no_wildcard ){ |
|
1750 | - if( ! delete_option( $option_name ) ){ |
|
1749 | + if ($no_wildcard) { |
|
1750 | + if ( ! delete_option($option_name)) { |
|
1751 | 1751 | $undeleted_options[] = $option_name; |
1752 | 1752 | } |
1753 | - }else{ |
|
1754 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1755 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1756 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1753 | + } else { |
|
1754 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1755 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1756 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1757 | 1757 | $undeleted_options[] = $option_name_from_wildcard; |
1758 | 1758 | } |
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | } |
1762 | 1762 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1763 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1763 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1764 | 1764 | |
1765 | - if ( $remove_all && $espresso_db_update = (array) get_option( 'espresso_db_update' )) { |
|
1765 | + if ($remove_all && $espresso_db_update = (array) get_option('espresso_db_update')) { |
|
1766 | 1766 | $db_update_sans_ee4 = array(); |
1767 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1768 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1767 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1768 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1769 | 1769 | $db_update_sans_ee4[$version] = $times_activated; |
1770 | 1770 | } |
1771 | 1771 | } |
1772 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1772 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1773 | 1773 | } |
1774 | 1774 | |
1775 | 1775 | $errors = ''; |
1776 | - if ( ! empty( $undeleted_options )) { |
|
1776 | + if ( ! empty($undeleted_options)) { |
|
1777 | 1777 | $errors .= sprintf( |
1778 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1778 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1779 | 1779 | '<br/>', |
1780 | - implode( ',<br/>', $undeleted_options ) |
|
1780 | + implode(',<br/>', $undeleted_options) |
|
1781 | 1781 | ); |
1782 | 1782 | |
1783 | 1783 | } |
1784 | - if ( ! empty( $errors ) ) { |
|
1785 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1784 | + if ( ! empty($errors)) { |
|
1785 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1786 | 1786 | } |
1787 | 1787 | } |
1788 | 1788 | |
@@ -1792,10 +1792,10 @@ discard block |
||
1792 | 1792 | */ |
1793 | 1793 | public static function last_wpdb_error_code() { |
1794 | 1794 | global $wpdb; |
1795 | - if( $wpdb->use_mysqli ) { |
|
1796 | - return mysqli_errno( $wpdb->dbh ); |
|
1795 | + if ($wpdb->use_mysqli) { |
|
1796 | + return mysqli_errno($wpdb->dbh); |
|
1797 | 1797 | } else { |
1798 | - return mysql_errno( $wpdb->dbh ); |
|
1798 | + return mysql_errno($wpdb->dbh); |
|
1799 | 1799 | } |
1800 | 1800 | } |
1801 | 1801 | |
@@ -1806,14 +1806,14 @@ discard block |
||
1806 | 1806 | * @param string $table_name with or without $wpdb->prefix |
1807 | 1807 | * @return boolean |
1808 | 1808 | */ |
1809 | - public static function table_exists( $table_name ){ |
|
1810 | - return \EEH_Activation::getTableAnalysis()->tableExists( $table_name ); |
|
1809 | + public static function table_exists($table_name) { |
|
1810 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1811 | 1811 | } |
1812 | 1812 | |
1813 | 1813 | /** |
1814 | 1814 | * Resets the cache on EEH_Activation |
1815 | 1815 | */ |
1816 | - public static function reset(){ |
|
1816 | + public static function reset() { |
|
1817 | 1817 | self::$_default_creator_id = NULL; |
1818 | 1818 | self::$_initialized_db_content_already_in_this_request = false; |
1819 | 1819 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | public function __construct() { |
44 | 44 | //set properties |
45 | 45 | $this->name = 'html'; |
46 | - $this->description = __( 'This messenger outputs a message to a browser for display.', 'event_espresso' ); |
|
46 | + $this->description = __('This messenger outputs a message to a browser for display.', 'event_espresso'); |
|
47 | 47 | $this->label = array( |
48 | - 'singular' => __( 'html', 'event_espresso' ), |
|
49 | - 'plural' => __( 'html', 'event_espresso' ), |
|
48 | + 'singular' => __('html', 'event_espresso'), |
|
49 | + 'plural' => __('html', 'event_espresso'), |
|
50 | 50 | ); |
51 | 51 | $this->activate_on_install = true; |
52 | 52 | // add the "powered by EE" credit link to the HTML receipt and invoice |
53 | 53 | add_filter( |
54 | 54 | 'FHEE__EE_Html_messenger___send_message__main_body', |
55 | - array( $this, 'add_powered_by_credit_link_to_receipt_and_invoice' ), |
|
55 | + array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'), |
|
56 | 56 | 10, |
57 | 57 | 3 |
58 | 58 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @see abstract declaration in EE_messenger for details. |
92 | 92 | */ |
93 | 93 | protected function _set_admin_pages() { |
94 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
94 | + $this->admin_registered_pages = array('events_edit' => true); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | protected function _set_validator_config() { |
112 | 112 | $this->_validator_config = array( |
113 | 113 | 'subject' => array( |
114 | - 'shortcodes' => array( 'organization', 'primary_registration_details', 'email', 'transaction' ), |
|
114 | + 'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'), |
|
115 | 115 | ), |
116 | 116 | 'content' => array( |
117 | 117 | 'shortcodes' => array( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'primary_registration_list', |
138 | 138 | 'event_author', |
139 | 139 | ), |
140 | - 'required' => array( '[EVENT_LIST]' ), |
|
140 | + 'required' => array('[EVENT_LIST]'), |
|
141 | 141 | ), |
142 | 142 | 'ticket_list' => array( |
143 | 143 | 'shortcodes' => array( |
@@ -148,39 +148,39 @@ discard block |
||
148 | 148 | 'line_item_list', |
149 | 149 | 'venue', |
150 | 150 | ), |
151 | - 'required' => array( '[TICKET_LIST]' ), |
|
151 | + 'required' => array('[TICKET_LIST]'), |
|
152 | 152 | ), |
153 | 153 | 'ticket_line_item_no_pms' => array( |
154 | - 'shortcodes' => array( 'line_item', 'ticket' ), |
|
155 | - 'required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
154 | + 'shortcodes' => array('line_item', 'ticket'), |
|
155 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
156 | 156 | ), |
157 | 157 | 'ticket_line_item_pms' => array( |
158 | - 'shortcodes' => array( 'line_item', 'ticket', 'line_item_list' ), |
|
159 | - 'required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
158 | + 'shortcodes' => array('line_item', 'ticket', 'line_item_list'), |
|
159 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
160 | 160 | ), |
161 | 161 | 'price_modifier_line_item_list' => array( |
162 | - 'shortcodes' => array( 'line_item' ), |
|
163 | - 'required' => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ), |
|
162 | + 'shortcodes' => array('line_item'), |
|
163 | + 'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
164 | 164 | ), |
165 | 165 | 'datetime_list' => array( |
166 | - 'shortcodes' => array( 'datetime' ), |
|
167 | - 'required' => array( '[DATETIME_LIST]' ), |
|
166 | + 'shortcodes' => array('datetime'), |
|
167 | + 'required' => array('[DATETIME_LIST]'), |
|
168 | 168 | ), |
169 | 169 | 'attendee_list' => array( |
170 | - 'shortcodes' => array( 'attendee' ), |
|
171 | - 'required' => array( '[ATTENDEE_LIST]' ), |
|
170 | + 'shortcodes' => array('attendee'), |
|
171 | + 'required' => array('[ATTENDEE_LIST]'), |
|
172 | 172 | ), |
173 | 173 | 'tax_line_item_list' => array( |
174 | - 'shortcodes' => array( 'line_item' ), |
|
175 | - 'required' => array( '[TAX_LINE_ITEM_LIST]' ), |
|
174 | + 'shortcodes' => array('line_item'), |
|
175 | + 'required' => array('[TAX_LINE_ITEM_LIST]'), |
|
176 | 176 | ), |
177 | 177 | 'additional_line_item_list' => array( |
178 | - 'shortcodes' => array( 'line_item' ), |
|
179 | - 'required' => array( '[ADDITIONAL_LINE_ITEM_LIST]' ), |
|
178 | + 'shortcodes' => array('line_item'), |
|
179 | + 'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
180 | 180 | ), |
181 | 181 | 'payment_list' => array( |
182 | - 'shortcodes' => array( 'payment' ), |
|
183 | - 'required' => array( '[PAYMENT_LIST_*]' ), |
|
182 | + 'shortcodes' => array('payment'), |
|
183 | + 'required' => array('[PAYMENT_LIST_*]'), |
|
184 | 184 | ), |
185 | 185 | ); |
186 | 186 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed. |
197 | 197 | * @return void |
198 | 198 | */ |
199 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
200 | - if ( $sending_messenger_name = 'pdf' ) { |
|
201 | - add_filter( 'EE_messenger__get_variation__variation', array( $this, 'add_html_css' ), 10, 8 ); |
|
199 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
200 | + if ($sending_messenger_name = 'pdf') { |
|
201 | + add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function enqueue_scripts_styles() { |
249 | 249 | parent::enqueue_scripts_styles(); |
250 | - do_action( 'AHEE__EE_Html_messenger__enqueue_scripts_styles' ); |
|
250 | + do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->_template_fields = array( |
276 | 276 | 'subject' => array( |
277 | 277 | 'input' => 'text', |
278 | - 'label' => __( 'Page Title', 'event_espresso' ), |
|
278 | + 'label' => __('Page Title', 'event_espresso'), |
|
279 | 279 | 'type' => 'string', |
280 | 280 | 'required' => true, |
281 | 281 | 'validation' => true, |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | 'content' => array( |
289 | 289 | 'main' => array( |
290 | 290 | 'input' => 'wp_editor', |
291 | - 'label' => __( 'Main Content', 'event_espresso' ), |
|
291 | + 'label' => __('Main Content', 'event_espresso'), |
|
292 | 292 | 'type' => 'string', |
293 | 293 | 'required' => true, |
294 | 294 | 'validation' => true, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'validation' => true, |
304 | 304 | 'format' => '%s', |
305 | 305 | 'rows' => '15', |
306 | - 'shortcodes_required' => array( '[EVENT_LIST]' ), |
|
306 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
307 | 307 | ), |
308 | 308 | 'ticket_list' => array( |
309 | 309 | 'input' => 'textarea', |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | 'format' => '%s', |
315 | 315 | 'css_class' => 'large-text', |
316 | 316 | 'rows' => '10', |
317 | - 'shortcodes_required' => array( '[TICKET_LIST]' ), |
|
317 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
318 | 318 | ), |
319 | 319 | 'ticket_line_item_no_pms' => array( |
320 | 320 | 'input' => 'textarea', |
321 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
321 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
322 | 322 | 'Ticket Line Item List with no Price Modifiers', |
323 | 323 | 'event_espresso' |
324 | 324 | ), |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | 'format' => '%s', |
329 | 329 | 'css_class' => 'large-text', |
330 | 330 | 'rows' => '5', |
331 | - 'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
331 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
332 | 332 | ), |
333 | 333 | 'ticket_line_item_pms' => array( |
334 | 334 | 'input' => 'textarea', |
335 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
335 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
336 | 336 | 'Ticket Line Item List with Price Modifiers', |
337 | 337 | 'event_espresso' |
338 | 338 | ), |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | 'format' => '%s', |
343 | 343 | 'css_class' => 'large-text', |
344 | 344 | 'rows' => '5', |
345 | - 'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
345 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
346 | 346 | ), |
347 | 347 | 'price_modifier_line_item_list' => array( |
348 | 348 | 'input' => 'textarea', |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | 'format' => '%s', |
354 | 354 | 'css_class' => 'large-text', |
355 | 355 | 'rows' => '5', |
356 | - 'shortcodes_required' => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ), |
|
356 | + 'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
357 | 357 | ), |
358 | 358 | 'datetime_list' => array( |
359 | 359 | 'input' => 'textarea', |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | 'format' => '%s', |
365 | 365 | 'css_class' => 'large-text', |
366 | 366 | 'rows' => '5', |
367 | - 'shortcodes_required' => array( '[DATETIME_LIST]' ), |
|
367 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
368 | 368 | ), |
369 | 369 | 'attendee_list' => array( |
370 | 370 | 'input' => 'textarea', |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | 'format' => '%s', |
376 | 376 | 'css_class' => 'large-text', |
377 | 377 | 'rows' => '5', |
378 | - 'shortcodes_required' => array( '[ATTENDEE_LIST]' ), |
|
378 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
379 | 379 | ), |
380 | 380 | 'tax_line_item_list' => array( |
381 | 381 | 'input' => 'textarea', |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'format' => '%s', |
387 | 387 | 'css_class' => 'large-text', |
388 | 388 | 'rows' => '5', |
389 | - 'shortcodes_required' => array( '[TAX_LINE_ITEM_LIST]' ), |
|
389 | + 'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'), |
|
390 | 390 | ), |
391 | 391 | 'additional_line_item_list' => array( |
392 | 392 | 'input' => 'textarea', |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | 'format' => '%s', |
398 | 398 | 'css_class' => 'large-text', |
399 | 399 | 'rows' => '5', |
400 | - 'shortcodes_required' => array( '[ADDITIONAL_LINE_ITEM_LIST]' ), |
|
400 | + 'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
401 | 401 | ), |
402 | 402 | 'payment_list' => array( |
403 | 403 | 'input' => 'textarea', |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'format' => '%s', |
409 | 409 | 'css_class' => 'large-text', |
410 | 410 | 'rows' => '5', |
411 | - 'shortcodes_required' => array( '[PAYMENT_LIST_*]' ), |
|
411 | + 'shortcodes_required' => array('[PAYMENT_LIST_*]'), |
|
412 | 412 | ), |
413 | 413 | ), |
414 | 414 | ), |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @since 4.5.0 |
423 | 423 | */ |
424 | 424 | protected function _set_default_message_types() { |
425 | - $this->_default_message_types = array( 'receipt', 'invoice' ); |
|
425 | + $this->_default_message_types = array('receipt', 'invoice'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @since 4.5.0 |
433 | 433 | */ |
434 | 434 | protected function _set_valid_message_types() { |
435 | - $this->_valid_message_types = array( 'receipt', 'invoice' ); |
|
435 | + $this->_valid_message_types = array('receipt', 'invoice'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | protected function _send_message() { |
447 | 447 | $this->_template_args = array( |
448 | - 'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8" ), |
|
448 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
449 | 449 | 'base_css' => $this->get_variation( |
450 | 450 | $this->_tmp_pack, |
451 | 451 | $this->_incoming_message_type->name, |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | ), |
484 | 484 | ); |
485 | 485 | $this->_deregister_wp_hooks(); |
486 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
486 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
487 | 487 | echo $this->_get_main_template(); |
488 | 488 | exit(); |
489 | 489 | } |
@@ -499,16 +499,16 @@ discard block |
||
499 | 499 | * @return void |
500 | 500 | */ |
501 | 501 | protected function _deregister_wp_hooks() { |
502 | - remove_all_actions( 'wp_head' ); |
|
503 | - remove_all_actions( 'wp_footer' ); |
|
504 | - remove_all_actions( 'wp_print_footer_scripts' ); |
|
505 | - remove_all_actions( 'wp_enqueue_scripts' ); |
|
502 | + remove_all_actions('wp_head'); |
|
503 | + remove_all_actions('wp_footer'); |
|
504 | + remove_all_actions('wp_print_footer_scripts'); |
|
505 | + remove_all_actions('wp_enqueue_scripts'); |
|
506 | 506 | global $wp_scripts, $wp_styles; |
507 | 507 | $wp_scripts = $wp_styles = array(); |
508 | 508 | //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
509 | - add_action( 'wp_footer', 'wp_print_footer_scripts' ); |
|
510 | - add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
511 | - add_action( 'wp_head', 'wp_enqueue_scripts' ); |
|
509 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
510 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
511 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | * @param bool $preview |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - protected function _get_main_template( $preview = false ) { |
|
524 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, 'main' ); |
|
523 | + protected function _get_main_template($preview = false) { |
|
524 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
525 | 525 | //include message type as a template arg |
526 | 526 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
527 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, true ); |
|
527 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | EE_message_type $incoming_message_type |
558 | 558 | ) { |
559 | 559 | if ( |
560 | - ( $incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt' ) |
|
561 | - && apply_filters( 'FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true ) |
|
560 | + ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
561 | + && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
562 | 562 | ) { |
563 | - $content .= \EEH_Template::powered_by_event_espresso( 'aln-cntr' ) . EEH_HTML::div( EEH_HTML::p(' ') ); |
|
563 | + $content .= \EEH_Template::powered_by_event_espresso('aln-cntr').EEH_HTML::div(EEH_HTML::p(' ')); |
|
564 | 564 | } |
565 | 565 | return $content; |
566 | 566 | } |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | * @param $class_file |
9 | 9 | * @return array |
10 | 10 | */ |
11 | -function espresso_invoice_template_files( $class_file) { |
|
11 | +function espresso_invoice_template_files($class_file) { |
|
12 | 12 | // read our template dir and build an array of files |
13 | - $dhandle = opendir(dirname($class_file) . '/lib/templates/css/'); //If the template files have been moved to the uploads folder |
|
13 | + $dhandle = opendir(dirname($class_file).'/lib/templates/css/'); //If the template files have been moved to the uploads folder |
|
14 | 14 | //} else return FALSE; |
15 | 15 | |
16 | 16 | $files = array(); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @param string $selected |
51 | 51 | * @return string |
52 | 52 | */ |
53 | -function espresso_invoice_is_selected( $input_item, $selected='') { |
|
54 | - if ( $input_item === $selected ) { |
|
53 | +function espresso_invoice_is_selected($input_item, $selected = '') { |
|
54 | + if ($input_item === $selected) { |
|
55 | 55 | return 'selected="selected"'; |
56 | 56 | } else { |
57 | 57 | return ''; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | use EventEspresso\core\services\database\TableManager; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | /** |
22 | 22 | */ |
23 | -class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base{ |
|
23 | +class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Returns whether or not this data migration script can operate on the given version of the database. |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_migration_stages = array(); |
52 | 52 | $this->_pretty_name = __("Fatal Uncatchable Error Occurred", "event_espresso"); |
53 | 53 | // dd($this); |
54 | - parent::__construct( $table_manager, $table_analysis ); |
|
54 | + parent::__construct($table_manager, $table_analysis); |
|
55 | 55 | } |
56 | 56 | public function migration_page_hooks() { |
57 | 57 |
@@ -35,12 +35,12 @@ |
||
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
38 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | - * @param string $column_name |
|
40 | - * @param string $column_info |
|
41 | - * @return bool|false|int |
|
42 | - */ |
|
43 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
38 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | + * @param string $column_name |
|
40 | + * @param string $column_info |
|
41 | + * @return bool|false|int |
|
42 | + */ |
|
43 | + public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
44 | 44 | { |
45 | 45 | if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
46 | 46 | return FALSE; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\database; |
3 | 3 | |
4 | -defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
4 | +defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class TableManager |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param TableAnalysis $TableAnalysis |
30 | 30 | */ |
31 | - public function __construct( TableAnalysis $TableAnalysis ) { |
|
31 | + public function __construct(TableAnalysis $TableAnalysis) { |
|
32 | 32 | $this->table_analysis = $TableAnalysis; |
33 | 33 | } |
34 | 34 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * @throws \EE_Error |
39 | 39 | */ |
40 | 40 | protected function getTableAnalysis() { |
41 | - if( $this->table_analysis instanceof TableAnalysis ) { |
|
41 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
42 | 42 | return $this->table_analysis; |
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | - get_class( $this ) |
|
46 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | + get_class($this) |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | } |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | * @param string $column_info |
59 | 59 | * @return bool|false|int |
60 | 60 | */ |
61 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
61 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
62 | 62 | { |
63 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
63 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
64 | 64 | return FALSE; |
65 | 65 | } |
66 | 66 | global $wpdb; |
67 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
67 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
68 | 68 | $columns = $this->getTableColumns($table_name); |
69 | - if( !in_array( $column_name, $columns)){ |
|
70 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
69 | + if ( ! in_array($column_name, $columns)) { |
|
70 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
71 | 71 | return $wpdb->query($alter_query); |
72 | 72 | } |
73 | 73 | return TRUE; |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param string $table_name |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function getTableColumns( $table_name ) |
|
83 | + public function getTableColumns($table_name) |
|
84 | 84 | { |
85 | 85 | global $wpdb; |
86 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
86 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | $fieldArray = array(); |
88 | - if ( ! empty( $table_name )) { |
|
88 | + if ( ! empty($table_name)) { |
|
89 | 89 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
90 | 90 | if ($columns !== FALSE) { |
91 | - foreach( $columns as $column ){ |
|
91 | + foreach ($columns as $column) { |
|
92 | 92 | $fieldArray[] = $column->Field; |
93 | 93 | } |
94 | 94 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * @param string $table_name |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function dropTable( $table_name ) |
|
107 | + public function dropTable($table_name) |
|
108 | 108 | { |
109 | 109 | global $wpdb; |
110 | - if ( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
111 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
112 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
110 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
111 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
112 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
113 | 113 | } |
114 | 114 | return 0; |
115 | 115 | } |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | * @param array $table_names |
123 | 123 | * @return array of table names which we deleted |
124 | 124 | */ |
125 | - public function dropTables( $table_names ) |
|
125 | + public function dropTables($table_names) |
|
126 | 126 | { |
127 | 127 | $tables_to_delete = array(); |
128 | - foreach( $table_names as $table_name ) { |
|
129 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
130 | - if( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
128 | + foreach ($table_names as $table_name) { |
|
129 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
130 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
131 | 131 | $tables_to_delete[] = $table_name; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | global $wpdb; |
135 | - $wpdb->query( 'DROP TABLE ' . implode( ', ', $tables_to_delete ) ); |
|
135 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
136 | 136 | return $tables_to_delete; |
137 | 137 | } |
138 | 138 | |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * @param string $indexName |
146 | 146 | * @return int |
147 | 147 | */ |
148 | - public function dropIndex( $table_name, $indexName ) |
|
148 | + public function dropIndex($table_name, $indexName) |
|
149 | 149 | { |
150 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
150 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
151 | 151 | return FALSE; |
152 | 152 | } |
153 | 153 | global $wpdb; |
154 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
154 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
155 | 155 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
156 | 156 | if ( |
157 | - $this->getTableAnalysis()->tableExists( $table_name ) |
|
158 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
157 | + $this->getTableAnalysis()->tableExists($table_name) |
|
158 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
159 | 159 | ) { |
160 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $indexName" ); |
|
160 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
161 | 161 | } |
162 | 162 | return 0; |
163 | 163 | } |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | * @return void |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - public function createTable( $table_name, $createSql, $engine = 'MyISAM' ) |
|
174 | + public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
175 | 175 | { |
176 | 176 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
177 | - if ( preg_match( '((((.*?))(,\s))+)', $createSql, $valid_column_data ) ) { |
|
178 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
177 | + if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
178 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
179 | 179 | $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
180 | 180 | /** @var \wpdb $wpdb */ |
181 | 181 | global $wpdb; |
182 | 182 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
183 | 183 | //happened. And then we can choose to tell the end user |
184 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
185 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
184 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
185 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
186 | 186 | ob_start(); |
187 | - dbDelta( $SQL ); |
|
187 | + dbDelta($SQL); |
|
188 | 188 | $output = ob_get_contents(); |
189 | 189 | ob_end_clean(); |
190 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
191 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
192 | - if( ! empty( $output ) ){ |
|
193 | - throw new \EE_Error( $output ); |
|
190 | + $wpdb->show_errors($old_show_errors_policy); |
|
191 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
192 | + if ( ! empty($output)) { |
|
193 | + throw new \EE_Error($output); |
|
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | throw new \EE_Error( |
197 | 197 | sprintf( |
198 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
198 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
199 | 199 | '<br />', |
200 | 200 | $createSql |
201 | 201 | ) |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * This class is used for generating EE_Message objects with given info. |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return EE_Messages_Queue The new queue for holding generated EE_Message objects. |
118 | 118 | */ |
119 | - public function generate( $save = true ) { |
|
119 | + public function generate($save = true) { |
|
120 | 120 | //iterate through the messages in the queue, generate, and add to new queue. |
121 | 121 | $this->_generation_queue->get_message_repository()->rewind(); |
122 | - while ( $this->_generation_queue->get_message_repository()->valid() ) { |
|
122 | + while ($this->_generation_queue->get_message_repository()->valid()) { |
|
123 | 123 | //reset "current" properties |
124 | 124 | $this->_reset_current_properties(); |
125 | 125 | |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | $this->_generation_queue->get_message_repository()->next(); |
134 | 134 | $next_msg = $this->_generation_queue->get_message_repository()->current(); |
135 | 135 | //restore pointer to current item |
136 | - $this->_generation_queue->get_message_repository()->set_current( $msg ); |
|
136 | + $this->_generation_queue->get_message_repository()->set_current($msg); |
|
137 | 137 | |
138 | 138 | //skip and delete if the current $msg is NOT incomplete (queued for generation) |
139 | - if ( $msg->STS_ID() !== EEM_Message::status_incomplete ) { |
|
139 | + if ($msg->STS_ID() !== EEM_Message::status_incomplete) { |
|
140 | 140 | //we keep this item in the db just remove from the repo. |
141 | - $this->_generation_queue->get_message_repository()->remove( $msg ); |
|
141 | + $this->_generation_queue->get_message_repository()->remove($msg); |
|
142 | 142 | //next item |
143 | - $this->_generation_queue->get_message_repository()->set_current( $next_msg ); |
|
143 | + $this->_generation_queue->get_message_repository()->set_current($next_msg); |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | - if ( $this->_verify() ) { |
|
147 | + if ($this->_verify()) { |
|
148 | 148 | //let's get generating! |
149 | 149 | $this->_generate(); |
150 | 150 | } |
@@ -155,28 +155,28 @@ discard block |
||
155 | 155 | && ! EEM_Message::debug() |
156 | 156 | ) { |
157 | 157 | $this->_generation_queue->get_message_repository()->delete(); |
158 | - $this->_generation_queue->get_message_repository()->set_current( $next_msg ); |
|
158 | + $this->_generation_queue->get_message_repository()->set_current($next_msg); |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | //if there are error messages then let's set the status and the error message. |
163 | - if ( $this->_error_msg ) { |
|
163 | + if ($this->_error_msg) { |
|
164 | 164 | //if the status is already debug only, then let's leave it at that. |
165 | - if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) { |
|
166 | - $msg->set_STS_ID( EEM_Message::status_failed ); |
|
165 | + if ($msg->STS_ID() !== EEM_Message::status_debug_only) { |
|
166 | + $msg->set_STS_ID(EEM_Message::status_failed); |
|
167 | 167 | } |
168 | 168 | $msg->set_error_message( |
169 | - __( 'Message failed to generate for the following reasons: ' ) |
|
169 | + __('Message failed to generate for the following reasons: ') |
|
170 | 170 | . "\n" |
171 | - . implode( "\n", $this->_error_msg ) |
|
171 | + . implode("\n", $this->_error_msg) |
|
172 | 172 | ); |
173 | - $msg->set_modified( time() ); |
|
173 | + $msg->set_modified(time()); |
|
174 | 174 | } else { |
175 | 175 | //remove from db |
176 | 176 | $this->_generation_queue->get_message_repository()->delete(); |
177 | 177 | } |
178 | 178 | //next item |
179 | - $this->_generation_queue->get_message_repository()->set_current( $next_msg ); |
|
179 | + $this->_generation_queue->get_message_repository()->set_current($next_msg); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | //generation queue is ALWAYS saved to record any errors in the generation process. |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * so a EE_Extra_Meta entry could be created and attached to the EE_Message. In those cases the save flag is |
190 | 190 | * irrelevant. |
191 | 191 | */ |
192 | - if ( $save ) { |
|
192 | + if ($save) { |
|
193 | 193 | $this->_ready_queue->save(); |
194 | 194 | } |
195 | 195 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | protected function _reset_current_properties() { |
208 | 208 | $this->_verified = false; |
209 | 209 | //make sure any _data value in the current message type is reset |
210 | - if ( $this->_current_message_type instanceof EE_message_type ) { |
|
210 | + if ($this->_current_message_type instanceof EE_message_type) { |
|
211 | 211 | $this->_current_message_type->reset_data(); |
212 | 212 | } |
213 | 213 | $this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function _generate() { |
228 | 228 | //double check verification has run and that everything is ready to work with (saves us having to validate everything again). |
229 | - if ( ! $this->_verified ) { |
|
229 | + if ( ! $this->_verified) { |
|
230 | 230 | return false; //get out because we don't have a valid setup to work with. |
231 | 231 | } |
232 | 232 | |
@@ -236,34 +236,34 @@ discard block |
||
236 | 236 | $this->_current_data_handler, |
237 | 237 | $this->_generation_queue->get_message_repository()->current()->context() |
238 | 238 | ); |
239 | - } catch ( EE_Error $e ) { |
|
239 | + } catch (EE_Error $e) { |
|
240 | 240 | $this->_error_msg[] = $e->getMessage(); |
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | |
244 | 244 | |
245 | 245 | //if no addressees then get out because there is nothing to generation (possible bad data). |
246 | - if ( ! $this->_valid_addressees( $addressees ) ) { |
|
247 | - $this->_generation_queue->get_message_repository()->current()->set_STS_ID( EEM_Message::status_debug_only ); |
|
248 | - $this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
249 | - Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' ); |
|
246 | + if ( ! $this->_valid_addressees($addressees)) { |
|
247 | + $this->_generation_queue->get_message_repository()->current()->set_STS_ID(EEM_Message::status_debug_only); |
|
248 | + $this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
249 | + Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso'); |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
253 | 253 | $message_template_group = $this->_get_message_template_group(); |
254 | 254 | |
255 | 255 | //in the unlikely event there is no EE_Message_Template_Group available, get out! |
256 | - if ( ! $message_template_group instanceof EE_Message_Template_Group ) { |
|
257 | - $this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso' ); |
|
256 | + if ( ! $message_template_group instanceof EE_Message_Template_Group) { |
|
257 | + $this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso'); |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | |
261 | 261 | //get formatted templates for using to parse and setup EE_Message objects. |
262 | - $templates = $this->_get_templates( $message_template_group ); |
|
262 | + $templates = $this->_get_templates($message_template_group); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | //setup new EE_Message objects (and add to _ready_queue) |
266 | - return $this->_assemble_messages( $addressees, $templates, $message_template_group ); |
|
266 | + return $this->_assemble_messages($addressees, $templates, $message_template_group); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -281,18 +281,18 @@ discard block |
||
281 | 281 | //so let's use that. |
282 | 282 | $GRP_ID = $this->_generation_queue->get_message_repository()->current()->GRP_ID(); |
283 | 283 | |
284 | - if ( $GRP_ID ) { |
|
284 | + if ($GRP_ID) { |
|
285 | 285 | //attempt to retrieve from repo first |
286 | - $GRP = $this->_template_collection->get_by_ID( $GRP_ID ); |
|
287 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
288 | - return $GRP; //got it! |
|
286 | + $GRP = $this->_template_collection->get_by_ID($GRP_ID); |
|
287 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
288 | + return $GRP; //got it! |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | //nope don't have it yet. Get from DB then add to repo if its not here, then that means the current GRP_ID |
292 | 292 | //is not valid, so we'll continue on in the code assuming there's NO GRP_ID. |
293 | - $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
294 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
295 | - $this->_template_collection->add( $GRP ); |
|
293 | + $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
294 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
295 | + $this->_template_collection->add($GRP); |
|
296 | 296 | return $GRP; |
297 | 297 | } |
298 | 298 | } |
@@ -311,41 +311,41 @@ discard block |
||
311 | 311 | //in vanilla EE we're assuming there's only one event. |
312 | 312 | //However, if there are multiple events then we'll just use the default templates instead of different |
313 | 313 | // templates per event (which could create problems). |
314 | - if ( count( $this->_current_data_handler->events ) === 1 ) { |
|
315 | - foreach ( $this->_current_data_handler->events as $event ) { |
|
314 | + if (count($this->_current_data_handler->events) === 1) { |
|
315 | + foreach ($this->_current_data_handler->events as $event) { |
|
316 | 316 | $EVT_ID = $event['ID']; |
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | 320 | //before going any further, let's see if its in the queue |
321 | - $GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) ); |
|
321 | + $GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID)); |
|
322 | 322 | |
323 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
323 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
324 | 324 | return $GRP; |
325 | 325 | } |
326 | 326 | |
327 | 327 | //nope still no GRP? |
328 | 328 | //first we get the global template in case it has an override set. |
329 | - $global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa ); |
|
330 | - $global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) ); |
|
329 | + $global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa); |
|
330 | + $global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa)); |
|
331 | 331 | |
332 | 332 | //if this is an override, then we just return it. |
333 | - if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) { |
|
334 | - $this->_template_collection->add( $global_GRP, $EVT_ID ); |
|
333 | + if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) { |
|
334 | + $this->_template_collection->add($global_GRP, $EVT_ID); |
|
335 | 335 | return $global_GRP; |
336 | 336 | } |
337 | 337 | |
338 | 338 | //STILL here? Okay that means we want to see if there is event specific group and if there is we return it, |
339 | 339 | //otherwise we return the global group we retrieved. |
340 | - if ( $EVT_ID ) { |
|
340 | + if ($EVT_ID) { |
|
341 | 341 | $template_qa['Event.EVT_ID'] = $EVT_ID; |
342 | 342 | } |
343 | 343 | |
344 | - $GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) ); |
|
344 | + $GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa)); |
|
345 | 345 | $GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP; |
346 | 346 | |
347 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
348 | - $this->_template_collection->add( $GRP, $EVT_ID ); |
|
347 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
348 | + $this->_template_collection->add($GRP, $EVT_ID); |
|
349 | 349 | return $GRP; |
350 | 350 | } |
351 | 351 | |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | * ) |
370 | 370 | * ) |
371 | 371 | */ |
372 | - protected function _get_templates( EE_Message_Template_Group $message_template_group ) { |
|
372 | + protected function _get_templates(EE_Message_Template_Group $message_template_group) { |
|
373 | 373 | $templates = array(); |
374 | 374 | $context_templates = $message_template_group->context_templates(); |
375 | - foreach ( $context_templates as $context => $template_fields ) { |
|
376 | - foreach ( $template_fields as $template_field => $template_obj ) { |
|
377 | - if ( ! $template_obj instanceof EE_Message_Template ) { |
|
375 | + foreach ($context_templates as $context => $template_fields) { |
|
376 | + foreach ($template_fields as $template_field => $template_obj) { |
|
377 | + if ( ! $template_obj instanceof EE_Message_Template) { |
|
378 | 378 | continue; |
379 | 379 | } |
380 | - $templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' ); |
|
380 | + $templates[$template_field][$context] = $template_obj->get('MTP_content'); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | return $templates; |
@@ -399,21 +399,21 @@ discard block |
||
399 | 399 | * get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added |
400 | 400 | * to the queue as EEM_Message::status_failed. Very rarely should "false" be returned from this method. |
401 | 401 | */ |
402 | - protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) { |
|
402 | + protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) { |
|
403 | 403 | |
404 | 404 | //if templates are empty then get out because we can't generate anything. |
405 | - if ( ! $templates ) { |
|
406 | - $this->_error_msg[] = __( 'Unable to assemble messages because there are no templates retrieved for generating the messages with', 'event_espresso' ); |
|
405 | + if ( ! $templates) { |
|
406 | + $this->_error_msg[] = __('Unable to assemble messages because there are no templates retrieved for generating the messages with', 'event_espresso'); |
|
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | 410 | //We use this as the counter for generated messages because don't forget we may be executing this inside of a |
411 | 411 | //generation_queue. So _ready_queue may have generated EE_Message objects already. |
412 | 412 | $generated_count = 0; |
413 | - foreach ( $addressees as $context => $recipients ) { |
|
414 | - foreach ( $recipients as $recipient ) { |
|
415 | - $message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group ); |
|
416 | - if ( $message instanceof EE_Message ) { |
|
413 | + foreach ($addressees as $context => $recipients) { |
|
414 | + foreach ($recipients as $recipient) { |
|
415 | + $message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group); |
|
416 | + if ($message instanceof EE_Message) { |
|
417 | 417 | $this->_ready_queue->add( |
418 | 418 | $message, |
419 | 419 | array(), |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | //if the current MSG being generated is for a test send then we'll only use ONE message in the generation. |
427 | - if ( $this->_generation_queue->get_message_repository()->is_test_send() ) { |
|
427 | + if ($this->_generation_queue->get_message_repository()->is_test_send()) { |
|
428 | 428 | break 2; |
429 | 429 | } |
430 | 430 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | ) { |
454 | 454 | //stuff we already know |
455 | 455 | $transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0; |
456 | - $transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction |
|
456 | + $transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction |
|
457 | 457 | ? $this->_current_data_handler->txn->ID() |
458 | 458 | : $transaction_id; |
459 | 459 | $message_fields = array( |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | //recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the |
468 | 468 | //info from the att_obj found in the EE_Messages_Addressee object. |
469 | - if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) { |
|
469 | + if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) { |
|
470 | 470 | $message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee |
471 | 471 | ? $recipient->att_obj->ID() |
472 | 472 | : 0; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $message_fields['MSG_recipient_ID'] = $recipient->recipient_id; |
476 | 476 | $message_fields['MSG_recipient_type'] = $recipient->recipient_type; |
477 | 477 | } |
478 | - $message = EE_Message_Factory::create( $message_fields ); |
|
478 | + $message = EE_Message_Factory::create($message_fields); |
|
479 | 479 | |
480 | 480 | //grab valid shortcodes for shortcode parser |
481 | 481 | $mt_shortcodes = $this->_current_message_type->get_valid_shortcodes(); |
@@ -483,43 +483,43 @@ discard block |
||
483 | 483 | |
484 | 484 | //if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this |
485 | 485 | //context is turned off) EXCEPT if we're previewing |
486 | - if ( empty( $templates['to'][ $context ] ) |
|
486 | + if (empty($templates['to'][$context]) |
|
487 | 487 | && ! $this->_generation_queue->get_message_repository()->is_preview() |
488 | - && ! $this->_current_messenger->allow_empty_to_field() ) { |
|
488 | + && ! $this->_current_messenger->allow_empty_to_field()) { |
|
489 | 489 | //we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field. |
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | $error_msg = array(); |
493 | - foreach ( $templates as $field => $field_context ) { |
|
493 | + foreach ($templates as $field => $field_context) { |
|
494 | 494 | $error_msg = array(); |
495 | 495 | //let's setup the valid shortcodes for the incoming context. |
496 | - $valid_shortcodes = $mt_shortcodes[ $context ]; |
|
496 | + $valid_shortcodes = $mt_shortcodes[$context]; |
|
497 | 497 | //merge in valid shortcodes for the field. |
498 | - $shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes; |
|
499 | - if ( isset( $templates[ $field ][ $context ] ) ) { |
|
498 | + $shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes; |
|
499 | + if (isset($templates[$field][$context])) { |
|
500 | 500 | //prefix field. |
501 | - $column_name = 'MSG_' . $field; |
|
501 | + $column_name = 'MSG_'.$field; |
|
502 | 502 | try { |
503 | 503 | $content = $this->_shortcode_parser->parse_message_template( |
504 | - $templates[ $field ][ $context ], |
|
504 | + $templates[$field][$context], |
|
505 | 505 | $recipient, |
506 | 506 | $shortcodes, |
507 | 507 | $this->_current_message_type, |
508 | 508 | $this->_current_messenger, |
509 | 509 | $message ); |
510 | - $message->set_field_or_extra_meta( $column_name, $content ); |
|
511 | - } catch ( EE_Error $e ) { |
|
512 | - $error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() ); |
|
513 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
510 | + $message->set_field_or_extra_meta($column_name, $content); |
|
511 | + } catch (EE_Error $e) { |
|
512 | + $error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage()); |
|
513 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | - if ( $message->STS_ID() === EEM_Message::status_failed ) { |
|
519 | - $error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg ); |
|
520 | - $message->set_error_message( $error_msg ); |
|
518 | + if ($message->STS_ID() === EEM_Message::status_failed) { |
|
519 | + $error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg); |
|
520 | + $message->set_error_message($error_msg); |
|
521 | 521 | } else { |
522 | - $message->set_STS_ID( EEM_Message::status_idle ); |
|
522 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
523 | 523 | } |
524 | 524 | return $message; |
525 | 525 | } |
@@ -553,14 +553,14 @@ discard block |
||
553 | 553 | * @param array $addressees Keys correspond to contexts for the message type and values are EE_Messages_Addressee[] |
554 | 554 | * @return bool |
555 | 555 | */ |
556 | - protected function _valid_addressees( $addressees ) { |
|
557 | - if ( ! $addressees || ! is_array( $addressees ) ) { |
|
556 | + protected function _valid_addressees($addressees) { |
|
557 | + if ( ! $addressees || ! is_array($addressees)) { |
|
558 | 558 | return false; |
559 | 559 | } |
560 | 560 | |
561 | - foreach( $addressees as $addressee_array ) { |
|
562 | - foreach ( $addressee_array as $addressee ) { |
|
563 | - if ( ! $addressee instanceof EE_Messages_Addressee ) { |
|
561 | + foreach ($addressees as $addressee_array) { |
|
562 | + foreach ($addressee_array as $addressee) { |
|
563 | + if ( ! $addressee instanceof EE_Messages_Addressee) { |
|
564 | 564 | return false; |
565 | 565 | } |
566 | 566 | } |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | protected function _validate_messenger_and_message_type() { |
582 | 582 | |
583 | 583 | //first are there any existing error messages? If so then return. |
584 | - if ( $this->_error_msg ) { |
|
584 | + if ($this->_error_msg) { |
|
585 | 585 | return false; |
586 | 586 | } |
587 | 587 | /** @type EE_Message $message */ |
588 | 588 | $message = $this->_generation_queue->get_message_repository()->current(); |
589 | 589 | try { |
590 | - $this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null; |
|
591 | - } catch ( Exception $e ) { |
|
590 | + $this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null; |
|
591 | + } catch (Exception $e) { |
|
592 | 592 | $this->_error_msg[] = $e->getMessage(); |
593 | 593 | } |
594 | 594 | try { |
595 | - $this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null; |
|
596 | - } catch ( Exception $e ) { |
|
595 | + $this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null; |
|
596 | + } catch (Exception $e) { |
|
597 | 597 | $this->_error_msg[] = $e->getMessage(); |
598 | 598 | } |
599 | 599 | |
@@ -605,10 +605,10 @@ discard block |
||
605 | 605 | ! $this->_generation_queue->get_message_repository()->is_preview() |
606 | 606 | && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' ) |
607 | 607 | ) { |
608 | - $this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' ); |
|
608 | + $this->_error_msg[] = __('There is no generation data for this message. Unable to generate.'); |
|
609 | 609 | } |
610 | 610 | |
611 | - return empty( $this->_error_msg ); |
|
611 | + return empty($this->_error_msg); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | //First, are there any existing error messages? If so, return because if there were errors elsewhere this can't |
627 | 627 | //be used anyways. |
628 | - if ( $this->_error_msg ) { |
|
628 | + if ($this->_error_msg) { |
|
629 | 629 | return false; |
630 | 630 | } |
631 | 631 | |
@@ -634,29 +634,29 @@ discard block |
||
634 | 634 | /** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */ |
635 | 635 | $data_handler_class_name = $this->_generation_queue->get_message_repository()->get_data_handler() |
636 | 636 | ? $this->_generation_queue->get_message_repository()->get_data_handler() |
637 | - : 'EE_Messages_' . $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data'; |
|
637 | + : 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data'; |
|
638 | 638 | |
639 | 639 | //If this EE_Message is for a preview, then let's switch out to the preview data handler. |
640 | - if ( $this->_generation_queue->get_message_repository()->is_preview() ) { |
|
641 | - $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
640 | + if ($this->_generation_queue->get_message_repository()->is_preview()) { |
|
641 | + $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | //First get the class name for the data handler (and also verifies it exists. |
645 | - if ( ! class_exists( $data_handler_class_name ) ) { |
|
645 | + if ( ! class_exists($data_handler_class_name)) { |
|
646 | 646 | $this->_error_msg[] = sprintf( |
647 | - __( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes. Looking for %s.', 'event_espresso' ), |
|
647 | + __('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes. Looking for %s.', 'event_espresso'), |
|
648 | 648 | $data_handler_class_name |
649 | 649 | ); |
650 | 650 | return false; |
651 | 651 | } |
652 | 652 | |
653 | 653 | //convert generation_data for data_handler_instantiation. |
654 | - $generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data ); |
|
654 | + $generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data); |
|
655 | 655 | |
656 | 656 | //note, this may set error messages as well. |
657 | - $this->_set_data_handler( $generation_data, $data_handler_class_name ); |
|
657 | + $this->_set_data_handler($generation_data, $data_handler_class_name); |
|
658 | 658 | |
659 | - return empty( $this->_error_msg ); |
|
659 | + return empty($this->_error_msg); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | |
@@ -673,16 +673,16 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return void. |
675 | 675 | */ |
676 | - protected function _set_data_handler( $generating_data, $data_handler_class_name ) { |
|
676 | + protected function _set_data_handler($generating_data, $data_handler_class_name) { |
|
677 | 677 | //valid classname for the data handler. Now let's setup the key for the data handler repository to see if there |
678 | 678 | //is already a ready data handler in the repository. |
679 | - $this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) ); |
|
680 | - if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) { |
|
679 | + $this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data)); |
|
680 | + if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) { |
|
681 | 681 | //no saved data_handler in the repo so let's set one up and add it to the repo. |
682 | 682 | try { |
683 | - $this->_current_data_handler = new $data_handler_class_name( $generating_data ); |
|
684 | - $this->_data_handler_collection->add( $this->_current_data_handler, $generating_data ); |
|
685 | - } catch( EE_Error $e ) { |
|
683 | + $this->_current_data_handler = new $data_handler_class_name($generating_data); |
|
684 | + $this->_data_handler_collection->add($this->_current_data_handler, $generating_data); |
|
685 | + } catch (EE_Error $e) { |
|
686 | 686 | $this->_error_msg[] = $e->get_error(); |
687 | 687 | } |
688 | 688 | } |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | * @param bool $preview Indicate whether this is being used for a preview or not. |
703 | 703 | * @return mixed Prepped data for persisting to the queue. false is returned if unable to prep data. |
704 | 704 | */ |
705 | - protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) { |
|
705 | + protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) { |
|
706 | 706 | /** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */ |
707 | - $data_handler = $message_to_generate->get_data_handler_class_name( $preview ); |
|
708 | - if ( ! $message_to_generate->valid() ) { |
|
707 | + $data_handler = $message_to_generate->get_data_handler_class_name($preview); |
|
708 | + if ( ! $message_to_generate->valid()) { |
|
709 | 709 | return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid. |
710 | 710 | } |
711 | - return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() ); |
|
711 | + return $data_handler::convert_data_for_persistent_storage($message_to_generate->data()); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -721,26 +721,26 @@ discard block |
||
721 | 721 | * @param EE_Message_To_Generate $message_to_generate |
722 | 722 | * @param bool $test_send Whether this is just a test send or not. Typically used for previews. |
723 | 723 | */ |
724 | - public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
724 | + public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
725 | 725 | //prep data |
726 | - $data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() ); |
|
726 | + $data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview()); |
|
727 | 727 | |
728 | 728 | $message = $message_to_generate->get_EE_Message(); |
729 | 729 | |
730 | 730 | //is there a GRP_ID in the request? |
731 | - if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) { |
|
732 | - $message->set_GRP_ID( $GRP_ID ); |
|
731 | + if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) { |
|
732 | + $message->set_GRP_ID($GRP_ID); |
|
733 | 733 | } |
734 | 734 | |
735 | - if ( $data === false ) { |
|
736 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
737 | - $message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) ); |
|
735 | + if ($data === false) { |
|
736 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
737 | + $message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso')); |
|
738 | 738 | } else { |
739 | 739 | //make sure that the data handler is cached on the message as well |
740 | 740 | $data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name(); |
741 | 741 | } |
742 | 742 | |
743 | - $this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send ); |
|
743 | + $this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data'; |
13 | 13 | |
@@ -71,52 +71,52 @@ discard block |
||
71 | 71 | * } @see EE_Form_Section_Validatable::__construct() |
72 | 72 | * @throws \EE_Error |
73 | 73 | */ |
74 | - public function __construct( $options_array = array() ){ |
|
75 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
74 | + public function __construct($options_array = array()) { |
|
75 | + $options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
76 | 76 | //call parent first, as it may be setting the name |
77 | 77 | parent::__construct($options_array); |
78 | 78 | //if they've included subsections in the constructor, add them now |
79 | - if( isset( $options_array['include'] )){ |
|
79 | + if (isset($options_array['include'])) { |
|
80 | 80 | //we are going to make sure we ONLY have those subsections to include |
81 | 81 | //AND we are going to make sure they're in that specified order |
82 | 82 | $reordered_subsections = array(); |
83 | - foreach($options_array['include'] as $input_name){ |
|
84 | - if(isset($this->_subsections[$input_name])){ |
|
83 | + foreach ($options_array['include'] as $input_name) { |
|
84 | + if (isset($this->_subsections[$input_name])) { |
|
85 | 85 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | $this->_subsections = $reordered_subsections; |
89 | 89 | } |
90 | - if(isset($options_array['exclude'])){ |
|
90 | + if (isset($options_array['exclude'])) { |
|
91 | 91 | $exclude = $options_array['exclude']; |
92 | 92 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
93 | 93 | } |
94 | - if(isset($options_array['layout_strategy'])){ |
|
94 | + if (isset($options_array['layout_strategy'])) { |
|
95 | 95 | $this->_layout_strategy = $options_array['layout_strategy']; |
96 | 96 | } |
97 | - if( ! $this->_layout_strategy){ |
|
97 | + if ( ! $this->_layout_strategy) { |
|
98 | 98 | $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout(); |
99 | 99 | } |
100 | 100 | $this->_layout_strategy->_construct_finalize($this); |
101 | 101 | |
102 | 102 | //ok so we are definitely going to want the forms JS, |
103 | 103 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
104 | - if( did_action( 'wp_enqueue_scripts' ) |
|
105 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
104 | + if (did_action('wp_enqueue_scripts') |
|
105 | + || did_action('admin_enqueue_scripts')) { |
|
106 | 106 | //ok so they've constructed this object after when they should have. |
107 | 107 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
108 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
108 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
109 | 109 | \EE_Form_Section_Proper::wp_deregister_conflicting_scripts(); |
110 | 110 | } else { |
111 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
112 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
113 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts' ), 100 ); |
|
114 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts' ), 100 ); |
|
111 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
112 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
113 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts'), 100); |
|
114 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts'), 100); |
|
115 | 115 | } |
116 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
116 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
117 | 117 | |
118 | - if( isset( $options_array[ 'name' ] ) ) { |
|
119 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
118 | + if (isset($options_array['name'])) { |
|
119 | + $this->_construct_finalize(null, $options_array['name']); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | * @param string $name |
130 | 130 | * @throws \EE_Error |
131 | 131 | */ |
132 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
132 | + public function _construct_finalize($parent_form_section, $name) { |
|
133 | 133 | parent::_construct_finalize($parent_form_section, $name); |
134 | 134 | $this->_set_default_name_if_empty(); |
135 | 135 | $this->_set_default_html_id_if_empty(); |
136 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
137 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
138 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
136 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
137 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
138 | + $subsection->_construct_finalize($this, $subsection_name); |
|
139 | 139 | } else { |
140 | 140 | throw new EE_Error( |
141 | 141 | sprintf( |
142 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
142 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
143 | 143 | $subsection_name, |
144 | 144 | get_class($this), |
145 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
145 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | } |
149 | 149 | } |
150 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
150 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * Gets the layout strategy for this form section |
157 | 157 | * @return EE_Form_Section_Layout_Base |
158 | 158 | */ |
159 | - public function get_layout_strategy(){ |
|
159 | + public function get_layout_strategy() { |
|
160 | 160 | return $this->_layout_strategy; |
161 | 161 | } |
162 | 162 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param EE_Form_Input_Base $input |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function get_html_for_input($input){ |
|
171 | + public function get_html_for_input($input) { |
|
172 | 172 | return $this->_layout_strategy->layout_input($input); |
173 | 173 | } |
174 | 174 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param null $form_data |
182 | 182 | * @return boolean |
183 | 183 | */ |
184 | - public function was_submitted($form_data = NULL){ |
|
184 | + public function was_submitted($form_data = NULL) { |
|
185 | 185 | return $this->form_data_present_in($form_data); |
186 | 186 | } |
187 | 187 | |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | * (eg you validated the data then stored it in the DB) |
207 | 207 | * you may want to skip this step. |
208 | 208 | */ |
209 | - public function receive_form_submission( $req_data = null, $validate = true ){ |
|
210 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
211 | - if( $req_data === null ){ |
|
212 | - $req_data = array_merge( $_GET, $_POST ); |
|
209 | + public function receive_form_submission($req_data = null, $validate = true) { |
|
210 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
211 | + if ($req_data === null) { |
|
212 | + $req_data = array_merge($_GET, $_POST); |
|
213 | 213 | } |
214 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
215 | - $this->_normalize( $req_data ); |
|
216 | - if( $validate ){ |
|
214 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
215 | + $this->_normalize($req_data); |
|
216 | + if ($validate) { |
|
217 | 217 | $this->_validate(); |
218 | 218 | //if it's invalid, we're going to want to re-display so remember what they submitted |
219 | - if ( ! $this->is_valid() ) { |
|
219 | + if ( ! $this->is_valid()) { |
|
220 | 220 | $this->store_submitted_form_data_in_session(); |
221 | 221 | } |
222 | 222 | } |
223 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
223 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | protected function store_submitted_form_data_in_session() { |
235 | 235 | return EE_Registry::instance()->SSN->set_session_data( |
236 | 236 | array( |
237 | - \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values( true ) |
|
237 | + \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true) |
|
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | protected function get_submitted_form_data_from_session() { |
251 | 251 | $session = EE_Registry::instance()->SSN; |
252 | - if( $session instanceof EE_Session ) { |
|
252 | + if ($session instanceof EE_Session) { |
|
253 | 253 | return $session->get_session_data( |
254 | 254 | \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY |
255 | 255 | ); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | protected function flush_submitted_form_data_from_session() { |
269 | 269 | return EE_Registry::instance()->SSN->reset_data( |
270 | - array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY ) |
|
270 | + array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY) |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function populate_from_session() { |
285 | 285 | $form_data_in_session = $this->get_submitted_form_data_from_session(); |
286 | - if ( empty( $form_data_in_session ) ) { |
|
286 | + if (empty($form_data_in_session)) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | - $this->receive_form_submission( $form_data_in_session ); |
|
289 | + $this->receive_form_submission($form_data_in_session); |
|
290 | 290 | $this->flush_submitted_form_data_from_session(); |
291 | - if ( $this->form_data_present_in( $form_data_in_session ) ) { |
|
291 | + if ($this->form_data_present_in($form_data_in_session)) { |
|
292 | 292 | return true; |
293 | 293 | } else { |
294 | 294 | return false; |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * the value being an array formatted in teh same way |
306 | 306 | * @param array $default_data |
307 | 307 | */ |
308 | - public function populate_defaults($default_data){ |
|
309 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
310 | - if(isset($default_data[$subsection_name])){ |
|
311 | - if($subsection instanceof EE_Form_Input_Base){ |
|
308 | + public function populate_defaults($default_data) { |
|
309 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
310 | + if (isset($default_data[$subsection_name])) { |
|
311 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
312 | 312 | $subsection->set_default($default_data[$subsection_name]); |
313 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
313 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
314 | 314 | $subsection->populate_defaults($default_data[$subsection_name]); |
315 | 315 | } |
316 | 316 | } |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | * @param string $name |
326 | 326 | * @return boolean |
327 | 327 | */ |
328 | - public function subsection_exists( $name ){ |
|
329 | - return isset( $this->_subsections[ $name ] ) ? true : false; |
|
328 | + public function subsection_exists($name) { |
|
329 | + return isset($this->_subsections[$name]) ? true : false; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
@@ -344,11 +344,11 @@ discard block |
||
344 | 344 | * @return EE_Form_Section_Base |
345 | 345 | * @throws \EE_Error |
346 | 346 | */ |
347 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
348 | - if( $require_construction_to_be_finalized ){ |
|
347 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
348 | + if ($require_construction_to_be_finalized) { |
|
349 | 349 | $this->ensure_construct_finalized_called(); |
350 | 350 | } |
351 | - return $this->subsection_exists( $name ) ? $this->_subsections[$name] : NULL; |
|
351 | + return $this->subsection_exists($name) ? $this->_subsections[$name] : NULL; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * Gets all the validatable subsections of this form section |
358 | 358 | * @return EE_Form_Section_Validatable[] |
359 | 359 | */ |
360 | - public function get_validatable_subsections(){ |
|
360 | + public function get_validatable_subsections() { |
|
361 | 361 | $validatable_subsections = array(); |
362 | - foreach($this->subsections() as $name=>$obj){ |
|
363 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
362 | + foreach ($this->subsections() as $name=>$obj) { |
|
363 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
364 | 364 | $validatable_subsections[$name] = $obj; |
365 | 365 | } |
366 | 366 | } |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | * @return EE_Form_Input_Base |
381 | 381 | * @throws EE_Error |
382 | 382 | */ |
383 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
383 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
384 | 384 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
385 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
385 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
386 | 386 | throw new EE_Error( |
387 | 387 | sprintf( |
388 | 388 | __( |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | 'event_espresso' |
391 | 391 | ), |
392 | 392 | $name, |
393 | - get_class( $this ), |
|
394 | - $subsection ? get_class( $subsection ) : __( "NULL", 'event_espresso' ) |
|
393 | + get_class($this), |
|
394 | + $subsection ? get_class($subsection) : __("NULL", 'event_espresso') |
|
395 | 395 | ) |
396 | 396 | ); |
397 | 397 | } |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * @return EE_Form_Section_Proper |
412 | 412 | * @throws EE_Error |
413 | 413 | */ |
414 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
415 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
416 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
414 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
415 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
416 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
417 | 417 | throw new EE_Error( |
418 | 418 | sprintf( |
419 | - __( "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso' ), |
|
419 | + __("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), |
|
420 | 420 | $name, |
421 | - get_class( $this ) |
|
421 | + get_class($this) |
|
422 | 422 | ) |
423 | 423 | ); |
424 | 424 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @return mixed depending on the input's type and its normalization strategy |
436 | 436 | * @throws \EE_Error |
437 | 437 | */ |
438 | - public function get_input_value($name){ |
|
438 | + public function get_input_value($name) { |
|
439 | 439 | $input = $this->get_input($name); |
440 | 440 | return $input->normalized_value(); |
441 | 441 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @return boolean |
449 | 449 | */ |
450 | 450 | public function is_valid() { |
451 | - if( ! $this->has_received_submission()){ |
|
451 | + if ( ! $this->has_received_submission()) { |
|
452 | 452 | throw new EE_Error( |
453 | 453 | sprintf( |
454 | 454 | __( |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | ) |
459 | 459 | ); |
460 | 460 | } |
461 | - if( ! parent::is_valid() ) { |
|
461 | + if ( ! parent::is_valid()) { |
|
462 | 462 | return false; |
463 | 463 | } |
464 | 464 | // ok so no general errors to this entire form section. |
465 | 465 | // so let's check the subsections, but only set errors if that hasn't been done yet |
466 | 466 | $set_submission_errors = $this->submission_error_message() === '' ? true : false; |
467 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
468 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
469 | - if ( $set_submission_errors ) { |
|
470 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
467 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
468 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
469 | + if ($set_submission_errors) { |
|
470 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
471 | 471 | } |
472 | 472 | return false; |
473 | 473 | } |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | * gets teh default name of this form section if none is specified |
482 | 482 | * @return string |
483 | 483 | */ |
484 | - protected function _set_default_name_if_empty(){ |
|
485 | - if( ! $this->_name ){ |
|
484 | + protected function _set_default_name_if_empty() { |
|
485 | + if ( ! $this->_name) { |
|
486 | 486 | $classname = get_class($this); |
487 | 487 | $default_name = str_replace("EE_", "", $classname); |
488 | - $this->_name = $default_name; |
|
488 | + $this->_name = $default_name; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * and get_html when you are about to display the form. |
502 | 502 | * @throws \EE_Error |
503 | 503 | */ |
504 | - public function get_html_and_js(){ |
|
504 | + public function get_html_and_js() { |
|
505 | 505 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
506 | 506 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
507 | 507 | $this->enqueue_js(); |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | * @param bool $display_previously_submitted_data |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - public function get_html( $display_previously_submitted_data = true ){ |
|
519 | + public function get_html($display_previously_submitted_data = true) { |
|
520 | 520 | $this->ensure_construct_finalized_called(); |
521 | - if ( $display_previously_submitted_data ) { |
|
521 | + if ($display_previously_submitted_data) { |
|
522 | 522 | $this->populate_from_session(); |
523 | 523 | } |
524 | 524 | return $this->_layout_strategy->layout_form(); |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | * @return string |
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | - public function enqueue_js(){ |
|
535 | + public function enqueue_js() { |
|
536 | 536 | $this->_enqueue_and_localize_form_js(); |
537 | - foreach( $this->subsections() as $subsection ) { |
|
537 | + foreach ($this->subsections() as $subsection) { |
|
538 | 538 | $subsection->enqueue_js(); |
539 | 539 | } |
540 | 540 | } |
@@ -553,19 +553,19 @@ discard block |
||
553 | 553 | * to be triggered automatically or not |
554 | 554 | * @return void |
555 | 555 | */ |
556 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
557 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
556 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
557 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
558 | 558 | wp_register_script( |
559 | 559 | 'ee_form_section_validation', |
560 | - EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', |
|
561 | - array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), |
|
560 | + EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', |
|
561 | + array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), |
|
562 | 562 | EVENT_ESPRESSO_VERSION, |
563 | 563 | true |
564 | 564 | ); |
565 | 565 | wp_localize_script( |
566 | 566 | 'ee_form_section_validation', |
567 | 567 | 'ee_form_section_validation_init', |
568 | - array( 'init' => $init_form_validation_automatically ? true : false ) |
|
568 | + array('init' => $init_form_validation_automatically ? true : false) |
|
569 | 569 | ); |
570 | 570 | } |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | public static function wp_deregister_conflicting_scripts() { |
577 | 577 | //jquery-form (included in WP core, but deprecated) also declares some of the same methods |
578 | 578 | //as jquery validate |
579 | - wp_deregister_script( 'jquery-form' ); |
|
579 | + wp_deregister_script('jquery-form'); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -588,14 +588,14 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @throws \EE_Error |
590 | 590 | */ |
591 | - public function _enqueue_and_localize_form_js(){ |
|
591 | + public function _enqueue_and_localize_form_js() { |
|
592 | 592 | $this->ensure_construct_finalized_called(); |
593 | 593 | //actually, we don't want to localize just yet. There may be other forms on the page. |
594 | 594 | //so we need to add our form section data to a static variable accessible by all form sections |
595 | 595 | //and localize it just before the footer |
596 | 596 | $this->localize_validation_rules(); |
597 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
598 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
597 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
598 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | * @return void |
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
610 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
611 | 611 | // we only want to localize vars ONCE for the entire form, |
612 | 612 | // so if the form section doesn't have a parent, then it must be the top dog |
613 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
614 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
615 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
613 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
614 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
615 | + 'form_section_id'=> $this->html_id(TRUE), |
|
616 | 616 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
617 | 617 | 'other_data' => $this->get_other_js_data(), |
618 | 618 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | * @param array $form_other_js_data |
629 | 629 | * @return array |
630 | 630 | */ |
631 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
632 | - foreach( $this->subsections() as $subsection ) { |
|
633 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
631 | + public function get_other_js_data($form_other_js_data = array()) { |
|
632 | + foreach ($this->subsections() as $subsection) { |
|
633 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
634 | 634 | } |
635 | 635 | return $form_other_js_data; |
636 | 636 | } |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | * Keys are their form names, and values are the inputs themselves |
642 | 642 | * @return EE_Form_Input_Base |
643 | 643 | */ |
644 | - public function inputs_in_subsections(){ |
|
644 | + public function inputs_in_subsections() { |
|
645 | 645 | $inputs = array(); |
646 | - foreach($this->subsections() as $subsection){ |
|
647 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
648 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
649 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
646 | + foreach ($this->subsections() as $subsection) { |
|
647 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
648 | + $inputs[$subsection->html_name()] = $subsection; |
|
649 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
650 | 650 | $inputs += $subsection->inputs_in_subsections(); |
651 | 651 | } |
652 | 652 | } |
@@ -659,12 +659,12 @@ discard block |
||
659 | 659 | * and values are a string of all their validation errors |
660 | 660 | * @return string[] |
661 | 661 | */ |
662 | - public function subsection_validation_errors_by_html_name(){ |
|
662 | + public function subsection_validation_errors_by_html_name() { |
|
663 | 663 | $inputs = $this->inputs(); |
664 | 664 | $errors = array(); |
665 | - foreach( $inputs as $form_input ){ |
|
666 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
667 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
665 | + foreach ($inputs as $form_input) { |
|
666 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
667 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | return $errors; |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
677 | 677 | * Should be setup by each form during the _enqueues_and_localize_form_js |
678 | 678 | */ |
679 | - public static function localize_script_for_all_forms(){ |
|
679 | + public static function localize_script_for_all_forms() { |
|
680 | 680 | //allow inputs and stuff to hook in their JS and stuff here |
681 | - do_action( 'AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin' ); |
|
681 | + do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
|
682 | 682 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
683 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
683 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
684 | 684 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
685 | 685 | : 'wp_default'; |
686 | 686 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
687 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
687 | + wp_enqueue_script('ee_form_section_validation'); |
|
688 | 688 | wp_localize_script( |
689 | 689 | 'ee_form_section_validation', |
690 | 690 | 'ee_form_section_vars', |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * ensure_scripts_localized |
699 | 699 | */ |
700 | - public function ensure_scripts_localized(){ |
|
701 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
700 | + public function ensure_scripts_localized() { |
|
701 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
702 | 702 | $this->_enqueue_and_localize_form_js(); |
703 | 703 | } |
704 | 704 | } |
@@ -710,10 +710,10 @@ discard block |
||
710 | 710 | * is that the key here should be the same as the custom validation rule put in the JS file |
711 | 711 | * @return array keys are custom validation rules, and values are internationalized strings |
712 | 712 | */ |
713 | - private static function _get_localized_error_messages(){ |
|
713 | + private static function _get_localized_error_messages() { |
|
714 | 714 | return array( |
715 | 715 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
716 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
716 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
717 | 717 | ); |
718 | 718 | } |
719 | 719 | |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @return array |
745 | 745 | */ |
746 | - public function get_jquery_validation_rules(){ |
|
746 | + public function get_jquery_validation_rules() { |
|
747 | 747 | $jquery_validation_rules = array(); |
748 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
748 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
749 | 749 | $jquery_validation_rules = array_merge( |
750 | 750 | $jquery_validation_rules, |
751 | 751 | $subsection->get_jquery_validation_rules() |
@@ -762,14 +762,14 @@ discard block |
||
762 | 762 | * @param array $req_data like $_POST |
763 | 763 | * @return void |
764 | 764 | */ |
765 | - protected function _normalize( $req_data ) { |
|
765 | + protected function _normalize($req_data) { |
|
766 | 766 | $this->_received_submission = true; |
767 | 767 | $this->_validation_errors = array(); |
768 | - foreach ( $this->get_validatable_subsections() as $subsection ) { |
|
768 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
769 | 769 | try { |
770 | - $subsection->_normalize( $req_data ); |
|
771 | - } catch ( EE_Validation_Error $e ) { |
|
772 | - $subsection->add_validation_error( $e ); |
|
770 | + $subsection->_normalize($req_data); |
|
771 | + } catch (EE_Validation_Error $e) { |
|
772 | + $subsection->add_validation_error($e); |
|
773 | 773 | } |
774 | 774 | } |
775 | 775 | } |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | * calling parent::_validate() first. |
787 | 787 | */ |
788 | 788 | protected function _validate() { |
789 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
790 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
791 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
789 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
790 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
791 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
792 | 792 | } |
793 | 793 | $subsection->_validate(); |
794 | 794 | } |
@@ -800,13 +800,13 @@ discard block |
||
800 | 800 | * Gets all the validated inputs for the form section |
801 | 801 | * @return array |
802 | 802 | */ |
803 | - public function valid_data(){ |
|
803 | + public function valid_data() { |
|
804 | 804 | $inputs = array(); |
805 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
806 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
807 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
808 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
809 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
805 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
806 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
807 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
808 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
809 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | return $inputs; |
@@ -818,11 +818,11 @@ discard block |
||
818 | 818 | * Gets all the inputs on this form section |
819 | 819 | * @return EE_Form_Input_Base[] |
820 | 820 | */ |
821 | - public function inputs(){ |
|
821 | + public function inputs() { |
|
822 | 822 | $inputs = array(); |
823 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
824 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
825 | - $inputs[ $subsection_name ] = $subsection; |
|
823 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
824 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
825 | + $inputs[$subsection_name] = $subsection; |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | return $inputs; |
@@ -834,10 +834,10 @@ discard block |
||
834 | 834 | * Gets all the subsections which are a proper form |
835 | 835 | * @return EE_Form_Section_Proper[] |
836 | 836 | */ |
837 | - public function subforms(){ |
|
837 | + public function subforms() { |
|
838 | 838 | $form_sections = array(); |
839 | - foreach($this->subsections() as $name=>$obj){ |
|
840 | - if($obj instanceof EE_Form_Section_Proper){ |
|
839 | + foreach ($this->subsections() as $name=>$obj) { |
|
840 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
841 | 841 | $form_sections[$name] = $obj; |
842 | 842 | } |
843 | 843 | } |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | * if you only want form inputs or proper form sections. |
853 | 853 | * @return EE_Form_Section_Proper[] |
854 | 854 | */ |
855 | - public function subsections(){ |
|
855 | + public function subsections() { |
|
856 | 856 | $this->ensure_construct_finalized_called(); |
857 | 857 | return $this->_subsections; |
858 | 858 | } |
@@ -874,8 +874,8 @@ discard block |
||
874 | 874 | * where keys are always subsection names and values are either |
875 | 875 | * the input's normalized value, or an array like the top-level array |
876 | 876 | */ |
877 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
878 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
877 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
878 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * where keys are always subsection names and values are either |
896 | 896 | * the input's normalized value, or an array like the top-level array |
897 | 897 | */ |
898 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
899 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
898 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
899 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -914,19 +914,19 @@ discard block |
||
914 | 914 | * where keys are always subsection names and values are either |
915 | 915 | * the input's normalized value, or an array like the top-level array |
916 | 916 | */ |
917 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
917 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
918 | 918 | $input_values = array(); |
919 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
920 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
921 | - $input_values[ $subsection_name ] = $pretty |
|
919 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
920 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
921 | + $input_values[$subsection_name] = $pretty |
|
922 | 922 | ? $subsection->pretty_value() |
923 | 923 | : $subsection->normalized_value(); |
924 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
925 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
926 | - if( $flatten ) { |
|
927 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
924 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
925 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
926 | + if ($flatten) { |
|
927 | + $input_values = array_merge($input_values, $subform_input_values); |
|
928 | 928 | } else { |
929 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
929 | + $input_values[$subsection_name] = $subform_input_values; |
|
930 | 930 | } |
931 | 931 | } |
932 | 932 | } |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | * where keys are always subsection names and values are either |
948 | 948 | * the input's normalized value, or an array like the top-level array |
949 | 949 | */ |
950 | - public function submitted_values( $include_subforms = false ) { |
|
950 | + public function submitted_values($include_subforms = false) { |
|
951 | 951 | $submitted_values = array(); |
952 | - foreach( $this->subsections() as $subsection ) { |
|
953 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
952 | + foreach ($this->subsections() as $subsection) { |
|
953 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
954 | 954 | // is this input part of an array of inputs? |
955 | - if ( strpos( $subsection->html_name(), '[' ) !== false ) { |
|
955 | + if (strpos($subsection->html_name(), '[') !== false) { |
|
956 | 956 | $full_input_name = \EEH_Array::convert_array_values_to_keys( |
957 | - explode( '[', str_replace( ']', '', $subsection->html_name() ) ), |
|
957 | + explode('[', str_replace(']', '', $subsection->html_name())), |
|
958 | 958 | $subsection->raw_value() |
959 | 959 | ); |
960 | - $submitted_values = array_replace_recursive( $submitted_values, $full_input_name ); |
|
960 | + $submitted_values = array_replace_recursive($submitted_values, $full_input_name); |
|
961 | 961 | } else { |
962 | - $submitted_values[ $subsection->html_name() ] = $subsection->raw_value(); |
|
962 | + $submitted_values[$subsection->html_name()] = $subsection->raw_value(); |
|
963 | 963 | } |
964 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subforms ) { |
|
965 | - $subform_input_values = $subsection->submitted_values( $include_subforms ); |
|
966 | - $submitted_values = array_replace_recursive( $submitted_values, $subform_input_values ); |
|
964 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) { |
|
965 | + $subform_input_values = $subsection->submitted_values($include_subforms); |
|
966 | + $submitted_values = array_replace_recursive($submitted_values, $subform_input_values); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | return $submitted_values; |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @return boolean |
979 | 979 | * @throws \EE_Error |
980 | 980 | */ |
981 | - public function has_received_submission(){ |
|
981 | + public function has_received_submission() { |
|
982 | 982 | $this->ensure_construct_finalized_called(); |
983 | 983 | return $this->_received_submission; |
984 | 984 | } |
@@ -991,8 +991,8 @@ discard block |
||
991 | 991 | * @param array $inputs_to_exclude values are the input names |
992 | 992 | * @return void |
993 | 993 | */ |
994 | - public function exclude($inputs_to_exclude = array()){ |
|
995 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
994 | + public function exclude($inputs_to_exclude = array()) { |
|
995 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
996 | 996 | unset($this->_subsections[$input_to_exclude_name]); |
997 | 997 | } |
998 | 998 | } |
@@ -1003,8 +1003,8 @@ discard block |
||
1003 | 1003 | * @param array $inputs_to_hide |
1004 | 1004 | * @throws \EE_Error |
1005 | 1005 | */ |
1006 | - public function hide($inputs_to_hide= array()){ |
|
1007 | - foreach($inputs_to_hide as $input_to_hide){ |
|
1006 | + public function hide($inputs_to_hide = array()) { |
|
1007 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
1008 | 1008 | $input = $this->get_input($input_to_hide); |
1009 | 1009 | |
1010 | 1010 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -1034,21 +1034,21 @@ discard block |
||
1034 | 1034 | * @return void |
1035 | 1035 | * @throws \EE_Error |
1036 | 1036 | */ |
1037 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
1038 | - foreach( $new_subsections as $subsection_name => $subsection ){ |
|
1039 | - if( ! $subsection instanceof EE_Form_Section_Base ){ |
|
1037 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
1038 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
1039 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
1040 | 1040 | EE_Error::add_error( |
1041 | 1041 | sprintf( |
1042 | 1042 | __( |
1043 | 1043 | "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", |
1044 | 1044 | "event_espresso" |
1045 | 1045 | ), |
1046 | - get_class( $subsection ), |
|
1046 | + get_class($subsection), |
|
1047 | 1047 | $subsection_name, |
1048 | 1048 | $this->name() |
1049 | 1049 | ) |
1050 | 1050 | ); |
1051 | - unset( $new_subsections[ $subsection_name ] ); |
|
1051 | + unset($new_subsections[$subsection_name]); |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | $this->_subsections = EEH_Array::insert_into_array( |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | ); |
1060 | 1060 | |
1061 | 1061 | |
1062 | - if( $this->_construction_finalized ){ |
|
1063 | - foreach($this->_subsections as $name => $subsection){ |
|
1062 | + if ($this->_construction_finalized) { |
|
1063 | + foreach ($this->_subsections as $name => $subsection) { |
|
1064 | 1064 | $subsection->_construct_finalize($this, $name); |
1065 | 1065 | } |
1066 | 1066 | } |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | /** |
1072 | 1072 | * Just gets all validatable subsections to clean their sensitive data |
1073 | 1073 | */ |
1074 | - public function clean_sensitive_data(){ |
|
1075 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
1074 | + public function clean_sensitive_data() { |
|
1075 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1076 | 1076 | $subsection->clean_sensitive_data(); |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1082,10 +1082,10 @@ discard block |
||
1082 | 1082 | /** |
1083 | 1083 | * @param string $form_submission_error_message |
1084 | 1084 | */ |
1085 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
1086 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) |
|
1085 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
1086 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) |
|
1087 | 1087 | ? $form_submission_error_message |
1088 | - : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
1088 | + : __('Form submission failed due to errors', 'event_espresso'); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | |
@@ -1102,10 +1102,10 @@ discard block |
||
1102 | 1102 | /** |
1103 | 1103 | * @param string $form_submission_success_message |
1104 | 1104 | */ |
1105 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
1106 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) |
|
1105 | + public function set_submission_success_message($form_submission_success_message) { |
|
1106 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) |
|
1107 | 1107 | ? $form_submission_success_message |
1108 | - : __( 'Form submitted successfully', 'event_espresso' ); |
|
1108 | + : __('Form submitted successfully', 'event_espresso'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | |
@@ -1128,10 +1128,10 @@ discard block |
||
1128 | 1128 | * @return string |
1129 | 1129 | * @throws \EE_Error |
1130 | 1130 | */ |
1131 | - public function html_name_prefix(){ |
|
1132 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
1133 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
1134 | - }else{ |
|
1131 | + public function html_name_prefix() { |
|
1132 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
1133 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
1134 | + } else { |
|
1135 | 1135 | return $this->name(); |
1136 | 1136 | } |
1137 | 1137 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | * @return string |
1147 | 1147 | * @throws \EE_Error |
1148 | 1148 | */ |
1149 | - public function name(){ |
|
1149 | + public function name() { |
|
1150 | 1150 | $this->ensure_construct_finalized_called(); |
1151 | 1151 | return parent::name(); |
1152 | 1152 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @return EE_Form_Section_Proper |
1158 | 1158 | * @throws \EE_Error |
1159 | 1159 | */ |
1160 | - public function parent_section(){ |
|
1160 | + public function parent_section() { |
|
1161 | 1161 | $this->ensure_construct_finalized_called(); |
1162 | 1162 | return parent::parent_section(); |
1163 | 1163 | } |
@@ -1170,9 +1170,9 @@ discard block |
||
1170 | 1170 | * @return void |
1171 | 1171 | * @throws \EE_Error |
1172 | 1172 | */ |
1173 | - public function ensure_construct_finalized_called(){ |
|
1174 | - if( ! $this->_construction_finalized ){ |
|
1175 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
1173 | + public function ensure_construct_finalized_called() { |
|
1174 | + if ( ! $this->_construction_finalized) { |
|
1175 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
1176 | 1176 | } |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1184,17 +1184,17 @@ discard block |
||
1184 | 1184 | * @param array $req_data |
1185 | 1185 | * @return boolean |
1186 | 1186 | */ |
1187 | - public function form_data_present_in( $req_data = NULL ) { |
|
1188 | - if( $req_data === NULL){ |
|
1187 | + public function form_data_present_in($req_data = NULL) { |
|
1188 | + if ($req_data === NULL) { |
|
1189 | 1189 | $req_data = $_POST; |
1190 | 1190 | } |
1191 | - foreach( $this->subsections() as $subsection ) { |
|
1192 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
1193 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1191 | + foreach ($this->subsections() as $subsection) { |
|
1192 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
1193 | + if ($subsection->form_data_present_in($req_data)) { |
|
1194 | 1194 | return TRUE; |
1195 | 1195 | } |
1196 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
1197 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1196 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
1197 | + if ($subsection->form_data_present_in($req_data)) { |
|
1198 | 1198 | return TRUE; |
1199 | 1199 | } |
1200 | 1200 | } |
@@ -1211,14 +1211,14 @@ discard block |
||
1211 | 1211 | */ |
1212 | 1212 | public function get_validation_errors_accumulated() { |
1213 | 1213 | $validation_errors = $this->get_validation_errors(); |
1214 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
1215 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
1214 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1215 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
1216 | 1216 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
1217 | 1217 | } else { |
1218 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1218 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1219 | 1219 | } |
1220 | - if( $validation_errors_on_this_subsection ){ |
|
1221 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
1220 | + if ($validation_errors_on_this_subsection) { |
|
1221 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | return $validation_errors; |
@@ -1240,24 +1240,24 @@ discard block |
||
1240 | 1240 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
1241 | 1241 | * @return EE_Form_Section_Base |
1242 | 1242 | */ |
1243 | - public function find_section_from_path( $form_section_path ) { |
|
1243 | + public function find_section_from_path($form_section_path) { |
|
1244 | 1244 | //check if we can find the input from purely going straight up the tree |
1245 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1246 | - if( $input instanceof EE_Form_Section_Base ) { |
|
1245 | + $input = parent::find_section_from_path($form_section_path); |
|
1246 | + if ($input instanceof EE_Form_Section_Base) { |
|
1247 | 1247 | return $input; |
1248 | 1248 | } |
1249 | 1249 | |
1250 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1251 | - if( $next_slash_pos !== false ) { |
|
1252 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1253 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1250 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1251 | + if ($next_slash_pos !== false) { |
|
1252 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1253 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1254 | 1254 | } else { |
1255 | 1255 | $child_section_name = $form_section_path; |
1256 | 1256 | $subpath = ''; |
1257 | 1257 | } |
1258 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1259 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1260 | - return $child_section->find_section_from_path( $subpath ); |
|
1258 | + $child_section = $this->get_subsection($child_section_name); |
|
1259 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1260 | + return $child_section->find_section_from_path($subpath); |
|
1261 | 1261 | } else { |
1262 | 1262 | return null; |
1263 | 1263 | } |
@@ -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,81 +210,81 @@ 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 | // hook that can be used to display the full template path that will be used |
274 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
274 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | // if we got it and you want to see it... |
280 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
281 | - if ( $return_string ) { |
|
282 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
280 | + if ($template_path && $load && ! $check_if_custom) { |
|
281 | + if ($return_string) { |
|
282 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
283 | 283 | } else { |
284 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
284 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
285 | 285 | } |
286 | 286 | } |
287 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
287 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | * @param array $paths |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - protected static function _find_common_base_path( $paths ) { |
|
300 | + protected static function _find_common_base_path($paths) { |
|
301 | 301 | $last_offset = 0; |
302 | 302 | $common_base_path = ''; |
303 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
303 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
304 | 304 | $dir_length = $index - $last_offset + 1; |
305 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
306 | - foreach ( $paths as $path ) { |
|
307 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
305 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
306 | + foreach ($paths as $path) { |
|
307 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
308 | 308 | return $common_base_path; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | $common_base_path .= $directory; |
312 | 312 | $last_offset = $index + 1; |
313 | 313 | } |
314 | - return substr( $common_base_path, 0, -1 ); |
|
314 | + return substr($common_base_path, 0, -1); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
324 | 324 | * @return mixed string |
325 | 325 | */ |
326 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
326 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -334,26 +334,26 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @since 4.6.0 |
336 | 336 | */ |
337 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
338 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
337 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
338 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
339 | 339 | |
340 | 340 | // you gimme nuttin - YOU GET NUTTIN !! |
341 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
341 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
342 | 342 | return ''; |
343 | 343 | } |
344 | 344 | // if $template_args are not in an array, then make it so |
345 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
346 | - $template_args = array( $template_args ); |
|
345 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
346 | + $template_args = array($template_args); |
|
347 | 347 | } |
348 | - extract( (array) $template_args); |
|
348 | + extract((array) $template_args); |
|
349 | 349 | |
350 | - if ( $return_string ) { |
|
350 | + if ($return_string) { |
|
351 | 351 | // because we want to return a string, we are going to capture the output |
352 | 352 | ob_start(); |
353 | - include( $template_path ); |
|
353 | + include($template_path); |
|
354 | 354 | return ob_get_clean(); |
355 | 355 | } else { |
356 | - include( $template_path ); |
|
356 | + include($template_path); |
|
357 | 357 | } |
358 | 358 | return ''; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * @param string $suffix added to the end of the generated class |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
374 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
375 | 375 | // in the beginning... |
376 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
376 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
377 | 377 | // da muddle |
378 | 378 | $class = ''; |
379 | 379 | // the end |
380 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
380 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
381 | 381 | // is the passed object an EE object ? |
382 | - if ( $object instanceof EE_Base_Class ) { |
|
382 | + if ($object instanceof EE_Base_Class) { |
|
383 | 383 | // grab the exact type of object |
384 | - $obj_class = get_class( $object ); |
|
384 | + $obj_class = get_class($object); |
|
385 | 385 | // depending on the type of object... |
386 | - switch ( $obj_class ) { |
|
386 | + switch ($obj_class) { |
|
387 | 387 | // no specifics just yet... |
388 | 388 | default : |
389 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
390 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
389 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
390 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | } |
394 | - return $prefix . $class . $suffix; |
|
394 | + return $prefix.$class.$suffix; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -407,54 +407,54 @@ discard block |
||
407 | 407 | * @param string $cur_code_span_class |
408 | 408 | * @return string the html output for the formatted money value |
409 | 409 | */ |
410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
411 | 411 | // ensure amount was received |
412 | - if ( is_null( $amount ) ) { |
|
413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
412 | + if (is_null($amount)) { |
|
413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
415 | 415 | return ''; |
416 | 416 | } |
417 | 417 | //ensure amount is float |
418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // filter to allow global setting of display_code |
448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
449 | 449 | |
450 | 450 | // add currency code ? |
451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
452 | 452 | } |
453 | 453 | // filter results |
454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
455 | 455 | } |
456 | 456 | // clean up vars |
457 | - unset( $mny ); |
|
457 | + unset($mny); |
|
458 | 458 | // return formatted currency amount |
459 | 459 | return $amount_formatted; |
460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
470 | 470 | * @return string The localized label for the status id. |
471 | 471 | */ |
472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
473 | 473 | /** @type EEM_Status $EEM_Status */ |
474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
476 | - return $status[ $status_id ]; |
|
474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
476 | + return $status[$status_id]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -488,21 +488,21 @@ discard block |
||
488 | 488 | * @param string $title |
489 | 489 | * @return string the html output for the button |
490 | 490 | */ |
491 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '', $title = '' ) { |
|
491 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') { |
|
492 | 492 | $icon_html = ''; |
493 | - if ( ! empty( $icon ) ) { |
|
494 | - $dashicons = preg_split( "(ee-icon |dashicons )", $icon ); |
|
495 | - $dashicons = array_filter( $dashicons ); |
|
496 | - $count = count( $dashicons ); |
|
493 | + if ( ! empty($icon)) { |
|
494 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
495 | + $dashicons = array_filter($dashicons); |
|
496 | + $count = count($dashicons); |
|
497 | 497 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
498 | - foreach ( $dashicons as $dashicon ) { |
|
499 | - $type = strpos( $dashicon, 'ee-icon' ) !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
498 | + foreach ($dashicons as $dashicon) { |
|
499 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
501 | 501 | } |
502 | 502 | $icon_html .= $count > 1 ? '</span>' : ''; |
503 | 503 | } |
504 | - $label = ! empty( $icon ) ? $icon_html . $label : $label; |
|
505 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
504 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
505 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
506 | 506 | return $button; |
507 | 507 | } |
508 | 508 | |
@@ -519,21 +519,21 @@ discard block |
||
519 | 519 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
520 | 520 | * @return string generated link |
521 | 521 | */ |
522 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
522 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
523 | 523 | |
524 | - if ( ! $page ) |
|
525 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
524 | + if ( ! $page) |
|
525 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
526 | 526 | |
527 | - if ( ! $action ) |
|
528 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
527 | + if ( ! $action) |
|
528 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
529 | 529 | |
530 | 530 | $action = empty($action) ? 'default' : $action; |
531 | 531 | |
532 | 532 | |
533 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
534 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | - $help_text = !$help_text ? '' : $help_text; |
|
536 | - 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>'; |
|
533 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
534 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | + $help_text = ! $help_text ? '' : $help_text; |
|
536 | + 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>'; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,31 +545,31 @@ discard block |
||
545 | 545 | * @param EE_Help_Tour |
546 | 546 | * @return string html |
547 | 547 | */ |
548 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
548 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
549 | 549 | $id = $tour->get_slug(); |
550 | 550 | $stops = $tour->get_stops(); |
551 | 551 | |
552 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
552 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
553 | 553 | |
554 | - foreach ( $stops as $stop ) { |
|
555 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
556 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
554 | + foreach ($stops as $stop) { |
|
555 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
556 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
557 | 557 | |
558 | 558 | //if container is set to modal then let's make sure we set the options accordingly |
559 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
559 | + if (empty($data_id) && empty($data_class)) { |
|
560 | 560 | $stop['options']['modal'] = true; |
561 | 561 | $stop['options']['expose'] = true; |
562 | 562 | } |
563 | 563 | |
564 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
565 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
564 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
565 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
566 | 566 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
567 | 567 | |
568 | 568 | //options |
569 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
569 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
570 | 570 | $options = ' data-options="'; |
571 | - foreach ( $stop['options'] as $option => $value ) { |
|
572 | - $options .= $option . ':' . $value . ';'; |
|
571 | + foreach ($stop['options'] as $option => $value) { |
|
572 | + $options .= $option.':'.$value.';'; |
|
573 | 573 | } |
574 | 574 | $options .= '"'; |
575 | 575 | } else { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | //let's put all together |
580 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
580 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | $content .= '</ol>'; |
@@ -598,31 +598,31 @@ discard block |
||
598 | 598 | * @throws EE_Error |
599 | 599 | * @return string html structure for status. |
600 | 600 | */ |
601 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
602 | - if ( !is_array( $status_array ) ) |
|
603 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
601 | + public static function status_legend($status_array, $active_status = '') { |
|
602 | + if ( ! is_array($status_array)) |
|
603 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
604 | 604 | |
605 | 605 | $setup_array = array(); |
606 | - foreach ( $status_array as $item => $status ) { |
|
606 | + foreach ($status_array as $item => $status) { |
|
607 | 607 | $setup_array[$item] = array( |
608 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
609 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
608 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
609 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
610 | 610 | 'status' => $status |
611 | 611 | ); |
612 | 612 | } |
613 | 613 | |
614 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
615 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
616 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
617 | - foreach ( $setup_array as $item => $details ) { |
|
614 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
615 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
616 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
617 | + foreach ($setup_array as $item => $details) { |
|
618 | 618 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
619 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
620 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
621 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
622 | - $content .= '</dt>' . "\n"; |
|
619 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
620 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
621 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
622 | + $content .= '</dt>'."\n"; |
|
623 | 623 | } |
624 | - $content .= '</dl>' . "\n"; |
|
625 | - $content .= '</div>' . "\n"; |
|
624 | + $content .= '</dl>'."\n"; |
|
625 | + $content .= '</div>'."\n"; |
|
626 | 626 | return $content; |
627 | 627 | } |
628 | 628 | |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | * @return string |
636 | 636 | */ |
637 | 637 | public static function layout_array_as_table($data) { |
638 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
639 | - $data = (array)$data; |
|
638 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
639 | + $data = (array) $data; |
|
640 | 640 | } |
641 | 641 | ob_start(); |
642 | 642 | if (is_array($data)) { |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | ?> |
650 | 650 | <tr> |
651 | 651 | <td> |
652 | - <?php echo $data_key;?> |
|
652 | + <?php echo $data_key; ?> |
|
653 | 653 | </td> |
654 | 654 | <td> |
655 | - <?php echo self::layout_array_as_table($data_values);?> |
|
655 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
656 | 656 | </td> |
657 | 657 | </tr> |
658 | 658 | <?php |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | <ul> |
667 | 667 | <?php |
668 | 668 | foreach ($data as $datum) { |
669 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
669 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
670 | 670 | }?> |
671 | 671 | </ul> |
672 | 672 | <?php |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
700 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
699 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
700 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | * ) |
722 | 722 | * @return string |
723 | 723 | */ |
724 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
724 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
725 | 725 | $page_links = array(); |
726 | 726 | $disable_first = $disable_last = ''; |
727 | 727 | $total_items = (int) $total_items; |
728 | 728 | $per_page = (int) $per_page; |
729 | 729 | $current = (int) $current; |
730 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
730 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
731 | 731 | |
732 | 732 | //filter items_label |
733 | 733 | $items_label = apply_filters( |
@@ -735,68 +735,68 @@ discard block |
||
735 | 735 | $items_label |
736 | 736 | ); |
737 | 737 | |
738 | - if ( empty( $items_label ) |
|
739 | - || ! is_array( $items_label ) |
|
740 | - || ! isset( $items_label['single'] ) |
|
741 | - || ! isset( $items_label['plural'] ) ) { |
|
738 | + if (empty($items_label) |
|
739 | + || ! is_array($items_label) |
|
740 | + || ! isset($items_label['single']) |
|
741 | + || ! isset($items_label['plural'])) { |
|
742 | 742 | $items_label = array( |
743 | - 'single' => __( '1 item', 'event_espresso' ), |
|
744 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
743 | + 'single' => __('1 item', 'event_espresso'), |
|
744 | + 'plural' => __('%s items', 'event_espresso') |
|
745 | 745 | ); |
746 | 746 | } else { |
747 | 747 | $items_label = array( |
748 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
749 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
748 | + 'single' => '1 '.esc_html($items_label['single']), |
|
749 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
750 | 750 | ); |
751 | 751 | } |
752 | 752 | |
753 | - $total_pages = ceil( $total_items / $per_page ); |
|
753 | + $total_pages = ceil($total_items / $per_page); |
|
754 | 754 | |
755 | - if ( $total_pages <= 1 ) |
|
755 | + if ($total_pages <= 1) |
|
756 | 756 | return ''; |
757 | 757 | |
758 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
758 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
759 | 759 | |
760 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
760 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
761 | 761 | |
762 | - if ( $current === 1 ) { |
|
762 | + if ($current === 1) { |
|
763 | 763 | $disable_first = ' disabled'; |
764 | 764 | } |
765 | - if ( $current == $total_pages ) { |
|
765 | + if ($current == $total_pages) { |
|
766 | 766 | $disable_last = ' disabled'; |
767 | 767 | } |
768 | 768 | |
769 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | - 'first-page' . $disable_first, |
|
771 | - esc_attr__( 'Go to the first page' ), |
|
772 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
769 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | + 'first-page'.$disable_first, |
|
771 | + esc_attr__('Go to the first page'), |
|
772 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
773 | 773 | '«' |
774 | 774 | ); |
775 | 775 | |
776 | 776 | $page_links[] = sprintf( |
777 | 777 | '<a class="%s" title="%s" href="%s">%s</a>', |
778 | - 'prev-page' . $disable_first, |
|
779 | - esc_attr__( 'Go to the previous page' ), |
|
780 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
778 | + 'prev-page'.$disable_first, |
|
779 | + esc_attr__('Go to the previous page'), |
|
780 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
781 | 781 | '‹' |
782 | 782 | ); |
783 | 783 | |
784 | - if ( ! $show_num_field ) { |
|
784 | + if ( ! $show_num_field) { |
|
785 | 785 | $html_current_page = $current; |
786 | 786 | } else { |
787 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | - esc_attr__( 'Current page' ), |
|
787 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | + esc_attr__('Current page'), |
|
789 | 789 | $current, |
790 | - strlen( $total_pages ) |
|
790 | + strlen($total_pages) |
|
791 | 791 | ); |
792 | 792 | } |
793 | 793 | |
794 | 794 | $html_total_pages = sprintf( |
795 | 795 | '<span class="total-pages">%s</span>', |
796 | - number_format_i18n( $total_pages ) |
|
796 | + number_format_i18n($total_pages) |
|
797 | 797 | ); |
798 | 798 | $page_links[] = sprintf( |
799 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
799 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
800 | 800 | $html_current_page, |
801 | 801 | $html_total_pages, |
802 | 802 | '<span class="paging-input">', |
@@ -805,29 +805,29 @@ discard block |
||
805 | 805 | |
806 | 806 | $page_links[] = sprintf( |
807 | 807 | '<a class="%s" title="%s" href="%s">%s</a>', |
808 | - 'next-page' . $disable_last, |
|
809 | - esc_attr__( 'Go to the next page' ), |
|
810 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
808 | + 'next-page'.$disable_last, |
|
809 | + esc_attr__('Go to the next page'), |
|
810 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
811 | 811 | '›' |
812 | 812 | ); |
813 | 813 | |
814 | 814 | $page_links[] = sprintf( |
815 | 815 | '<a class="%s" title="%s" href="%s">%s</a>', |
816 | - 'last-page' . $disable_last, |
|
817 | - esc_attr__( 'Go to the last page' ), |
|
818 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
816 | + 'last-page'.$disable_last, |
|
817 | + esc_attr__('Go to the last page'), |
|
818 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
819 | 819 | '»' |
820 | 820 | ); |
821 | 821 | |
822 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
822 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
823 | 823 | // set page class |
824 | - if ( $total_pages ) { |
|
824 | + if ($total_pages) { |
|
825 | 825 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
826 | 826 | } else { |
827 | 827 | $page_class = ' no-pages'; |
828 | 828 | } |
829 | 829 | |
830 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
830 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * @param string $wrap_id |
838 | 838 | * @return string |
839 | 839 | */ |
840 | - public static function powered_by_event_espresso( $wrap_class = '', $wrap_id = '' ) { |
|
841 | - $admin = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
840 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '') { |
|
841 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
842 | 842 | if ( |
843 | 843 | ! $admin && |
844 | 844 | ! apply_filters( |
@@ -848,17 +848,17 @@ discard block |
||
848 | 848 | ) { |
849 | 849 | return ''; |
850 | 850 | } |
851 | - $attributes = ! empty( $wrap_id ) ? " id=\"{$wrap_id}\"" : ''; |
|
851 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
852 | 852 | $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
853 | - $attributes .= ! empty( $wrap_class ) |
|
853 | + $attributes .= ! empty($wrap_class) |
|
854 | 854 | ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
855 | 855 | : ' class="powered-by-event-espresso-credit"'; |
856 | 856 | $powered_by = $admin ? EVENT_ESPRESSO_POWERED_BY : 'Event Espresso'; |
857 | 857 | $url = add_query_arg( |
858 | - array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id() ), |
|
858 | + array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id()), |
|
859 | 859 | 'https://eventespresso.com/' |
860 | 860 | ); |
861 | - $url = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso__url', $url ); |
|
861 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
862 | 862 | return (string) apply_filters( |
863 | 863 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
864 | 864 | sprintf( |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
889 | 889 | |
890 | 890 | |
891 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
891 | +if ( ! function_exists('espresso_pagination')) { |
|
892 | 892 | /** |
893 | 893 | * espresso_pagination |
894 | 894 | * |
@@ -900,21 +900,21 @@ discard block |
||
900 | 900 | $big = 999999999; // need an unlikely integer |
901 | 901 | $pagination = paginate_links( |
902 | 902 | array( |
903 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
903 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
904 | 904 | 'format' => '?paged=%#%', |
905 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
905 | + 'current' => max(1, get_query_var('paged')), |
|
906 | 906 | 'total' => $wp_query->max_num_pages, |
907 | 907 | 'show_all' => true, |
908 | 908 | 'end_size' => 10, |
909 | 909 | 'mid_size' => 6, |
910 | 910 | 'prev_next' => true, |
911 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
912 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
911 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
912 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
913 | 913 | 'type' => 'plain', |
914 | 914 | 'add_args' => false, |
915 | 915 | 'add_fragment' => '' |
916 | 916 | ) |
917 | 917 | ); |
918 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
918 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate |
25 | 25 | * an error occurred which means the ajax script should probably stop executing. |
26 | 26 | */ |
27 | -class EE_Data_Migration_Manager{ |
|
27 | +class EE_Data_Migration_Manager { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * of this EE installation. Keys should be the name of the version the script upgraded to |
82 | 82 | * @var EE_Data_Migration_Script_Base[] |
83 | 83 | */ |
84 | - private $_data_migrations_ran =null; |
|
84 | + private $_data_migrations_ran = null; |
|
85 | 85 | /** |
86 | 86 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
87 | 87 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function instance() { |
143 | 143 | // check if class object is instantiated |
144 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
144 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
145 | 145 | self::$_instance = new self(); |
146 | 146 | } |
147 | 147 | return self::$_instance; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
152 | 152 | * @return EE_Data_Migration_Manager |
153 | 153 | */ |
154 | - public static function reset(){ |
|
154 | + public static function reset() { |
|
155 | 155 | self::$_instance = NULL; |
156 | 156 | return self::instance(); |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * constructor |
163 | 163 | */ |
164 | - private function __construct(){ |
|
164 | + private function __construct() { |
|
165 | 165 | $this->stati_that_indicate_to_continue_migrations = array( |
166 | 166 | self::status_continue, |
167 | 167 | self::status_completed |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | ); |
181 | 181 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
182 | 182 | //to be defined, because right now it doesn't get autoloaded on its own |
183 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
184 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
185 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
186 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
187 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
188 | - $this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
189 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
183 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
184 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
185 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
186 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
187 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
188 | + $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
189 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
200 | 200 | * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0') |
201 | 201 | */ |
202 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
202 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
203 | 203 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
204 | 204 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
205 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
205 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
206 | 206 | |
207 | - if(count($parts) == 4){ |
|
207 | + if (count($parts) == 4) { |
|
208 | 208 | //it's 4.2-style.eg Core.4.1.0 |
209 | - $plugin_slug = $parts[0];//eg Core |
|
209 | + $plugin_slug = $parts[0]; //eg Core |
|
210 | 210 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
211 | - }else{ |
|
211 | + } else { |
|
212 | 212 | //it's 4.1-style: eg 4.1.0 |
213 | 213 | $plugin_slug = 'Core'; |
214 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
214 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
215 | 215 | } |
216 | - return array($plugin_slug,$version_string); |
|
216 | + return array($plugin_slug, $version_string); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | * @return EE_Data_Migration_Script_Base |
225 | 225 | * @throws EE_Error |
226 | 226 | */ |
227 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
227 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
228 | 228 | $data_migration_data = maybe_unserialize($dms_option_value); |
229 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
229 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
230 | 230 | $class = new $data_migration_data['class']; |
231 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
231 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
232 | 232 | $class->instantiate_from_array_of_properties($data_migration_data); |
233 | 233 | return $class; |
234 | - }else{ |
|
234 | + } else { |
|
235 | 235 | //huh, so its an object but not a data migration script?? that shouldn't happen |
236 | 236 | //just leave it as an array (which will probably just get ignored) |
237 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
237 | + throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class'])); |
|
238 | 238 | } |
239 | - }else{ |
|
239 | + } else { |
|
240 | 240 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
241 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
241 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | /** |
@@ -246,34 +246,34 @@ discard block |
||
246 | 246 | * the last ran which hasn't finished yet |
247 | 247 | * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored) |
248 | 248 | */ |
249 | - public function get_data_migrations_ran(){ |
|
250 | - if( ! $this->_data_migrations_ran ){ |
|
249 | + public function get_data_migrations_ran() { |
|
250 | + if ( ! $this->_data_migrations_ran) { |
|
251 | 251 | //setup autoloaders for each of the scripts in there |
252 | 252 | $this->get_all_data_migration_scripts_available(); |
253 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
253 | + $data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
254 | 254 | |
255 | 255 | $data_migrations_ran = array(); |
256 | 256 | //convert into data migration script classes where possible |
257 | - foreach($data_migrations_options as $data_migration_option){ |
|
258 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
257 | + foreach ($data_migrations_options as $data_migration_option) { |
|
258 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
259 | 259 | |
260 | - try{ |
|
261 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
260 | + try { |
|
261 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
262 | 262 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
263 | 263 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
264 | 264 | $this->_last_ran_script = $class; |
265 | - if( ! $class->is_completed()){ |
|
265 | + if ( ! $class->is_completed()) { |
|
266 | 266 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
267 | 267 | $this->_last_ran_incomplete_script = $class; |
268 | 268 | } |
269 | - }catch(EE_Error $e){ |
|
269 | + } catch (EE_Error $e) { |
|
270 | 270 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
271 | 271 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
275 | 275 | $this->_data_migrations_ran = $data_migrations_ran; |
276 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
276 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
277 | 277 | $this->_data_migrations_ran = array(); |
278 | 278 | } |
279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param $new_table |
291 | 291 | * @return mixed string or int |
292 | 292 | */ |
293 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
293 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
294 | 294 | $script = EE_Registry::instance()->load_dms($script_name); |
295 | 295 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
296 | 296 | return $mapping; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * option returned in this array is the most-recently ran DMS option |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public function get_all_migration_script_options(){ |
|
304 | + public function get_all_migration_script_options() { |
|
305 | 305 | global $wpdb; |
306 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
306 | + return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
312 | 312 | * folder name. |
313 | 313 | */ |
314 | - public function get_data_migration_script_folders(){ |
|
315 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
314 | + public function get_data_migration_script_folders() { |
|
315 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * } |
325 | 325 | * @throws EE_Error |
326 | 326 | */ |
327 | - public function script_migrates_to_version($migration_script_name){ |
|
327 | + public function script_migrates_to_version($migration_script_name) { |
|
328 | 328 | $dms_info = $this->parse_dms_classname($migration_script_name); |
329 | 329 | return array( |
330 | - 'slug'=> $dms_info[ 'slug' ], |
|
331 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
330 | + 'slug'=> $dms_info['slug'], |
|
331 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
338 | 338 | * @throws EE_Error |
339 | 339 | */ |
340 | - public function parse_dms_classname($classname){ |
|
340 | + public function parse_dms_classname($classname) { |
|
341 | 341 | $matches = array(); |
342 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
343 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
344 | - throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname)); |
|
342 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
343 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
344 | + throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname)); |
|
345 | 345 | } |
346 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
346 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
347 | 347 | } |
348 | 348 | /** |
349 | 349 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -352,33 +352,33 @@ discard block |
||
352 | 352 | * to 4.1.x. |
353 | 353 | * @return string of current db state |
354 | 354 | */ |
355 | - public function ensure_current_database_state_is_set(){ |
|
356 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
355 | + public function ensure_current_database_state_is_set() { |
|
356 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
357 | 357 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
358 | - if( ! $db_state ){ |
|
358 | + if ( ! $db_state) { |
|
359 | 359 | //mark the DB as being in the state as the last version in there. |
360 | 360 | //this is done to trigger maintenance mode and do data migration scripts |
361 | 361 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
362 | 362 | //otherwise, the normal maintenance mode code is fine |
363 | 363 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
364 | 364 | $previous_version_installed = end($previous_versions_installed); |
365 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
365 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
366 | 366 | //last installed version was less than 4.1 |
367 | 367 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
368 | 368 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
369 | 369 | $db_state = array('Core'=>$previous_version_installed); |
370 | - }else{ |
|
370 | + } else { |
|
371 | 371 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
372 | 372 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
373 | 373 | } |
374 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
374 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
375 | 375 | } |
376 | 376 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
377 | 377 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
378 | 378 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
379 | - if( ! is_array($db_state)){ |
|
379 | + if ( ! is_array($db_state)) { |
|
380 | 380 | $db_state = array('Core'=>$db_state); |
381 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
381 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
382 | 382 | } |
383 | 383 | return $db_state; |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * or they don't apply), returns an empty array |
390 | 390 | * @return EE_Data_Migration_Script_Base[] |
391 | 391 | */ |
392 | - public function check_for_applicable_data_migration_scripts(){ |
|
392 | + public function check_for_applicable_data_migration_scripts() { |
|
393 | 393 | //get the option describing what options have already run |
394 | 394 | $scripts_ran = $this->get_data_migrations_ran(); |
395 | 395 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -402,62 +402,62 @@ discard block |
||
402 | 402 | $iteration = 0; |
403 | 403 | $next_database_state_to_consider = $current_database_state; |
404 | 404 | $theoretical_database_state = NULL; |
405 | - do{ |
|
405 | + do { |
|
406 | 406 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
407 | 407 | $theoretical_database_state = $next_database_state_to_consider; |
408 | 408 | //the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?) |
409 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
409 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
410 | 410 | |
411 | 411 | $migrates_to_version = $this->script_migrates_to_version($classname); |
412 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
413 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
412 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
413 | + $script_converts_to_version = $migrates_to_version['version']; |
|
414 | 414 | //check if this version script is DONE or not; or if it's never been ran |
415 | - if( ! $scripts_ran || |
|
415 | + if ( ! $scripts_ran || |
|
416 | 416 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
417 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
417 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
418 | 418 | //we haven't ran this conversion script before |
419 | 419 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
420 | - $script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() ); |
|
420 | + $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis()); |
|
421 | 421 | /* @var $script EE_Data_Migration_Script_Base */ |
422 | 422 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
423 | - if($can_migrate){ |
|
423 | + if ($can_migrate) { |
|
424 | 424 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
425 | 425 | $migrates_to_version = $script->migrates_to_version(); |
426 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
426 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
427 | 427 | unset($script_class_and_filepaths_available[$classname]); |
428 | 428 | } |
429 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
429 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
430 | 430 | //this script has been ran, or at least started |
431 | 431 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
432 | - if( $script->get_status() != self::status_completed){ |
|
432 | + if ($script->get_status() != self::status_completed) { |
|
433 | 433 | //this script is already underway... keep going with it |
434 | 434 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
435 | 435 | $migrates_to_version = $script->migrates_to_version(); |
436 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
436 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
437 | 437 | unset($script_class_and_filepaths_available[$classname]); |
438 | - }else{ |
|
438 | + } else { |
|
439 | 439 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
440 | 440 | } |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | //it exists but it's not a proper data migration script |
443 | 443 | //maybe the script got renamed? or was simply removed from EE? |
444 | 444 | //either way, its certainly not runnable! |
445 | 445 | } |
446 | 446 | } |
447 | 447 | $iteration++; |
448 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
448 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
449 | 449 | //ok we have all the scripts that should run, now let's make them into flat array |
450 | 450 | $scripts_that_should_run = array(); |
451 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
451 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
452 | 452 | ksort($scripts_at_priority); |
453 | - foreach($scripts_at_priority as $scripts){ |
|
454 | - foreach($scripts as $script){ |
|
453 | + foreach ($scripts_at_priority as $scripts) { |
|
454 | + foreach ($scripts as $script) { |
|
455 | 455 | $scripts_that_should_run[get_class($script)] = $script; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
460 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
461 | 461 | return $scripts_that_should_run; |
462 | 462 | } |
463 | 463 | |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | * @param bool $include_completed_scripts |
472 | 472 | * @return EE_Data_Migration_Script_Base |
473 | 473 | */ |
474 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
474 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
475 | 475 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
476 | - if( ! $this->_data_migrations_ran){ |
|
476 | + if ( ! $this->_data_migrations_ran) { |
|
477 | 477 | $this->get_data_migrations_ran(); |
478 | 478 | } |
479 | - if($include_completed_scripts){ |
|
479 | + if ($include_completed_scripts) { |
|
480 | 480 | return $this->_last_ran_script; |
481 | - }else{ |
|
481 | + } else { |
|
482 | 482 | return $this->_last_ran_incomplete_script; |
483 | 483 | } |
484 | 484 | } |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | * @type string $message string describing what was done during this step |
502 | 502 | * } |
503 | 503 | */ |
504 | - public function migration_step( $step_size = 0 ){ |
|
504 | + public function migration_step($step_size = 0) { |
|
505 | 505 | |
506 | 506 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
507 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
508 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
507 | + if (class_exists('EE_CPT_Strategy')) { |
|
508 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
509 | 509 | } |
510 | 510 | |
511 | - try{ |
|
511 | + try { |
|
512 | 512 | $currently_executing_script = $this->get_last_ran_script(); |
513 | - if( ! $currently_executing_script){ |
|
513 | + if ( ! $currently_executing_script) { |
|
514 | 514 | //Find the next script that needs to execute |
515 | 515 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
516 | - if( ! $scripts ){ |
|
516 | + if ( ! $scripts) { |
|
517 | 517 | //huh, no more scripts to run... apparently we're done! |
518 | 518 | //but dont forget to make sure initial data is there |
519 | 519 | //we should be good to allow them to exit maintenance mode now |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | //and add to the array/wp option showing the scripts ran |
535 | 535 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
536 | 536 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
537 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
538 | - $version = $migrates_to[ 'version' ]; |
|
537 | + $plugin_slug = $migrates_to['slug']; |
|
538 | + $version = $migrates_to['version']; |
|
539 | 539 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
540 | 540 | } |
541 | 541 | $current_script_name = get_class($currently_executing_script); |
542 | - }catch(Exception $e){ |
|
542 | + } catch (Exception $e) { |
|
543 | 543 | //an exception occurred while trying to get migration scripts |
544 | 544 | |
545 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
545 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
546 | 546 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
547 | 547 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
548 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
548 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
549 | 549 | return array( |
550 | 550 | 'records_to_migrate'=>1, |
551 | 551 | 'records_migrated'=>0, |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | ); |
556 | 556 | } |
557 | 557 | //ok so we definitely have a data migration script |
558 | - try{ |
|
558 | + try { |
|
559 | 559 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
560 | - if( ! absint( $step_size ) > 0 ){ |
|
561 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
560 | + if ( ! absint($step_size) > 0) { |
|
561 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
562 | 562 | } |
563 | 563 | //do what we came to do! |
564 | 564 | $currently_executing_script->migration_step($step_size); |
565 | 565 | //can we wrap it up and verify default data? |
566 | 566 | $init_dbs = false; |
567 | - switch($currently_executing_script->get_status()){ |
|
567 | + switch ($currently_executing_script->get_status()) { |
|
568 | 568 | case EE_Data_Migration_Manager::status_continue: |
569 | 569 | $response_array = array( |
570 | 570 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -576,16 +576,16 @@ discard block |
||
576 | 576 | case EE_Data_Migration_Manager::status_completed: |
577 | 577 | //ok so THAT script has completed |
578 | 578 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
579 | - $response_array = array( |
|
579 | + $response_array = array( |
|
580 | 580 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
581 | 581 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
582 | 582 | 'status'=> EE_Data_Migration_Manager::status_completed, |
583 | 583 | 'message'=>$currently_executing_script->get_feedback_message(), |
584 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
584 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
585 | 585 | ); |
586 | 586 | //check if there are any more after this one. |
587 | 587 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
588 | - if( ! $scripts_remaining ){ |
|
588 | + if ( ! $scripts_remaining) { |
|
589 | 589 | //we should be good to allow them to exit maintenance mode now |
590 | 590 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
591 | 591 | ////huh, no more scripts to run... apparently we're done! |
@@ -599,39 +599,39 @@ discard block |
||
599 | 599 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
600 | 600 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
601 | 601 | 'status'=> $currently_executing_script->get_status(), |
602 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
602 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
603 | 603 | 'script'=>$currently_executing_script->pretty_name() |
604 | 604 | ); |
605 | 605 | break; |
606 | 606 | } |
607 | - }catch(Exception $e){ |
|
607 | + } catch (Exception $e) { |
|
608 | 608 | //ok so some exception was thrown which killed the data migration script |
609 | 609 | //double-check we have a real script |
610 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
610 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
611 | 611 | $script_name = $currently_executing_script->pretty_name(); |
612 | 612 | $currently_executing_script->set_broken(); |
613 | 613 | $currently_executing_script->add_error($e->getMessage()); |
614 | - }else{ |
|
614 | + } else { |
|
615 | 615 | $script_name = __("Error getting Migration Script", "event_espresso"); |
616 | 616 | } |
617 | 617 | $response_array = array( |
618 | 618 | 'records_to_migrate'=>1, |
619 | 619 | 'records_migrated'=>0, |
620 | 620 | 'status'=>self::status_fatal_error, |
621 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
621 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
622 | 622 | 'script'=>$script_name |
623 | 623 | ); |
624 | 624 | } |
625 | 625 | $successful_save = $this->_save_migrations_ran(); |
626 | - if($successful_save !== TRUE){ |
|
626 | + if ($successful_save !== TRUE) { |
|
627 | 627 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
628 | 628 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
629 | 629 | //however, if we throw an exception, and return that, then the next request |
630 | 630 | //won't have as much info in it, and it may be able to save |
631 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
631 | + throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save)); |
|
632 | 632 | } |
633 | 633 | //if we're all done, initialize EE plugins' default data etc. |
634 | - if( $init_dbs ) { |
|
634 | + if ($init_dbs) { |
|
635 | 635 | $this->initialize_db_for_enqueued_ee_plugins(); |
636 | 636 | } |
637 | 637 | return $response_array; |
@@ -649,23 +649,23 @@ discard block |
||
649 | 649 | * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes |
650 | 650 | * 'script'=>a pretty name of the script currently running |
651 | 651 | */ |
652 | - public function response_to_migration_ajax_request(){ |
|
652 | + public function response_to_migration_ajax_request() { |
|
653 | 653 | // //start output buffer just to make sure we don't mess up the json |
654 | 654 | ob_start(); |
655 | - try{ |
|
655 | + try { |
|
656 | 656 | $response = $this->migration_step(); |
657 | - }catch(Exception $e){ |
|
657 | + } catch (Exception $e) { |
|
658 | 658 | $response = array( |
659 | 659 | 'records_to_migrate'=>0, |
660 | 660 | 'records_migrated'=>0, |
661 | 661 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
662 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
662 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
663 | 663 | 'script'=>'Unknown'); |
664 | 664 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
665 | 665 | } |
666 | 666 | $warnings_etc = @ob_get_contents(); |
667 | 667 | ob_end_clean(); |
668 | - $response['message'] .=$warnings_etc; |
|
668 | + $response['message'] .= $warnings_etc; |
|
669 | 669 | return $response; |
670 | 670 | } |
671 | 671 | |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * } |
679 | 679 | * @return void |
680 | 680 | */ |
681 | - public function update_current_database_state_to($slug_and_version = null){ |
|
682 | - if( ! $slug_and_version ){ |
|
681 | + public function update_current_database_state_to($slug_and_version = null) { |
|
682 | + if ( ! $slug_and_version) { |
|
683 | 683 | //no version was provided, assume it should be at the current code version |
684 | 684 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
685 | 685 | } |
686 | 686 | $current_database_state = get_option(self::current_database_state); |
687 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
688 | - update_option(self::current_database_state,$current_database_state); |
|
687 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
688 | + update_option(self::current_database_state, $current_database_state); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -696,20 +696,20 @@ discard block |
||
696 | 696 | * } |
697 | 697 | * @return boolean |
698 | 698 | */ |
699 | - public function database_needs_updating_to( $slug_and_version ) { |
|
699 | + public function database_needs_updating_to($slug_and_version) { |
|
700 | 700 | |
701 | - $slug = $slug_and_version[ 'slug' ]; |
|
702 | - $version = $slug_and_version[ 'version' ]; |
|
701 | + $slug = $slug_and_version['slug']; |
|
702 | + $version = $slug_and_version['version']; |
|
703 | 703 | $current_database_state = get_option(self::current_database_state); |
704 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
704 | + if ( ! isset($current_database_state[$slug])) { |
|
705 | 705 | return true; |
706 | - }else{ |
|
706 | + } else { |
|
707 | 707 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
708 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
709 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
708 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
709 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
710 | 710 | $needs_updating = false; |
711 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
712 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
711 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
712 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
713 | 713 | $needs_updating = true; |
714 | 714 | break; |
715 | 715 | } |
@@ -723,29 +723,29 @@ discard block |
||
723 | 723 | * in addons. Has the side effect of adding them for autoloading |
724 | 724 | * @return array keys are expected classnames, values are their filepaths |
725 | 725 | */ |
726 | - public function get_all_data_migration_scripts_available(){ |
|
727 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
726 | + public function get_all_data_migration_scripts_available() { |
|
727 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
728 | 728 | $this->_data_migration_class_to_filepath_map = array(); |
729 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
730 | - if($folder_path[count($folder_path-1)] != DS ){ |
|
731 | - $folder_path.= DS; |
|
729 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
730 | + if ($folder_path[count($folder_path - 1)] != DS) { |
|
731 | + $folder_path .= DS; |
|
732 | 732 | } |
733 | - $files = glob( $folder_path. '*.dms.php' ); |
|
733 | + $files = glob($folder_path.'*.dms.php'); |
|
734 | 734 | |
735 | - if ( empty( $files ) ) { |
|
735 | + if (empty($files)) { |
|
736 | 736 | continue; |
737 | 737 | } |
738 | 738 | |
739 | - foreach($files as $file){ |
|
740 | - $pos_of_last_slash = strrpos($file,DS); |
|
741 | - $classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1)); |
|
742 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
743 | - $slug = $migrates_to[ 'slug' ]; |
|
739 | + foreach ($files as $file) { |
|
740 | + $pos_of_last_slash = strrpos($file, DS); |
|
741 | + $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1)); |
|
742 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
743 | + $slug = $migrates_to['slug']; |
|
744 | 744 | //check that the slug as contained in the DMS is associated with |
745 | 745 | //the slug of an addon or core |
746 | - if( $slug != 'Core' ){ |
|
747 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
748 | - EE_Error::doing_it_wrong(__FUNCTION__, sprintf( __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),$classname,$slug,implode(",", array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ), '4.3.0.alpha.019' ); |
|
746 | + if ($slug != 'Core') { |
|
747 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
748 | + EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019'); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | $this->_data_migration_class_to_filepath_map[$classname] = $file; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * from each addon, and check if they need updating, |
766 | 766 | * @return boolean |
767 | 767 | */ |
768 | - public function addons_need_updating(){ |
|
768 | + public function addons_need_updating() { |
|
769 | 769 | return false; |
770 | 770 | } |
771 | 771 | /** |
@@ -774,25 +774,25 @@ discard block |
||
774 | 774 | * @param string $error_message |
775 | 775 | * @throws EE_Error |
776 | 776 | */ |
777 | - public function add_error_to_migrations_ran($error_message){ |
|
777 | + public function add_error_to_migrations_ran($error_message) { |
|
778 | 778 | //get last-ran migration script |
779 | 779 | global $wpdb; |
780 | - $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A); |
|
780 | + $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A); |
|
781 | 781 | |
782 | 782 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
783 | 783 | //now, tread lightly because we're here because a FATAL non-catchable error |
784 | 784 | //was thrown last time when we were trying to run a data migration script |
785 | 785 | //so the fatal error could have happened while getting the migration script |
786 | 786 | //or doing running it... |
787 | - $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null; |
|
787 | + $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null; |
|
788 | 788 | |
789 | 789 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
790 | 790 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
791 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
791 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
792 | 792 | //ok then just add this error to its list of errors |
793 | 793 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
794 | 794 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
795 | - }else{ |
|
795 | + } else { |
|
796 | 796 | //so we don't even know which script was last running |
797 | 797 | //use the data migration error stub, which is designed specifically for this type of thing |
798 | 798 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -802,39 +802,39 @@ discard block |
||
802 | 802 | $versions_migrated_to = 'Unknown.1.0.0'; |
803 | 803 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
804 | 804 | //delete the old one |
805 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
805 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
806 | 806 | } |
807 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
807 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * saves what data migrations have ran to the database |
812 | 812 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
813 | 813 | */ |
814 | - protected function _save_migrations_ran(){ |
|
815 | - if($this->_data_migrations_ran == null){ |
|
814 | + protected function _save_migrations_ran() { |
|
815 | + if ($this->_data_migrations_ran == null) { |
|
816 | 816 | $this->get_data_migrations_ran(); |
817 | 817 | } |
818 | 818 | //now, we don't want to save actual classes to the DB because that's messy |
819 | 819 | $successful_updates = true; |
820 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
821 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
820 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
821 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
822 | 822 | // echo "saving migration script to $version_string<br>"; |
823 | 823 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
824 | 824 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
825 | 825 | $old_option_value = get_option($option_name); |
826 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
826 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
827 | 827 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
828 | - if( $old_option_value != $script_array_for_saving){ |
|
829 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
828 | + if ($old_option_value != $script_array_for_saving) { |
|
829 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
830 | 830 | } |
831 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
831 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
832 | 832 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
833 | - if($old_option_value != $array_or_migration_obj){ |
|
834 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
833 | + if ($old_option_value != $array_or_migration_obj) { |
|
834 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
835 | 835 | } |
836 | 836 | } |
837 | - if( ! $successful_updates ){ |
|
837 | + if ( ! $successful_updates) { |
|
838 | 838 | global $wpdb; |
839 | 839 | return $wpdb->last_error; |
840 | 840 | } |
@@ -858,17 +858,17 @@ discard block |
||
858 | 858 | * @return EE_Data_Migration_Script_Base |
859 | 859 | * @throws EE_Error |
860 | 860 | */ |
861 | - function _instantiate_script_from_properties_array($properties_array){ |
|
862 | - if( ! isset($properties_array['class'])){ |
|
863 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
861 | + function _instantiate_script_from_properties_array($properties_array) { |
|
862 | + if ( ! isset($properties_array['class'])) { |
|
863 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
864 | 864 | } |
865 | 865 | $class_name = $properties_array['class']; |
866 | - if( ! class_exists($class_name)){ |
|
867 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
866 | + if ( ! class_exists($class_name)) { |
|
867 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
868 | 868 | } |
869 | 869 | $class = new $class_name; |
870 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
871 | - throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class))); |
|
870 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
871 | + throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class))); |
|
872 | 872 | } |
873 | 873 | $class->instantiate_from_array_of_properties($properties_array); |
874 | 874 | return $class; |
@@ -880,25 +880,25 @@ discard block |
||
880 | 880 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
881 | 881 | * @return string |
882 | 882 | */ |
883 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
883 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
884 | 884 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
885 | 885 | $most_up_to_date_dms_classname = NULL; |
886 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
887 | - if($most_up_to_date_dms_classname === NULL){ |
|
886 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
887 | + if ($most_up_to_date_dms_classname === NULL) { |
|
888 | 888 | $migrates_to = $this->script_migrates_to_version($classname); |
889 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
889 | + $this_plugin_slug = $migrates_to['slug']; |
|
890 | 890 | // $version_string = $migrates_to[ 'version' ]; |
891 | 891 | // $details = $this->parse_dms_classname($classname); |
892 | - if($this_plugin_slug == $plugin_slug){ |
|
892 | + if ($this_plugin_slug == $plugin_slug) { |
|
893 | 893 | //if it's for core, it wins |
894 | 894 | $most_up_to_date_dms_classname = $classname; |
895 | 895 | } |
896 | 896 | //if it wasn't for core, we must keep searching for one that is! |
897 | 897 | continue; |
898 | - }else{ |
|
899 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
898 | + } else { |
|
899 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
900 | 900 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
901 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
901 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
902 | 902 | //so the contenders version is higher and its for Core |
903 | 903 | $most_up_to_date_dms_classname = $classname; |
904 | 904 | } |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
919 | 919 | * @return EE_Data_Migration_Script_Base |
920 | 920 | */ |
921 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
921 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
922 | 922 | $migrations_ran = $this->get_data_migrations_ran(); |
923 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
924 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
925 | - }else{ |
|
923 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
924 | + return $migrations_ran[$plugin_slug][$version]; |
|
925 | + } else { |
|
926 | 926 | return NULL; |
927 | 927 | } |
928 | 928 | } |
@@ -934,20 +934,20 @@ discard block |
||
934 | 934 | * @return bool |
935 | 935 | * @throws \EE_Error |
936 | 936 | */ |
937 | - public function reattempt(){ |
|
937 | + public function reattempt() { |
|
938 | 938 | //find if the last-ran script was borked |
939 | 939 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
940 | 940 | //add an 'error' saying that we attempted to reset |
941 | 941 | //does it have a stage that was borked too? if so make it no longer borked |
942 | 942 | //add an 'error' saying we attempted to reset |
943 | 943 | $last_ran_script = $this->get_last_ran_script(); |
944 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
944 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
945 | 945 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
946 | 946 | $last_ran_script->set_completed(); |
947 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
947 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
948 | 948 | $last_ran_script->reattempt(); |
949 | - }else{ |
|
950 | - throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
|
949 | + } else { |
|
950 | + throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true))); |
|
951 | 951 | } |
952 | 952 | return $this->_save_migrations_ran(); |
953 | 953 | } |
@@ -957,19 +957,19 @@ discard block |
||
957 | 957 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
958 | 958 | * @return boolean |
959 | 959 | */ |
960 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
961 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
960 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
961 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
962 | 962 | } |
963 | 963 | /** |
964 | 964 | * Enqueues this ee plugin to have its data initialized |
965 | 965 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
966 | 966 | */ |
967 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
967 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
968 | 968 | $queue = $this->get_db_initialization_queue(); |
969 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
969 | + if ( ! in_array($plugin_slug, $queue)) { |
|
970 | 970 | $queue[] = $plugin_slug; |
971 | 971 | } |
972 | - update_option( self::db_init_queue_option_name, $queue ); |
|
972 | + update_option(self::db_init_queue_option_name, $queue); |
|
973 | 973 | } |
974 | 974 | /** |
975 | 975 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -979,26 +979,26 @@ discard block |
||
979 | 979 | public function initialize_db_for_enqueued_ee_plugins() { |
980 | 980 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
981 | 981 | $queue = $this->get_db_initialization_queue(); |
982 | - foreach( $queue as $plugin_slug ) { |
|
983 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
984 | - if( ! $most_up_to_date_dms ) { |
|
982 | + foreach ($queue as $plugin_slug) { |
|
983 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
984 | + if ( ! $most_up_to_date_dms) { |
|
985 | 985 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
986 | 986 | $verify_db = false; |
987 | - }else{ |
|
988 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
989 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
987 | + } else { |
|
988 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
989 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
990 | 990 | } |
991 | - if( $plugin_slug == 'Core' ){ |
|
991 | + if ($plugin_slug == 'Core') { |
|
992 | 992 | EE_System::instance()->initialize_db_if_no_migrations_required( |
993 | 993 | false, |
994 | 994 | $verify_db |
995 | 995 | ); |
996 | - }else{ |
|
996 | + } else { |
|
997 | 997 | //just loop through the addons to make sure their database is setup |
998 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
999 | - if( $addon->name() == $plugin_slug ) { |
|
998 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
999 | + if ($addon->name() == $plugin_slug) { |
|
1000 | 1000 | |
1001 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
1001 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
1002 | 1002 | break; |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | // EEH_Debug_Tools::instance()->show_times(); |
1009 | 1009 | //because we just initialized the DBs for the enqueued ee plugins |
1010 | 1010 | //we don't need to keep remembering which ones needed to be initialized |
1011 | - delete_option( self::db_init_queue_option_name ); |
|
1011 | + delete_option(self::db_init_queue_option_name); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * 'Core', or the return value of EE_Addon::name() for an addon |
1018 | 1018 | * @return array |
1019 | 1019 | */ |
1020 | - public function get_db_initialization_queue(){ |
|
1021 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
1020 | + public function get_db_initialization_queue() { |
|
1021 | + return get_option(self::db_init_queue_option_name, array()); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1027,13 +1027,13 @@ discard block |
||
1027 | 1027 | * @throws \EE_Error |
1028 | 1028 | */ |
1029 | 1029 | protected function _get_table_analysis() { |
1030 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
1030 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
1031 | 1031 | return $this->_table_analysis; |
1032 | 1032 | } else { |
1033 | 1033 | throw new \EE_Error( |
1034 | 1034 | sprintf( |
1035 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | - get_class( $this ) |
|
1035 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | + get_class($this) |
|
1037 | 1037 | ) |
1038 | 1038 | ); |
1039 | 1039 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | * @throws \EE_Error |
1046 | 1046 | */ |
1047 | 1047 | protected function _get_table_manager() { |
1048 | - if( $this->_table_manager instanceof TableManager ) { |
|
1048 | + if ($this->_table_manager instanceof TableManager) { |
|
1049 | 1049 | return $this->_table_manager; |
1050 | 1050 | } else { |
1051 | 1051 | throw new \EE_Error( |
1052 | 1052 | sprintf( |
1053 | - __( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | - get_class( $this ) |
|
1053 | + __('Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | + get_class($this) |
|
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | //it's 4.2-style.eg Core.4.1.0 |
209 | 209 | $plugin_slug = $parts[0];//eg Core |
210 | 210 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
211 | - }else{ |
|
211 | + } else{ |
|
212 | 212 | //it's 4.1-style: eg 4.1.0 |
213 | 213 | $plugin_slug = 'Core'; |
214 | 214 | $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | if($class instanceof EE_Data_Migration_Script_Base){ |
232 | 232 | $class->instantiate_from_array_of_properties($data_migration_data); |
233 | 233 | return $class; |
234 | - }else{ |
|
234 | + } else{ |
|
235 | 235 | //huh, so its an object but not a data migration script?? that shouldn't happen |
236 | 236 | //just leave it as an array (which will probably just get ignored) |
237 | 237 | throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
238 | 238 | } |
239 | - }else{ |
|
239 | + } else{ |
|
240 | 240 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
241 | 241 | throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
242 | 242 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
267 | 267 | $this->_last_ran_incomplete_script = $class; |
268 | 268 | } |
269 | - }catch(EE_Error $e){ |
|
269 | + } catch(EE_Error $e){ |
|
270 | 270 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
271 | 271 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
272 | 272 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
368 | 368 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
369 | 369 | $db_state = array('Core'=>$previous_version_installed); |
370 | - }else{ |
|
370 | + } else{ |
|
371 | 371 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
372 | 372 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
373 | 373 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | $migrates_to_version = $script->migrates_to_version(); |
436 | 436 | $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
437 | 437 | unset($script_class_and_filepaths_available[$classname]); |
438 | - }else{ |
|
438 | + } else{ |
|
439 | 439 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
440 | 440 | } |
441 | - }else{ |
|
441 | + } else{ |
|
442 | 442 | //it exists but it's not a proper data migration script |
443 | 443 | //maybe the script got renamed? or was simply removed from EE? |
444 | 444 | //either way, its certainly not runnable! |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | } |
479 | 479 | if($include_completed_scripts){ |
480 | 480 | return $this->_last_ran_script; |
481 | - }else{ |
|
481 | + } else{ |
|
482 | 482 | return $this->_last_ran_incomplete_script; |
483 | 483 | } |
484 | 484 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
540 | 540 | } |
541 | 541 | $current_script_name = get_class($currently_executing_script); |
542 | - }catch(Exception $e){ |
|
542 | + } catch(Exception $e){ |
|
543 | 543 | //an exception occurred while trying to get migration scripts |
544 | 544 | |
545 | 545 | $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
@@ -604,14 +604,14 @@ discard block |
||
604 | 604 | ); |
605 | 605 | break; |
606 | 606 | } |
607 | - }catch(Exception $e){ |
|
607 | + } catch(Exception $e){ |
|
608 | 608 | //ok so some exception was thrown which killed the data migration script |
609 | 609 | //double-check we have a real script |
610 | 610 | if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
611 | 611 | $script_name = $currently_executing_script->pretty_name(); |
612 | 612 | $currently_executing_script->set_broken(); |
613 | 613 | $currently_executing_script->add_error($e->getMessage()); |
614 | - }else{ |
|
614 | + } else{ |
|
615 | 615 | $script_name = __("Error getting Migration Script", "event_espresso"); |
616 | 616 | } |
617 | 617 | $response_array = array( |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | ob_start(); |
655 | 655 | try{ |
656 | 656 | $response = $this->migration_step(); |
657 | - }catch(Exception $e){ |
|
657 | + } catch(Exception $e){ |
|
658 | 658 | $response = array( |
659 | 659 | 'records_to_migrate'=>0, |
660 | 660 | 'records_migrated'=>0, |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | $current_database_state = get_option(self::current_database_state); |
704 | 704 | if( ! isset( $current_database_state[ $slug ] ) ) { |
705 | 705 | return true; |
706 | - }else{ |
|
706 | + } else{ |
|
707 | 707 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
708 | 708 | $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
709 | 709 | $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | //ok then just add this error to its list of errors |
804 | 804 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
805 | 805 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
806 | - }else{ |
|
806 | + } else{ |
|
807 | 807 | //so we don't even know which script was last running |
808 | 808 | //use the data migration error stub, which is designed specifically for this type of thing |
809 | 809 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | if( $old_option_value != $script_array_for_saving){ |
840 | 840 | $successful_updates = update_option($option_name,$script_array_for_saving); |
841 | 841 | } |
842 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
842 | + } else{//we don't know what this array-thing is. So just save it as-is |
|
843 | 843 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
844 | 844 | if($old_option_value != $array_or_migration_obj){ |
845 | 845 | $successful_updates = update_option($option_name,$array_or_migration_obj); |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | } |
907 | 907 | //if it wasn't for core, we must keep searching for one that is! |
908 | 908 | continue; |
909 | - }else{ |
|
909 | + } else{ |
|
910 | 910 | $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
911 | 911 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
912 | 912 | if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | $migrations_ran = $this->get_data_migrations_ran(); |
934 | 934 | if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
935 | 935 | return $migrations_ran[ $plugin_slug ][ $version ]; |
936 | - }else{ |
|
936 | + } else{ |
|
937 | 937 | return NULL; |
938 | 938 | } |
939 | 939 | } |
@@ -955,9 +955,9 @@ discard block |
||
955 | 955 | if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
956 | 956 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
957 | 957 | $last_ran_script->set_completed(); |
958 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
958 | + } elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
959 | 959 | $last_ran_script->reattempt(); |
960 | - }else{ |
|
960 | + } else{ |
|
961 | 961 | throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
962 | 962 | } |
963 | 963 | return $this->_save_migrations_ran(); |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | if( ! $most_up_to_date_dms ) { |
996 | 996 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
997 | 997 | $verify_db = false; |
998 | - }else{ |
|
998 | + } else{ |
|
999 | 999 | $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
1000 | 1000 | $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
1001 | 1001 | } |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | false, |
1005 | 1005 | $verify_db |
1006 | 1006 | ); |
1007 | - }else{ |
|
1007 | + } else{ |
|
1008 | 1008 | //just loop through the addons to make sure their database is setup |
1009 | 1009 | foreach( EE_Registry::instance()->addons as $addon ) { |
1010 | 1010 | if( $addon->name() == $plugin_slug ) { |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | protected $_table_analysis; |
128 | 128 | |
129 | 129 | /** |
130 | - * @var EE_Data_Migration_Manager $_instance |
|
130 | + * @var EE_Data_Migration_Manager $_instance |
|
131 | 131 | * @access private |
132 | - */ |
|
132 | + */ |
|
133 | 133 | private static $_instance = NULL; |
134 | 134 | |
135 | 135 | |
@@ -928,12 +928,12 @@ discard block |
||
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
931 | - * Resets the borked data migration scripts so they're no longer borked |
|
932 | - * so we can again attempt to migrate |
|
933 | - * |
|
934 | - * @return bool |
|
935 | - * @throws \EE_Error |
|
936 | - */ |
|
931 | + * Resets the borked data migration scripts so they're no longer borked |
|
932 | + * so we can again attempt to migrate |
|
933 | + * |
|
934 | + * @return bool |
|
935 | + * @throws \EE_Error |
|
936 | + */ |
|
937 | 937 | public function reattempt(){ |
938 | 938 | //find if the last-ran script was borked |
939 | 939 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |