@@ -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 | * |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * @param $table_name |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
| 51 | + public static function ensure_table_name_has_prefix($table_name) { |
|
| 52 | 52 | global $wpdb; |
| 53 | - return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
| 53 | + return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return boolean success, whether the database and folders are setup properly |
| 79 | 79 | * @throws \EE_Error |
| 80 | 80 | */ |
| 81 | - public static function initialize_db_and_folders(){ |
|
| 81 | + public static function initialize_db_and_folders() { |
|
| 82 | 82 | $good_filesystem = EEH_Activation::create_upload_directories(); |
| 83 | 83 | $good_db = EEH_Activation::create_database_tables(); |
| 84 | 84 | return $good_filesystem && $good_db; |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @throws \EE_Error |
| 96 | 96 | */ |
| 97 | - public static function initialize_db_content(){ |
|
| 97 | + public static function initialize_db_content() { |
|
| 98 | 98 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
| 99 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
| 99 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | EEH_Activation::remove_cron_tasks(); |
| 114 | 114 | EEH_Activation::create_cron_tasks(); |
| 115 | 115 | // remove all TXN locks since that is being done via extra meta now |
| 116 | - delete_option( 'ee_locked_transactions' ); |
|
| 116 | + delete_option('ee_locked_transactions'); |
|
| 117 | 117 | //also, check for CAF default db content |
| 118 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
| 118 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
| 119 | 119 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
| 120 | 120 | //which users really won't care about on initial activation |
| 121 | 121 | EE_Error::overwrite_success(); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @return array |
| 136 | 136 | * @throws \EE_Error |
| 137 | 137 | */ |
| 138 | - public static function get_cron_tasks( $which_to_include ) { |
|
| 138 | + public static function get_cron_tasks($which_to_include) { |
|
| 139 | 139 | $cron_tasks = apply_filters( |
| 140 | 140 | 'FHEE__EEH_Activation__get_cron_tasks', |
| 141 | 141 | array( |
@@ -144,16 +144,16 @@ discard block |
||
| 144 | 144 | '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 |
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | - if ( $which_to_include === 'old' ) { |
|
| 147 | + if ($which_to_include === 'old') { |
|
| 148 | 148 | $cron_tasks = array_filter( |
| 149 | 149 | $cron_tasks, |
| 150 | - function ( $value ) { |
|
| 150 | + function($value) { |
|
| 151 | 151 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
| 152 | 152 | } |
| 153 | 153 | ); |
| 154 | - } elseif ( $which_to_include === 'current' ) { |
|
| 155 | - $cron_tasks = array_filter( $cron_tasks ); |
|
| 156 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
| 154 | + } elseif ($which_to_include === 'current') { |
|
| 155 | + $cron_tasks = array_filter($cron_tasks); |
|
| 156 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
| 157 | 157 | throw new EE_Error( |
| 158 | 158 | sprintf( |
| 159 | 159 | __( |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function create_cron_tasks() { |
| 178 | 178 | |
| 179 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
| 180 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
| 181 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
| 179 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
| 180 | + if ( ! wp_next_scheduled($hook_name)) { |
|
| 181 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
| 193 | 193 | * @throws \EE_Error |
| 194 | 194 | */ |
| 195 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
| 195 | + public static function remove_cron_tasks($remove_all = true) { |
|
| 196 | 196 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
| 197 | 197 | $crons = _get_cron_array(); |
| 198 | - $crons = is_array( $crons ) ? $crons : array(); |
|
| 198 | + $crons = is_array($crons) ? $crons : array(); |
|
| 199 | 199 | /* reminder of what $crons look like: |
| 200 | 200 | * Top-level keys are timestamps, and their values are arrays. |
| 201 | 201 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -213,23 +213,23 @@ discard block |
||
| 213 | 213 | * ... |
| 214 | 214 | * ... |
| 215 | 215 | */ |
| 216 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
| 217 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
| 218 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
| 219 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
| 220 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
| 221 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
| 216 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
| 217 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
| 218 | + if (is_array($hooks_to_fire_at_time)) { |
|
| 219 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
| 220 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
| 221 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
| 222 | 222 | ) { |
| 223 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
| 223 | + unset($crons[$timestamp][$hook_name]); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | //also take care of any empty cron timestamps. |
| 227 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
| 228 | - unset( $crons[ $timestamp ] ); |
|
| 227 | + if (empty($hooks_to_fire_at_time)) { |
|
| 228 | + unset($crons[$timestamp]); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | - _set_cron_array( $crons ); |
|
| 232 | + _set_cron_array($crons); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public static function CPT_initialization() { |
| 246 | 246 | // register Custom Post Types |
| 247 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
| 247 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
| 248 | 248 | flush_rewrite_rules(); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | 264 | public static function reset_and_update_config() { |
| 265 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
| 266 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
| 265 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
| 266 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
| 267 | 267 | //EE_Config::reset(); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,28 +276,28 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public static function load_calendar_config() { |
| 278 | 278 | // grab array of all plugin folders and loop thru it |
| 279 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
| 280 | - if ( empty( $plugins ) ) { |
|
| 279 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
| 280 | + if (empty($plugins)) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | - foreach ( $plugins as $plugin_path ) { |
|
| 283 | + foreach ($plugins as $plugin_path) { |
|
| 284 | 284 | // grab plugin folder name from path |
| 285 | - $plugin = basename( $plugin_path ); |
|
| 285 | + $plugin = basename($plugin_path); |
|
| 286 | 286 | // drill down to Espresso plugins |
| 287 | 287 | // then to calendar related plugins |
| 288 | 288 | if ( |
| 289 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
| 290 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
| 291 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
| 292 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
| 293 | - || strpos( $plugin, 'calendar' ) !== false |
|
| 289 | + strpos($plugin, 'espresso') !== FALSE |
|
| 290 | + || strpos($plugin, 'Espresso') !== FALSE |
|
| 291 | + || strpos($plugin, 'ee4') !== FALSE |
|
| 292 | + || strpos($plugin, 'EE4') !== FALSE |
|
| 293 | + || strpos($plugin, 'calendar') !== false |
|
| 294 | 294 | ) { |
| 295 | 295 | // this is what we are looking for |
| 296 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
| 296 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
| 297 | 297 | // does it exist in this folder ? |
| 298 | - if ( is_readable( $calendar_config )) { |
|
| 298 | + if (is_readable($calendar_config)) { |
|
| 299 | 299 | // YEAH! let's load it |
| 300 | - require_once( $calendar_config ); |
|
| 300 | + require_once($calendar_config); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | * @param \EE_Config $EE_Config |
| 314 | 314 | * @return \stdClass |
| 315 | 315 | */ |
| 316 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
| 317 | - $convert_from_array = array( 'addons' ); |
|
| 316 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
| 317 | + $convert_from_array = array('addons'); |
|
| 318 | 318 | // in case old settings were saved as an array |
| 319 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
| 319 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
| 320 | 320 | // convert existing settings to an object |
| 321 | 321 | $config_array = $settings; |
| 322 | 322 | $settings = new stdClass(); |
| 323 | - foreach ( $config_array as $key => $value ){ |
|
| 324 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
| 325 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
| 323 | + foreach ($config_array as $key => $value) { |
|
| 324 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
| 325 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
| 326 | 326 | } else { |
| 327 | 327 | $settings->{$key} = $value; |
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
| 330 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
| 331 | 331 | } |
| 332 | 332 | return $settings; |
| 333 | 333 | } |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public static function deactivate_event_espresso() { |
| 345 | 345 | // check permissions |
| 346 | - if ( current_user_can( 'activate_plugins' )) { |
|
| 347 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
| 346 | + if (current_user_can('activate_plugins')) { |
|
| 347 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
@@ -366,25 +366,25 @@ discard block |
||
| 366 | 366 | $critical_pages = array( |
| 367 | 367 | array( |
| 368 | 368 | 'id' =>'reg_page_id', |
| 369 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
| 369 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
| 370 | 370 | 'post' => NULL, |
| 371 | 371 | 'code' => 'ESPRESSO_CHECKOUT' |
| 372 | 372 | ), |
| 373 | 373 | array( |
| 374 | 374 | 'id' => 'txn_page_id', |
| 375 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
| 375 | + 'name' => __('Transactions', 'event_espresso'), |
|
| 376 | 376 | 'post' => NULL, |
| 377 | 377 | 'code' => 'ESPRESSO_TXN_PAGE' |
| 378 | 378 | ), |
| 379 | 379 | array( |
| 380 | 380 | 'id' => 'thank_you_page_id', |
| 381 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
| 381 | + 'name' => __('Thank You', 'event_espresso'), |
|
| 382 | 382 | 'post' => NULL, |
| 383 | 383 | 'code' => 'ESPRESSO_THANK_YOU' |
| 384 | 384 | ), |
| 385 | 385 | array( |
| 386 | 386 | 'id' => 'cancel_page_id', |
| 387 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
| 387 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
| 388 | 388 | 'post' => NULL, |
| 389 | 389 | 'code' => 'ESPRESSO_CANCELLED' |
| 390 | 390 | ), |
@@ -392,62 +392,62 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
| 394 | 394 | |
| 395 | - foreach ( $critical_pages as $critical_page ) { |
|
| 395 | + foreach ($critical_pages as $critical_page) { |
|
| 396 | 396 | // is critical page ID set in config ? |
| 397 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
| 397 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
| 398 | 398 | // attempt to find post by ID |
| 399 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
| 399 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
| 400 | 400 | } |
| 401 | 401 | // no dice? |
| 402 | - if ( $critical_page['post'] === null ) { |
|
| 402 | + if ($critical_page['post'] === null) { |
|
| 403 | 403 | // attempt to find post by title |
| 404 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
| 404 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
| 405 | 405 | // still nothing? |
| 406 | - if ( $critical_page['post'] === null ) { |
|
| 407 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
| 406 | + if ($critical_page['post'] === null) { |
|
| 407 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
| 408 | 408 | // REALLY? Still nothing ??!?!? |
| 409 | - if ( $critical_page['post'] === null ) { |
|
| 410 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
| 411 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 409 | + if ($critical_page['post'] === null) { |
|
| 410 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
| 411 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 412 | 412 | break; |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | // track post_shortcodes |
| 417 | - if ( $critical_page['post'] ) { |
|
| 418 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
| 417 | + if ($critical_page['post']) { |
|
| 418 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
| 419 | 419 | } |
| 420 | 420 | // check that Post ID matches critical page ID in config |
| 421 | 421 | if ( |
| 422 | - isset( $critical_page['post']->ID ) |
|
| 423 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
| 422 | + isset($critical_page['post']->ID) |
|
| 423 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
| 424 | 424 | ) { |
| 425 | 425 | //update Config with post ID |
| 426 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
| 427 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
| 428 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
| 429 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 426 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
| 427 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
| 428 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
| 429 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | $critical_page_problem = |
| 434 | - ! isset( $critical_page['post']->post_status ) |
|
| 434 | + ! isset($critical_page['post']->post_status) |
|
| 435 | 435 | || $critical_page['post']->post_status !== 'publish' |
| 436 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
| 436 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
| 437 | 437 | ? TRUE |
| 438 | 438 | : $critical_page_problem; |
| 439 | 439 | |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if ( $critical_page_problem ) { |
|
| 442 | + if ($critical_page_problem) { |
|
| 443 | 443 | $msg = sprintf( |
| 444 | - __('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' ), |
|
| 445 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
| 444 | + __('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'), |
|
| 445 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
| 446 | 446 | ); |
| 447 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
| 447 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
| 448 | 448 | } |
| 449 | - if ( EE_Error::has_notices() ) { |
|
| 450 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
| 449 | + if (EE_Error::has_notices()) { |
|
| 450 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
@@ -459,13 +459,13 @@ discard block |
||
| 459 | 459 | * parameter to the shortcode |
| 460 | 460 | * @return WP_Post or NULl |
| 461 | 461 | */ |
| 462 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
| 462 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
| 463 | 463 | global $wpdb; |
| 464 | 464 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
| 465 | 465 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
| 466 | - if($post_id){ |
|
| 466 | + if ($post_id) { |
|
| 467 | 467 | return get_post($post_id); |
| 468 | - }else{ |
|
| 468 | + } else { |
|
| 469 | 469 | return NULL; |
| 470 | 470 | } |
| 471 | 471 | |
@@ -482,32 +482,32 @@ discard block |
||
| 482 | 482 | * @param array $critical_page |
| 483 | 483 | * @return array |
| 484 | 484 | */ |
| 485 | - public static function create_critical_page( $critical_page ) { |
|
| 485 | + public static function create_critical_page($critical_page) { |
|
| 486 | 486 | |
| 487 | 487 | $post_args = array( |
| 488 | 488 | 'post_title' => $critical_page['name'], |
| 489 | 489 | 'post_status' => 'publish', |
| 490 | 490 | 'post_type' => 'page', |
| 491 | 491 | 'comment_status' => 'closed', |
| 492 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
| 492 | + 'post_content' => '['.$critical_page['code'].']' |
|
| 493 | 493 | ); |
| 494 | 494 | |
| 495 | - $post_id = wp_insert_post( $post_args ); |
|
| 496 | - if ( ! $post_id ) { |
|
| 495 | + $post_id = wp_insert_post($post_args); |
|
| 496 | + if ( ! $post_id) { |
|
| 497 | 497 | $msg = sprintf( |
| 498 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
| 498 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
| 499 | 499 | $critical_page['name'] |
| 500 | 500 | ); |
| 501 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 501 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 502 | 502 | return $critical_page; |
| 503 | 503 | } |
| 504 | 504 | // get newly created post's details |
| 505 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
| 505 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
| 506 | 506 | $msg = sprintf( |
| 507 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
| 507 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
| 508 | 508 | $critical_page['name'] |
| 509 | 509 | ); |
| 510 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 510 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | return $critical_page; |
@@ -526,35 +526,35 @@ discard block |
||
| 526 | 526 | * @param array $critical_page |
| 527 | 527 | * @return void |
| 528 | 528 | */ |
| 529 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
| 529 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
| 530 | 530 | // check the goods |
| 531 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
| 531 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
| 532 | 532 | $msg = sprintf( |
| 533 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
| 533 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
| 534 | 534 | $critical_page['name'] |
| 535 | 535 | ); |
| 536 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 536 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 537 | 537 | return; |
| 538 | 538 | } |
| 539 | 539 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
| 540 | 540 | // map shortcode to post |
| 541 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
| 541 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
| 542 | 542 | // and make sure it's NOT added to the WP "Posts Page" |
| 543 | 543 | // name of the WP Posts Page |
| 544 | 544 | $posts_page = EE_Config::get_page_for_posts(); |
| 545 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
| 546 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
| 545 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
| 546 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
| 547 | 547 | } |
| 548 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
| 549 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
| 548 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
| 549 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
| 550 | 550 | } |
| 551 | 551 | // update post_shortcode CFG |
| 552 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
| 552 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
| 553 | 553 | $msg = sprintf( |
| 554 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
| 554 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
| 555 | 555 | $critical_page['name'] |
| 556 | 556 | ); |
| 557 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 557 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | |
@@ -572,24 +572,24 @@ discard block |
||
| 572 | 572 | public static function get_default_creator_id() { |
| 573 | 573 | global $wpdb; |
| 574 | 574 | |
| 575 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
| 575 | + if ( ! empty(self::$_default_creator_id)) { |
|
| 576 | 576 | return self::$_default_creator_id; |
| 577 | 577 | }/**/ |
| 578 | 578 | |
| 579 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
| 579 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
| 580 | 580 | |
| 581 | 581 | //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. |
| 582 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
| 583 | - if ( $pre_filtered_id !== false ) { |
|
| 582 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
| 583 | + if ($pre_filtered_id !== false) { |
|
| 584 | 584 | return (int) $pre_filtered_id; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
| 588 | - $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 . '%' ); |
|
| 589 | - $user_id = $wpdb->get_var( $query ); |
|
| 590 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
| 591 | - if ( $user_id && (int)$user_id ) { |
|
| 592 | - self::$_default_creator_id = (int)$user_id; |
|
| 587 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
| 588 | + $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.'%'); |
|
| 589 | + $user_id = $wpdb->get_var($query); |
|
| 590 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
| 591 | + if ($user_id && (int) $user_id) { |
|
| 592 | + self::$_default_creator_id = (int) $user_id; |
|
| 593 | 593 | return self::$_default_creator_id; |
| 594 | 594 | } else { |
| 595 | 595 | return NULL; |
@@ -616,29 +616,29 @@ discard block |
||
| 616 | 616 | * @return void |
| 617 | 617 | * @throws EE_Error if there are database errors |
| 618 | 618 | */ |
| 619 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
| 620 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
| 619 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
| 620 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
| 621 | 621 | return; |
| 622 | 622 | } |
| 623 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 624 | - if ( ! function_exists( 'dbDelta' )) { |
|
| 625 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 623 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 624 | + if ( ! function_exists('dbDelta')) { |
|
| 625 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 626 | 626 | } |
| 627 | 627 | /** @var WPDB $wpdb */ |
| 628 | 628 | global $wpdb; |
| 629 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 629 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 630 | 630 | // do we need to first delete an existing version of this table ? |
| 631 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
| 631 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
| 632 | 632 | // ok, delete the table... but ONLY if it's empty |
| 633 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
| 633 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
| 634 | 634 | // table is NOT empty, are you SURE you want to delete this table ??? |
| 635 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
| 636 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
| 637 | - } else if ( ! $deleted_safely ) { |
|
| 635 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
| 636 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
| 637 | + } else if ( ! $deleted_safely) { |
|
| 638 | 638 | // so we should be more cautious rather than just dropping tables so easily |
| 639 | 639 | EE_Error::add_persistent_admin_notice( |
| 640 | - 'bad_table_' . $wp_table_name . '_detected', |
|
| 641 | - 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' ), |
|
| 640 | + 'bad_table_'.$wp_table_name.'_detected', |
|
| 641 | + 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'), |
|
| 642 | 642 | $wp_table_name, |
| 643 | 643 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
| 644 | 644 | '<b>wp-config.php</b>', |
@@ -647,25 +647,25 @@ discard block |
||
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
| 650 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
| 650 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
| 651 | 651 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
| 652 | 652 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
| 653 | 653 | //happened. And then we can choose to tell the end user |
| 654 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
| 655 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
| 654 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
| 655 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
| 656 | 656 | ob_start(); |
| 657 | - dbDelta( $SQL ); |
|
| 657 | + dbDelta($SQL); |
|
| 658 | 658 | $output = ob_get_contents(); |
| 659 | 659 | ob_end_clean(); |
| 660 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
| 661 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
| 662 | - if( ! empty( $output ) ){ |
|
| 663 | - throw new EE_Error( $output ); |
|
| 660 | + $wpdb->show_errors($old_show_errors_policy); |
|
| 661 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
| 662 | + if ( ! empty($output)) { |
|
| 663 | + throw new EE_Error($output); |
|
| 664 | 664 | } |
| 665 | 665 | } else { |
| 666 | 666 | throw new EE_Error( |
| 667 | 667 | sprintf( |
| 668 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
| 668 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
| 669 | 669 | '<br />', |
| 670 | 670 | $sql |
| 671 | 671 | ) |
@@ -688,15 +688,15 @@ discard block |
||
| 688 | 688 | * 'VARCHAR(10)' |
| 689 | 689 | * @return bool|int |
| 690 | 690 | */ |
| 691 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
| 692 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
| 691 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
| 692 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
| 693 | 693 | return FALSE; |
| 694 | 694 | } |
| 695 | 695 | global $wpdb; |
| 696 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 696 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 697 | 697 | $fields = self::get_fields_on_table($table_name); |
| 698 | - if (!in_array($column_name, $fields)){ |
|
| 699 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
| 698 | + if ( ! in_array($column_name, $fields)) { |
|
| 699 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
| 700 | 700 | //echo "alter query:$alter_query"; |
| 701 | 701 | return $wpdb->query($alter_query); |
| 702 | 702 | } |
@@ -715,14 +715,14 @@ discard block |
||
| 715 | 715 | * @param string $table_name, without prefixed $wpdb->prefix |
| 716 | 716 | * @return array of database column names |
| 717 | 717 | */ |
| 718 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
| 718 | + public static function get_fields_on_table($table_name = NULL) { |
|
| 719 | 719 | global $wpdb; |
| 720 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 721 | - if ( ! empty( $table_name )) { |
|
| 720 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 721 | + if ( ! empty($table_name)) { |
|
| 722 | 722 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
| 723 | 723 | if ($columns !== FALSE) { |
| 724 | 724 | $field_array = array(); |
| 725 | - foreach($columns as $column ){ |
|
| 725 | + foreach ($columns as $column) { |
|
| 726 | 726 | $field_array[] = $column->Field; |
| 727 | 727 | } |
| 728 | 728 | return $field_array; |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | * @param string $table_name |
| 742 | 742 | * @return bool |
| 743 | 743 | */ |
| 744 | - public static function db_table_is_empty( $table_name ) { |
|
| 744 | + public static function db_table_is_empty($table_name) { |
|
| 745 | 745 | global $wpdb; |
| 746 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
| 748 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
| 749 | - return absint( $count ) === 0 ? true : false; |
|
| 746 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 747 | + if (EEH_Activation::table_exists($table_name)) { |
|
| 748 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
| 749 | + return absint($count) === 0 ? true : false; |
|
| 750 | 750 | } |
| 751 | 751 | return false; |
| 752 | 752 | } |
@@ -761,9 +761,9 @@ discard block |
||
| 761 | 761 | * @param string $table_name |
| 762 | 762 | * @return bool | int |
| 763 | 763 | */ |
| 764 | - public static function delete_db_table_if_empty( $table_name ) { |
|
| 765 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
| 766 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
| 764 | + public static function delete_db_table_if_empty($table_name) { |
|
| 765 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
| 766 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
| 767 | 767 | } |
| 768 | 768 | return false; |
| 769 | 769 | } |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @param string $table_name |
| 779 | 779 | * @return bool | int |
| 780 | 780 | */ |
| 781 | - public static function delete_unused_db_table( $table_name ) { |
|
| 781 | + public static function delete_unused_db_table($table_name) { |
|
| 782 | 782 | global $wpdb; |
| 783 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
| 784 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 785 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
| 783 | + if (EEH_Activation::table_exists($table_name)) { |
|
| 784 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 785 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
| 786 | 786 | } |
| 787 | 787 | return false; |
| 788 | 788 | } |
@@ -798,18 +798,18 @@ discard block |
||
| 798 | 798 | * @param string $index_name |
| 799 | 799 | * @return bool | int |
| 800 | 800 | */ |
| 801 | - public static function drop_index( $table_name, $index_name ) { |
|
| 802 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
| 801 | + public static function drop_index($table_name, $index_name) { |
|
| 802 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
| 803 | 803 | return FALSE; |
| 804 | 804 | } |
| 805 | 805 | global $wpdb; |
| 806 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 806 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 807 | 807 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
| 808 | 808 | if ( |
| 809 | - EEH_Activation::table_exists( $table_name ) |
|
| 810 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
| 809 | + EEH_Activation::table_exists($table_name) |
|
| 810 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
| 811 | 811 | ) { |
| 812 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
| 812 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
| 813 | 813 | } |
| 814 | 814 | return TRUE; |
| 815 | 815 | } |
@@ -825,27 +825,27 @@ discard block |
||
| 825 | 825 | * @return boolean success (whether database is setup properly or not) |
| 826 | 826 | */ |
| 827 | 827 | public static function create_database_tables() { |
| 828 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
| 828 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
| 829 | 829 | //find the migration script that sets the database to be compatible with the code |
| 830 | 830 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
| 831 | - if( $dms_name ){ |
|
| 832 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
| 833 | - $current_data_migration_script->set_migrating( false ); |
|
| 831 | + if ($dms_name) { |
|
| 832 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
| 833 | + $current_data_migration_script->set_migrating(false); |
|
| 834 | 834 | $current_data_migration_script->schema_changes_before_migration(); |
| 835 | 835 | $current_data_migration_script->schema_changes_after_migration(); |
| 836 | - if( $current_data_migration_script->get_errors() ){ |
|
| 837 | - if( WP_DEBUG ){ |
|
| 838 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
| 839 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 836 | + if ($current_data_migration_script->get_errors()) { |
|
| 837 | + if (WP_DEBUG) { |
|
| 838 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
| 839 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 840 | 840 | } |
| 841 | - }else{ |
|
| 842 | - 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' ) ); |
|
| 841 | + } else { |
|
| 842 | + 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')); |
|
| 843 | 843 | } |
| 844 | 844 | return false; |
| 845 | 845 | } |
| 846 | 846 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
| 847 | - }else{ |
|
| 848 | - 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__); |
|
| 847 | + } else { |
|
| 848 | + 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__); |
|
| 849 | 849 | return false; |
| 850 | 850 | } |
| 851 | 851 | return true; |
@@ -865,27 +865,27 @@ discard block |
||
| 865 | 865 | public static function initialize_system_questions() { |
| 866 | 866 | // QUESTION GROUPS |
| 867 | 867 | global $wpdb; |
| 868 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
| 868 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
| 869 | 869 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
| 870 | 870 | // what we have |
| 871 | - $question_groups = $wpdb->get_col( $SQL ); |
|
| 871 | + $question_groups = $wpdb->get_col($SQL); |
|
| 872 | 872 | // check the response |
| 873 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
| 873 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
| 874 | 874 | // what we should have |
| 875 | - $QSG_systems = array( 1, 2 ); |
|
| 875 | + $QSG_systems = array(1, 2); |
|
| 876 | 876 | // loop thru what we should have and compare to what we have |
| 877 | - foreach ( $QSG_systems as $QSG_system ) { |
|
| 877 | + foreach ($QSG_systems as $QSG_system) { |
|
| 878 | 878 | // reset values array |
| 879 | 879 | $QSG_values = array(); |
| 880 | 880 | // 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) |
| 881 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
| 881 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
| 882 | 882 | // add it |
| 883 | - switch ( $QSG_system ) { |
|
| 883 | + switch ($QSG_system) { |
|
| 884 | 884 | |
| 885 | 885 | case 1: |
| 886 | 886 | $QSG_values = array( |
| 887 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
| 888 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
| 887 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
| 888 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
| 889 | 889 | 'QSG_desc' => '', |
| 890 | 890 | 'QSG_order' => 1, |
| 891 | 891 | 'QSG_show_group_name' => 1, |
@@ -897,8 +897,8 @@ discard block |
||
| 897 | 897 | |
| 898 | 898 | case 2: |
| 899 | 899 | $QSG_values = array( |
| 900 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
| 901 | - 'QSG_identifier' => 'address-information-' . time(), |
|
| 900 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
| 901 | + 'QSG_identifier' => 'address-information-'.time(), |
|
| 902 | 902 | 'QSG_desc' => '', |
| 903 | 903 | 'QSG_order' => 2, |
| 904 | 904 | 'QSG_show_group_name' => 1, |
@@ -910,14 +910,14 @@ discard block |
||
| 910 | 910 | |
| 911 | 911 | } |
| 912 | 912 | // make sure we have some values before inserting them |
| 913 | - if ( ! empty( $QSG_values )) { |
|
| 913 | + if ( ! empty($QSG_values)) { |
|
| 914 | 914 | // insert system question |
| 915 | 915 | $wpdb->insert( |
| 916 | 916 | $table_name, |
| 917 | 917 | $QSG_values, |
| 918 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
| 918 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
| 919 | 919 | ); |
| 920 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
| 920 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -926,10 +926,10 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | // QUESTIONS |
| 928 | 928 | global $wpdb; |
| 929 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
| 929 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
| 930 | 930 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
| 931 | 931 | // what we have |
| 932 | - $questions = $wpdb->get_col( $SQL ); |
|
| 932 | + $questions = $wpdb->get_col($SQL); |
|
| 933 | 933 | // what we should have |
| 934 | 934 | $QST_systems = array( |
| 935 | 935 | 'fname', |
@@ -946,25 +946,25 @@ discard block |
||
| 946 | 946 | $order_for_group_1 = 1; |
| 947 | 947 | $order_for_group_2 = 1; |
| 948 | 948 | // loop thru what we should have and compare to what we have |
| 949 | - foreach ( $QST_systems as $QST_system ) { |
|
| 949 | + foreach ($QST_systems as $QST_system) { |
|
| 950 | 950 | // reset values array |
| 951 | 951 | $QST_values = array(); |
| 952 | 952 | // if we don't have what we should have |
| 953 | - if ( ! in_array( $QST_system, $questions )) { |
|
| 953 | + if ( ! in_array($QST_system, $questions)) { |
|
| 954 | 954 | // add it |
| 955 | - switch ( $QST_system ) { |
|
| 955 | + switch ($QST_system) { |
|
| 956 | 956 | |
| 957 | 957 | case 'fname': |
| 958 | 958 | $QST_values = array( |
| 959 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
| 960 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
| 959 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
| 960 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
| 961 | 961 | 'QST_system' => 'fname', |
| 962 | 962 | 'QST_type' => 'TEXT', |
| 963 | 963 | 'QST_required' => 1, |
| 964 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 964 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 965 | 965 | 'QST_order' => 1, |
| 966 | 966 | 'QST_admin_only' => 0, |
| 967 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 967 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 968 | 968 | 'QST_wp_user' => self::get_default_creator_id(), |
| 969 | 969 | 'QST_deleted' => 0 |
| 970 | 970 | ); |
@@ -972,15 +972,15 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | case 'lname': |
| 974 | 974 | $QST_values = array( |
| 975 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
| 976 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
| 975 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
| 976 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
| 977 | 977 | 'QST_system' => 'lname', |
| 978 | 978 | 'QST_type' => 'TEXT', |
| 979 | 979 | 'QST_required' => 1, |
| 980 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 980 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 981 | 981 | 'QST_order' => 2, |
| 982 | 982 | 'QST_admin_only' => 0, |
| 983 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 983 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 984 | 984 | 'QST_wp_user' => self::get_default_creator_id(), |
| 985 | 985 | 'QST_deleted' => 0 |
| 986 | 986 | ); |
@@ -988,15 +988,15 @@ discard block |
||
| 988 | 988 | |
| 989 | 989 | case 'email': |
| 990 | 990 | $QST_values = array( |
| 991 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
| 992 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
| 991 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
| 992 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
| 993 | 993 | 'QST_system' => 'email', |
| 994 | 994 | 'QST_type' => 'EMAIL', |
| 995 | 995 | 'QST_required' => 1, |
| 996 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 996 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 997 | 997 | 'QST_order' => 3, |
| 998 | 998 | 'QST_admin_only' => 0, |
| 999 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 999 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1000 | 1000 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1001 | 1001 | 'QST_deleted' => 0 |
| 1002 | 1002 | ); |
@@ -1004,15 +1004,15 @@ discard block |
||
| 1004 | 1004 | |
| 1005 | 1005 | case 'address': |
| 1006 | 1006 | $QST_values = array( |
| 1007 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
| 1008 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
| 1007 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
| 1008 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
| 1009 | 1009 | 'QST_system' => 'address', |
| 1010 | 1010 | 'QST_type' => 'TEXT', |
| 1011 | 1011 | 'QST_required' => 0, |
| 1012 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1012 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1013 | 1013 | 'QST_order' => 4, |
| 1014 | 1014 | 'QST_admin_only' => 0, |
| 1015 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 1015 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1016 | 1016 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1017 | 1017 | 'QST_deleted' => 0 |
| 1018 | 1018 | ); |
@@ -1020,15 +1020,15 @@ discard block |
||
| 1020 | 1020 | |
| 1021 | 1021 | case 'address2': |
| 1022 | 1022 | $QST_values = array( |
| 1023 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
| 1024 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
| 1023 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
| 1024 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
| 1025 | 1025 | 'QST_system' => 'address2', |
| 1026 | 1026 | 'QST_type' => 'TEXT', |
| 1027 | 1027 | 'QST_required' => 0, |
| 1028 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1028 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1029 | 1029 | 'QST_order' => 5, |
| 1030 | 1030 | 'QST_admin_only' => 0, |
| 1031 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 1031 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1032 | 1032 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1033 | 1033 | 'QST_deleted' => 0 |
| 1034 | 1034 | ); |
@@ -1036,15 +1036,15 @@ discard block |
||
| 1036 | 1036 | |
| 1037 | 1037 | case 'city': |
| 1038 | 1038 | $QST_values = array( |
| 1039 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
| 1040 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
| 1039 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
| 1040 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
| 1041 | 1041 | 'QST_system' => 'city', |
| 1042 | 1042 | 'QST_type' => 'TEXT', |
| 1043 | 1043 | 'QST_required' => 0, |
| 1044 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1044 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1045 | 1045 | 'QST_order' => 6, |
| 1046 | 1046 | 'QST_admin_only' => 0, |
| 1047 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 1047 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1048 | 1048 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1049 | 1049 | 'QST_deleted' => 0 |
| 1050 | 1050 | ); |
@@ -1052,12 +1052,12 @@ discard block |
||
| 1052 | 1052 | |
| 1053 | 1053 | case 'state': |
| 1054 | 1054 | $QST_values = array( |
| 1055 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
| 1056 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
| 1055 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 1056 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
| 1057 | 1057 | 'QST_system' => 'state', |
| 1058 | 1058 | 'QST_type' => 'STATE', |
| 1059 | 1059 | 'QST_required' => 0, |
| 1060 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1060 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1061 | 1061 | 'QST_order' => 7, |
| 1062 | 1062 | 'QST_admin_only' => 0, |
| 1063 | 1063 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1067,12 +1067,12 @@ discard block |
||
| 1067 | 1067 | |
| 1068 | 1068 | case 'country' : |
| 1069 | 1069 | $QST_values = array( |
| 1070 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
| 1071 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
| 1070 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 1071 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
| 1072 | 1072 | 'QST_system' => 'country', |
| 1073 | 1073 | 'QST_type' => 'COUNTRY', |
| 1074 | 1074 | 'QST_required' => 0, |
| 1075 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1075 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1076 | 1076 | 'QST_order' => 8, |
| 1077 | 1077 | 'QST_admin_only' => 0, |
| 1078 | 1078 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1082,15 +1082,15 @@ discard block |
||
| 1082 | 1082 | |
| 1083 | 1083 | case 'zip': |
| 1084 | 1084 | $QST_values = array( |
| 1085 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
| 1086 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
| 1085 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
| 1086 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
| 1087 | 1087 | 'QST_system' => 'zip', |
| 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_order' => 9, |
| 1092 | 1092 | 'QST_admin_only' => 0, |
| 1093 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 1093 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1094 | 1094 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1095 | 1095 | 'QST_deleted' => 0 |
| 1096 | 1096 | ); |
@@ -1098,49 +1098,49 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | case 'phone': |
| 1100 | 1100 | $QST_values = array( |
| 1101 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
| 1102 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
| 1101 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
| 1102 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
| 1103 | 1103 | 'QST_system' => 'phone', |
| 1104 | 1104 | 'QST_type' => 'TEXT', |
| 1105 | 1105 | 'QST_required' => 0, |
| 1106 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
| 1106 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
| 1107 | 1107 | 'QST_order' => 10, |
| 1108 | 1108 | 'QST_admin_only' => 0, |
| 1109 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
| 1109 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
| 1110 | 1110 | 'QST_wp_user' => self::get_default_creator_id(), |
| 1111 | 1111 | 'QST_deleted' => 0 |
| 1112 | 1112 | ); |
| 1113 | 1113 | break; |
| 1114 | 1114 | |
| 1115 | 1115 | } |
| 1116 | - if ( ! empty( $QST_values )) { |
|
| 1116 | + if ( ! empty($QST_values)) { |
|
| 1117 | 1117 | // insert system question |
| 1118 | 1118 | $wpdb->insert( |
| 1119 | 1119 | $table_name, |
| 1120 | 1120 | $QST_values, |
| 1121 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
| 1121 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
| 1122 | 1122 | ); |
| 1123 | 1123 | $QST_ID = $wpdb->insert_id; |
| 1124 | 1124 | |
| 1125 | 1125 | // QUESTION GROUP QUESTIONS |
| 1126 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
| 1126 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
| 1127 | 1127 | $system_question_we_want = EEM_Question_Group::system_personal; |
| 1128 | 1128 | } else { |
| 1129 | 1129 | $system_question_we_want = EEM_Question_Group::system_address; |
| 1130 | 1130 | } |
| 1131 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
| 1132 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
| 1131 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
| 1132 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
| 1133 | 1133 | } else { |
| 1134 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
| 1135 | - if( is_array( $id_col ) ) { |
|
| 1136 | - $QSG_ID = reset( $id_col ); |
|
| 1134 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
| 1135 | + if (is_array($id_col)) { |
|
| 1136 | + $QSG_ID = reset($id_col); |
|
| 1137 | 1137 | } else { |
| 1138 | 1138 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
| 1139 | 1139 | EE_Log::instance()->log( |
| 1140 | 1140 | __FILE__, |
| 1141 | 1141 | __FUNCTION__, |
| 1142 | 1142 | sprintf( |
| 1143 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
| 1143 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
| 1144 | 1144 | $QST_ID ), |
| 1145 | 1145 | 'error' ); |
| 1146 | 1146 | continue; |
@@ -1149,12 +1149,12 @@ discard block |
||
| 1149 | 1149 | |
| 1150 | 1150 | // add system questions to groups |
| 1151 | 1151 | $wpdb->insert( |
| 1152 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
| 1153 | - array( 'QSG_ID' => $QSG_ID, |
|
| 1152 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
| 1153 | + array('QSG_ID' => $QSG_ID, |
|
| 1154 | 1154 | 'QST_ID' => $QST_ID, |
| 1155 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
| 1155 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
| 1156 | 1156 | ), |
| 1157 | - array( '%d', '%d', '%d' ) |
|
| 1157 | + array('%d', '%d', '%d') |
|
| 1158 | 1158 | ); |
| 1159 | 1159 | } |
| 1160 | 1160 | } |
@@ -1170,11 +1170,11 @@ discard block |
||
| 1170 | 1170 | * |
| 1171 | 1171 | * @throws \EE_Error |
| 1172 | 1172 | */ |
| 1173 | - public static function insert_default_payment_methods(){ |
|
| 1174 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
| 1175 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
| 1176 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
| 1177 | - }else{ |
|
| 1173 | + public static function insert_default_payment_methods() { |
|
| 1174 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
| 1175 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
| 1176 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
| 1177 | + } else { |
|
| 1178 | 1178 | EEM_Payment_Method::instance()->verify_button_urls(); |
| 1179 | 1179 | } |
| 1180 | 1180 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | global $wpdb; |
| 1192 | 1192 | |
| 1193 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
| 1193 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
| 1194 | 1194 | |
| 1195 | 1195 | $table_name = EEM_Status::instance()->table(); |
| 1196 | 1196 | |
@@ -1265,33 +1265,33 @@ discard block |
||
| 1265 | 1265 | $folders = array( |
| 1266 | 1266 | EVENT_ESPRESSO_TEMPLATE_DIR, |
| 1267 | 1267 | EVENT_ESPRESSO_GATEWAY_DIR, |
| 1268 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
| 1269 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
| 1270 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
| 1268 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
| 1269 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
| 1270 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
| 1271 | 1271 | ); |
| 1272 | - foreach ( $folders as $folder ) { |
|
| 1272 | + foreach ($folders as $folder) { |
|
| 1273 | 1273 | try { |
| 1274 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
| 1275 | - @ chmod( $folder, 0755 ); |
|
| 1276 | - } catch( EE_Error $e ){ |
|
| 1274 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
| 1275 | + @ chmod($folder, 0755); |
|
| 1276 | + } catch (EE_Error $e) { |
|
| 1277 | 1277 | EE_Error::add_error( |
| 1278 | 1278 | sprintf( |
| 1279 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
| 1279 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
| 1280 | 1280 | $folder, |
| 1281 | - '<br />' . $e->getMessage() |
|
| 1281 | + '<br />'.$e->getMessage() |
|
| 1282 | 1282 | ), |
| 1283 | 1283 | __FILE__, __FUNCTION__, __LINE__ |
| 1284 | 1284 | ); |
| 1285 | 1285 | //indicate we'll need to fix this later |
| 1286 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
| 1286 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
| 1287 | 1287 | return FALSE; |
| 1288 | 1288 | } |
| 1289 | 1289 | } |
| 1290 | 1290 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
| 1291 | 1291 | //is disabled, there might be activation errors recorded in there |
| 1292 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
| 1292 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
| 1293 | 1293 | //remember EE's folders are all good |
| 1294 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
| 1294 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
| 1295 | 1295 | return TRUE; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
@@ -1304,7 +1304,7 @@ discard block |
||
| 1304 | 1304 | * @return boolean |
| 1305 | 1305 | */ |
| 1306 | 1306 | public static function upload_directories_incomplete() { |
| 1307 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
| 1307 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | */ |
| 1322 | 1322 | public static function generate_default_message_templates() { |
| 1323 | 1323 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
| 1324 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 1324 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 1325 | 1325 | /* |
| 1326 | 1326 | * This first method is taking care of ensuring any default messengers |
| 1327 | 1327 | * that should be made active and have templates generated are done. |
@@ -1357,22 +1357,22 @@ discard block |
||
| 1357 | 1357 | $active_messengers = $message_resource_manager->active_messengers(); |
| 1358 | 1358 | $installed_message_types = $message_resource_manager->installed_message_types(); |
| 1359 | 1359 | $templates_created = false; |
| 1360 | - foreach ( $active_messengers as $active_messenger ) { |
|
| 1360 | + foreach ($active_messengers as $active_messenger) { |
|
| 1361 | 1361 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
| 1362 | 1362 | $default_message_type_names_to_activate = array(); |
| 1363 | 1363 | // looping through each default message type reported by the messenger |
| 1364 | 1364 | // and setup the actual message types to activate. |
| 1365 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
| 1365 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
| 1366 | 1366 | // if already active or has already been activated before we skip |
| 1367 | 1367 | // (otherwise we might reactivate something user's intentionally deactivated.) |
| 1368 | 1368 | // we also skip if the message type is not installed. |
| 1369 | 1369 | if ( |
| 1370 | - $message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name ) |
|
| 1370 | + $message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name) |
|
| 1371 | 1371 | || $message_resource_manager->is_message_type_active_for_messenger( |
| 1372 | 1372 | $active_messenger->name, |
| 1373 | 1373 | $default_message_type_name_for_messenger |
| 1374 | 1374 | ) |
| 1375 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
| 1375 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
| 1376 | 1376 | ) { |
| 1377 | 1377 | continue; |
| 1378 | 1378 | } |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | false |
| 1386 | 1386 | ); |
| 1387 | 1387 | //activate the templates for these message types |
| 1388 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
| 1388 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
| 1389 | 1389 | $templates_created = EEH_MSG_Template::generate_new_templates( |
| 1390 | 1390 | $active_messenger->name, |
| 1391 | 1391 | $default_message_type_names_for_messenger, |
@@ -1412,18 +1412,18 @@ discard block |
||
| 1412 | 1412 | EE_Message_Resource_Manager $message_resource_manager |
| 1413 | 1413 | ) { |
| 1414 | 1414 | /** @type EE_messenger[] $messengers_to_generate */ |
| 1415 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
| 1415 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
| 1416 | 1416 | $installed_message_types = $message_resource_manager->installed_message_types(); |
| 1417 | 1417 | $templates_generated = false; |
| 1418 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
| 1418 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
| 1419 | 1419 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
| 1420 | 1420 | //verify the default message types match an installed message type. |
| 1421 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
| 1421 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
| 1422 | 1422 | if ( |
| 1423 | - ! isset( $installed_message_types[ $name ] ) |
|
| 1424 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name ) |
|
| 1423 | + ! isset($installed_message_types[$name]) |
|
| 1424 | + || $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name) |
|
| 1425 | 1425 | ) { |
| 1426 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
| 1426 | + unset($default_message_type_names_for_messenger[$key]); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | 1429 | // in previous iterations, the active_messengers option in the db |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | false |
| 1438 | 1438 | ); |
| 1439 | 1439 | //create any templates needing created (or will reactivate templates already generated as necessary). |
| 1440 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
| 1440 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
| 1441 | 1441 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
| 1442 | 1442 | $messenger_to_generate->name, |
| 1443 | 1443 | $default_message_type_names_for_messenger, |
@@ -1469,18 +1469,18 @@ discard block |
||
| 1469 | 1469 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
| 1470 | 1470 | |
| 1471 | 1471 | $messengers_to_generate = array(); |
| 1472 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
| 1472 | + foreach ($installed_messengers as $installed_messenger) { |
|
| 1473 | 1473 | //if installed messenger is a messenger that should be activated on install |
| 1474 | 1474 | //and is not already active |
| 1475 | 1475 | //and has never been activated |
| 1476 | 1476 | if ( |
| 1477 | 1477 | ! $installed_messenger->activate_on_install |
| 1478 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
| 1479 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
| 1478 | + || isset($active_messengers[$installed_messenger->name]) |
|
| 1479 | + || isset($has_activated[$installed_messenger->name]) |
|
| 1480 | 1480 | ) { |
| 1481 | 1481 | continue; |
| 1482 | 1482 | } |
| 1483 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
| 1483 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
| 1484 | 1484 | } |
| 1485 | 1485 | return $messengers_to_generate; |
| 1486 | 1486 | } |
@@ -1505,9 +1505,9 @@ discard block |
||
| 1505 | 1505 | */ |
| 1506 | 1506 | public static function validate_messages_system() { |
| 1507 | 1507 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
| 1508 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 1508 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 1509 | 1509 | $message_resource_manager->validate_active_message_types_are_installed(); |
| 1510 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
| 1510 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | |
@@ -1520,12 +1520,12 @@ discard block |
||
| 1520 | 1520 | * @static |
| 1521 | 1521 | * @return void |
| 1522 | 1522 | */ |
| 1523 | - public static function create_no_ticket_prices_array(){ |
|
| 1523 | + public static function create_no_ticket_prices_array() { |
|
| 1524 | 1524 | // this creates an array for tracking events that have no active ticket prices created |
| 1525 | 1525 | // this allows us to warn admins of the situation so that it can be corrected |
| 1526 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
| 1527 | - if ( ! $espresso_no_ticket_prices ) { |
|
| 1528 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
| 1526 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
| 1527 | + if ( ! $espresso_no_ticket_prices) { |
|
| 1528 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | 1531 | |
@@ -1550,24 +1550,24 @@ discard block |
||
| 1550 | 1550 | * @global wpdb $wpdb |
| 1551 | 1551 | * @throws \EE_Error |
| 1552 | 1552 | */ |
| 1553 | - public static function delete_all_espresso_cpt_data(){ |
|
| 1553 | + public static function delete_all_espresso_cpt_data() { |
|
| 1554 | 1554 | global $wpdb; |
| 1555 | 1555 | //get all the CPT post_types |
| 1556 | 1556 | $ee_post_types = array(); |
| 1557 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
| 1558 | - if ( method_exists( $model_name, 'instance' )) { |
|
| 1559 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
| 1560 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
| 1561 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
| 1557 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 1558 | + if (method_exists($model_name, 'instance')) { |
|
| 1559 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 1560 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
| 1561 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | } |
| 1564 | 1564 | } |
| 1565 | 1565 | //get all our CPTs |
| 1566 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
| 1566 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
| 1567 | 1567 | $cpt_ids = $wpdb->get_col($query); |
| 1568 | 1568 | //delete each post meta and term relations too |
| 1569 | - foreach($cpt_ids as $post_id){ |
|
| 1570 | - wp_delete_post($post_id,true); |
|
| 1569 | + foreach ($cpt_ids as $post_id) { |
|
| 1570 | + wp_delete_post($post_id, true); |
|
| 1571 | 1571 | } |
| 1572 | 1572 | } |
| 1573 | 1573 | |
@@ -1581,18 +1581,18 @@ discard block |
||
| 1581 | 1581 | * @param bool $remove_all |
| 1582 | 1582 | * @return void |
| 1583 | 1583 | */ |
| 1584 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
| 1584 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
| 1585 | 1585 | global $wpdb; |
| 1586 | 1586 | $undeleted_tables = array(); |
| 1587 | 1587 | |
| 1588 | 1588 | // load registry |
| 1589 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
| 1590 | - if ( method_exists( $model_name, 'instance' )) { |
|
| 1591 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
| 1592 | - if ( $model_obj instanceof EEM_Base ) { |
|
| 1593 | - foreach ( $model_obj->get_tables() as $table ) { |
|
| 1594 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
| 1595 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
| 1589 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 1590 | + if (method_exists($model_name, 'instance')) { |
|
| 1591 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 1592 | + if ($model_obj instanceof EEM_Base) { |
|
| 1593 | + foreach ($model_obj->get_tables() as $table) { |
|
| 1594 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
| 1595 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
| 1596 | 1596 | case false : |
| 1597 | 1597 | $undeleted_tables[] = $table->get_table_name(); |
| 1598 | 1598 | break; |
@@ -1617,8 +1617,8 @@ discard block |
||
| 1617 | 1617 | 'esp_promotion_rule', |
| 1618 | 1618 | 'esp_rule' |
| 1619 | 1619 | ); |
| 1620 | - foreach( $tables_without_models as $table ){ |
|
| 1621 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
| 1620 | + foreach ($tables_without_models as $table) { |
|
| 1621 | + EEH_Activation::delete_db_table_if_empty($table); |
|
| 1622 | 1622 | } |
| 1623 | 1623 | |
| 1624 | 1624 | |
@@ -1656,58 +1656,58 @@ discard block |
||
| 1656 | 1656 | 'ee_job_parameters_' => false, |
| 1657 | 1657 | 'ee_upload_directories_incomplete' => true, |
| 1658 | 1658 | ); |
| 1659 | - if( is_main_site() ) { |
|
| 1660 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
| 1659 | + if (is_main_site()) { |
|
| 1660 | + $wp_options_to_delete['ee_network_config'] = true; |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | $undeleted_options = array(); |
| 1664 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
| 1664 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
| 1665 | 1665 | |
| 1666 | - if( $no_wildcard ){ |
|
| 1667 | - if( ! delete_option( $option_name ) ){ |
|
| 1666 | + if ($no_wildcard) { |
|
| 1667 | + if ( ! delete_option($option_name)) { |
|
| 1668 | 1668 | $undeleted_options[] = $option_name; |
| 1669 | 1669 | } |
| 1670 | - }else{ |
|
| 1671 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
| 1672 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
| 1673 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
| 1670 | + } else { |
|
| 1671 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
| 1672 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
| 1673 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
| 1674 | 1674 | $undeleted_options[] = $option_name_from_wildcard; |
| 1675 | 1675 | } |
| 1676 | 1676 | } |
| 1677 | 1677 | } |
| 1678 | 1678 | } |
| 1679 | 1679 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
| 1680 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
| 1680 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
| 1681 | 1681 | |
| 1682 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
| 1682 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
| 1683 | 1683 | $db_update_sans_ee4 = array(); |
| 1684 | - foreach($espresso_db_update as $version => $times_activated){ |
|
| 1685 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
| 1684 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
| 1685 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
| 1686 | 1686 | $db_update_sans_ee4[$version] = $times_activated; |
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
| 1689 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | $errors = ''; |
| 1693 | - if ( ! empty( $undeleted_tables )) { |
|
| 1693 | + if ( ! empty($undeleted_tables)) { |
|
| 1694 | 1694 | $errors .= sprintf( |
| 1695 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
| 1695 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
| 1696 | 1696 | '<br/>', |
| 1697 | - implode( ',<br/>', $undeleted_tables ) |
|
| 1697 | + implode(',<br/>', $undeleted_tables) |
|
| 1698 | 1698 | ); |
| 1699 | 1699 | } |
| 1700 | - if ( ! empty( $undeleted_options )) { |
|
| 1701 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
| 1700 | + if ( ! empty($undeleted_options)) { |
|
| 1701 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
| 1702 | 1702 | $errors .= sprintf( |
| 1703 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
| 1703 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
| 1704 | 1704 | '<br/>', |
| 1705 | - implode( ',<br/>', $undeleted_options ) |
|
| 1705 | + implode(',<br/>', $undeleted_options) |
|
| 1706 | 1706 | ); |
| 1707 | 1707 | |
| 1708 | 1708 | } |
| 1709 | - if ( ! empty( $errors ) ) { |
|
| 1710 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1709 | + if ( ! empty($errors)) { |
|
| 1710 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 1711 | 1711 | } |
| 1712 | 1712 | } |
| 1713 | 1713 | |
@@ -1717,23 +1717,23 @@ discard block |
||
| 1717 | 1717 | * @param string $table_name with or without $wpdb->prefix |
| 1718 | 1718 | * @return boolean |
| 1719 | 1719 | */ |
| 1720 | - public static function table_exists( $table_name ){ |
|
| 1720 | + public static function table_exists($table_name) { |
|
| 1721 | 1721 | global $wpdb, $EZSQL_ERROR; |
| 1722 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
| 1722 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
| 1723 | 1723 | //ignore if this causes an sql error |
| 1724 | 1724 | $old_error = $wpdb->last_error; |
| 1725 | 1725 | $old_suppress_errors = $wpdb->suppress_errors(); |
| 1726 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
| 1726 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
| 1727 | 1727 | $ezsql_error_cache = $EZSQL_ERROR; |
| 1728 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
| 1729 | - $wpdb->show_errors( $old_show_errors_value ); |
|
| 1730 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
| 1728 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
| 1729 | + $wpdb->show_errors($old_show_errors_value); |
|
| 1730 | + $wpdb->suppress_errors($old_suppress_errors); |
|
| 1731 | 1731 | $new_error = $wpdb->last_error; |
| 1732 | 1732 | $wpdb->last_error = $old_error; |
| 1733 | 1733 | $EZSQL_ERROR = $ezsql_error_cache; |
| 1734 | - if( empty( $new_error ) ){ |
|
| 1734 | + if (empty($new_error)) { |
|
| 1735 | 1735 | return TRUE; |
| 1736 | - }else{ |
|
| 1736 | + } else { |
|
| 1737 | 1737 | return FALSE; |
| 1738 | 1738 | } |
| 1739 | 1739 | } |
@@ -1741,7 +1741,7 @@ discard block |
||
| 1741 | 1741 | /** |
| 1742 | 1742 | * Resets the cache on EEH_Activation |
| 1743 | 1743 | */ |
| 1744 | - public static function reset(){ |
|
| 1744 | + public static function reset() { |
|
| 1745 | 1745 | self::$_default_creator_id = NULL; |
| 1746 | 1746 | self::$_initialized_db_content_already_in_this_request = false; |
| 1747 | 1747 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @param \EE_Dependency_Map $dependency_map |
| 179 | 179 | * @return \EE_Registry instance |
| 180 | 180 | */ |
| 181 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
| 181 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
| 182 | 182 | // check if class object is instantiated |
| 183 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
| 184 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
| 183 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
| 184 | + self::$_instance = new EE_Registry($dependency_map); |
|
| 185 | 185 | } |
| 186 | 186 | return self::$_instance; |
| 187 | 187 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | * @param \EE_Dependency_Map $dependency_map |
| 197 | 197 | * @return \EE_Registry |
| 198 | 198 | */ |
| 199 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
| 199 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
| 200 | 200 | $this->_dependency_map = $dependency_map; |
| 201 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
| 201 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -225,19 +225,19 @@ discard block |
||
| 225 | 225 | $this->modules = new StdClass(); |
| 226 | 226 | $this->shortcodes = new StdClass(); |
| 227 | 227 | $this->widgets = new StdClass(); |
| 228 | - $this->load_core( 'Base', array(), true ); |
|
| 228 | + $this->load_core('Base', array(), true); |
|
| 229 | 229 | // add our request and response objects to the cache |
| 230 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
| 230 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
| 231 | 231 | $this->_set_cached_class( |
| 232 | 232 | $request_loader(), |
| 233 | 233 | 'EE_Request' |
| 234 | 234 | ); |
| 235 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
| 235 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
| 236 | 236 | $this->_set_cached_class( |
| 237 | 237 | $response_loader(), |
| 238 | 238 | 'EE_Response' |
| 239 | 239 | ); |
| 240 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
| 240 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function init() { |
| 252 | 252 | // Get current page protocol |
| 253 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
| 253 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 254 | 254 | // Output admin-ajax.php URL with same protocol as current page |
| 255 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
| 256 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
| 255 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
| 256 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | 266 | public static function localize_i18n_js_strings() { |
| 267 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
| 268 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
| 269 | - if ( is_scalar( $value ) ) { |
|
| 270 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
| 267 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
| 268 | + foreach ($i18n_js_strings as $key => $value) { |
|
| 269 | + if (is_scalar($value)) { |
|
| 270 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
| 274 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -279,15 +279,15 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @param mixed string | EED_Module $module |
| 281 | 281 | */ |
| 282 | - public function add_module( $module ) { |
|
| 283 | - if ( $module instanceof EED_Module ) { |
|
| 284 | - $module_class = get_class( $module ); |
|
| 282 | + public function add_module($module) { |
|
| 283 | + if ($module instanceof EED_Module) { |
|
| 284 | + $module_class = get_class($module); |
|
| 285 | 285 | $this->modules->{$module_class} = $module; |
| 286 | 286 | } else { |
| 287 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
| 288 | - $this->load_core( 'Module_Request_Router' ); |
|
| 287 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
| 288 | + $this->load_core('Module_Request_Router'); |
|
| 289 | 289 | } |
| 290 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
| 290 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | * @param string $module_name |
| 298 | 298 | * @return mixed EED_Module | NULL |
| 299 | 299 | */ |
| 300 | - public function get_module( $module_name = '' ) { |
|
| 301 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 300 | + public function get_module($module_name = '') { |
|
| 301 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -312,20 +312,20 @@ discard block |
||
| 312 | 312 | * @param bool $load_only |
| 313 | 313 | * @return mixed |
| 314 | 314 | */ |
| 315 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
| 315 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
| 316 | 316 | $core_paths = apply_filters( |
| 317 | 317 | 'FHEE__EE_Registry__load_core__core_paths', |
| 318 | 318 | array( |
| 319 | 319 | EE_CORE, |
| 320 | 320 | EE_ADMIN, |
| 321 | 321 | EE_CPTS, |
| 322 | - EE_CORE . 'data_migration_scripts' . DS, |
|
| 323 | - EE_CORE . 'request_stack' . DS, |
|
| 324 | - EE_CORE . 'middleware' . DS, |
|
| 322 | + EE_CORE.'data_migration_scripts'.DS, |
|
| 323 | + EE_CORE.'request_stack'.DS, |
|
| 324 | + EE_CORE.'middleware'.DS, |
|
| 325 | 325 | ) |
| 326 | 326 | ); |
| 327 | 327 | // retrieve instantiated class |
| 328 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
| 328 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | * @param bool $load_only |
| 340 | 340 | * @return mixed |
| 341 | 341 | */ |
| 342 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
| 342 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
| 343 | 343 | $service_paths = apply_filters( |
| 344 | 344 | 'FHEE__EE_Registry__load_service__service_paths', |
| 345 | 345 | array( |
| 346 | - EE_CORE . 'services' . DS, |
|
| 346 | + EE_CORE.'services'.DS, |
|
| 347 | 347 | ) |
| 348 | 348 | ); |
| 349 | 349 | // retrieve instantiated class |
| 350 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
| 350 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | * @param mixed $arguments |
| 361 | 361 | * @return EE_Data_Migration_Script_Base |
| 362 | 362 | */ |
| 363 | - public function load_dms( $class_name, $arguments = array() ) { |
|
| 363 | + public function load_dms($class_name, $arguments = array()) { |
|
| 364 | 364 | // retrieve instantiated class |
| 365 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
| 365 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
@@ -377,14 +377,14 @@ discard block |
||
| 377 | 377 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
| 378 | 378 | * @return EE_Base_Class | bool |
| 379 | 379 | */ |
| 380 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
| 381 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
| 380 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
| 381 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
| 382 | 382 | EE_CORE, |
| 383 | 383 | EE_CLASSES, |
| 384 | 384 | EE_BUSINESS |
| 385 | - ) ); |
|
| 385 | + )); |
|
| 386 | 386 | // retrieve instantiated class |
| 387 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
| 387 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | * @param bool $load_only |
| 398 | 398 | * @return EEH_Base | bool |
| 399 | 399 | */ |
| 400 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
| 400 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
| 401 | 401 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
| 402 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
| 402 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
| 403 | 403 | // retrieve instantiated class |
| 404 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
| 404 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | * @param bool $cache whether to cache the object or not. |
| 417 | 417 | * @return mixed |
| 418 | 418 | */ |
| 419 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
| 419 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
| 420 | 420 | $paths = array( |
| 421 | 421 | EE_LIBRARIES, |
| 422 | - EE_LIBRARIES . 'messages' . DS, |
|
| 423 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
| 424 | - EE_LIBRARIES . 'qtips' . DS, |
|
| 425 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
| 422 | + EE_LIBRARIES.'messages'.DS, |
|
| 423 | + EE_LIBRARIES.'shortcodes'.DS, |
|
| 424 | + EE_LIBRARIES.'qtips'.DS, |
|
| 425 | + EE_LIBRARIES.'payment_methods'.DS, |
|
| 426 | 426 | ); |
| 427 | 427 | // retrieve instantiated class |
| 428 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
| 428 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
@@ -438,13 +438,13 @@ discard block |
||
| 438 | 438 | * @param bool $load_only |
| 439 | 439 | * @return EEM_Base | bool |
| 440 | 440 | */ |
| 441 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
| 442 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
| 441 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
| 442 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
| 443 | 443 | EE_MODELS, |
| 444 | 444 | EE_CORE |
| 445 | - ) ); |
|
| 445 | + )); |
|
| 446 | 446 | // retrieve instantiated class |
| 447 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
| 447 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
@@ -457,15 +457,15 @@ discard block |
||
| 457 | 457 | * @param bool $load_only |
| 458 | 458 | * @return mixed | bool |
| 459 | 459 | */ |
| 460 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
| 460 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
| 461 | 461 | $paths = array( |
| 462 | - EE_MODELS . 'fields' . DS, |
|
| 463 | - EE_MODELS . 'helpers' . DS, |
|
| 464 | - EE_MODELS . 'relations' . DS, |
|
| 465 | - EE_MODELS . 'strategies' . DS |
|
| 462 | + EE_MODELS.'fields'.DS, |
|
| 463 | + EE_MODELS.'helpers'.DS, |
|
| 464 | + EE_MODELS.'relations'.DS, |
|
| 465 | + EE_MODELS.'strategies'.DS |
|
| 466 | 466 | ); |
| 467 | 467 | // retrieve instantiated class |
| 468 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
| 468 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
| 476 | 476 | * @return boolean |
| 477 | 477 | */ |
| 478 | - public function is_model_name( $model_name ) { |
|
| 479 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
| 478 | + public function is_model_name($model_name) { |
|
| 479 | + return isset($this->models[$model_name]) ? true : false; |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | * @param bool $load_only |
| 492 | 492 | * @return mixed |
| 493 | 493 | */ |
| 494 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
| 494 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
| 495 | 495 | // retrieve instantiated class |
| 496 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
| 496 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | * @param bool $load_only |
| 509 | 509 | * @return EE_Addon |
| 510 | 510 | */ |
| 511 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
| 511 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
| 512 | 512 | // retrieve instantiated class |
| 513 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
| 513 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
@@ -541,46 +541,46 @@ discard block |
||
| 541 | 541 | $load_only = false |
| 542 | 542 | ) { |
| 543 | 543 | // strip php file extension |
| 544 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
| 544 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
| 545 | 545 | // does the class have a prefix ? |
| 546 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
| 546 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
| 547 | 547 | // make sure $class_prefix is uppercase |
| 548 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
| 548 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
| 549 | 549 | // add class prefix ONCE!!! |
| 550 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
| 550 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
| 551 | 551 | } |
| 552 | - $class_exists = class_exists( $class_name ); |
|
| 552 | + $class_exists = class_exists($class_name); |
|
| 553 | 553 | // if we're only loading the class and it already exists, then let's just return true immediately |
| 554 | - if ( $load_only && $class_exists ) { |
|
| 554 | + if ($load_only && $class_exists) { |
|
| 555 | 555 | return true; |
| 556 | 556 | } |
| 557 | 557 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
| 558 | 558 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
| 559 | 559 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
| 560 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
| 560 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
| 561 | 561 | // return object if it's already cached |
| 562 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
| 563 | - if ( $cached_class !== null ) { |
|
| 562 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
| 563 | + if ($cached_class !== null) { |
|
| 564 | 564 | return $cached_class; |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | // if the class doesn't already exist.. then we need to try and find the file and load it |
| 568 | - if ( ! $class_exists ) { |
|
| 568 | + if ( ! $class_exists) { |
|
| 569 | 569 | // get full path to file |
| 570 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
| 570 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
| 571 | 571 | // load the file |
| 572 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
| 572 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
| 573 | 573 | // if loading failed, or we are only loading a file but NOT instantiating an object |
| 574 | - if ( ! $loaded || $load_only ) { |
|
| 574 | + if ( ! $loaded || $load_only) { |
|
| 575 | 575 | // return boolean if only loading, or null if an object was expected |
| 576 | 576 | return $load_only ? $loaded : null; |
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | // instantiate the requested object |
| 580 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
| 581 | - if ( $this->_cache_on && $cache ) { |
|
| 580 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
| 581 | + if ($this->_cache_on && $cache) { |
|
| 582 | 582 | // save it for later... kinda like gum { : $ |
| 583 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
| 583 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
| 584 | 584 | } |
| 585 | 585 | $this->_cache_on = true; |
| 586 | 586 | return $class_obj; |
@@ -603,21 +603,21 @@ discard block |
||
| 603 | 603 | * @param string $class_prefix |
| 604 | 604 | * @return null|object |
| 605 | 605 | */ |
| 606 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
| 607 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 608 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 606 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
| 607 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 608 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 609 | 609 | } else { |
| 610 | 610 | // have to specify something, but not anything that will conflict |
| 611 | 611 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
| 612 | 612 | } |
| 613 | 613 | // check if class has already been loaded, and return it if it has been |
| 614 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
| 614 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
| 615 | 615 | return $this->{$class_abbreviation}; |
| 616 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
| 616 | + } else if (isset ($this->{$class_name} )) { |
|
| 617 | 617 | return $this->{$class_name}; |
| 618 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
| 618 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
| 619 | 619 | return $this->LIB->{$class_name}; |
| 620 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
| 620 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
| 621 | 621 | return $this->addons->{$class_name}; |
| 622 | 622 | } |
| 623 | 623 | return null; |
@@ -638,20 +638,20 @@ discard block |
||
| 638 | 638 | * @param array $file_paths |
| 639 | 639 | * @return string | bool |
| 640 | 640 | */ |
| 641 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
| 641 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
| 642 | 642 | // make sure $file_paths is an array |
| 643 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
| 643 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
| 644 | 644 | // cycle thru paths |
| 645 | - foreach ( $file_paths as $key => $file_path ) { |
|
| 645 | + foreach ($file_paths as $key => $file_path) { |
|
| 646 | 646 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
| 647 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
| 647 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
| 648 | 648 | // prep file type |
| 649 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
| 649 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
| 650 | 650 | // build full file path |
| 651 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
| 651 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
| 652 | 652 | //does the file exist and can be read ? |
| 653 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
| 654 | - return $file_paths[ $key ]; |
|
| 653 | + if (is_readable($file_paths[$key])) { |
|
| 654 | + return $file_paths[$key]; |
|
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | return false; |
@@ -673,29 +673,29 @@ discard block |
||
| 673 | 673 | * @return boolean |
| 674 | 674 | * @throws \EE_Error |
| 675 | 675 | */ |
| 676 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
| 676 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
| 677 | 677 | // don't give up! you gotta... |
| 678 | 678 | try { |
| 679 | 679 | //does the file exist and can it be read ? |
| 680 | - if ( ! $path ) { |
|
| 680 | + if ( ! $path) { |
|
| 681 | 681 | // so sorry, can't find the file |
| 682 | - throw new EE_Error ( |
|
| 682 | + throw new EE_Error( |
|
| 683 | 683 | sprintf( |
| 684 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
| 685 | - trim( $type, '.' ), |
|
| 684 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
| 685 | + trim($type, '.'), |
|
| 686 | 686 | $class_name, |
| 687 | - '<br />' . implode( ',<br />', $file_paths ) |
|
| 687 | + '<br />'.implode(',<br />', $file_paths) |
|
| 688 | 688 | ) |
| 689 | 689 | ); |
| 690 | 690 | } |
| 691 | 691 | // get the file |
| 692 | - require_once( $path ); |
|
| 692 | + require_once($path); |
|
| 693 | 693 | // if the class isn't already declared somewhere |
| 694 | - if ( class_exists( $class_name, false ) === false ) { |
|
| 694 | + if (class_exists($class_name, false) === false) { |
|
| 695 | 695 | // so sorry, not a class |
| 696 | 696 | throw new EE_Error( |
| 697 | 697 | sprintf( |
| 698 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
| 698 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
| 699 | 699 | $type, |
| 700 | 700 | $path, |
| 701 | 701 | $class_name |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | ); |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - } catch ( EE_Error $e ) { |
|
| 706 | + } catch (EE_Error $e) { |
|
| 707 | 707 | $e->get_error(); |
| 708 | 708 | return false; |
| 709 | 709 | } |
@@ -735,55 +735,55 @@ discard block |
||
| 735 | 735 | * @return null | object |
| 736 | 736 | * @throws \EE_Error |
| 737 | 737 | */ |
| 738 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
| 738 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
| 739 | 739 | $class_obj = null; |
| 740 | 740 | // don't give up! you gotta... |
| 741 | 741 | try { |
| 742 | 742 | // create reflection |
| 743 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
| 743 | + $reflector = $this->get_ReflectionClass($class_name); |
|
| 744 | 744 | // make sure arguments are an array |
| 745 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
| 745 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
| 746 | 746 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
| 747 | 747 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
| 748 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
| 748 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
| 749 | 749 | ? $arguments |
| 750 | - : array( $arguments ); |
|
| 750 | + : array($arguments); |
|
| 751 | 751 | // attempt to inject dependencies ? |
| 752 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
| 753 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
| 752 | + if ($this->_dependency_map->has($class_name)) { |
|
| 753 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
| 754 | 754 | } |
| 755 | 755 | // instantiate the class and add to the LIB array for tracking |
| 756 | 756 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
| 757 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) { |
|
| 757 | + if ($reflector->getConstructor() === null || $reflector->isAbstract()) { |
|
| 758 | 758 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
| 759 | 759 | //$instantiation_mode = "no constructor"; |
| 760 | 760 | $class_obj = true; |
| 761 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
| 761 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
| 762 | 762 | //$instantiation_mode = "new_instance_from_db"; |
| 763 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
| 764 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
| 763 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
| 764 | + } else if (method_exists($class_name, 'new_instance')) { |
|
| 765 | 765 | //$instantiation_mode = "new_instance"; |
| 766 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
| 767 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
| 766 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
| 767 | + } else if (method_exists($class_name, 'instance')) { |
|
| 768 | 768 | //$instantiation_mode = "instance"; |
| 769 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
| 770 | - } else if ( $reflector->isInstantiable() ) { |
|
| 769 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
| 770 | + } else if ($reflector->isInstantiable()) { |
|
| 771 | 771 | //$instantiation_mode = "isInstantiable"; |
| 772 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
| 772 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
| 773 | 773 | } else { |
| 774 | 774 | // heh ? something's not right ! |
| 775 | 775 | //$instantiation_mode = 'none'; |
| 776 | 776 | throw new EE_Error( |
| 777 | 777 | sprintf( |
| 778 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
| 778 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
| 779 | 779 | $type, |
| 780 | 780 | $class_name |
| 781 | 781 | ) |
| 782 | 782 | ); |
| 783 | 783 | } |
| 784 | - } catch ( Exception $e ) { |
|
| 785 | - if ( ! $e instanceof EE_Error ) { |
|
| 786 | - $e = new EE_Error( $e->getMessage() ); |
|
| 784 | + } catch (Exception $e) { |
|
| 785 | + if ( ! $e instanceof EE_Error) { |
|
| 786 | + $e = new EE_Error($e->getMessage()); |
|
| 787 | 787 | } |
| 788 | 788 | $e->get_error(); |
| 789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
| 797 | 797 | * @param array $array |
| 798 | 798 | * @return bool |
| 799 | 799 | */ |
| 800 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
| 801 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
| 800 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
| 801 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | * @param string $class_name |
| 814 | 814 | * @return ReflectionClass |
| 815 | 815 | */ |
| 816 | - public function get_ReflectionClass( $class_name ) { |
|
| 816 | + public function get_ReflectionClass($class_name) { |
|
| 817 | 817 | if ( |
| 818 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
| 819 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
| 818 | + ! isset($this->_reflectors[$class_name]) |
|
| 819 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
| 820 | 820 | ) { |
| 821 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
| 821 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
| 822 | 822 | } |
| 823 | - return $this->_reflectors[ $class_name ]; |
|
| 823 | + return $this->_reflectors[$class_name]; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | |
@@ -845,45 +845,45 @@ discard block |
||
| 845 | 845 | * @param array $arguments |
| 846 | 846 | * @return array |
| 847 | 847 | */ |
| 848 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
| 848 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
| 849 | 849 | // let's examine the constructor |
| 850 | 850 | $constructor = $reflector->getConstructor(); |
| 851 | 851 | // whu? huh? nothing? |
| 852 | - if ( ! $constructor ) { |
|
| 852 | + if ( ! $constructor) { |
|
| 853 | 853 | return $arguments; |
| 854 | 854 | } |
| 855 | 855 | // get constructor parameters |
| 856 | 856 | $params = $constructor->getParameters(); |
| 857 | 857 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
| 858 | - $argument_keys = array_keys( $arguments ); |
|
| 858 | + $argument_keys = array_keys($arguments); |
|
| 859 | 859 | // now loop thru all of the constructors expected parameters |
| 860 | - foreach ( $params as $index => $param ) { |
|
| 860 | + foreach ($params as $index => $param) { |
|
| 861 | 861 | // is this a dependency for a specific class ? |
| 862 | 862 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
| 863 | 863 | if ( |
| 864 | 864 | // param is not even a class |
| 865 | - empty( $param_class ) |
|
| 865 | + empty($param_class) |
|
| 866 | 866 | // and something already exists in the incoming arguments for this param |
| 867 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 867 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 868 | 868 | ) { |
| 869 | 869 | // so let's skip this argument and move on to the next |
| 870 | 870 | continue; |
| 871 | 871 | } else if ( |
| 872 | 872 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
| 873 | - ! empty( $param_class ) |
|
| 874 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 875 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
| 873 | + ! empty($param_class) |
|
| 874 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 875 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
| 876 | 876 | ) { |
| 877 | 877 | // skip this argument and move on to the next |
| 878 | 878 | continue; |
| 879 | 879 | } else if ( |
| 880 | 880 | // parameter is type hinted as a class, and should be injected |
| 881 | - ! empty( $param_class ) |
|
| 882 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
| 881 | + ! empty($param_class) |
|
| 882 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
| 883 | 883 | ) { |
| 884 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
| 884 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
| 885 | 885 | } else { |
| 886 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
| 886 | + $arguments[$index] = $param->getDefaultValue(); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | } |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * @param mixed $index |
| 901 | 901 | * @return array |
| 902 | 902 | */ |
| 903 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
| 903 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
| 904 | 904 | $dependency = null; |
| 905 | 905 | // should dependency be loaded from cache ? |
| 906 | 906 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( |
@@ -910,30 +910,30 @@ discard block |
||
| 910 | 910 | : false; |
| 911 | 911 | // we might have a dependency... |
| 912 | 912 | // let's MAYBE try and find it in our cache if that's what's been requested |
| 913 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
| 913 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
| 914 | 914 | // and grab it if it exists |
| 915 | - if ( $cached_class instanceof $param_class ) { |
|
| 915 | + if ($cached_class instanceof $param_class) { |
|
| 916 | 916 | $dependency = $cached_class; |
| 917 | - } else if ( $param_class != $class_name ) { |
|
| 917 | + } else if ($param_class != $class_name) { |
|
| 918 | 918 | // obtain the loader method from the dependency map |
| 919 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
| 919 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
| 920 | 920 | // is loader a custom closure ? |
| 921 | - if ( $loader instanceof Closure ) { |
|
| 921 | + if ($loader instanceof Closure) { |
|
| 922 | 922 | $dependency = $loader(); |
| 923 | 923 | } else { |
| 924 | 924 | // set the cache on property for the recursive loading call |
| 925 | 925 | $this->_cache_on = $cache_on; |
| 926 | 926 | // if not, then let's try and load it via the registry |
| 927 | - $dependency = $this->{$loader}( $param_class ); |
|
| 927 | + $dependency = $this->{$loader}($param_class); |
|
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | // did we successfully find the correct dependency ? |
| 931 | - if ( $dependency instanceof $param_class ) { |
|
| 931 | + if ($dependency instanceof $param_class) { |
|
| 932 | 932 | // then let's inject it into the incoming array of arguments at the correct location |
| 933 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
| 934 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
| 933 | + if (isset($argument_keys[$index])) { |
|
| 934 | + $arguments[$argument_keys[$index]] = $dependency; |
|
| 935 | 935 | } else { |
| 936 | - $arguments[ $index ] = $dependency; |
|
| 936 | + $arguments[$index] = $dependency; |
|
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | return $arguments; |
@@ -958,16 +958,16 @@ discard block |
||
| 958 | 958 | * @param bool $from_db |
| 959 | 959 | * @return void |
| 960 | 960 | */ |
| 961 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
| 961 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
| 962 | 962 | // return newly instantiated class |
| 963 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 964 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 963 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 964 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 965 | 965 | $this->{$class_abbreviation} = $class_obj; |
| 966 | - } else if ( property_exists( $this, $class_name ) ) { |
|
| 966 | + } else if (property_exists($this, $class_name)) { |
|
| 967 | 967 | $this->{$class_name} = $class_obj; |
| 968 | - } else if ( $class_prefix == 'addon' ) { |
|
| 968 | + } else if ($class_prefix == 'addon') { |
|
| 969 | 969 | $this->addons->{$class_name} = $class_obj; |
| 970 | - } else if ( ! $from_db ) { |
|
| 970 | + } else if ( ! $from_db) { |
|
| 971 | 971 | $this->LIB->{$class_name} = $class_obj; |
| 972 | 972 | } |
| 973 | 973 | } |
@@ -984,12 +984,12 @@ discard block |
||
| 984 | 984 | * @param array $arguments |
| 985 | 985 | * @return object |
| 986 | 986 | */ |
| 987 | - public static function factory( $classname, $arguments = array() ) { |
|
| 988 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
| 989 | - if ( $loader instanceof Closure ) { |
|
| 990 | - return $loader( $arguments ); |
|
| 991 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
| 992 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
| 987 | + public static function factory($classname, $arguments = array()) { |
|
| 988 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
| 989 | + if ($loader instanceof Closure) { |
|
| 990 | + return $loader($arguments); |
|
| 991 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
| 992 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
| 993 | 993 | } |
| 994 | 994 | return null; |
| 995 | 995 | } |
@@ -1002,9 +1002,9 @@ discard block |
||
| 1002 | 1002 | * @param string $name |
| 1003 | 1003 | * @return EE_Addon |
| 1004 | 1004 | */ |
| 1005 | - public function get_addon_by_name( $name ) { |
|
| 1006 | - foreach ( $this->addons as $addon ) { |
|
| 1007 | - if ( $addon->name() == $name ) { |
|
| 1005 | + public function get_addon_by_name($name) { |
|
| 1006 | + foreach ($this->addons as $addon) { |
|
| 1007 | + if ($addon->name() == $name) { |
|
| 1008 | 1008 | return $addon; |
| 1009 | 1009 | } |
| 1010 | 1010 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
| 1020 | 1020 | */ |
| 1021 | 1021 | public function get_addons_by_name() { |
| 1022 | 1022 | $addons = array(); |
| 1023 | - foreach ( $this->addons as $addon ) { |
|
| 1024 | - $addons[ $addon->name() ] = $addon; |
|
| 1023 | + foreach ($this->addons as $addon) { |
|
| 1024 | + $addons[$addon->name()] = $addon; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return $addons; |
| 1027 | 1027 | } |
@@ -1036,14 +1036,14 @@ discard block |
||
| 1036 | 1036 | * @return \EEM_Base |
| 1037 | 1037 | * @throws \EE_Error |
| 1038 | 1038 | */ |
| 1039 | - public function reset_model( $model_name ) { |
|
| 1040 | - $model = $this->load_model( $model_name ); |
|
| 1041 | - $model_class_name = get_class( $model ); |
|
| 1039 | + public function reset_model($model_name) { |
|
| 1040 | + $model = $this->load_model($model_name); |
|
| 1041 | + $model_class_name = get_class($model); |
|
| 1042 | 1042 | //get that model reset it and make sure we nuke the old reference to it |
| 1043 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
| 1043 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
| 1044 | 1044 | $this->LIB->{$model_class_name} = $model::reset(); |
| 1045 | 1045 | } else { |
| 1046 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
| 1046 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
| 1047 | 1047 | } |
| 1048 | 1048 | return $this->LIB->{$model_class_name}; |
| 1049 | 1049 | } |
@@ -1081,26 +1081,26 @@ discard block |
||
| 1081 | 1081 | * |
| 1082 | 1082 | * @return EE_Registry |
| 1083 | 1083 | */ |
| 1084 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
| 1084 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
| 1085 | 1085 | $instance = self::instance(); |
| 1086 | 1086 | EEH_Activation::reset(); |
| 1087 | 1087 | |
| 1088 | 1088 | //properties that get reset |
| 1089 | 1089 | $instance->_cache_on = true; |
| 1090 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
| 1090 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
| 1091 | 1091 | $instance->CART = null; |
| 1092 | 1092 | $instance->MRM = null; |
| 1093 | 1093 | |
| 1094 | 1094 | //handle of objects cached on LIB |
| 1095 | - foreach ( $instance->_classes_to_unset_from_LIB_on_reset() as $class_name ) { |
|
| 1096 | - if ( isset( $instance->LIB->$class_name ) ) { |
|
| 1097 | - unset( $instance->LIB->$class_name ); |
|
| 1095 | + foreach ($instance->_classes_to_unset_from_LIB_on_reset() as $class_name) { |
|
| 1096 | + if (isset($instance->LIB->$class_name)) { |
|
| 1097 | + unset($instance->LIB->$class_name); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - if ( $reset_models ) { |
|
| 1102 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
| 1103 | - $instance->reset_model( $model_name ); |
|
| 1101 | + if ($reset_models) { |
|
| 1102 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
| 1103 | + $instance->reset_model($model_name); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return array |
| 1116 | 1116 | */ |
| 1117 | 1117 | protected function _classes_to_unset_from_LIB_on_reset() { |
| 1118 | - return apply_filters( 'EE_Registry___classes_to_unset_from_LIB_on_reset', array( |
|
| 1118 | + return apply_filters('EE_Registry___classes_to_unset_from_LIB_on_reset', array( |
|
| 1119 | 1119 | 'EE_Data_Migration_Manager', |
| 1120 | 1120 | 'EE_Messages_Processor', |
| 1121 | 1121 | 'EE_Messages_Queue', |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | * @param $a |
| 1138 | 1138 | * @param $b |
| 1139 | 1139 | */ |
| 1140 | - final function __call( $a, $b ) { |
|
| 1140 | + final function __call($a, $b) { |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | /** |
| 1146 | 1146 | * @param $a |
| 1147 | 1147 | */ |
| 1148 | - final function __get( $a ) { |
|
| 1148 | + final function __get($a) { |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | * @param $a |
| 1155 | 1155 | * @param $b |
| 1156 | 1156 | */ |
| 1157 | - final function __set( $a, $b ) { |
|
| 1157 | + final function __set($a, $b) { |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | /** |
| 1163 | 1163 | * @param $a |
| 1164 | 1164 | */ |
| 1165 | - final function __isset( $a ) { |
|
| 1165 | + final function __isset($a) { |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | /** |
| 1171 | 1171 | * @param $a |
| 1172 | 1172 | */ |
| 1173 | - final function __unset( $a ) { |
|
| 1173 | + final function __unset($a) { |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | * @param $a |
| 1218 | 1218 | * @param $b |
| 1219 | 1219 | */ |
| 1220 | - final static function __callStatic( $a, $b ) { |
|
| 1220 | + final static function __callStatic($a, $b) { |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
@@ -1226,9 +1226,9 @@ discard block |
||
| 1226 | 1226 | */ |
| 1227 | 1227 | public function cpt_models() { |
| 1228 | 1228 | $cpt_models = array(); |
| 1229 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
| 1230 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
| 1231 | - $cpt_models[ $short_name ] = $classname; |
|
| 1229 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
| 1230 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
| 1231 | + $cpt_models[$short_name] = $classname; |
|
| 1232 | 1232 | } |
| 1233 | 1233 | } |
| 1234 | 1234 | return $cpt_models; |