@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @since 4.6.0 |
601 | 601 | * @global WPDB $wpdb |
602 | 602 | * |
603 | - * @return mixed null|int WP_user ID or NULL |
|
603 | + * @return integer|null null|int WP_user ID or NULL |
|
604 | 604 | */ |
605 | 605 | public static function get_default_creator_id() { |
606 | 606 | global $wpdb; |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @static |
760 | 760 | * @deprecated instead use TableManager::dropTable() |
761 | 761 | * @param string $table_name |
762 | - * @return bool | int |
|
762 | + * @return integer | int |
|
763 | 763 | */ |
764 | 764 | public static function delete_unused_db_table( $table_name ) { |
765 | 765 | return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | * @deprecated instead use TableManager::dropIndex() |
776 | 776 | * @param string $table_name |
777 | 777 | * @param string $index_name |
778 | - * @return bool | int |
|
778 | + * @return integer | int |
|
779 | 779 | */ |
780 | 780 | public static function drop_index( $table_name, $index_name ) { |
781 | 781 | return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if ( is_array( $hooks_to_fire_at_time ) ) { |
252 | 252 | foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
253 | 253 | if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | + && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
255 | 255 | ) { |
256 | 256 | unset( $crons[ $timestamp ][ $hook_name ] ); |
257 | 257 | } |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | |
737 | 737 | |
738 | 738 | /** |
739 | - * delete_db_table_if_empty |
|
740 | - * |
|
741 | - * @access public |
|
742 | - * @static |
|
743 | - * @param string $table_name |
|
744 | - * @return bool | int |
|
745 | - */ |
|
739 | + * delete_db_table_if_empty |
|
740 | + * |
|
741 | + * @access public |
|
742 | + * @static |
|
743 | + * @param string $table_name |
|
744 | + * @return bool | int |
|
745 | + */ |
|
746 | 746 | public static function delete_db_table_if_empty( $table_name ) { |
747 | 747 | if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
748 | 748 | return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | $QSG_ID = reset( $id_col ); |
1104 | 1104 | } else { |
1105 | 1105 | //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 |
1106 | - EE_Log::instance()->log( |
|
1107 | - __FILE__, |
|
1108 | - __FUNCTION__, |
|
1109 | - sprintf( |
|
1110 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1111 | - $QST_ID ), |
|
1112 | - 'error' ); |
|
1113 | - continue; |
|
1106 | + EE_Log::instance()->log( |
|
1107 | + __FILE__, |
|
1108 | + __FUNCTION__, |
|
1109 | + sprintf( |
|
1110 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1111 | + $QST_ID ), |
|
1112 | + 'error' ); |
|
1113 | + continue; |
|
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1118,8 +1118,8 @@ discard block |
||
1118 | 1118 | $wpdb->insert( |
1119 | 1119 | \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group_question' ), |
1120 | 1120 | array( 'QSG_ID' => $QSG_ID, |
1121 | - 'QST_ID' => $QST_ID, |
|
1122 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1121 | + 'QST_ID' => $QST_ID, |
|
1122 | + 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1123 | 1123 | ), |
1124 | 1124 | array( '%d', '%d', '%d' ) |
1125 | 1125 | ); |
@@ -1663,8 +1663,8 @@ discard block |
||
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | } |
1666 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1667 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1666 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1667 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1668 | 1668 | |
1669 | 1669 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1670 | 1670 | $db_update_sans_ee4 = array(); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EEH_Activation Helper |
4 | 4 | * |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return \EventEspresso\core\services\database\TableAnalysis |
55 | 55 | */ |
56 | 56 | public static function getTableAnalysis() { |
57 | - if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis ) { |
|
58 | - self::$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
57 | + if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
58 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
59 | 59 | } |
60 | 60 | return self::$table_analysis; |
61 | 61 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return \EventEspresso\core\services\database\TableManager |
67 | 67 | */ |
68 | 68 | public static function getTableManager() { |
69 | - if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager ) { |
|
70 | - self::$table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
69 | + if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
70 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
71 | 71 | } |
72 | 72 | return self::$table_manager; |
73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param $table_name |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
86 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
85 | + public static function ensure_table_name_has_prefix($table_name) { |
|
86 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return boolean success, whether the database and folders are setup properly |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public static function initialize_db_and_folders(){ |
|
114 | + public static function initialize_db_and_folders() { |
|
115 | 115 | $good_filesystem = EEH_Activation::create_upload_directories(); |
116 | 116 | $good_db = EEH_Activation::create_database_tables(); |
117 | 117 | return $good_filesystem && $good_db; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | - public static function initialize_db_content(){ |
|
130 | + public static function initialize_db_content() { |
|
131 | 131 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
132 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
132 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | EEH_Activation::remove_cron_tasks(); |
147 | 147 | EEH_Activation::create_cron_tasks(); |
148 | 148 | // remove all TXN locks since that is being done via extra meta now |
149 | - delete_option( 'ee_locked_transactions' ); |
|
149 | + delete_option('ee_locked_transactions'); |
|
150 | 150 | //also, check for CAF default db content |
151 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
151 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
152 | 152 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
153 | 153 | //which users really won't care about on initial activation |
154 | 154 | EE_Error::overwrite_success(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return array |
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | - public static function get_cron_tasks( $which_to_include ) { |
|
171 | + public static function get_cron_tasks($which_to_include) { |
|
172 | 172 | $cron_tasks = apply_filters( |
173 | 173 | 'FHEE__EEH_Activation__get_cron_tasks', |
174 | 174 | array( |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
178 | 178 | ) |
179 | 179 | ); |
180 | - if ( $which_to_include === 'old' ) { |
|
180 | + if ($which_to_include === 'old') { |
|
181 | 181 | $cron_tasks = array_filter( |
182 | 182 | $cron_tasks, |
183 | - function ( $value ) { |
|
183 | + function($value) { |
|
184 | 184 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
185 | 185 | } |
186 | 186 | ); |
187 | - } elseif ( $which_to_include === 'current' ) { |
|
188 | - $cron_tasks = array_filter( $cron_tasks ); |
|
189 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
187 | + } elseif ($which_to_include === 'current') { |
|
188 | + $cron_tasks = array_filter($cron_tasks); |
|
189 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
190 | 190 | throw new EE_Error( |
191 | 191 | sprintf( |
192 | 192 | __( |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function create_cron_tasks() { |
211 | 211 | |
212 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
213 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
214 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
212 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
213 | + if ( ! wp_next_scheduled($hook_name)) { |
|
214 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
226 | 226 | * @throws \EE_Error |
227 | 227 | */ |
228 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
228 | + public static function remove_cron_tasks($remove_all = true) { |
|
229 | 229 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
230 | 230 | $crons = _get_cron_array(); |
231 | - $crons = is_array( $crons ) ? $crons : array(); |
|
231 | + $crons = is_array($crons) ? $crons : array(); |
|
232 | 232 | /* reminder of what $crons look like: |
233 | 233 | * Top-level keys are timestamps, and their values are arrays. |
234 | 234 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -246,23 +246,23 @@ discard block |
||
246 | 246 | * ... |
247 | 247 | * ... |
248 | 248 | */ |
249 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
250 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
251 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
252 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
253 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
249 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
250 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
251 | + if (is_array($hooks_to_fire_at_time)) { |
|
252 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
253 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
254 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
255 | 255 | ) { |
256 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
256 | + unset($crons[$timestamp][$hook_name]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | //also take care of any empty cron timestamps. |
260 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
261 | - unset( $crons[ $timestamp ] ); |
|
260 | + if (empty($hooks_to_fire_at_time)) { |
|
261 | + unset($crons[$timestamp]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | - _set_cron_array( $crons ); |
|
265 | + _set_cron_array($crons); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function CPT_initialization() { |
279 | 279 | // register Custom Post Types |
280 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
280 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
281 | 281 | flush_rewrite_rules(); |
282 | 282 | } |
283 | 283 | |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @return void |
296 | 296 | */ |
297 | 297 | public static function reset_and_update_config() { |
298 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
299 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
298 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
299 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
300 | 300 | //EE_Config::reset(); |
301 | 301 | } |
302 | 302 | |
@@ -309,28 +309,28 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public static function load_calendar_config() { |
311 | 311 | // grab array of all plugin folders and loop thru it |
312 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
313 | - if ( empty( $plugins ) ) { |
|
312 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
313 | + if (empty($plugins)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | - foreach ( $plugins as $plugin_path ) { |
|
316 | + foreach ($plugins as $plugin_path) { |
|
317 | 317 | // grab plugin folder name from path |
318 | - $plugin = basename( $plugin_path ); |
|
318 | + $plugin = basename($plugin_path); |
|
319 | 319 | // drill down to Espresso plugins |
320 | 320 | // then to calendar related plugins |
321 | 321 | if ( |
322 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
323 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
324 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
325 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
326 | - || strpos( $plugin, 'calendar' ) !== false |
|
322 | + strpos($plugin, 'espresso') !== FALSE |
|
323 | + || strpos($plugin, 'Espresso') !== FALSE |
|
324 | + || strpos($plugin, 'ee4') !== FALSE |
|
325 | + || strpos($plugin, 'EE4') !== FALSE |
|
326 | + || strpos($plugin, 'calendar') !== false |
|
327 | 327 | ) { |
328 | 328 | // this is what we are looking for |
329 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
329 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
330 | 330 | // does it exist in this folder ? |
331 | - if ( is_readable( $calendar_config )) { |
|
331 | + if (is_readable($calendar_config)) { |
|
332 | 332 | // YEAH! let's load it |
333 | - require_once( $calendar_config ); |
|
333 | + require_once($calendar_config); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | * @param \EE_Config $EE_Config |
347 | 347 | * @return \stdClass |
348 | 348 | */ |
349 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
350 | - $convert_from_array = array( 'addons' ); |
|
349 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
350 | + $convert_from_array = array('addons'); |
|
351 | 351 | // in case old settings were saved as an array |
352 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
352 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
353 | 353 | // convert existing settings to an object |
354 | 354 | $config_array = $settings; |
355 | 355 | $settings = new stdClass(); |
356 | - foreach ( $config_array as $key => $value ){ |
|
357 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
358 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
356 | + foreach ($config_array as $key => $value) { |
|
357 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
358 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
359 | 359 | } else { |
360 | 360 | $settings->{$key} = $value; |
361 | 361 | } |
362 | 362 | } |
363 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
363 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
364 | 364 | } |
365 | 365 | return $settings; |
366 | 366 | } |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public static function deactivate_event_espresso() { |
378 | 378 | // check permissions |
379 | - if ( current_user_can( 'activate_plugins' )) { |
|
380 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
379 | + if (current_user_can('activate_plugins')) { |
|
380 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | $critical_pages = array( |
400 | 400 | array( |
401 | 401 | 'id' =>'reg_page_id', |
402 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
402 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
403 | 403 | 'post' => NULL, |
404 | 404 | 'code' => 'ESPRESSO_CHECKOUT' |
405 | 405 | ), |
406 | 406 | array( |
407 | 407 | 'id' => 'txn_page_id', |
408 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
408 | + 'name' => __('Transactions', 'event_espresso'), |
|
409 | 409 | 'post' => NULL, |
410 | 410 | 'code' => 'ESPRESSO_TXN_PAGE' |
411 | 411 | ), |
412 | 412 | array( |
413 | 413 | 'id' => 'thank_you_page_id', |
414 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
414 | + 'name' => __('Thank You', 'event_espresso'), |
|
415 | 415 | 'post' => NULL, |
416 | 416 | 'code' => 'ESPRESSO_THANK_YOU' |
417 | 417 | ), |
418 | 418 | array( |
419 | 419 | 'id' => 'cancel_page_id', |
420 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
420 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
421 | 421 | 'post' => NULL, |
422 | 422 | 'code' => 'ESPRESSO_CANCELLED' |
423 | 423 | ), |
@@ -425,62 +425,62 @@ discard block |
||
425 | 425 | |
426 | 426 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
427 | 427 | |
428 | - foreach ( $critical_pages as $critical_page ) { |
|
428 | + foreach ($critical_pages as $critical_page) { |
|
429 | 429 | // is critical page ID set in config ? |
430 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
430 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
431 | 431 | // attempt to find post by ID |
432 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
432 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
433 | 433 | } |
434 | 434 | // no dice? |
435 | - if ( $critical_page['post'] === null ) { |
|
435 | + if ($critical_page['post'] === null) { |
|
436 | 436 | // attempt to find post by title |
437 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
437 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
438 | 438 | // still nothing? |
439 | - if ( $critical_page['post'] === null ) { |
|
440 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
439 | + if ($critical_page['post'] === null) { |
|
440 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
441 | 441 | // REALLY? Still nothing ??!?!? |
442 | - if ( $critical_page['post'] === null ) { |
|
443 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
444 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
442 | + if ($critical_page['post'] === null) { |
|
443 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
444 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
445 | 445 | break; |
446 | 446 | } |
447 | 447 | } |
448 | 448 | } |
449 | 449 | // track post_shortcodes |
450 | - if ( $critical_page['post'] ) { |
|
451 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
450 | + if ($critical_page['post']) { |
|
451 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
452 | 452 | } |
453 | 453 | // check that Post ID matches critical page ID in config |
454 | 454 | if ( |
455 | - isset( $critical_page['post']->ID ) |
|
456 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
455 | + isset($critical_page['post']->ID) |
|
456 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
457 | 457 | ) { |
458 | 458 | //update Config with post ID |
459 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
460 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
461 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
462 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
459 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
460 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
461 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
462 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | 466 | $critical_page_problem = |
467 | - ! isset( $critical_page['post']->post_status ) |
|
467 | + ! isset($critical_page['post']->post_status) |
|
468 | 468 | || $critical_page['post']->post_status !== 'publish' |
469 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
469 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
470 | 470 | ? TRUE |
471 | 471 | : $critical_page_problem; |
472 | 472 | |
473 | 473 | } |
474 | 474 | |
475 | - if ( $critical_page_problem ) { |
|
475 | + if ($critical_page_problem) { |
|
476 | 476 | $msg = sprintf( |
477 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
478 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
477 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
478 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
479 | 479 | ); |
480 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
480 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
481 | 481 | } |
482 | - if ( EE_Error::has_notices() ) { |
|
483 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
482 | + if (EE_Error::has_notices()) { |
|
483 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -492,13 +492,13 @@ discard block |
||
492 | 492 | * parameter to the shortcode |
493 | 493 | * @return WP_Post or NULl |
494 | 494 | */ |
495 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
495 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
496 | 496 | global $wpdb; |
497 | 497 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
498 | 498 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
499 | - if($post_id){ |
|
499 | + if ($post_id) { |
|
500 | 500 | return get_post($post_id); |
501 | - }else{ |
|
501 | + } else { |
|
502 | 502 | return NULL; |
503 | 503 | } |
504 | 504 | |
@@ -515,32 +515,32 @@ discard block |
||
515 | 515 | * @param array $critical_page |
516 | 516 | * @return array |
517 | 517 | */ |
518 | - public static function create_critical_page( $critical_page ) { |
|
518 | + public static function create_critical_page($critical_page) { |
|
519 | 519 | |
520 | 520 | $post_args = array( |
521 | 521 | 'post_title' => $critical_page['name'], |
522 | 522 | 'post_status' => 'publish', |
523 | 523 | 'post_type' => 'page', |
524 | 524 | 'comment_status' => 'closed', |
525 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
525 | + 'post_content' => '['.$critical_page['code'].']' |
|
526 | 526 | ); |
527 | 527 | |
528 | - $post_id = wp_insert_post( $post_args ); |
|
529 | - if ( ! $post_id ) { |
|
528 | + $post_id = wp_insert_post($post_args); |
|
529 | + if ( ! $post_id) { |
|
530 | 530 | $msg = sprintf( |
531 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
531 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
532 | 532 | $critical_page['name'] |
533 | 533 | ); |
534 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
534 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
535 | 535 | return $critical_page; |
536 | 536 | } |
537 | 537 | // get newly created post's details |
538 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
538 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
539 | 539 | $msg = sprintf( |
540 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
540 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
541 | 541 | $critical_page['name'] |
542 | 542 | ); |
543 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
543 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | return $critical_page; |
@@ -559,35 +559,35 @@ discard block |
||
559 | 559 | * @param array $critical_page |
560 | 560 | * @return void |
561 | 561 | */ |
562 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
562 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
563 | 563 | // check the goods |
564 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
564 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
565 | 565 | $msg = sprintf( |
566 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
566 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
567 | 567 | $critical_page['name'] |
568 | 568 | ); |
569 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
569 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
570 | 570 | return; |
571 | 571 | } |
572 | 572 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
573 | 573 | // map shortcode to post |
574 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
574 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
575 | 575 | // and make sure it's NOT added to the WP "Posts Page" |
576 | 576 | // name of the WP Posts Page |
577 | 577 | $posts_page = EE_Config::get_page_for_posts(); |
578 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
579 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
578 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
579 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
580 | 580 | } |
581 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
582 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
581 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
582 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
583 | 583 | } |
584 | 584 | // update post_shortcode CFG |
585 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
585 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
586 | 586 | $msg = sprintf( |
587 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
587 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
588 | 588 | $critical_page['name'] |
589 | 589 | ); |
590 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
590 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
@@ -605,24 +605,24 @@ discard block |
||
605 | 605 | public static function get_default_creator_id() { |
606 | 606 | global $wpdb; |
607 | 607 | |
608 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
608 | + if ( ! empty(self::$_default_creator_id)) { |
|
609 | 609 | return self::$_default_creator_id; |
610 | 610 | }/**/ |
611 | 611 | |
612 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
612 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
613 | 613 | |
614 | 614 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
615 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
616 | - if ( $pre_filtered_id !== false ) { |
|
615 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
616 | + if ($pre_filtered_id !== false) { |
|
617 | 617 | return (int) $pre_filtered_id; |
618 | 618 | } |
619 | 619 | |
620 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'capabilities' ); |
|
621 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
622 | - $user_id = $wpdb->get_var( $query ); |
|
623 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
624 | - if ( $user_id && (int)$user_id ) { |
|
625 | - self::$_default_creator_id = (int)$user_id; |
|
620 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
621 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
622 | + $user_id = $wpdb->get_var($query); |
|
623 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
624 | + if ($user_id && (int) $user_id) { |
|
625 | + self::$_default_creator_id = (int) $user_id; |
|
626 | 626 | return self::$_default_creator_id; |
627 | 627 | } else { |
628 | 628 | return NULL; |
@@ -651,28 +651,28 @@ discard block |
||
651 | 651 | * @return void |
652 | 652 | * @throws EE_Error if there are database errors |
653 | 653 | */ |
654 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
655 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
654 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
655 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
659 | - if ( ! function_exists( 'dbDelta' )) { |
|
660 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
658 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
659 | + if ( ! function_exists('dbDelta')) { |
|
660 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
661 | 661 | } |
662 | 662 | $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
663 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix( $table_name ); |
|
663 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
664 | 664 | // do we need to first delete an existing version of this table ? |
665 | - if ( $drop_pre_existing_table && $tableAnalysis->tableExists( $wp_table_name ) ){ |
|
665 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
666 | 666 | // ok, delete the table... but ONLY if it's empty |
667 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
667 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
668 | 668 | // table is NOT empty, are you SURE you want to delete this table ??? |
669 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
670 | - \EEH_Activation::getTableManager()->dropTable( $wp_table_name ); |
|
671 | - } else if ( ! $deleted_safely ) { |
|
669 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
670 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
671 | + } else if ( ! $deleted_safely) { |
|
672 | 672 | // so we should be more cautious rather than just dropping tables so easily |
673 | 673 | EE_Error::add_persistent_admin_notice( |
674 | - 'bad_table_' . $wp_table_name . '_detected', |
|
675 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
674 | + 'bad_table_'.$wp_table_name.'_detected', |
|
675 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
676 | 676 | $wp_table_name, |
677 | 677 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
678 | 678 | '<b>wp-config.php</b>', |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | TRUE ); |
681 | 681 | } |
682 | 682 | } |
683 | - $engine = str_replace( 'ENGINE=', '', $engine ); |
|
684 | - \EEH_Activation::getTableManager()->createTable( $table_name, $sql, $engine ); |
|
683 | + $engine = str_replace('ENGINE=', '', $engine); |
|
684 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | * 'VARCHAR(10)' |
700 | 700 | * @return bool|int |
701 | 701 | */ |
702 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
703 | - return \EEH_Activation::getTableManager()->addColumn( $table_name, $column_name, $column_info ); |
|
702 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
703 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @param string $table_name, without prefixed $wpdb->prefix |
717 | 717 | * @return array of database column names |
718 | 718 | */ |
719 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
720 | - return \EEH_Activation::getTableManager()->getTableColumns( $table_name ); |
|
719 | + public static function get_fields_on_table($table_name = NULL) { |
|
720 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | * @param string $table_name |
732 | 732 | * @return bool |
733 | 733 | */ |
734 | - public static function db_table_is_empty( $table_name ) { |
|
735 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ); |
|
734 | + public static function db_table_is_empty($table_name) { |
|
735 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | * @param string $table_name |
746 | 746 | * @return bool | int |
747 | 747 | */ |
748 | - public static function delete_db_table_if_empty( $table_name ) { |
|
749 | - if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
|
750 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
748 | + public static function delete_db_table_if_empty($table_name) { |
|
749 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
750 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
751 | 751 | } |
752 | 752 | return false; |
753 | 753 | } |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | * @param string $table_name |
764 | 764 | * @return bool | int |
765 | 765 | */ |
766 | - public static function delete_unused_db_table( $table_name ) { |
|
767 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
766 | + public static function delete_unused_db_table($table_name) { |
|
767 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | * @param string $index_name |
780 | 780 | * @return bool | int |
781 | 781 | */ |
782 | - public static function drop_index( $table_name, $index_name ) { |
|
783 | - return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
|
782 | + public static function drop_index($table_name, $index_name) { |
|
783 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -794,27 +794,27 @@ discard block |
||
794 | 794 | * @return boolean success (whether database is setup properly or not) |
795 | 795 | */ |
796 | 796 | public static function create_database_tables() { |
797 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
797 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
798 | 798 | //find the migration script that sets the database to be compatible with the code |
799 | 799 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
800 | - if( $dms_name ){ |
|
801 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
802 | - $current_data_migration_script->set_migrating( false ); |
|
800 | + if ($dms_name) { |
|
801 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
802 | + $current_data_migration_script->set_migrating(false); |
|
803 | 803 | $current_data_migration_script->schema_changes_before_migration(); |
804 | 804 | $current_data_migration_script->schema_changes_after_migration(); |
805 | - if( $current_data_migration_script->get_errors() ){ |
|
806 | - if( WP_DEBUG ){ |
|
807 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
808 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
805 | + if ($current_data_migration_script->get_errors()) { |
|
806 | + if (WP_DEBUG) { |
|
807 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
808 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
809 | 809 | } |
810 | - }else{ |
|
811 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
810 | + } else { |
|
811 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
812 | 812 | } |
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
816 | - }else{ |
|
817 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
816 | + } else { |
|
817 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
818 | 818 | return false; |
819 | 819 | } |
820 | 820 | return true; |
@@ -834,27 +834,27 @@ discard block |
||
834 | 834 | public static function initialize_system_questions() { |
835 | 835 | // QUESTION GROUPS |
836 | 836 | global $wpdb; |
837 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group' ); |
|
837 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
838 | 838 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
839 | 839 | // what we have |
840 | - $question_groups = $wpdb->get_col( $SQL ); |
|
840 | + $question_groups = $wpdb->get_col($SQL); |
|
841 | 841 | // check the response |
842 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
842 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
843 | 843 | // what we should have |
844 | - $QSG_systems = array( 1, 2 ); |
|
844 | + $QSG_systems = array(1, 2); |
|
845 | 845 | // loop thru what we should have and compare to what we have |
846 | - foreach ( $QSG_systems as $QSG_system ) { |
|
846 | + foreach ($QSG_systems as $QSG_system) { |
|
847 | 847 | // reset values array |
848 | 848 | $QSG_values = array(); |
849 | 849 | // 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) |
850 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
850 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
851 | 851 | // add it |
852 | - switch ( $QSG_system ) { |
|
852 | + switch ($QSG_system) { |
|
853 | 853 | |
854 | 854 | case 1: |
855 | 855 | $QSG_values = array( |
856 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
857 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
856 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
857 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
858 | 858 | 'QSG_desc' => '', |
859 | 859 | 'QSG_order' => 1, |
860 | 860 | 'QSG_show_group_name' => 1, |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | |
867 | 867 | case 2: |
868 | 868 | $QSG_values = array( |
869 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
870 | - 'QSG_identifier' => 'address-information-' . time(), |
|
869 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
870 | + 'QSG_identifier' => 'address-information-'.time(), |
|
871 | 871 | 'QSG_desc' => '', |
872 | 872 | 'QSG_order' => 2, |
873 | 873 | 'QSG_show_group_name' => 1, |
@@ -879,14 +879,14 @@ discard block |
||
879 | 879 | |
880 | 880 | } |
881 | 881 | // make sure we have some values before inserting them |
882 | - if ( ! empty( $QSG_values )) { |
|
882 | + if ( ! empty($QSG_values)) { |
|
883 | 883 | // insert system question |
884 | 884 | $wpdb->insert( |
885 | 885 | $table_name, |
886 | 886 | $QSG_values, |
887 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
887 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
888 | 888 | ); |
889 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
889 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | } |
@@ -895,10 +895,10 @@ discard block |
||
895 | 895 | |
896 | 896 | // QUESTIONS |
897 | 897 | global $wpdb; |
898 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question' ); |
|
898 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
899 | 899 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
900 | 900 | // what we have |
901 | - $questions = $wpdb->get_col( $SQL ); |
|
901 | + $questions = $wpdb->get_col($SQL); |
|
902 | 902 | // what we should have |
903 | 903 | $QST_systems = array( |
904 | 904 | 'fname', |
@@ -915,25 +915,25 @@ discard block |
||
915 | 915 | $order_for_group_1 = 1; |
916 | 916 | $order_for_group_2 = 1; |
917 | 917 | // loop thru what we should have and compare to what we have |
918 | - foreach ( $QST_systems as $QST_system ) { |
|
918 | + foreach ($QST_systems as $QST_system) { |
|
919 | 919 | // reset values array |
920 | 920 | $QST_values = array(); |
921 | 921 | // if we don't have what we should have |
922 | - if ( ! in_array( $QST_system, $questions )) { |
|
922 | + if ( ! in_array($QST_system, $questions)) { |
|
923 | 923 | // add it |
924 | - switch ( $QST_system ) { |
|
924 | + switch ($QST_system) { |
|
925 | 925 | |
926 | 926 | case 'fname': |
927 | 927 | $QST_values = array( |
928 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
929 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
928 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
929 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
930 | 930 | 'QST_system' => 'fname', |
931 | 931 | 'QST_type' => 'TEXT', |
932 | 932 | 'QST_required' => 1, |
933 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
933 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
934 | 934 | 'QST_order' => 1, |
935 | 935 | 'QST_admin_only' => 0, |
936 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
936 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
937 | 937 | 'QST_wp_user' => self::get_default_creator_id(), |
938 | 938 | 'QST_deleted' => 0 |
939 | 939 | ); |
@@ -941,15 +941,15 @@ discard block |
||
941 | 941 | |
942 | 942 | case 'lname': |
943 | 943 | $QST_values = array( |
944 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
945 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
944 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
945 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
946 | 946 | 'QST_system' => 'lname', |
947 | 947 | 'QST_type' => 'TEXT', |
948 | 948 | 'QST_required' => 1, |
949 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
949 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
950 | 950 | 'QST_order' => 2, |
951 | 951 | 'QST_admin_only' => 0, |
952 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
952 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
953 | 953 | 'QST_wp_user' => self::get_default_creator_id(), |
954 | 954 | 'QST_deleted' => 0 |
955 | 955 | ); |
@@ -957,15 +957,15 @@ discard block |
||
957 | 957 | |
958 | 958 | case 'email': |
959 | 959 | $QST_values = array( |
960 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
961 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
960 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
961 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
962 | 962 | 'QST_system' => 'email', |
963 | 963 | 'QST_type' => 'EMAIL', |
964 | 964 | 'QST_required' => 1, |
965 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
965 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
966 | 966 | 'QST_order' => 3, |
967 | 967 | 'QST_admin_only' => 0, |
968 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
968 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
969 | 969 | 'QST_wp_user' => self::get_default_creator_id(), |
970 | 970 | 'QST_deleted' => 0 |
971 | 971 | ); |
@@ -973,15 +973,15 @@ discard block |
||
973 | 973 | |
974 | 974 | case 'address': |
975 | 975 | $QST_values = array( |
976 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
977 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
976 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
977 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
978 | 978 | 'QST_system' => 'address', |
979 | 979 | 'QST_type' => 'TEXT', |
980 | 980 | 'QST_required' => 0, |
981 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
981 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
982 | 982 | 'QST_order' => 4, |
983 | 983 | 'QST_admin_only' => 0, |
984 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
984 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
985 | 985 | 'QST_wp_user' => self::get_default_creator_id(), |
986 | 986 | 'QST_deleted' => 0 |
987 | 987 | ); |
@@ -989,15 +989,15 @@ discard block |
||
989 | 989 | |
990 | 990 | case 'address2': |
991 | 991 | $QST_values = array( |
992 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
993 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
992 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
993 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
994 | 994 | 'QST_system' => 'address2', |
995 | 995 | 'QST_type' => 'TEXT', |
996 | 996 | 'QST_required' => 0, |
997 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
997 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
998 | 998 | 'QST_order' => 5, |
999 | 999 | 'QST_admin_only' => 0, |
1000 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1000 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1001 | 1001 | 'QST_wp_user' => self::get_default_creator_id(), |
1002 | 1002 | 'QST_deleted' => 0 |
1003 | 1003 | ); |
@@ -1005,15 +1005,15 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | case 'city': |
1007 | 1007 | $QST_values = array( |
1008 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1009 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1008 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1009 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1010 | 1010 | 'QST_system' => 'city', |
1011 | 1011 | 'QST_type' => 'TEXT', |
1012 | 1012 | 'QST_required' => 0, |
1013 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1013 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1014 | 1014 | 'QST_order' => 6, |
1015 | 1015 | 'QST_admin_only' => 0, |
1016 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1016 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1017 | 1017 | 'QST_wp_user' => self::get_default_creator_id(), |
1018 | 1018 | 'QST_deleted' => 0 |
1019 | 1019 | ); |
@@ -1021,12 +1021,12 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | case 'state': |
1023 | 1023 | $QST_values = array( |
1024 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1025 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1024 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1025 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1026 | 1026 | 'QST_system' => 'state', |
1027 | 1027 | 'QST_type' => 'STATE', |
1028 | 1028 | 'QST_required' => 0, |
1029 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1029 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1030 | 1030 | 'QST_order' => 7, |
1031 | 1031 | 'QST_admin_only' => 0, |
1032 | 1032 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1036,12 +1036,12 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | case 'country' : |
1038 | 1038 | $QST_values = array( |
1039 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1040 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1039 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1040 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1041 | 1041 | 'QST_system' => 'country', |
1042 | 1042 | 'QST_type' => 'COUNTRY', |
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' => 8, |
1046 | 1046 | 'QST_admin_only' => 0, |
1047 | 1047 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1051,15 +1051,15 @@ discard block |
||
1051 | 1051 | |
1052 | 1052 | case 'zip': |
1053 | 1053 | $QST_values = array( |
1054 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1055 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1054 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1055 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1056 | 1056 | 'QST_system' => 'zip', |
1057 | 1057 | 'QST_type' => 'TEXT', |
1058 | 1058 | 'QST_required' => 0, |
1059 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1059 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1060 | 1060 | 'QST_order' => 9, |
1061 | 1061 | 'QST_admin_only' => 0, |
1062 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1062 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1063 | 1063 | 'QST_wp_user' => self::get_default_creator_id(), |
1064 | 1064 | 'QST_deleted' => 0 |
1065 | 1065 | ); |
@@ -1067,49 +1067,49 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | case 'phone': |
1069 | 1069 | $QST_values = array( |
1070 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1071 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1070 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1071 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1072 | 1072 | 'QST_system' => 'phone', |
1073 | 1073 | 'QST_type' => 'TEXT', |
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' => 10, |
1077 | 1077 | 'QST_admin_only' => 0, |
1078 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1078 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1079 | 1079 | 'QST_wp_user' => self::get_default_creator_id(), |
1080 | 1080 | 'QST_deleted' => 0 |
1081 | 1081 | ); |
1082 | 1082 | break; |
1083 | 1083 | |
1084 | 1084 | } |
1085 | - if ( ! empty( $QST_values )) { |
|
1085 | + if ( ! empty($QST_values)) { |
|
1086 | 1086 | // insert system question |
1087 | 1087 | $wpdb->insert( |
1088 | 1088 | $table_name, |
1089 | 1089 | $QST_values, |
1090 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1090 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1091 | 1091 | ); |
1092 | 1092 | $QST_ID = $wpdb->insert_id; |
1093 | 1093 | |
1094 | 1094 | // QUESTION GROUP QUESTIONS |
1095 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1095 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1096 | 1096 | $system_question_we_want = EEM_Question_Group::system_personal; |
1097 | 1097 | } else { |
1098 | 1098 | $system_question_we_want = EEM_Question_Group::system_address; |
1099 | 1099 | } |
1100 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1101 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1100 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1101 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1102 | 1102 | } else { |
1103 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1104 | - if( is_array( $id_col ) ) { |
|
1105 | - $QSG_ID = reset( $id_col ); |
|
1103 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1104 | + if (is_array($id_col)) { |
|
1105 | + $QSG_ID = reset($id_col); |
|
1106 | 1106 | } else { |
1107 | 1107 | //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 |
1108 | 1108 | EE_Log::instance()->log( |
1109 | 1109 | __FILE__, |
1110 | 1110 | __FUNCTION__, |
1111 | 1111 | sprintf( |
1112 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1112 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1113 | 1113 | $QST_ID ), |
1114 | 1114 | 'error' ); |
1115 | 1115 | continue; |
@@ -1118,12 +1118,12 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | // add system questions to groups |
1120 | 1120 | $wpdb->insert( |
1121 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group_question' ), |
|
1122 | - array( 'QSG_ID' => $QSG_ID, |
|
1121 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1122 | + array('QSG_ID' => $QSG_ID, |
|
1123 | 1123 | 'QST_ID' => $QST_ID, |
1124 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1124 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
1125 | 1125 | ), |
1126 | - array( '%d', '%d', '%d' ) |
|
1126 | + array('%d', '%d', '%d') |
|
1127 | 1127 | ); |
1128 | 1128 | } |
1129 | 1129 | } |
@@ -1139,11 +1139,11 @@ discard block |
||
1139 | 1139 | * |
1140 | 1140 | * @throws \EE_Error |
1141 | 1141 | */ |
1142 | - public static function insert_default_payment_methods(){ |
|
1143 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1144 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1145 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1146 | - }else{ |
|
1142 | + public static function insert_default_payment_methods() { |
|
1143 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1144 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1145 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1146 | + } else { |
|
1147 | 1147 | EEM_Payment_Method::instance()->verify_button_urls(); |
1148 | 1148 | } |
1149 | 1149 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | global $wpdb; |
1161 | 1161 | |
1162 | - if ( \EEH_Activation::getTableAnalysis()->tableExists( EEM_Status::instance()->table() ) ) { |
|
1162 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1163 | 1163 | |
1164 | 1164 | $table_name = EEM_Status::instance()->table(); |
1165 | 1165 | |
@@ -1235,33 +1235,33 @@ discard block |
||
1235 | 1235 | $folders = array( |
1236 | 1236 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1237 | 1237 | EVENT_ESPRESSO_GATEWAY_DIR, |
1238 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1239 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1240 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1238 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1239 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1240 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1241 | 1241 | ); |
1242 | - foreach ( $folders as $folder ) { |
|
1242 | + foreach ($folders as $folder) { |
|
1243 | 1243 | try { |
1244 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1245 | - @ chmod( $folder, 0755 ); |
|
1246 | - } catch( EE_Error $e ){ |
|
1244 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1245 | + @ chmod($folder, 0755); |
|
1246 | + } catch (EE_Error $e) { |
|
1247 | 1247 | EE_Error::add_error( |
1248 | 1248 | sprintf( |
1249 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1249 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1250 | 1250 | $folder, |
1251 | - '<br />' . $e->getMessage() |
|
1251 | + '<br />'.$e->getMessage() |
|
1252 | 1252 | ), |
1253 | 1253 | __FILE__, __FUNCTION__, __LINE__ |
1254 | 1254 | ); |
1255 | 1255 | //indicate we'll need to fix this later |
1256 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1256 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1257 | 1257 | return FALSE; |
1258 | 1258 | } |
1259 | 1259 | } |
1260 | 1260 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1261 | 1261 | //is disabled, there might be activation errors recorded in there |
1262 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1262 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1263 | 1263 | //remember EE's folders are all good |
1264 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1264 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1265 | 1265 | return TRUE; |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | * @return boolean |
1275 | 1275 | */ |
1276 | 1276 | public static function upload_directories_incomplete() { |
1277 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1277 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | */ |
1292 | 1292 | public static function generate_default_message_templates() { |
1293 | 1293 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1294 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1294 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1295 | 1295 | /* |
1296 | 1296 | * This first method is taking care of ensuring any default messengers |
1297 | 1297 | * that should be made active and have templates generated are done. |
@@ -1327,22 +1327,22 @@ discard block |
||
1327 | 1327 | $active_messengers = $message_resource_manager->active_messengers(); |
1328 | 1328 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1329 | 1329 | $templates_created = false; |
1330 | - foreach ( $active_messengers as $active_messenger ) { |
|
1330 | + foreach ($active_messengers as $active_messenger) { |
|
1331 | 1331 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1332 | 1332 | $default_message_type_names_to_activate = array(); |
1333 | 1333 | // looping through each default message type reported by the messenger |
1334 | 1334 | // and setup the actual message types to activate. |
1335 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1335 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1336 | 1336 | // if already active or has already been activated before we skip |
1337 | 1337 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1338 | 1338 | // we also skip if the message type is not installed. |
1339 | 1339 | if ( |
1340 | - $message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name ) |
|
1340 | + $message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name) |
|
1341 | 1341 | || $message_resource_manager->is_message_type_active_for_messenger( |
1342 | 1342 | $active_messenger->name, |
1343 | 1343 | $default_message_type_name_for_messenger |
1344 | 1344 | ) |
1345 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1345 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1346 | 1346 | ) { |
1347 | 1347 | continue; |
1348 | 1348 | } |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | false |
1356 | 1356 | ); |
1357 | 1357 | //activate the templates for these message types |
1358 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1358 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1359 | 1359 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1360 | 1360 | $active_messenger->name, |
1361 | 1361 | $default_message_type_names_for_messenger, |
@@ -1382,18 +1382,18 @@ discard block |
||
1382 | 1382 | EE_Message_Resource_Manager $message_resource_manager |
1383 | 1383 | ) { |
1384 | 1384 | /** @type EE_messenger[] $messengers_to_generate */ |
1385 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1385 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1386 | 1386 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1387 | 1387 | $templates_generated = false; |
1388 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1388 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1389 | 1389 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1390 | 1390 | //verify the default message types match an installed message type. |
1391 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1391 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1392 | 1392 | if ( |
1393 | - ! isset( $installed_message_types[ $name ] ) |
|
1394 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name ) |
|
1393 | + ! isset($installed_message_types[$name]) |
|
1394 | + || $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name) |
|
1395 | 1395 | ) { |
1396 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1396 | + unset($default_message_type_names_for_messenger[$key]); |
|
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | // in previous iterations, the active_messengers option in the db |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | false |
1408 | 1408 | ); |
1409 | 1409 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1410 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1410 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1411 | 1411 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1412 | 1412 | $messenger_to_generate->name, |
1413 | 1413 | $default_message_type_names_for_messenger, |
@@ -1439,18 +1439,18 @@ discard block |
||
1439 | 1439 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1440 | 1440 | |
1441 | 1441 | $messengers_to_generate = array(); |
1442 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1442 | + foreach ($installed_messengers as $installed_messenger) { |
|
1443 | 1443 | //if installed messenger is a messenger that should be activated on install |
1444 | 1444 | //and is not already active |
1445 | 1445 | //and has never been activated |
1446 | 1446 | if ( |
1447 | 1447 | ! $installed_messenger->activate_on_install |
1448 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1449 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1448 | + || isset($active_messengers[$installed_messenger->name]) |
|
1449 | + || isset($has_activated[$installed_messenger->name]) |
|
1450 | 1450 | ) { |
1451 | 1451 | continue; |
1452 | 1452 | } |
1453 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1453 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1454 | 1454 | } |
1455 | 1455 | return $messengers_to_generate; |
1456 | 1456 | } |
@@ -1475,9 +1475,9 @@ discard block |
||
1475 | 1475 | */ |
1476 | 1476 | public static function validate_messages_system() { |
1477 | 1477 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1478 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1478 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1479 | 1479 | $message_resource_manager->validate_active_message_types_are_installed(); |
1480 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1480 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | |
@@ -1490,12 +1490,12 @@ discard block |
||
1490 | 1490 | * @static |
1491 | 1491 | * @return void |
1492 | 1492 | */ |
1493 | - public static function create_no_ticket_prices_array(){ |
|
1493 | + public static function create_no_ticket_prices_array() { |
|
1494 | 1494 | // this creates an array for tracking events that have no active ticket prices created |
1495 | 1495 | // this allows us to warn admins of the situation so that it can be corrected |
1496 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1497 | - if ( ! $espresso_no_ticket_prices ) { |
|
1498 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1496 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1497 | + if ( ! $espresso_no_ticket_prices) { |
|
1498 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1499 | 1499 | } |
1500 | 1500 | } |
1501 | 1501 | |
@@ -1520,24 +1520,24 @@ discard block |
||
1520 | 1520 | * @global wpdb $wpdb |
1521 | 1521 | * @throws \EE_Error |
1522 | 1522 | */ |
1523 | - public static function delete_all_espresso_cpt_data(){ |
|
1523 | + public static function delete_all_espresso_cpt_data() { |
|
1524 | 1524 | global $wpdb; |
1525 | 1525 | //get all the CPT post_types |
1526 | 1526 | $ee_post_types = array(); |
1527 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1528 | - if ( method_exists( $model_name, 'instance' )) { |
|
1529 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1530 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1531 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1527 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1528 | + if (method_exists($model_name, 'instance')) { |
|
1529 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1530 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1531 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | } |
1535 | 1535 | //get all our CPTs |
1536 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1536 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1537 | 1537 | $cpt_ids = $wpdb->get_col($query); |
1538 | 1538 | //delete each post meta and term relations too |
1539 | - foreach($cpt_ids as $post_id){ |
|
1540 | - wp_delete_post($post_id,true); |
|
1539 | + foreach ($cpt_ids as $post_id) { |
|
1540 | + wp_delete_post($post_id, true); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | |
@@ -1549,12 +1549,12 @@ discard block |
||
1549 | 1549 | public static function drop_espresso_tables() { |
1550 | 1550 | $tables = array(); |
1551 | 1551 | // load registry |
1552 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1553 | - if ( method_exists( $model_name, 'instance' )) { |
|
1554 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1555 | - if ( $model_obj instanceof EEM_Base ) { |
|
1556 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1557 | - if ( strpos( $table->get_table_name(), 'esp_' ) |
|
1552 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1553 | + if (method_exists($model_name, 'instance')) { |
|
1554 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1555 | + if ($model_obj instanceof EEM_Base) { |
|
1556 | + foreach ($model_obj->get_tables() as $table) { |
|
1557 | + if (strpos($table->get_table_name(), 'esp_') |
|
1558 | 1558 | && |
1559 | 1559 | ( |
1560 | 1560 | is_main_site()//main site? nuke them all |
@@ -1577,10 +1577,10 @@ discard block |
||
1577 | 1577 | 'esp_promotion_rule', |
1578 | 1578 | 'esp_rule' |
1579 | 1579 | ); |
1580 | - foreach( $tables_without_models as $table ){ |
|
1580 | + foreach ($tables_without_models as $table) { |
|
1581 | 1581 | $tables[] = $table; |
1582 | 1582 | } |
1583 | - return \EEH_Activation::getTableManager()->dropTables( $tables ); |
|
1583 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1584 | 1584 | } |
1585 | 1585 | |
1586 | 1586 | /** |
@@ -1592,8 +1592,8 @@ discard block |
||
1592 | 1592 | * @param array $table_names |
1593 | 1593 | * @return array of table names which we deleted |
1594 | 1594 | */ |
1595 | - public static function drop_tables( $table_names ) { |
|
1596 | - return \EEH_Activation::getTableManager()->dropTables( $table_names ); |
|
1595 | + public static function drop_tables($table_names) { |
|
1596 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1597 | 1597 | } |
1598 | 1598 | /** |
1599 | 1599 | * plugin_uninstall |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | * @param bool $remove_all |
1604 | 1604 | * @return void |
1605 | 1605 | */ |
1606 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1606 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1607 | 1607 | global $wpdb; |
1608 | 1608 | self::drop_espresso_tables(); |
1609 | 1609 | |
@@ -1641,50 +1641,50 @@ discard block |
||
1641 | 1641 | 'ee_job_parameters_' => false, |
1642 | 1642 | 'ee_upload_directories_incomplete' => true, |
1643 | 1643 | ); |
1644 | - if( is_main_site() ) { |
|
1645 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1644 | + if (is_main_site()) { |
|
1645 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | $undeleted_options = array(); |
1649 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1649 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1650 | 1650 | |
1651 | - if( $no_wildcard ){ |
|
1652 | - if( ! delete_option( $option_name ) ){ |
|
1651 | + if ($no_wildcard) { |
|
1652 | + if ( ! delete_option($option_name)) { |
|
1653 | 1653 | $undeleted_options[] = $option_name; |
1654 | 1654 | } |
1655 | - }else{ |
|
1656 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1657 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1658 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1655 | + } else { |
|
1656 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1657 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1658 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1659 | 1659 | $undeleted_options[] = $option_name_from_wildcard; |
1660 | 1660 | } |
1661 | 1661 | } |
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1665 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1665 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1666 | 1666 | |
1667 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1667 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1668 | 1668 | $db_update_sans_ee4 = array(); |
1669 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1670 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1669 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1670 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1671 | 1671 | $db_update_sans_ee4[$version] = $times_activated; |
1672 | 1672 | } |
1673 | 1673 | } |
1674 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1674 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | $errors = ''; |
1678 | - if ( ! empty( $undeleted_options )) { |
|
1678 | + if ( ! empty($undeleted_options)) { |
|
1679 | 1679 | $errors .= sprintf( |
1680 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1680 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1681 | 1681 | '<br/>', |
1682 | - implode( ',<br/>', $undeleted_options ) |
|
1682 | + implode(',<br/>', $undeleted_options) |
|
1683 | 1683 | ); |
1684 | 1684 | |
1685 | 1685 | } |
1686 | - if ( ! empty( $errors ) ) { |
|
1687 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1686 | + if ( ! empty($errors)) { |
|
1687 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1688 | 1688 | } |
1689 | 1689 | } |
1690 | 1690 | |
@@ -1694,10 +1694,10 @@ discard block |
||
1694 | 1694 | */ |
1695 | 1695 | public static function last_wpdb_error_code() { |
1696 | 1696 | global $wpdb; |
1697 | - if( $wpdb->use_mysqli ) { |
|
1698 | - return mysqli_errno( $wpdb->dbh ); |
|
1697 | + if ($wpdb->use_mysqli) { |
|
1698 | + return mysqli_errno($wpdb->dbh); |
|
1699 | 1699 | } else { |
1700 | - return mysql_errno( $wpdb->dbh ); |
|
1700 | + return mysql_errno($wpdb->dbh); |
|
1701 | 1701 | } |
1702 | 1702 | } |
1703 | 1703 | |
@@ -1708,14 +1708,14 @@ discard block |
||
1708 | 1708 | * @param string $table_name with or without $wpdb->prefix |
1709 | 1709 | * @return boolean |
1710 | 1710 | */ |
1711 | - public static function table_exists( $table_name ){ |
|
1712 | - return \EEH_Activation::getTableAnalysis()->tableExists( $table_name ); |
|
1711 | + public static function table_exists($table_name) { |
|
1712 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | /** |
1716 | 1716 | * Resets the cache on EEH_Activation |
1717 | 1717 | */ |
1718 | - public static function reset(){ |
|
1718 | + public static function reset() { |
|
1719 | 1719 | self::$_default_creator_id = NULL; |
1720 | 1720 | self::$_initialized_db_content_already_in_this_request = false; |
1721 | 1721 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $table_name |
25 | 25 | * @return string $tableName, having ensured it has the wpdb prefix on the front |
26 | 26 | */ |
27 | - public function ensureTableNameHasPrefix( $table_name ) |
|
27 | + public function ensureTableNameHasPrefix($table_name) |
|
28 | 28 | { |
29 | 29 | global $wpdb; |
30 | - return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
30 | + return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param $table_name |
37 | 37 | * @return bool |
38 | 38 | */ |
39 | - public function tableIsEmpty( $table_name ) |
|
39 | + public function tableIsEmpty($table_name) |
|
40 | 40 | { |
41 | 41 | global $wpdb; |
42 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
43 | - if ( $this->tableExists( $table_name ) ) { |
|
44 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
45 | - return absint( $count ) === 0 ? true : false; |
|
42 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
43 | + if ($this->tableExists($table_name)) { |
|
44 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
45 | + return absint($count) === 0 ? true : false; |
|
46 | 46 | } |
47 | 47 | return false; |
48 | 48 | } |
@@ -53,24 +53,24 @@ discard block |
||
53 | 53 | * @param $table_name |
54 | 54 | * @return bool |
55 | 55 | */ |
56 | - public function tableExists( $table_name ) |
|
56 | + public function tableExists($table_name) |
|
57 | 57 | { |
58 | 58 | global $wpdb, $EZSQL_ERROR; |
59 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
59 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
60 | 60 | //ignore if this causes an sql error |
61 | 61 | $old_error = $wpdb->last_error; |
62 | 62 | $old_suppress_errors = $wpdb->suppress_errors(); |
63 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
63 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
64 | 64 | $ezsql_error_cache = $EZSQL_ERROR; |
65 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
66 | - $wpdb->show_errors( $old_show_errors_value ); |
|
67 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
65 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
66 | + $wpdb->show_errors($old_show_errors_value); |
|
67 | + $wpdb->suppress_errors($old_suppress_errors); |
|
68 | 68 | $new_error = $wpdb->last_error; |
69 | 69 | $wpdb->last_error = $old_error; |
70 | 70 | $EZSQL_ERROR = $ezsql_error_cache; |
71 | 71 | //if there was a table doesn't exist error |
72 | - if( ! empty( $new_error ) ) { |
|
73 | - if( |
|
72 | + if ( ! empty($new_error)) { |
|
73 | + if ( |
|
74 | 74 | in_array( |
75 | 75 | \EEH_Activation::last_wpdb_error_code(), |
76 | 76 | array( |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | ) |
81 | 81 | ) |
82 | 82 | || |
83 | - preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
83 | + preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
84 | 84 | ) { |
85 | 85 | return false; |
86 | 86 | } else { |
87 | 87 | //log this because that's weird. Just use the normal PHP error log |
88 | 88 | error_log( |
89 | 89 | sprintf( |
90 | - __( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ), |
|
90 | + __('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'), |
|
91 | 91 | $new_error |
92 | 92 | ) |
93 | 93 | ); |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | 12 | $stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | -foreach($stages as $filepath){ |
|
14 | +foreach ($stages as $filepath) { |
|
15 | 15 | $matches = array(); |
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | 17 | $class_to_filepath[$matches[1]] = $filepath; |
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages',$class_to_filepath); |
|
20 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
|
21 | 21 | EEH_Autoloader::register_autoloader($class_to_filepath); |
22 | 22 | |
23 | 23 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @since 4.6.0 |
34 | 34 | * |
35 | 35 | */ |
36 | -class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base{ |
|
36 | +class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base { |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * return EE_DMS_Core_4_9_0 |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @param TableManager $table_manager |
42 | 42 | * @param TableAnalysis $table_analysis |
43 | 43 | */ |
44 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
45 | 45 | $this->_pretty_name = __("Data Migration to Event Espresso 4.9.0.P", "event_espresso"); |
46 | 46 | $this->_priority = 10; |
47 | 47 | $this->_migration_stages = array( |
48 | 48 | new EE_DMS_4_9_0_Email_System_Question(), |
49 | 49 | new EE_DMS_4_9_0_Answers_With_No_Registration(), |
50 | 50 | ); |
51 | - parent::__construct( $table_manager, $table_analysis ); |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function can_migrate_from_version($version_array) { |
62 | 62 | $version_string = $version_array['Core']; |
63 | - if( $version_string <= '4.9.0' && $version_string >= '4.8.0' ){ |
|
63 | + if ($version_string <= '4.9.0' && $version_string >= '4.8.0') { |
|
64 | 64 | // echo "$version_string can be migrated from"; |
65 | 65 | return true; |
66 | - } elseif( ! $version_string ){ |
|
66 | + } elseif ( ! $version_string) { |
|
67 | 67 | // echo "no version string provided: $version_string"; |
68 | 68 | //no version string provided... this must be pre 4.3 |
69 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | - }else{ |
|
69 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + } else { |
|
71 | 71 | // echo "$version_string doesnt apply"; |
72 | 72 | return false; |
73 | 73 | } |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * @return bool |
89 | 89 | */ |
90 | 90 | public function schema_changes_before_migration() { |
91 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
92 | - $now_in_mysql = current_time( 'mysql', true ); |
|
91 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
92 | + $now_in_mysql = current_time('mysql', true); |
|
93 | 93 | |
94 | - $table_name='esp_answer'; |
|
95 | - $sql=" ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $table_name = 'esp_answer'; |
|
95 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
96 | 96 | REG_ID int(10) unsigned NOT NULL, |
97 | 97 | QST_ID int(10) unsigned NOT NULL, |
98 | 98 | ANS_value text NOT NULL, |
99 | 99 | PRIMARY KEY (ANS_ID), |
100 | 100 | KEY REG_ID (REG_ID), |
101 | 101 | KEY QST_ID (QST_ID)"; |
102 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
102 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
103 | 103 | |
104 | 104 | $table_name = 'esp_attendee_meta'; |
105 | 105 | $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | KEY ATT_fname (ATT_fname)"; |
122 | 122 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
123 | 123 | |
124 | - $table_name='esp_checkin'; |
|
124 | + $table_name = 'esp_checkin'; |
|
125 | 125 | $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
126 | 126 | REG_ID int(10) unsigned NOT NULL, |
127 | 127 | DTT_ID int(10) unsigned NOT NULL, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | CNT_is_EU tinyint(1) DEFAULT '0', |
150 | 150 | CNT_active tinyint(1) DEFAULT '0', |
151 | 151 | PRIMARY KEY (CNT_ISO)"; |
152 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
152 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
153 | 153 | |
154 | 154 | $table_name = 'esp_currency'; |
155 | 155 | $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
160 | 160 | CUR_active tinyint(1) DEFAULT '0', |
161 | 161 | PRIMARY KEY (CUR_code)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | $table_name = 'esp_currency_payment_method'; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | KEY DTT_EVT_start (DTT_EVT_start), |
188 | 188 | KEY EVT_ID (EVT_ID), |
189 | 189 | KEY DTT_is_primary (DTT_is_primary)"; |
190 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
190 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | 191 | |
192 | 192 | $table_name = "esp_datetime_ticket"; |
193 | 193 | $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | PRIMARY KEY (EMT_ID), |
206 | 206 | KEY EVT_ID (EVT_ID), |
207 | 207 | KEY GRP_ID (GRP_ID)"; |
208 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
208 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
209 | 209 | |
210 | 210 | $table_name = 'esp_event_meta'; |
211 | 211 | $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | EVT_donations tinyint(1) NULL, |
224 | 224 | PRIMARY KEY (EVTM_ID), |
225 | 225 | KEY EVT_ID (EVT_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | 227 | |
228 | - $table_name='esp_event_question_group'; |
|
228 | + $table_name = 'esp_event_question_group'; |
|
229 | 229 | $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | QSG_ID int(10) unsigned NOT NULL, |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | PRIMARY KEY (EQG_ID), |
234 | 234 | KEY EVT_ID (EVT_ID), |
235 | 235 | KEY QSG_ID (QSG_ID)"; |
236 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
236 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
237 | 237 | |
238 | - $table_name='esp_event_venue'; |
|
238 | + $table_name = 'esp_event_venue'; |
|
239 | 239 | $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
240 | 240 | EVT_ID bigint(20) unsigned NOT NULL, |
241 | 241 | VNU_ID bigint(20) unsigned NOT NULL, |
242 | 242 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
243 | 243 | PRIMARY KEY (EVV_ID)"; |
244 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
244 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
245 | 245 | |
246 | - $table_name='esp_extra_meta'; |
|
246 | + $table_name = 'esp_extra_meta'; |
|
247 | 247 | $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
248 | 248 | OBJ_ID int(11) DEFAULT NULL, |
249 | 249 | EXM_type varchar(45) DEFAULT NULL, |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | EXM_value text, |
252 | 252 | PRIMARY KEY (EXM_ID), |
253 | 253 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
254 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
254 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
255 | 255 | |
256 | 256 | $table_name = 'esp_extra_join'; |
257 | 257 | $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
265 | 265 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
266 | 266 | |
267 | - $table_name='esp_line_item'; |
|
267 | + $table_name = 'esp_line_item'; |
|
268 | 268 | $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
269 | 269 | LIN_code varchar(245) NOT NULL DEFAULT '', |
270 | 270 | TXN_ID int(11) DEFAULT NULL, |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | PRIMARY KEY (LIN_ID), |
285 | 285 | KEY LIN_code (LIN_code(191)), |
286 | 286 | KEY TXN_ID (TXN_ID)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB' ); |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | 288 | |
289 | 289 | $table_name = 'esp_log'; |
290 | 290 | $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | KEY STS_ID (STS_ID), |
334 | 334 | KEY MSG_created (MSG_created), |
335 | 335 | KEY MSG_modified (MSG_modified)"; |
336 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
336 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
337 | 337 | |
338 | 338 | $table_name = 'esp_message_template'; |
339 | 339 | $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
359 | 359 | PRIMARY KEY (GRP_ID), |
360 | 360 | KEY MTP_user_id (MTP_user_id)"; |
361 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
361 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
362 | 362 | |
363 | 363 | $table_name = 'esp_payment'; |
364 | 364 | $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | PRIMARY KEY (TTM_ID)"; |
417 | 417 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
418 | 418 | |
419 | - $table_name='esp_question'; |
|
419 | + $table_name = 'esp_question'; |
|
420 | 420 | $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
421 | 421 | QST_display_text text NOT NULL, |
422 | 422 | QST_admin_label varchar(255) NOT NULL, |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
432 | 432 | PRIMARY KEY (QST_ID), |
433 | 433 | KEY QST_order (QST_order)'; |
434 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
434 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | 435 | |
436 | - $table_name='esp_question_group_question'; |
|
436 | + $table_name = 'esp_question_group_question'; |
|
437 | 437 | $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
438 | 438 | QSG_ID int(10) unsigned NOT NULL, |
439 | 439 | QST_ID int(10) unsigned NOT NULL, |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | PRIMARY KEY (QGQ_ID), |
442 | 442 | KEY QST_ID (QST_ID), |
443 | 443 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
444 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
444 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
445 | 445 | |
446 | - $table_name='esp_question_option'; |
|
446 | + $table_name = 'esp_question_option'; |
|
447 | 447 | $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
448 | 448 | QSO_value varchar(255) NOT NULL, |
449 | 449 | QSO_desc text NOT NULL, |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | PRIMARY KEY (QSO_ID), |
455 | 455 | KEY QST_ID (QST_ID), |
456 | 456 | KEY QSO_order (QSO_order)"; |
457 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
457 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
458 | 458 | |
459 | 459 | $table_name = 'esp_registration'; |
460 | 460 | $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | PRC_parent int(10) unsigned DEFAULT 0, |
568 | 568 | PRIMARY KEY (PRC_ID), |
569 | 569 | KEY PRT_ID (PRT_ID)"; |
570 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
570 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | 571 | |
572 | 572 | $table_name = "esp_price_type"; |
573 | 573 | $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
605 | 605 | PRIMARY KEY (TKT_ID), |
606 | 606 | KEY TKT_start_date (TKT_start_date)"; |
607 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
607 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
608 | 608 | |
609 | 609 | $table_name = 'esp_question_group'; |
610 | 610 | $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | PRIMARY KEY (QSG_ID), |
621 | 621 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
622 | 622 | KEY QSG_order (QSG_order)'; |
623 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
623 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
624 | 624 | |
625 | 625 | /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
626 | 626 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
@@ -654,5 +654,5 @@ discard block |
||
654 | 654 | return true; |
655 | 655 | } |
656 | 656 | |
657 | - public function migration_page_hooks(){} |
|
657 | + public function migration_page_hooks() {} |
|
658 | 658 | } |
659 | 659 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | use EventEspresso\core\services\database\TableManager; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | /** |
22 | 22 | */ |
23 | -class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base{ |
|
23 | +class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Returns whether or not this data migration script can operate on the given version of the database. |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_migration_stages = array(); |
52 | 52 | $this->_pretty_name = __("Fatal Uncatchable Error Occurred", "event_espresso"); |
53 | 53 | // dd($this); |
54 | - parent::__construct( $table_manager, $table_analysis ); |
|
54 | + parent::__construct($table_manager, $table_analysis); |
|
55 | 55 | } |
56 | 56 | public function migration_page_hooks() { |
57 | 57 |
@@ -35,12 +35,12 @@ |
||
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
38 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | - * @param string $column_name |
|
40 | - * @param string $column_info |
|
41 | - * @return bool|false|int |
|
42 | - */ |
|
43 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
38 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | + * @param string $column_name |
|
40 | + * @param string $column_info |
|
41 | + * @return bool|false|int |
|
42 | + */ |
|
43 | + public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
44 | 44 | { |
45 | 45 | if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
46 | 46 | return FALSE; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\database; |
3 | 3 | |
4 | -defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
4 | +defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class TableManager |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param TableAnalysis $TableAnalysis |
30 | 30 | */ |
31 | - public function __construct( TableAnalysis $TableAnalysis ) { |
|
31 | + public function __construct(TableAnalysis $TableAnalysis) { |
|
32 | 32 | $this->table_analysis = $TableAnalysis; |
33 | 33 | } |
34 | 34 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * @throws \EE_Error |
39 | 39 | */ |
40 | 40 | protected function getTableAnalysis() { |
41 | - if( $this->table_analysis instanceof TableAnalysis ) { |
|
41 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
42 | 42 | return $this->table_analysis; |
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | - get_class( $this ) |
|
46 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | + get_class($this) |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | } |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | * @param string $column_info |
59 | 59 | * @return bool|false|int |
60 | 60 | */ |
61 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
61 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
62 | 62 | { |
63 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
63 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
64 | 64 | return FALSE; |
65 | 65 | } |
66 | 66 | global $wpdb; |
67 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
67 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
68 | 68 | $columns = $this->getTableColumns($table_name); |
69 | - if( !in_array( $column_name, $columns)){ |
|
70 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
69 | + if ( ! in_array($column_name, $columns)) { |
|
70 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
71 | 71 | return $wpdb->query($alter_query); |
72 | 72 | } |
73 | 73 | return TRUE; |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param string $table_name |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function getTableColumns( $table_name ) |
|
83 | + public function getTableColumns($table_name) |
|
84 | 84 | { |
85 | 85 | global $wpdb; |
86 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
86 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | $fieldArray = array(); |
88 | - if ( ! empty( $table_name )) { |
|
88 | + if ( ! empty($table_name)) { |
|
89 | 89 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
90 | 90 | if ($columns !== FALSE) { |
91 | - foreach( $columns as $column ){ |
|
91 | + foreach ($columns as $column) { |
|
92 | 92 | $fieldArray[] = $column->Field; |
93 | 93 | } |
94 | 94 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * @param string $table_name |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function dropTable( $table_name ) |
|
107 | + public function dropTable($table_name) |
|
108 | 108 | { |
109 | 109 | global $wpdb; |
110 | - if ( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
111 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
112 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
110 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
111 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
112 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
113 | 113 | } |
114 | 114 | return 0; |
115 | 115 | } |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | * @param array $table_names |
123 | 123 | * @return array of table names which we deleted |
124 | 124 | */ |
125 | - public function dropTables( $table_names ) |
|
125 | + public function dropTables($table_names) |
|
126 | 126 | { |
127 | 127 | $tables_to_delete = array(); |
128 | - foreach( $table_names as $table_name ) { |
|
129 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
130 | - if( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
128 | + foreach ($table_names as $table_name) { |
|
129 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
130 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
131 | 131 | $tables_to_delete[] = $table_name; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | global $wpdb; |
135 | - $wpdb->query( 'DROP TABLE ' . implode( ', ', $tables_to_delete ) ); |
|
135 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
136 | 136 | return $tables_to_delete; |
137 | 137 | } |
138 | 138 | |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * @param string $indexName |
146 | 146 | * @return int |
147 | 147 | */ |
148 | - public function dropIndex( $table_name, $indexName ) |
|
148 | + public function dropIndex($table_name, $indexName) |
|
149 | 149 | { |
150 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
150 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
151 | 151 | return FALSE; |
152 | 152 | } |
153 | 153 | global $wpdb; |
154 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
154 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
155 | 155 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
156 | 156 | if ( |
157 | - $this->getTableAnalysis()->tableExists( $table_name ) |
|
158 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
157 | + $this->getTableAnalysis()->tableExists($table_name) |
|
158 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
159 | 159 | ) { |
160 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $indexName" ); |
|
160 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
161 | 161 | } |
162 | 162 | return 0; |
163 | 163 | } |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | * @return void |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - public function createTable( $table_name, $createSql, $engine = 'MyISAM' ) |
|
174 | + public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
175 | 175 | { |
176 | 176 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
177 | - if ( preg_match( '((((.*?))(,\s))+)', $createSql, $valid_column_data ) ) { |
|
178 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
177 | + if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
178 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
179 | 179 | $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
180 | 180 | /** @var \wpdb $wpdb */ |
181 | 181 | global $wpdb; |
182 | 182 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
183 | 183 | //happened. And then we can choose to tell the end user |
184 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
185 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
184 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
185 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
186 | 186 | ob_start(); |
187 | - dbDelta( $SQL ); |
|
187 | + dbDelta($SQL); |
|
188 | 188 | $output = ob_get_contents(); |
189 | 189 | ob_end_clean(); |
190 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
191 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
192 | - if( ! empty( $output ) ){ |
|
193 | - throw new \EE_Error( $output ); |
|
190 | + $wpdb->show_errors($old_show_errors_policy); |
|
191 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
192 | + if ( ! empty($output)) { |
|
193 | + throw new \EE_Error($output); |
|
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | throw new \EE_Error( |
197 | 197 | sprintf( |
198 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
198 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
199 | 199 | '<br />', |
200 | 200 | $createSql |
201 | 201 | ) |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate |
25 | 25 | * an error occurred which means the ajax script should probably stop executing. |
26 | 26 | */ |
27 | -class EE_Data_Migration_Manager{ |
|
27 | +class EE_Data_Migration_Manager { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * of this EE installation. Keys should be the name of the version the script upgraded to |
82 | 82 | * @var EE_Data_Migration_Script_Base[] |
83 | 83 | */ |
84 | - private $_data_migrations_ran =null; |
|
84 | + private $_data_migrations_ran = null; |
|
85 | 85 | /** |
86 | 86 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
87 | 87 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function instance() { |
143 | 143 | // check if class object is instantiated |
144 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
144 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
145 | 145 | self::$_instance = new self(); |
146 | 146 | } |
147 | 147 | return self::$_instance; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
152 | 152 | * @return EE_Data_Migration_Manager |
153 | 153 | */ |
154 | - public static function reset(){ |
|
154 | + public static function reset() { |
|
155 | 155 | self::$_instance = NULL; |
156 | 156 | return self::instance(); |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * constructor |
163 | 163 | */ |
164 | - private function __construct(){ |
|
164 | + private function __construct() { |
|
165 | 165 | $this->stati_that_indicate_to_continue_migrations = array( |
166 | 166 | self::status_continue, |
167 | 167 | self::status_completed |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | ); |
181 | 181 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
182 | 182 | //to be defined, because right now it doesn't get autoloaded on its own |
183 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
184 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
185 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
186 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
187 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
188 | - $this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
189 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
183 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
184 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
185 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
186 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
187 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
188 | + $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
189 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
200 | 200 | * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0') |
201 | 201 | */ |
202 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
202 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
203 | 203 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
204 | 204 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
205 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
205 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
206 | 206 | |
207 | - if(count($parts) == 4){ |
|
207 | + if (count($parts) == 4) { |
|
208 | 208 | //it's 4.2-style.eg Core.4.1.0 |
209 | - $plugin_slug = $parts[0];//eg Core |
|
209 | + $plugin_slug = $parts[0]; //eg Core |
|
210 | 210 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
211 | - }else{ |
|
211 | + } else { |
|
212 | 212 | //it's 4.1-style: eg 4.1.0 |
213 | 213 | $plugin_slug = 'Core'; |
214 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
214 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
215 | 215 | } |
216 | - return array($plugin_slug,$version_string); |
|
216 | + return array($plugin_slug, $version_string); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | * @return EE_Data_Migration_Script_Base |
225 | 225 | * @throws EE_Error |
226 | 226 | */ |
227 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
227 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
228 | 228 | $data_migration_data = maybe_unserialize($dms_option_value); |
229 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
229 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
230 | 230 | $class = new $data_migration_data['class']; |
231 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
231 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
232 | 232 | $class->instantiate_from_array_of_properties($data_migration_data); |
233 | 233 | return $class; |
234 | - }else{ |
|
234 | + } else { |
|
235 | 235 | //huh, so its an object but not a data migration script?? that shouldn't happen |
236 | 236 | //just leave it as an array (which will probably just get ignored) |
237 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
237 | + throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class'])); |
|
238 | 238 | } |
239 | - }else{ |
|
239 | + } else { |
|
240 | 240 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
241 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
241 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | /** |
@@ -246,34 +246,34 @@ discard block |
||
246 | 246 | * the last ran which hasn't finished yet |
247 | 247 | * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored) |
248 | 248 | */ |
249 | - public function get_data_migrations_ran(){ |
|
250 | - if( ! $this->_data_migrations_ran ){ |
|
249 | + public function get_data_migrations_ran() { |
|
250 | + if ( ! $this->_data_migrations_ran) { |
|
251 | 251 | //setup autoloaders for each of the scripts in there |
252 | 252 | $this->get_all_data_migration_scripts_available(); |
253 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
253 | + $data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
254 | 254 | |
255 | 255 | $data_migrations_ran = array(); |
256 | 256 | //convert into data migration script classes where possible |
257 | - foreach($data_migrations_options as $data_migration_option){ |
|
258 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
257 | + foreach ($data_migrations_options as $data_migration_option) { |
|
258 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
259 | 259 | |
260 | - try{ |
|
261 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
260 | + try { |
|
261 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
262 | 262 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
263 | 263 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
264 | 264 | $this->_last_ran_script = $class; |
265 | - if( ! $class->is_completed()){ |
|
265 | + if ( ! $class->is_completed()) { |
|
266 | 266 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
267 | 267 | $this->_last_ran_incomplete_script = $class; |
268 | 268 | } |
269 | - }catch(EE_Error $e){ |
|
269 | + } catch (EE_Error $e) { |
|
270 | 270 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
271 | 271 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
275 | 275 | $this->_data_migrations_ran = $data_migrations_ran; |
276 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
276 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
277 | 277 | $this->_data_migrations_ran = array(); |
278 | 278 | } |
279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param $new_table |
291 | 291 | * @return mixed string or int |
292 | 292 | */ |
293 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
293 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
294 | 294 | $script = EE_Registry::instance()->load_dms($script_name); |
295 | 295 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
296 | 296 | return $mapping; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * option returned in this array is the most-recently ran DMS option |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public function get_all_migration_script_options(){ |
|
304 | + public function get_all_migration_script_options() { |
|
305 | 305 | global $wpdb; |
306 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
306 | + return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
312 | 312 | * folder name. |
313 | 313 | */ |
314 | - public function get_data_migration_script_folders(){ |
|
315 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
314 | + public function get_data_migration_script_folders() { |
|
315 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * } |
325 | 325 | * @throws EE_Error |
326 | 326 | */ |
327 | - public function script_migrates_to_version($migration_script_name){ |
|
327 | + public function script_migrates_to_version($migration_script_name) { |
|
328 | 328 | $dms_info = $this->parse_dms_classname($migration_script_name); |
329 | 329 | return array( |
330 | - 'slug'=> $dms_info[ 'slug' ], |
|
331 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
330 | + 'slug'=> $dms_info['slug'], |
|
331 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
338 | 338 | * @throws EE_Error |
339 | 339 | */ |
340 | - public function parse_dms_classname($classname){ |
|
340 | + public function parse_dms_classname($classname) { |
|
341 | 341 | $matches = array(); |
342 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
343 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
344 | - throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname)); |
|
342 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
343 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
344 | + throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname)); |
|
345 | 345 | } |
346 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
346 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
347 | 347 | } |
348 | 348 | /** |
349 | 349 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -352,33 +352,33 @@ discard block |
||
352 | 352 | * to 4.1.x. |
353 | 353 | * @return string of current db state |
354 | 354 | */ |
355 | - public function ensure_current_database_state_is_set(){ |
|
356 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
355 | + public function ensure_current_database_state_is_set() { |
|
356 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
357 | 357 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
358 | - if( ! $db_state ){ |
|
358 | + if ( ! $db_state) { |
|
359 | 359 | //mark the DB as being in the state as the last version in there. |
360 | 360 | //this is done to trigger maintenance mode and do data migration scripts |
361 | 361 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
362 | 362 | //otherwise, the normal maintenance mode code is fine |
363 | 363 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
364 | 364 | $previous_version_installed = end($previous_versions_installed); |
365 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
365 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
366 | 366 | //last installed version was less than 4.1 |
367 | 367 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
368 | 368 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
369 | 369 | $db_state = array('Core'=>$previous_version_installed); |
370 | - }else{ |
|
370 | + } else { |
|
371 | 371 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
372 | 372 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
373 | 373 | } |
374 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
374 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
375 | 375 | } |
376 | 376 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
377 | 377 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
378 | 378 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
379 | - if( ! is_array($db_state)){ |
|
379 | + if ( ! is_array($db_state)) { |
|
380 | 380 | $db_state = array('Core'=>$db_state); |
381 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
381 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
382 | 382 | } |
383 | 383 | return $db_state; |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * or they don't apply), returns an empty array |
390 | 390 | * @return EE_Data_Migration_Script_Base[] |
391 | 391 | */ |
392 | - public function check_for_applicable_data_migration_scripts(){ |
|
392 | + public function check_for_applicable_data_migration_scripts() { |
|
393 | 393 | //get the option describing what options have already run |
394 | 394 | $scripts_ran = $this->get_data_migrations_ran(); |
395 | 395 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -402,62 +402,62 @@ discard block |
||
402 | 402 | $iteration = 0; |
403 | 403 | $next_database_state_to_consider = $current_database_state; |
404 | 404 | $theoretical_database_state = NULL; |
405 | - do{ |
|
405 | + do { |
|
406 | 406 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
407 | 407 | $theoretical_database_state = $next_database_state_to_consider; |
408 | 408 | //the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?) |
409 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
409 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
410 | 410 | |
411 | 411 | $migrates_to_version = $this->script_migrates_to_version($classname); |
412 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
413 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
412 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
413 | + $script_converts_to_version = $migrates_to_version['version']; |
|
414 | 414 | //check if this version script is DONE or not; or if it's never been ran |
415 | - if( ! $scripts_ran || |
|
415 | + if ( ! $scripts_ran || |
|
416 | 416 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
417 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
417 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
418 | 418 | //we haven't ran this conversion script before |
419 | 419 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
420 | - $script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() ); |
|
420 | + $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis()); |
|
421 | 421 | /* @var $script EE_Data_Migration_Script_Base */ |
422 | 422 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
423 | - if($can_migrate){ |
|
423 | + if ($can_migrate) { |
|
424 | 424 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
425 | 425 | $migrates_to_version = $script->migrates_to_version(); |
426 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
426 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
427 | 427 | unset($script_class_and_filepaths_available[$classname]); |
428 | 428 | } |
429 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
429 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
430 | 430 | //this script has been ran, or at least started |
431 | 431 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
432 | - if( $script->get_status() != self::status_completed){ |
|
432 | + if ($script->get_status() != self::status_completed) { |
|
433 | 433 | //this script is already underway... keep going with it |
434 | 434 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
435 | 435 | $migrates_to_version = $script->migrates_to_version(); |
436 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
436 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
437 | 437 | unset($script_class_and_filepaths_available[$classname]); |
438 | - }else{ |
|
438 | + } else { |
|
439 | 439 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
440 | 440 | } |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | //it exists but it's not a proper data migration script |
443 | 443 | //maybe the script got renamed? or was simply removed from EE? |
444 | 444 | //either way, its certainly not runnable! |
445 | 445 | } |
446 | 446 | } |
447 | 447 | $iteration++; |
448 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
448 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
449 | 449 | //ok we have all the scripts that should run, now let's make them into flat array |
450 | 450 | $scripts_that_should_run = array(); |
451 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
451 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
452 | 452 | ksort($scripts_at_priority); |
453 | - foreach($scripts_at_priority as $scripts){ |
|
454 | - foreach($scripts as $script){ |
|
453 | + foreach ($scripts_at_priority as $scripts) { |
|
454 | + foreach ($scripts as $script) { |
|
455 | 455 | $scripts_that_should_run[get_class($script)] = $script; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
460 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
461 | 461 | return $scripts_that_should_run; |
462 | 462 | } |
463 | 463 | |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | * @param bool $include_completed_scripts |
472 | 472 | * @return EE_Data_Migration_Script_Base |
473 | 473 | */ |
474 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
474 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
475 | 475 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
476 | - if( ! $this->_data_migrations_ran){ |
|
476 | + if ( ! $this->_data_migrations_ran) { |
|
477 | 477 | $this->get_data_migrations_ran(); |
478 | 478 | } |
479 | - if($include_completed_scripts){ |
|
479 | + if ($include_completed_scripts) { |
|
480 | 480 | return $this->_last_ran_script; |
481 | - }else{ |
|
481 | + } else { |
|
482 | 482 | return $this->_last_ran_incomplete_script; |
483 | 483 | } |
484 | 484 | } |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | * @type string $message string describing what was done during this step |
502 | 502 | * } |
503 | 503 | */ |
504 | - public function migration_step( $step_size = 0 ){ |
|
504 | + public function migration_step($step_size = 0) { |
|
505 | 505 | |
506 | 506 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
507 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
508 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
507 | + if (class_exists('EE_CPT_Strategy')) { |
|
508 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
509 | 509 | } |
510 | 510 | |
511 | - try{ |
|
511 | + try { |
|
512 | 512 | $currently_executing_script = $this->get_last_ran_script(); |
513 | - if( ! $currently_executing_script){ |
|
513 | + if ( ! $currently_executing_script) { |
|
514 | 514 | //Find the next script that needs to execute |
515 | 515 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
516 | - if( ! $scripts ){ |
|
516 | + if ( ! $scripts) { |
|
517 | 517 | //huh, no more scripts to run... apparently we're done! |
518 | 518 | //but dont forget to make sure initial data is there |
519 | 519 | //we should be good to allow them to exit maintenance mode now |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | //and add to the array/wp option showing the scripts ran |
535 | 535 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
536 | 536 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
537 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
538 | - $version = $migrates_to[ 'version' ]; |
|
537 | + $plugin_slug = $migrates_to['slug']; |
|
538 | + $version = $migrates_to['version']; |
|
539 | 539 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
540 | 540 | } |
541 | 541 | $current_script_name = get_class($currently_executing_script); |
542 | - }catch(Exception $e){ |
|
542 | + } catch (Exception $e) { |
|
543 | 543 | //an exception occurred while trying to get migration scripts |
544 | 544 | |
545 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
545 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
546 | 546 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
547 | 547 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
548 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
548 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
549 | 549 | return array( |
550 | 550 | 'records_to_migrate'=>1, |
551 | 551 | 'records_migrated'=>0, |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | ); |
556 | 556 | } |
557 | 557 | //ok so we definitely have a data migration script |
558 | - try{ |
|
558 | + try { |
|
559 | 559 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
560 | - if( ! absint( $step_size ) > 0 ){ |
|
561 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
560 | + if ( ! absint($step_size) > 0) { |
|
561 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
562 | 562 | } |
563 | 563 | //do what we came to do! |
564 | 564 | $currently_executing_script->migration_step($step_size); |
565 | 565 | //can we wrap it up and verify default data? |
566 | 566 | $init_dbs = false; |
567 | - switch($currently_executing_script->get_status()){ |
|
567 | + switch ($currently_executing_script->get_status()) { |
|
568 | 568 | case EE_Data_Migration_Manager::status_continue: |
569 | 569 | $response_array = array( |
570 | 570 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -576,16 +576,16 @@ discard block |
||
576 | 576 | case EE_Data_Migration_Manager::status_completed: |
577 | 577 | //ok so THAT script has completed |
578 | 578 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
579 | - $response_array = array( |
|
579 | + $response_array = array( |
|
580 | 580 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
581 | 581 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
582 | 582 | 'status'=> EE_Data_Migration_Manager::status_completed, |
583 | 583 | 'message'=>$currently_executing_script->get_feedback_message(), |
584 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
584 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
585 | 585 | ); |
586 | 586 | //check if there are any more after this one. |
587 | 587 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
588 | - if( ! $scripts_remaining ){ |
|
588 | + if ( ! $scripts_remaining) { |
|
589 | 589 | //we should be good to allow them to exit maintenance mode now |
590 | 590 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
591 | 591 | ////huh, no more scripts to run... apparently we're done! |
@@ -599,39 +599,39 @@ discard block |
||
599 | 599 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
600 | 600 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
601 | 601 | 'status'=> $currently_executing_script->get_status(), |
602 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
602 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
603 | 603 | 'script'=>$currently_executing_script->pretty_name() |
604 | 604 | ); |
605 | 605 | break; |
606 | 606 | } |
607 | - }catch(Exception $e){ |
|
607 | + } catch (Exception $e) { |
|
608 | 608 | //ok so some exception was thrown which killed the data migration script |
609 | 609 | //double-check we have a real script |
610 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
610 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
611 | 611 | $script_name = $currently_executing_script->pretty_name(); |
612 | 612 | $currently_executing_script->set_broken(); |
613 | 613 | $currently_executing_script->add_error($e->getMessage()); |
614 | - }else{ |
|
614 | + } else { |
|
615 | 615 | $script_name = __("Error getting Migration Script", "event_espresso"); |
616 | 616 | } |
617 | 617 | $response_array = array( |
618 | 618 | 'records_to_migrate'=>1, |
619 | 619 | 'records_migrated'=>0, |
620 | 620 | 'status'=>self::status_fatal_error, |
621 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
621 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
622 | 622 | 'script'=>$script_name |
623 | 623 | ); |
624 | 624 | } |
625 | 625 | $successful_save = $this->_save_migrations_ran(); |
626 | - if($successful_save !== TRUE){ |
|
626 | + if ($successful_save !== TRUE) { |
|
627 | 627 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
628 | 628 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
629 | 629 | //however, if we throw an exception, and return that, then the next request |
630 | 630 | //won't have as much info in it, and it may be able to save |
631 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
631 | + throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save)); |
|
632 | 632 | } |
633 | 633 | //if we're all done, initialize EE plugins' default data etc. |
634 | - if( $init_dbs ) { |
|
634 | + if ($init_dbs) { |
|
635 | 635 | $this->initialize_db_for_enqueued_ee_plugins(); |
636 | 636 | } |
637 | 637 | return $response_array; |
@@ -649,23 +649,23 @@ discard block |
||
649 | 649 | * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes |
650 | 650 | * 'script'=>a pretty name of the script currently running |
651 | 651 | */ |
652 | - public function response_to_migration_ajax_request(){ |
|
652 | + public function response_to_migration_ajax_request() { |
|
653 | 653 | // //start output buffer just to make sure we don't mess up the json |
654 | 654 | ob_start(); |
655 | - try{ |
|
655 | + try { |
|
656 | 656 | $response = $this->migration_step(); |
657 | - }catch(Exception $e){ |
|
657 | + } catch (Exception $e) { |
|
658 | 658 | $response = array( |
659 | 659 | 'records_to_migrate'=>0, |
660 | 660 | 'records_migrated'=>0, |
661 | 661 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
662 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
662 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
663 | 663 | 'script'=>'Unknown'); |
664 | 664 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
665 | 665 | } |
666 | 666 | $warnings_etc = @ob_get_contents(); |
667 | 667 | ob_end_clean(); |
668 | - $response['message'] .=$warnings_etc; |
|
668 | + $response['message'] .= $warnings_etc; |
|
669 | 669 | return $response; |
670 | 670 | } |
671 | 671 | |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * } |
679 | 679 | * @return void |
680 | 680 | */ |
681 | - public function update_current_database_state_to($slug_and_version = null){ |
|
682 | - if( ! $slug_and_version ){ |
|
681 | + public function update_current_database_state_to($slug_and_version = null) { |
|
682 | + if ( ! $slug_and_version) { |
|
683 | 683 | //no version was provided, assume it should be at the current code version |
684 | 684 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
685 | 685 | } |
686 | 686 | $current_database_state = get_option(self::current_database_state); |
687 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
688 | - update_option(self::current_database_state,$current_database_state); |
|
687 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
688 | + update_option(self::current_database_state, $current_database_state); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -696,20 +696,20 @@ discard block |
||
696 | 696 | * } |
697 | 697 | * @return boolean |
698 | 698 | */ |
699 | - public function database_needs_updating_to( $slug_and_version ) { |
|
699 | + public function database_needs_updating_to($slug_and_version) { |
|
700 | 700 | |
701 | - $slug = $slug_and_version[ 'slug' ]; |
|
702 | - $version = $slug_and_version[ 'version' ]; |
|
701 | + $slug = $slug_and_version['slug']; |
|
702 | + $version = $slug_and_version['version']; |
|
703 | 703 | $current_database_state = get_option(self::current_database_state); |
704 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
704 | + if ( ! isset($current_database_state[$slug])) { |
|
705 | 705 | return true; |
706 | - }else{ |
|
706 | + } else { |
|
707 | 707 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
708 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
709 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
708 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
709 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
710 | 710 | $needs_updating = false; |
711 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
712 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
711 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
712 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
713 | 713 | $needs_updating = true; |
714 | 714 | break; |
715 | 715 | } |
@@ -723,29 +723,29 @@ discard block |
||
723 | 723 | * in addons. Has the side effect of adding them for autoloading |
724 | 724 | * @return array keys are expected classnames, values are their filepaths |
725 | 725 | */ |
726 | - public function get_all_data_migration_scripts_available(){ |
|
727 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
726 | + public function get_all_data_migration_scripts_available() { |
|
727 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
728 | 728 | $this->_data_migration_class_to_filepath_map = array(); |
729 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
730 | - if($folder_path[count($folder_path-1)] != DS ){ |
|
731 | - $folder_path.= DS; |
|
729 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
730 | + if ($folder_path[count($folder_path - 1)] != DS) { |
|
731 | + $folder_path .= DS; |
|
732 | 732 | } |
733 | - $files = glob( $folder_path. '*.dms.php' ); |
|
733 | + $files = glob($folder_path.'*.dms.php'); |
|
734 | 734 | |
735 | - if ( empty( $files ) ) { |
|
735 | + if (empty($files)) { |
|
736 | 736 | continue; |
737 | 737 | } |
738 | 738 | |
739 | - foreach($files as $file){ |
|
740 | - $pos_of_last_slash = strrpos($file,DS); |
|
741 | - $classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1)); |
|
742 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
743 | - $slug = $migrates_to[ 'slug' ]; |
|
739 | + foreach ($files as $file) { |
|
740 | + $pos_of_last_slash = strrpos($file, DS); |
|
741 | + $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1)); |
|
742 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
743 | + $slug = $migrates_to['slug']; |
|
744 | 744 | //check that the slug as contained in the DMS is associated with |
745 | 745 | //the slug of an addon or core |
746 | - if( $slug != 'Core' ){ |
|
747 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
748 | - EE_Error::doing_it_wrong(__FUNCTION__, sprintf( __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),$classname,$slug,implode(",", array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ), '4.3.0.alpha.019' ); |
|
746 | + if ($slug != 'Core') { |
|
747 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
748 | + EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019'); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | $this->_data_migration_class_to_filepath_map[$classname] = $file; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * from each addon, and check if they need updating, |
766 | 766 | * @return boolean |
767 | 767 | */ |
768 | - public function addons_need_updating(){ |
|
768 | + public function addons_need_updating() { |
|
769 | 769 | return false; |
770 | 770 | } |
771 | 771 | /** |
@@ -774,25 +774,25 @@ discard block |
||
774 | 774 | * @param string $error_message |
775 | 775 | * @throws EE_Error |
776 | 776 | */ |
777 | - public function add_error_to_migrations_ran($error_message){ |
|
777 | + public function add_error_to_migrations_ran($error_message) { |
|
778 | 778 | //get last-ran migration script |
779 | 779 | global $wpdb; |
780 | - $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A); |
|
780 | + $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A); |
|
781 | 781 | |
782 | 782 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
783 | 783 | //now, tread lightly because we're here because a FATAL non-catchable error |
784 | 784 | //was thrown last time when we were trying to run a data migration script |
785 | 785 | //so the fatal error could have happened while getting the migration script |
786 | 786 | //or doing running it... |
787 | - $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null; |
|
787 | + $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null; |
|
788 | 788 | |
789 | 789 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
790 | 790 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
791 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
791 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
792 | 792 | //ok then just add this error to its list of errors |
793 | 793 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
794 | 794 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
795 | - }else{ |
|
795 | + } else { |
|
796 | 796 | //so we don't even know which script was last running |
797 | 797 | //use the data migration error stub, which is designed specifically for this type of thing |
798 | 798 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -802,39 +802,39 @@ discard block |
||
802 | 802 | $versions_migrated_to = 'Unknown.1.0.0'; |
803 | 803 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
804 | 804 | //delete the old one |
805 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
805 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
806 | 806 | } |
807 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
807 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * saves what data migrations have ran to the database |
812 | 812 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
813 | 813 | */ |
814 | - protected function _save_migrations_ran(){ |
|
815 | - if($this->_data_migrations_ran == null){ |
|
814 | + protected function _save_migrations_ran() { |
|
815 | + if ($this->_data_migrations_ran == null) { |
|
816 | 816 | $this->get_data_migrations_ran(); |
817 | 817 | } |
818 | 818 | //now, we don't want to save actual classes to the DB because that's messy |
819 | 819 | $successful_updates = true; |
820 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
821 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
820 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
821 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
822 | 822 | // echo "saving migration script to $version_string<br>"; |
823 | 823 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
824 | 824 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
825 | 825 | $old_option_value = get_option($option_name); |
826 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
826 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
827 | 827 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
828 | - if( $old_option_value != $script_array_for_saving){ |
|
829 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
828 | + if ($old_option_value != $script_array_for_saving) { |
|
829 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
830 | 830 | } |
831 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
831 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
832 | 832 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
833 | - if($old_option_value != $array_or_migration_obj){ |
|
834 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
833 | + if ($old_option_value != $array_or_migration_obj) { |
|
834 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
835 | 835 | } |
836 | 836 | } |
837 | - if( ! $successful_updates ){ |
|
837 | + if ( ! $successful_updates) { |
|
838 | 838 | global $wpdb; |
839 | 839 | return $wpdb->last_error; |
840 | 840 | } |
@@ -858,17 +858,17 @@ discard block |
||
858 | 858 | * @return EE_Data_Migration_Script_Base |
859 | 859 | * @throws EE_Error |
860 | 860 | */ |
861 | - function _instantiate_script_from_properties_array($properties_array){ |
|
862 | - if( ! isset($properties_array['class'])){ |
|
863 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
861 | + function _instantiate_script_from_properties_array($properties_array) { |
|
862 | + if ( ! isset($properties_array['class'])) { |
|
863 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
864 | 864 | } |
865 | 865 | $class_name = $properties_array['class']; |
866 | - if( ! class_exists($class_name)){ |
|
867 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
866 | + if ( ! class_exists($class_name)) { |
|
867 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
868 | 868 | } |
869 | 869 | $class = new $class_name; |
870 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
871 | - throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class))); |
|
870 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
871 | + throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class))); |
|
872 | 872 | } |
873 | 873 | $class->instantiate_from_array_of_properties($properties_array); |
874 | 874 | return $class; |
@@ -880,25 +880,25 @@ discard block |
||
880 | 880 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
881 | 881 | * @return string |
882 | 882 | */ |
883 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
883 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
884 | 884 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
885 | 885 | $most_up_to_date_dms_classname = NULL; |
886 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
887 | - if($most_up_to_date_dms_classname === NULL){ |
|
886 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
887 | + if ($most_up_to_date_dms_classname === NULL) { |
|
888 | 888 | $migrates_to = $this->script_migrates_to_version($classname); |
889 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
889 | + $this_plugin_slug = $migrates_to['slug']; |
|
890 | 890 | // $version_string = $migrates_to[ 'version' ]; |
891 | 891 | // $details = $this->parse_dms_classname($classname); |
892 | - if($this_plugin_slug == $plugin_slug){ |
|
892 | + if ($this_plugin_slug == $plugin_slug) { |
|
893 | 893 | //if it's for core, it wins |
894 | 894 | $most_up_to_date_dms_classname = $classname; |
895 | 895 | } |
896 | 896 | //if it wasn't for core, we must keep searching for one that is! |
897 | 897 | continue; |
898 | - }else{ |
|
899 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
898 | + } else { |
|
899 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
900 | 900 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
901 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
901 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
902 | 902 | //so the contenders version is higher and its for Core |
903 | 903 | $most_up_to_date_dms_classname = $classname; |
904 | 904 | } |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
919 | 919 | * @return EE_Data_Migration_Script_Base |
920 | 920 | */ |
921 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
921 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
922 | 922 | $migrations_ran = $this->get_data_migrations_ran(); |
923 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
924 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
925 | - }else{ |
|
923 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
924 | + return $migrations_ran[$plugin_slug][$version]; |
|
925 | + } else { |
|
926 | 926 | return NULL; |
927 | 927 | } |
928 | 928 | } |
@@ -934,20 +934,20 @@ discard block |
||
934 | 934 | * @return bool |
935 | 935 | * @throws \EE_Error |
936 | 936 | */ |
937 | - public function reattempt(){ |
|
937 | + public function reattempt() { |
|
938 | 938 | //find if the last-ran script was borked |
939 | 939 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
940 | 940 | //add an 'error' saying that we attempted to reset |
941 | 941 | //does it have a stage that was borked too? if so make it no longer borked |
942 | 942 | //add an 'error' saying we attempted to reset |
943 | 943 | $last_ran_script = $this->get_last_ran_script(); |
944 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
944 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
945 | 945 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
946 | 946 | $last_ran_script->set_completed(); |
947 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
947 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
948 | 948 | $last_ran_script->reattempt(); |
949 | - }else{ |
|
950 | - throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
|
949 | + } else { |
|
950 | + throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true))); |
|
951 | 951 | } |
952 | 952 | return $this->_save_migrations_ran(); |
953 | 953 | } |
@@ -957,19 +957,19 @@ discard block |
||
957 | 957 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
958 | 958 | * @return boolean |
959 | 959 | */ |
960 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
961 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
960 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
961 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
962 | 962 | } |
963 | 963 | /** |
964 | 964 | * Enqueues this ee plugin to have its data initialized |
965 | 965 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
966 | 966 | */ |
967 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
967 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
968 | 968 | $queue = $this->get_db_initialization_queue(); |
969 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
969 | + if ( ! in_array($plugin_slug, $queue)) { |
|
970 | 970 | $queue[] = $plugin_slug; |
971 | 971 | } |
972 | - update_option( self::db_init_queue_option_name, $queue ); |
|
972 | + update_option(self::db_init_queue_option_name, $queue); |
|
973 | 973 | } |
974 | 974 | /** |
975 | 975 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -979,26 +979,26 @@ discard block |
||
979 | 979 | public function initialize_db_for_enqueued_ee_plugins() { |
980 | 980 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
981 | 981 | $queue = $this->get_db_initialization_queue(); |
982 | - foreach( $queue as $plugin_slug ) { |
|
983 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
984 | - if( ! $most_up_to_date_dms ) { |
|
982 | + foreach ($queue as $plugin_slug) { |
|
983 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
984 | + if ( ! $most_up_to_date_dms) { |
|
985 | 985 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
986 | 986 | $verify_db = false; |
987 | - }else{ |
|
988 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
989 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
987 | + } else { |
|
988 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
989 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
990 | 990 | } |
991 | - if( $plugin_slug == 'Core' ){ |
|
991 | + if ($plugin_slug == 'Core') { |
|
992 | 992 | EE_System::instance()->initialize_db_if_no_migrations_required( |
993 | 993 | false, |
994 | 994 | $verify_db |
995 | 995 | ); |
996 | - }else{ |
|
996 | + } else { |
|
997 | 997 | //just loop through the addons to make sure their database is setup |
998 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
999 | - if( $addon->name() == $plugin_slug ) { |
|
998 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
999 | + if ($addon->name() == $plugin_slug) { |
|
1000 | 1000 | |
1001 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
1001 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
1002 | 1002 | break; |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | // EEH_Debug_Tools::instance()->show_times(); |
1009 | 1009 | //because we just initialized the DBs for the enqueued ee plugins |
1010 | 1010 | //we don't need to keep remembering which ones needed to be initialized |
1011 | - delete_option( self::db_init_queue_option_name ); |
|
1011 | + delete_option(self::db_init_queue_option_name); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * 'Core', or the return value of EE_Addon::name() for an addon |
1018 | 1018 | * @return array |
1019 | 1019 | */ |
1020 | - public function get_db_initialization_queue(){ |
|
1021 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
1020 | + public function get_db_initialization_queue() { |
|
1021 | + return get_option(self::db_init_queue_option_name, array()); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1027,13 +1027,13 @@ discard block |
||
1027 | 1027 | * @throws \EE_Error |
1028 | 1028 | */ |
1029 | 1029 | protected function _get_table_analysis() { |
1030 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
1030 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
1031 | 1031 | return $this->_table_analysis; |
1032 | 1032 | } else { |
1033 | 1033 | throw new \EE_Error( |
1034 | 1034 | sprintf( |
1035 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | - get_class( $this ) |
|
1035 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | + get_class($this) |
|
1037 | 1037 | ) |
1038 | 1038 | ); |
1039 | 1039 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | * @throws \EE_Error |
1046 | 1046 | */ |
1047 | 1047 | protected function _get_table_manager() { |
1048 | - if( $this->_table_manager instanceof TableManager ) { |
|
1048 | + if ($this->_table_manager instanceof TableManager) { |
|
1049 | 1049 | return $this->_table_manager; |
1050 | 1050 | } else { |
1051 | 1051 | throw new \EE_Error( |
1052 | 1052 | sprintf( |
1053 | - __( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | - get_class( $this ) |
|
1053 | + __('Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | + get_class($this) |
|
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | -abstract class EE_Data_Migration_Class_Base{ |
|
23 | +abstract class EE_Data_Migration_Class_Base { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var $records_to_migrate int count of all that have been migrated |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param TableManager $table_manager |
73 | 73 | * @param TableAnalysis $table_analysis |
74 | 74 | */ |
75 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ){ |
|
75 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
76 | 76 | $this->_table_manager = $table_manager; |
77 | 77 | $this->_table_analysis = $table_analysis; |
78 | 78 | $this->set_status(EE_Data_Migration_Manager::status_continue); |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @throws EE_Error |
86 | 86 | * @return string |
87 | 87 | */ |
88 | - public function pretty_name(){ |
|
89 | - if($this->_pretty_name === null){ |
|
90 | - throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"),get_class($this))); |
|
88 | + public function pretty_name() { |
|
89 | + if ($this->_pretty_name === null) { |
|
90 | + throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"), get_class($this))); |
|
91 | 91 | } |
92 | 92 | return $this->_pretty_name; |
93 | 93 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return int |
97 | 97 | */ |
98 | - public function count_records_to_migrate(){ |
|
99 | - if( $this->_records_to_migrate == null){ |
|
98 | + public function count_records_to_migrate() { |
|
99 | + if ($this->_records_to_migrate == null) { |
|
100 | 100 | $this->_records_to_migrate = $this->_count_records_to_migrate(); |
101 | 101 | } |
102 | 102 | return $this->_records_to_migrate; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @return string one of EE_Data_Migration_Manager::status_* constants |
117 | 117 | * @throws EE_Error |
118 | 118 | */ |
119 | - public function get_status(){ |
|
120 | - if($this->_status === null){ |
|
121 | - throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"),get_class($this))); |
|
119 | + public function get_status() { |
|
120 | + if ($this->_status === null) { |
|
121 | + throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"), get_class($this))); |
|
122 | 122 | } |
123 | 123 | return $this->_status; |
124 | 124 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string $status |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - protected function set_status($status){ |
|
130 | + protected function set_status($status) { |
|
131 | 131 | $this->_status = $status; |
132 | 132 | } |
133 | 133 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * Returns the last error that occurred. If none occurred, returns null |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public function get_last_error(){ |
|
142 | + public function get_last_error() { |
|
143 | 143 | $errors = $this->get_errors(); |
144 | - if($errors){ |
|
144 | + if ($errors) { |
|
145 | 145 | return end($errors); |
146 | - }else{ |
|
146 | + } else { |
|
147 | 147 | return null; |
148 | 148 | } |
149 | 149 | } |
@@ -152,26 +152,26 @@ discard block |
||
152 | 152 | * @param string $error a string describing the error that will be useful for debugging. Consider including all the data that led to the error, and a stack trace etc. |
153 | 153 | * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are already at their limit, we will purposefully forget the first half |
154 | 154 | */ |
155 | - public function add_error($error, $force = FALSE ){ |
|
156 | - if( ! defined( 'EE_DMS_ERROR_LIMIT' ) ){ |
|
155 | + public function add_error($error, $force = FALSE) { |
|
156 | + if ( ! defined('EE_DMS_ERROR_LIMIT')) { |
|
157 | 157 | $limit = 50; |
158 | - }else{ |
|
158 | + } else { |
|
159 | 159 | $limit = EE_DMS_ERROR_LIMIT; |
160 | 160 | } |
161 | 161 | //make sure errors is an array, see ticket #8261 |
162 | - if( is_string( $this->_errors ) ){ |
|
163 | - $this->_errors = array( $this->_errors ); |
|
162 | + if (is_string($this->_errors)) { |
|
163 | + $this->_errors = array($this->_errors); |
|
164 | 164 | } |
165 | - if(count($this->_errors) >= $limit ){ |
|
166 | - if( $force ){ |
|
165 | + if (count($this->_errors) >= $limit) { |
|
166 | + if ($force) { |
|
167 | 167 | //get rid of the first half of the errors and any above the limit |
168 | - $this->_errors = array_slice( $this->_errors, $limit / 2, $limit / 2 ); |
|
168 | + $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
169 | 169 | $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
170 | 170 | $this->_errors[] = $error; |
171 | - }else{ |
|
172 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
171 | + } else { |
|
172 | + $this->_errors[$limit] = 'More, but limit reached...'; |
|
173 | 173 | } |
174 | - }else{ |
|
174 | + } else { |
|
175 | 175 | $this->_errors[] = $error; |
176 | 176 | } |
177 | 177 | } |
@@ -180,57 +180,57 @@ discard block |
||
180 | 180 | * Indicates there was a fatal error and the migration cannot possibly continue |
181 | 181 | * @return boolean |
182 | 182 | */ |
183 | - public function is_broken(){ |
|
183 | + public function is_broken() { |
|
184 | 184 | return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
185 | 185 | } |
186 | 186 | /** |
187 | 187 | * @deprecated since 4.6.12 |
188 | 188 | */ |
189 | - public function is_borked(){ |
|
190 | - EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12'); |
|
189 | + public function is_borked() { |
|
190 | + EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12'); |
|
191 | 191 | return $this->is_broken(); |
192 | 192 | } |
193 | 193 | /** |
194 | 194 | * Sets the status to as having a fatal error |
195 | 195 | */ |
196 | - public function set_broken(){ |
|
196 | + public function set_broken() { |
|
197 | 197 | $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
198 | 198 | } |
199 | 199 | /** |
200 | 200 | * |
201 | 201 | * @deprecated since 4.6.12 |
202 | 202 | */ |
203 | - public function set_borked(){ |
|
204 | - EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12'); |
|
203 | + public function set_borked() { |
|
204 | + EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12'); |
|
205 | 205 | return $this->set_broken(); |
206 | 206 | } |
207 | 207 | /** |
208 | 208 | * Checks if this thing believes it is completed |
209 | 209 | * @return boolean |
210 | 210 | */ |
211 | - public function is_completed(){ |
|
211 | + public function is_completed() { |
|
212 | 212 | return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
216 | 216 | * @return boolean |
217 | 217 | */ |
218 | - public function has_more_to_do(){ |
|
218 | + public function has_more_to_do() { |
|
219 | 219 | return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
220 | 220 | } |
221 | 221 | /** |
222 | 222 | * Marks that we believe this migration thing is completed |
223 | 223 | */ |
224 | - public function set_completed(){ |
|
224 | + public function set_completed() { |
|
225 | 225 | $this->_status = EE_Data_Migration_Manager::status_completed; |
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Marks that we think this migration class can continue to migrate |
230 | 230 | */ |
231 | - public function reattempt(){ |
|
231 | + public function reattempt() { |
|
232 | 232 | $this->_status = EE_Data_Migration_Manager::status_continue; |
233 | - $this->add_error( __( 'Reattempt migration', 'event_espresso' ), TRUE ); |
|
233 | + $this->add_error(__('Reattempt migration', 'event_espresso'), TRUE); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * possible that this class is defined when it goes to sleep, but NOT available when it |
240 | 240 | * awakes (eg, this class is part of an addon that is deactivated at some point). |
241 | 241 | */ |
242 | - public function properties_as_array(){ |
|
243 | - $properties = get_object_vars($this); |
|
242 | + public function properties_as_array() { |
|
243 | + $properties = get_object_vars($this); |
|
244 | 244 | $properties['class'] = get_class($this); |
245 | 245 | unset($properties['_migration_script']); |
246 | 246 | return $properties; |
@@ -261,22 +261,22 @@ discard block |
||
261 | 261 | * @param array $data_types numerically indexed |
262 | 262 | * @return string |
263 | 263 | */ |
264 | - protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types){ |
|
264 | + protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types) { |
|
265 | 265 | global $wpdb; |
266 | 266 | $old_columns_and_values_for_string = array(); |
267 | - foreach($old_row_as_array as $column => $value){ |
|
267 | + foreach ($old_row_as_array as $column => $value) { |
|
268 | 268 | $old_columns_and_values_for_string[] = "$column => $value"; |
269 | 269 | } |
270 | 270 | $new_columns_and_values_for_string = array(); |
271 | 271 | $count = 0; |
272 | - foreach($new_row_as_array as $column => $value){ |
|
272 | + foreach ($new_row_as_array as $column => $value) { |
|
273 | 273 | $new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")"; |
274 | 274 | } |
275 | 275 | return sprintf( |
276 | 276 | __('Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4%s.', "event_espresso"), |
277 | - implode(", ",$new_columns_and_values_for_string), |
|
277 | + implode(", ", $new_columns_and_values_for_string), |
|
278 | 278 | $new_table, |
279 | - implode(", ",$old_columns_and_values_for_string), |
|
279 | + implode(", ", $old_columns_and_values_for_string), |
|
280 | 280 | $old_table, |
281 | 281 | '<br/>', |
282 | 282 | $wpdb->last_error |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | * @param array $array_of_data |
292 | 292 | * @return string |
293 | 293 | */ |
294 | - protected function _json_encode($array_of_data){ |
|
294 | + protected function _json_encode($array_of_data) { |
|
295 | 295 | //we'd rather NOT serialize the transaction details |
296 | 296 | $fields_to_include = array(); |
297 | - foreach($array_of_data as $name => $value){ |
|
297 | + foreach ($array_of_data as $name => $value) { |
|
298 | 298 | $unserialized_data = @unserialize($value); |
299 | - if($unserialized_data === FALSE){ |
|
299 | + if ($unserialized_data === FALSE) { |
|
300 | 300 | $fields_to_include[$name] = $value; |
301 | 301 | } |
302 | 302 | } |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * @throws EE_Error |
310 | 310 | */ |
311 | 311 | protected function _get_table_manager() { |
312 | - if( $this->_table_manager instanceof TableManager ) { |
|
312 | + if ($this->_table_manager instanceof TableManager) { |
|
313 | 313 | return $this->_table_manager; |
314 | 314 | } else { |
315 | 315 | throw new EE_Error( |
316 | 316 | sprintf( |
317 | - __( 'Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
318 | - get_class( $this ) |
|
317 | + __('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
318 | + get_class($this) |
|
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | } |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * @throws EE_Error |
328 | 328 | */ |
329 | 329 | protected function _get_table_analysis() { |
330 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
330 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
331 | 331 | return $this->_table_analysis; |
332 | 332 | } else { |
333 | 333 | throw new EE_Error( |
334 | 334 | sprintf( |
335 | - __( 'Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
336 | - get_class( $this ) |
|
335 | + __('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
336 | + get_class($this) |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | } |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | // (all other times it gets resurrected from a wordpress option) |
18 | 18 | $stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*'); |
19 | 19 | $class_to_filepath = array(); |
20 | -foreach($stages as $filepath){ |
|
20 | +foreach ($stages as $filepath) { |
|
21 | 21 | $matches = array(); |
22 | - preg_match('~4_7_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
22 | + preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
23 | 23 | $class_to_filepath[$matches[1]] = $filepath; |
24 | 24 | } |
25 | 25 | //give addons a chance to autoload their stages too |
26 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages',$class_to_filepath); |
|
26 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath); |
|
27 | 27 | EEH_Autoloader::register_autoloader($class_to_filepath); |
28 | 28 | |
29 | 29 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @since 4.7.0 |
40 | 40 | * |
41 | 41 | */ |
42 | -class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{ |
|
42 | +class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base { |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * return EE_DMS_Core_4_7_0 |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso"); |
52 | 52 | $this->_priority = 10; |
53 | 53 | $this->_migration_stages = array( |
54 | 54 | new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
55 | 55 | new EE_DMS_4_7_0_Registration_Payments(), |
56 | 56 | ); |
57 | - parent::__construct( $table_manager, $table_analysis ); |
|
57 | + parent::__construct($table_manager, $table_analysis); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | public function can_migrate_from_version($version_array) { |
67 | 67 | $version_string = $version_array['Core']; |
68 | 68 | if ( |
69 | - ( $version_string <= '4.7.0' && $version_string >= '4.6.0' ) |
|
69 | + ($version_string <= '4.7.0' && $version_string >= '4.6.0') |
|
70 | 70 | || |
71 | - ( $version_string >= '4.7.0' && |
|
72 | - ! $this->_get_table_analysis()->tableExists( 'esp_registration_payment' ) && |
|
73 | - $this->_get_table_analysis()->tableExists( 'esp_registration' ) ) ) { |
|
71 | + ($version_string >= '4.7.0' && |
|
72 | + ! $this->_get_table_analysis()->tableExists('esp_registration_payment') && |
|
73 | + $this->_get_table_analysis()->tableExists('esp_registration')) ) { |
|
74 | 74 | return true; |
75 | - } elseif ( ! $version_string ) { |
|
75 | + } elseif ( ! $version_string) { |
|
76 | 76 | //no version string provided... this must be pre 4.3 |
77 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
78 | 78 | } else { |
79 | 79 | return false; |
80 | 80 | } |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function schema_changes_before_migration() { |
98 | 98 | //relies on 4.1's EEH_Activation::create_table |
99 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
100 | - $table_name='esp_answer'; |
|
101 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
99 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
100 | + $table_name = 'esp_answer'; |
|
101 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
102 | 102 | REG_ID INT UNSIGNED NOT NULL, |
103 | 103 | QST_ID INT UNSIGNED NOT NULL, |
104 | 104 | ANS_value TEXT NOT NULL, |
105 | 105 | PRIMARY KEY (ANS_ID), |
106 | 106 | KEY REG_ID (REG_ID), |
107 | 107 | KEY QST_ID (QST_ID)"; |
108 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
108 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
109 | 109 | |
110 | 110 | $table_name = 'esp_attendee_meta'; |
111 | 111 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | CNT_is_EU TINYINT(1) DEFAULT '0', |
146 | 146 | CNT_active TINYINT(1) DEFAULT '0', |
147 | 147 | PRIMARY KEY (CNT_ISO)"; |
148 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
148 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
149 | 149 | |
150 | 150 | $table_name = 'esp_currency'; |
151 | 151 | $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
156 | 156 | CUR_active TINYINT(1) DEFAULT '0', |
157 | 157 | PRIMARY KEY (CUR_code)"; |
158 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
158 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | 159 | |
160 | 160 | |
161 | 161 | $table_name = 'esp_currency_payment_method'; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | KEY EVT_ID (EVT_ID), |
186 | 186 | KEY DTT_is_primary (DTT_is_primary)"; |
187 | 187 | |
188 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
188 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
189 | 189 | |
190 | 190 | $table_name = 'esp_event_meta'; |
191 | 191 | $sql = " |
@@ -204,44 +204,44 @@ discard block |
||
204 | 204 | EVT_donations TINYINT(1) NULL, |
205 | 205 | PRIMARY KEY (EVTM_ID), |
206 | 206 | KEY EVT_ID (EVT_ID)"; |
207 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
207 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | |
211 | - $table_name='esp_event_question_group'; |
|
212 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
211 | + $table_name = 'esp_event_question_group'; |
|
212 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
214 | 214 | QSG_ID INT UNSIGNED NOT NULL, |
215 | 215 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
216 | 216 | PRIMARY KEY (EQG_ID), |
217 | 217 | KEY EVT_ID (EVT_ID), |
218 | 218 | KEY QSG_ID (QSG_ID)"; |
219 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
219 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | 220 | |
221 | 221 | |
222 | 222 | |
223 | - $table_name='esp_event_venue'; |
|
224 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $table_name = 'esp_event_venue'; |
|
224 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
225 | 225 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
226 | 226 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
227 | 227 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
228 | 228 | PRIMARY KEY (EVV_ID)"; |
229 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
229 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | |
233 | - $table_name='esp_extra_meta'; |
|
234 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
233 | + $table_name = 'esp_extra_meta'; |
|
234 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
235 | 235 | OBJ_ID INT(11) DEFAULT NULL, |
236 | 236 | EXM_type VARCHAR(45) DEFAULT NULL, |
237 | 237 | EXM_key VARCHAR(45) DEFAULT NULL, |
238 | 238 | EXM_value TEXT, |
239 | 239 | PRIMARY KEY (EXM_ID), |
240 | 240 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
241 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
241 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
242 | 242 | |
243 | - $table_name='esp_line_item'; |
|
244 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
243 | + $table_name = 'esp_line_item'; |
|
244 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
245 | 245 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
246 | 246 | TXN_ID INT(11) DEFAULT NULL, |
247 | 247 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | PRIMARY KEY (LIN_ID), |
260 | 260 | KEY LIN_code (LIN_code(191)), |
261 | 261 | KEY TXN_ID (TXN_ID)"; |
262 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
262 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
263 | 263 | |
264 | 264 | $table_name = 'esp_log'; |
265 | 265 | $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
300 | 300 | PRIMARY KEY (GRP_ID), |
301 | 301 | KEY MTP_user_id (MTP_user_id)"; |
302 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
303 | 303 | |
304 | 304 | $table_name = 'esp_event_message_template'; |
305 | 305 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | PRIMARY KEY (EMT_ID), |
309 | 309 | KEY EVT_ID (EVT_ID), |
310 | 310 | KEY GRP_ID (GRP_ID)"; |
311 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
311 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | 312 | |
313 | 313 | |
314 | 314 | $table_name = 'esp_payment'; |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | PRIMARY KEY (TTM_ID)"; |
382 | 382 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
383 | 383 | |
384 | - $table_name='esp_question'; |
|
385 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
384 | + $table_name = 'esp_question'; |
|
385 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
386 | 386 | QST_display_text TEXT NOT NULL, |
387 | 387 | QST_admin_label VARCHAR(255) NOT NULL, |
388 | 388 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -395,22 +395,22 @@ discard block |
||
395 | 395 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
396 | 396 | PRIMARY KEY (QST_ID), |
397 | 397 | KEY QST_order (QST_order)'; |
398 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
398 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
399 | 399 | |
400 | - $table_name='esp_question_group_question'; |
|
401 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
400 | + $table_name = 'esp_question_group_question'; |
|
401 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
402 | 402 | QSG_ID INT UNSIGNED NOT NULL, |
403 | 403 | QST_ID INT UNSIGNED NOT NULL, |
404 | 404 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
405 | 405 | PRIMARY KEY (QGQ_ID), |
406 | 406 | KEY QST_ID (QST_ID), |
407 | 407 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
408 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
408 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
409 | 409 | |
410 | 410 | |
411 | 411 | |
412 | - $table_name='esp_question_option'; |
|
413 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
412 | + $table_name = 'esp_question_option'; |
|
413 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSO_value VARCHAR(255) NOT NULL, |
415 | 415 | QSO_desc TEXT NOT NULL, |
416 | 416 | QST_ID INT UNSIGNED NOT NULL, |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | PRIMARY KEY (QSO_ID), |
420 | 420 | KEY QST_ID (QST_ID), |
421 | 421 | KEY QSO_order (QSO_order)"; |
422 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
422 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
423 | 423 | |
424 | 424 | |
425 | 425 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | |
466 | 466 | |
467 | 467 | |
468 | - $table_name='esp_checkin'; |
|
469 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
468 | + $table_name = 'esp_checkin'; |
|
469 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
470 | 470 | REG_ID INT(10) UNSIGNED NOT NULL, |
471 | 471 | DTT_ID INT(10) UNSIGNED NOT NULL, |
472 | 472 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
562 | 562 | PRIMARY KEY (PRC_ID), |
563 | 563 | KEY PRT_ID (PRT_ID)"; |
564 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
564 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
565 | 565 | |
566 | 566 | $table_name = "esp_price_type"; |
567 | 567 | $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
600 | 600 | PRIMARY KEY (TKT_ID), |
601 | 601 | KEY TKT_start_date (TKT_start_date)"; |
602 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
602 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
603 | 603 | |
604 | 604 | $table_name = 'esp_question_group'; |
605 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
605 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
606 | 606 | QSG_name VARCHAR(255) NOT NULL, |
607 | 607 | QSG_identifier VARCHAR(100) NOT NULL, |
608 | 608 | QSG_desc TEXT NULL, |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | PRIMARY KEY (QSG_ID), |
616 | 616 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
617 | 617 | KEY QSG_order (QSG_order)'; |
618 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
618 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
619 | 619 | |
620 | 620 | /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
621 | 621 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | return true; |
648 | 648 | } |
649 | 649 | |
650 | - public function migration_page_hooks(){ |
|
650 | + public function migration_page_hooks() { |
|
651 | 651 | |
652 | 652 | } |
653 | 653 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | 12 | $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | -if ( ! empty( $stages ) ) { |
|
15 | - foreach($stages as $filepath){ |
|
14 | +if ( ! empty($stages)) { |
|
15 | + foreach ($stages as $filepath) { |
|
16 | 16 | $matches = array(); |
17 | - preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
17 | + preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | 18 | $class_to_filepath[$matches[1]] = $filepath; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath); |
|
22 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath); |
|
23 | 23 | EEH_Autoloader::register_autoloader($class_to_filepath); |
24 | 24 | |
25 | 25 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * --a function named update_espresso_config() which saves the EE_Config object to the database |
38 | 38 | * --...and all its subclasses... really, you're best off copying the whole thing when 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...} |
39 | 39 | */ |
40 | -class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{ |
|
40 | +class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base { |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso"); |
52 | 52 | $this->_priority = 10; |
53 | 53 | $this->_migration_stages = array( |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | new EE_DMS_4_1_0_answers(), |
70 | 70 | new EE_DMS_4_1_0_checkins(), |
71 | 71 | ); |
72 | - parent::__construct( $table_manager, $table_analysis ); |
|
72 | + parent::__construct($table_manager, $table_analysis); |
|
73 | 73 | } |
74 | 74 | /** |
75 | 75 | * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | * @global wpdb $wpdb |
78 | 78 | * @return boolean |
79 | 79 | */ |
80 | - private function _checkin_table_exists(){ |
|
80 | + private function _checkin_table_exists() { |
|
81 | 81 | global $wpdb; |
82 | 82 | $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'"); |
83 | - if($results){ |
|
83 | + if ($results) { |
|
84 | 84 | return true; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | public function can_migrate_from_version($version_array) { |
91 | 91 | $version_string = $version_array['Core']; |
92 | - if($version_string < '4.0.0' && $version_string > '3.1.26' ){ |
|
92 | + if ($version_string < '4.0.0' && $version_string > '3.1.26') { |
|
93 | 93 | // echo "$version_string can be migrated fro"; |
94 | 94 | return true; |
95 | - }elseif( ! $version_string ){ |
|
95 | + }elseif ( ! $version_string) { |
|
96 | 96 | // echo "no version string provided: $version_string"; |
97 | 97 | //no version string provided... this must be pre 4.1 |
98 | 98 | //because since 4.1 we're |
99 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
100 | - }else{ |
|
99 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
100 | + } else { |
|
101 | 101 | // echo "$version_string doesnt apply"; |
102 | 102 | return false; |
103 | 103 | } |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | } |
108 | 108 | public function schema_changes_before_migration() { |
109 | 109 | //relies on 4.1's EEH_Activation::create_table |
110 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
110 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
111 | 111 | |
112 | - $table_name='esp_answer'; |
|
113 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
112 | + $table_name = 'esp_answer'; |
|
113 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
114 | 114 | REG_ID INT UNSIGNED NOT NULL, |
115 | 115 | QST_ID INT UNSIGNED NOT NULL, |
116 | 116 | ANS_value TEXT NOT NULL, |
117 | 117 | PRIMARY KEY (ANS_ID)"; |
118 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
118 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
119 | 119 | |
120 | 120 | $table_name = 'esp_attendee_meta'; |
121 | 121 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | CNT_is_EU TINYINT(1) DEFAULT '0', |
156 | 156 | CNT_active TINYINT(1) DEFAULT '0', |
157 | 157 | PRIMARY KEY (CNT_ISO)"; |
158 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
158 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | 159 | |
160 | 160 | |
161 | 161 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
179 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
180 | 180 | $table_name = 'esp_event_meta'; |
181 | 181 | $sql = " |
182 | 182 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -193,41 +193,41 @@ discard block |
||
193 | 193 | EVT_external_URL VARCHAR(200) NULL, |
194 | 194 | EVT_donations TINYINT(1) NULL, |
195 | 195 | PRIMARY KEY (EVTM_ID)"; |
196 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
196 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
197 | 197 | |
198 | 198 | |
199 | 199 | |
200 | - $table_name='esp_event_question_group'; |
|
201 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
200 | + $table_name = 'esp_event_question_group'; |
|
201 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
202 | 202 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
203 | 203 | QSG_ID INT UNSIGNED NOT NULL, |
204 | 204 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
205 | 205 | PRIMARY KEY (EQG_ID)"; |
206 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
206 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - $table_name='esp_event_venue'; |
|
211 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
210 | + $table_name = 'esp_event_venue'; |
|
211 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
212 | 212 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
213 | 213 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
214 | 214 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
215 | 215 | PRIMARY KEY (EVV_ID)"; |
216 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
216 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - $table_name='esp_extra_meta'; |
|
221 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
220 | + $table_name = 'esp_extra_meta'; |
|
221 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | OBJ_ID INT(11) DEFAULT NULL, |
223 | 223 | EXM_type VARCHAR(45) DEFAULT NULL, |
224 | 224 | EXM_key VARCHAR(45) DEFAULT NULL, |
225 | 225 | EXM_value TEXT, |
226 | 226 | PRIMARY KEY (EXM_ID)"; |
227 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
227 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | 228 | |
229 | - $table_name='esp_line_item'; |
|
230 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
229 | + $table_name = 'esp_line_item'; |
|
230 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
231 | 231 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
232 | 232 | TXN_ID INT(11) DEFAULT NULL, |
233 | 233 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | OBJ_ID INT(11) DEFAULT NULL, |
244 | 244 | OBJ_type VARCHAR(45)DEFAULT NULL, |
245 | 245 | PRIMARY KEY (LIN_ID)"; |
246 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
246 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | 247 | |
248 | 248 | $table_name = 'esp_message_template'; |
249 | 249 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | PRIMARY KEY (GRP_ID), |
271 | 271 | KEY EVT_ID (EVT_ID), |
272 | 272 | KEY MTP_user_id (MTP_user_id)"; |
273 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
273 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
274 | 274 | |
275 | 275 | |
276 | 276 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | |
379 | 379 | |
380 | 380 | |
381 | - $table_name='esp_question'; |
|
382 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
381 | + $table_name = 'esp_question'; |
|
382 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | 383 | QST_display_text TEXT NOT NULL, |
384 | 384 | QST_admin_label VARCHAR(255) NOT NULL, |
385 | 385 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | QST_wp_user BIGINT UNSIGNED NULL, |
392 | 392 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
393 | 393 | PRIMARY KEY (QST_ID)'; |
394 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
394 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
395 | 395 | |
396 | - $this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
396 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
397 | 397 | |
398 | 398 | $table_name = 'esp_question_group'; |
399 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
399 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
400 | 400 | QSG_name VARCHAR(255) NOT NULL, |
401 | 401 | QSG_identifier VARCHAR(100) NOT NULL, |
402 | 402 | QSG_desc TEXT NULL, |
@@ -407,27 +407,27 @@ discard block |
||
407 | 407 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
408 | 408 | PRIMARY KEY (QSG_ID), |
409 | 409 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
410 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
410 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | - $table_name='esp_question_group_question'; |
|
415 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
414 | + $table_name = 'esp_question_group_question'; |
|
415 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
416 | 416 | QSG_ID INT UNSIGNED NOT NULL, |
417 | 417 | QST_ID INT UNSIGNED NOT NULL, |
418 | 418 | PRIMARY KEY (QGQ_ID) "; |
419 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
419 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
420 | 420 | |
421 | 421 | |
422 | 422 | |
423 | - $table_name='esp_question_option'; |
|
424 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
423 | + $table_name = 'esp_question_option'; |
|
424 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
425 | 425 | QSO_value VARCHAR(255) NOT NULL, |
426 | 426 | QSO_desc TEXT NOT NULL, |
427 | 427 | QST_ID INT UNSIGNED NOT NULL, |
428 | 428 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
429 | 429 | PRIMARY KEY (QSO_ID)"; |
430 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
430 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
431 | 431 | |
432 | 432 | |
433 | 433 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | |
461 | 461 | |
462 | 462 | |
463 | - $table_name='esp_checkin'; |
|
464 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
463 | + $table_name = 'esp_checkin'; |
|
464 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
465 | 465 | REG_ID INT(10) UNSIGNED NOT NULL, |
466 | 466 | DTT_ID INT(10) UNSIGNED NOT NULL, |
467 | 467 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -568,12 +568,12 @@ discard block |
||
568 | 568 | |
569 | 569 | global $wpdb; |
570 | 570 | $state_table = $wpdb->prefix."esp_state"; |
571 | - if ( $this->_get_table_analysis()->tableExists( $state_table ) ) { |
|
571 | + if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
572 | 572 | |
573 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
573 | + $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table; |
|
574 | 574 | $states = $wpdb->get_var($SQL); |
575 | - if ( ! $states ) { |
|
576 | - $SQL = "INSERT INTO " . $state_table . " |
|
575 | + if ( ! $states) { |
|
576 | + $SQL = "INSERT INTO ".$state_table." |
|
577 | 577 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
578 | 578 | (1, 'US', 'AK', 'Alaska', 1), |
579 | 579 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | |
661 | 661 | global $wpdb; |
662 | 662 | $country_table = $wpdb->prefix."esp_country"; |
663 | - if ( $this->_get_table_analysis()->tableExists( $country_table ) ) { |
|
663 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
664 | 664 | |
665 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
665 | + $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table; |
|
666 | 666 | $countries = $wpdb->get_var($SQL); |
667 | - if ( ! $countries ) { |
|
668 | - $SQL = "INSERT INTO " . $country_table . " |
|
667 | + if ( ! $countries) { |
|
668 | + $SQL = "INSERT INTO ".$country_table." |
|
669 | 669 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
670 | 670 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
671 | 671 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -912,20 +912,20 @@ discard block |
||
912 | 912 | global $wpdb; |
913 | 913 | $price_type_table = $wpdb->prefix."esp_price_type"; |
914 | 914 | |
915 | - if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) { |
|
915 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
916 | 916 | |
917 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
918 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
917 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
918 | + $price_types_exist = $wpdb->get_var($SQL); |
|
919 | 919 | |
920 | - if ( ! $price_types_exist ) { |
|
920 | + if ( ! $price_types_exist) { |
|
921 | 921 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
922 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
|
923 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
|
924 | - (3, '" . __('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
|
925 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
|
926 | - (5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
|
927 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL ); |
|
928 | - $wpdb->query( $SQL ); |
|
922 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, 0), |
|
923 | + (2, '" . __('Percent Discount', 'event_espresso')."', 2, 1, 20, 0), |
|
924 | + (3, '" . __('Fixed Discount', 'event_espresso')."', 2, 0, 30, 0), |
|
925 | + (4, '" . __('Percent Surcharge', 'event_espresso')."', 3, 1, 40, 0), |
|
926 | + (5, '" . __('Fixed Surcharge', 'event_espresso')."', 3, 0, 50, 0);"; |
|
927 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
928 | + $wpdb->query($SQL); |
|
929 | 929 | } |
930 | 930 | } |
931 | 931 | } |
@@ -945,16 +945,16 @@ discard block |
||
945 | 945 | global $wpdb; |
946 | 946 | $price_table = $wpdb->prefix."esp_price"; |
947 | 947 | |
948 | - if ( $this->_get_table_analysis()->tableExists( $price_table ) ) { |
|
948 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
949 | 949 | |
950 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
951 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
950 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
951 | + $prices_exist = $wpdb->get_var($SQL); |
|
952 | 952 | |
953 | - if ( ! $prices_exist ) { |
|
953 | + if ( ! $prices_exist) { |
|
954 | 954 | $SQL = "INSERT INTO $price_table |
955 | 955 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
956 | 956 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);"; |
957 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL ); |
|
957 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
958 | 958 | $wpdb->query($SQL); |
959 | 959 | } |
960 | 960 | } |
@@ -971,34 +971,34 @@ discard block |
||
971 | 971 | |
972 | 972 | global $wpdb; |
973 | 973 | $ticket_table = $wpdb->prefix."esp_ticket"; |
974 | - if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) { |
|
974 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
975 | 975 | |
976 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
976 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
977 | 977 | $tickets_exist = $wpdb->get_var($SQL); |
978 | 978 | |
979 | - if ( ! $tickets_exist ) { |
|
979 | + if ( ! $tickets_exist) { |
|
980 | 980 | $SQL = "INSERT INTO $ticket_table |
981 | 981 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
982 | - ( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
983 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
982 | + ( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
983 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
984 | 984 | $wpdb->query($SQL); |
985 | 985 | } |
986 | 986 | } |
987 | 987 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
988 | 988 | |
989 | - if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) { |
|
989 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
990 | 990 | |
991 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
991 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
992 | 992 | $ticket_prc_exist = $wpdb->get_var($SQL); |
993 | 993 | |
994 | - if ( ! $ticket_prc_exist ) { |
|
994 | + if ( ! $ticket_prc_exist) { |
|
995 | 995 | |
996 | 996 | $SQL = "INSERT INTO $ticket_price_table |
997 | 997 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
998 | 998 | ( 1, 1, 1 ) |
999 | 999 | "; |
1000 | 1000 | |
1001 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
1001 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
1002 | 1002 | $wpdb->query($SQL); |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1011,20 +1011,20 @@ discard block |
||
1011 | 1011 | * @param string $country_name |
1012 | 1012 | * @return array where keys are columns, values are column values |
1013 | 1013 | */ |
1014 | - public function get_or_create_country($country_name){ |
|
1015 | - if( ! $country_name ){ |
|
1014 | + public function get_or_create_country($country_name) { |
|
1015 | + if ( ! $country_name) { |
|
1016 | 1016 | throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso")); |
1017 | 1017 | } |
1018 | 1018 | global $wpdb; |
1019 | 1019 | $country_table = $wpdb->prefix."esp_country"; |
1020 | - if(is_int($country_name)){ |
|
1020 | + if (is_int($country_name)) { |
|
1021 | 1021 | $country_name = $this->get_iso_from_3_1_country_id($country_name); |
1022 | 1022 | } |
1023 | 1023 | $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
1024 | 1024 | CNT_ISO LIKE %s OR |
1025 | 1025 | CNT_ISO3 LIKE %s OR |
1026 | - CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A); |
|
1027 | - if( ! $country ){ |
|
1026 | + CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
|
1027 | + if ( ! $country) { |
|
1028 | 1028 | //insert a new one then |
1029 | 1029 | $cols_n_values = array( |
1030 | 1030 | 'CNT_ISO'=> $this->_find_available_country_iso(2), |
@@ -1044,26 +1044,26 @@ discard block |
||
1044 | 1044 | 'CNT_active'=>true |
1045 | 1045 | ); |
1046 | 1046 | $data_types = array( |
1047 | - '%s',//CNT_ISO |
|
1048 | - '%s',//CNT_ISO3 |
|
1049 | - '%d',//RGN_ID |
|
1050 | - '%s',//CNT_name |
|
1051 | - '%s',//CNT_cur_code |
|
1052 | - '%s',//CNT_cur_single |
|
1053 | - '%s',//CNT_cur_plural |
|
1054 | - '%s',//CNT_cur_sign |
|
1055 | - '%d',//CNT_cur_sign_b4 |
|
1056 | - '%d',//CNT_cur_dec_plc |
|
1057 | - '%s',//CNT_cur_dec_mrk |
|
1058 | - '%s',//CNT_cur_thsnds |
|
1059 | - '%s',//CNT_tel_code |
|
1060 | - '%d',//CNT_is_EU |
|
1061 | - '%d',//CNT_active |
|
1047 | + '%s', //CNT_ISO |
|
1048 | + '%s', //CNT_ISO3 |
|
1049 | + '%d', //RGN_ID |
|
1050 | + '%s', //CNT_name |
|
1051 | + '%s', //CNT_cur_code |
|
1052 | + '%s', //CNT_cur_single |
|
1053 | + '%s', //CNT_cur_plural |
|
1054 | + '%s', //CNT_cur_sign |
|
1055 | + '%d', //CNT_cur_sign_b4 |
|
1056 | + '%d', //CNT_cur_dec_plc |
|
1057 | + '%s', //CNT_cur_dec_mrk |
|
1058 | + '%s', //CNT_cur_thsnds |
|
1059 | + '%s', //CNT_tel_code |
|
1060 | + '%d', //CNT_is_EU |
|
1061 | + '%d', //CNT_active |
|
1062 | 1062 | ); |
1063 | 1063 | $success = $wpdb->insert($country_table, |
1064 | 1064 | $cols_n_values, |
1065 | 1065 | $data_types); |
1066 | - if( ! $success){ |
|
1066 | + if ( ! $success) { |
|
1067 | 1067 | throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types)); |
1068 | 1068 | } |
1069 | 1069 | $country = $cols_n_values; |
@@ -1075,13 +1075,13 @@ discard block |
||
1075 | 1075 | * @global type $wpdb |
1076 | 1076 | * @return string |
1077 | 1077 | */ |
1078 | - private function _find_available_country_iso($num_letters = 2){ |
|
1078 | + private function _find_available_country_iso($num_letters = 2) { |
|
1079 | 1079 | global $wpdb; |
1080 | 1080 | $country_table = $wpdb->prefix."esp_country"; |
1081 | - do{ |
|
1081 | + do { |
|
1082 | 1082 | $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
1083 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso)); |
|
1084 | - }while(intval($country_with_that_iso)); |
|
1083 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso)); |
|
1084 | + }while (intval($country_with_that_iso)); |
|
1085 | 1085 | return $current_iso; |
1086 | 1086 | } |
1087 | 1087 | |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | * @param string $state_name |
1093 | 1093 | * @return array where keys are columns, values are column values |
1094 | 1094 | */ |
1095 | - public function get_or_create_state($state_name,$country_name = ''){ |
|
1096 | - if( ! $state_name ){ |
|
1095 | + public function get_or_create_state($state_name, $country_name = '') { |
|
1096 | + if ( ! $state_name) { |
|
1097 | 1097 | throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso")); |
1098 | 1098 | } |
1099 | - try{ |
|
1099 | + try { |
|
1100 | 1100 | $country = $this->get_or_create_country($country_name); |
1101 | 1101 | $country_iso = $country['CNT_ISO']; |
1102 | - }catch(EE_Error $e){ |
|
1102 | + } catch (EE_Error $e) { |
|
1103 | 1103 | $country_iso = $this->get_default_country_iso(); |
1104 | 1104 | } |
1105 | 1105 | global $wpdb; |
@@ -1107,24 +1107,24 @@ discard block |
||
1107 | 1107 | $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
1108 | 1108 | (STA_abbrev LIKE %s OR |
1109 | 1109 | STA_name LIKE %s) AND |
1110 | - CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A); |
|
1111 | - if ( ! $state){ |
|
1110 | + CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
|
1111 | + if ( ! $state) { |
|
1112 | 1112 | //insert a new one then |
1113 | 1113 | $cols_n_values = array( |
1114 | 1114 | 'CNT_ISO'=>$country_iso, |
1115 | - 'STA_abbrev'=>substr($state_name,0,6), |
|
1115 | + 'STA_abbrev'=>substr($state_name, 0, 6), |
|
1116 | 1116 | 'STA_name'=>$state_name, |
1117 | 1117 | 'STA_active'=>true |
1118 | 1118 | ); |
1119 | 1119 | $data_types = array( |
1120 | - '%s',//CNT_ISO |
|
1121 | - '%s',//STA_abbrev |
|
1122 | - '%s',//STA_name |
|
1123 | - '%d',//STA_active |
|
1120 | + '%s', //CNT_ISO |
|
1121 | + '%s', //STA_abbrev |
|
1122 | + '%s', //STA_name |
|
1123 | + '%d', //STA_active |
|
1124 | 1124 | ); |
1125 | - $success = $wpdb->insert($state_table,$cols_n_values,$data_types); |
|
1126 | - if ( ! $success ){ |
|
1127 | - throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1125 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1126 | + if ( ! $success) { |
|
1127 | + throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1128 | 1128 | } |
1129 | 1129 | $state = $cols_n_values; |
1130 | 1130 | $state['STA_ID'] = $wpdb->insert_id; |
@@ -1137,21 +1137,21 @@ discard block |
||
1137 | 1137 | * @param type $timeString |
1138 | 1138 | * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros) |
1139 | 1139 | */ |
1140 | - public function convertTimeFromAMPM($timeString){ |
|
1140 | + public function convertTimeFromAMPM($timeString) { |
|
1141 | 1141 | $matches = array(); |
1142 | - preg_match("~(\\d*):(\\d*)~",$timeString,$matches); |
|
1143 | - if( ! $matches || count($matches)<3){ |
|
1142 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1143 | + if ( ! $matches || count($matches) < 3) { |
|
1144 | 1144 | $hour = '00'; |
1145 | 1145 | $minutes = '00'; |
1146 | - }else{ |
|
1146 | + } else { |
|
1147 | 1147 | $hour = intval($matches[1]); |
1148 | 1148 | $minutes = $matches[2]; |
1149 | 1149 | } |
1150 | - if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){ |
|
1150 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1151 | 1151 | $hour = intval($hour) + 12; |
1152 | 1152 | } |
1153 | - $hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT); |
|
1154 | - $minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT); |
|
1153 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1154 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1155 | 1155 | return "$hour:$minutes"; |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | * @param int $country_id |
1161 | 1161 | * @return string the country's ISO3 code |
1162 | 1162 | */ |
1163 | - public function get_iso_from_3_1_country_id($country_id){ |
|
1163 | + public function get_iso_from_3_1_country_id($country_id) { |
|
1164 | 1164 | $old_countries = array( |
1165 | 1165 | array(64, 'United States', 'US', 'USA', 1), |
1166 | 1166 | array(15, 'Australia', 'AU', 'AUS', 1), |
@@ -1386,9 +1386,9 @@ discard block |
||
1386 | 1386 | array(226, 'Zimbabwe', 'ZW', 'ZWE', 1)); |
1387 | 1387 | |
1388 | 1388 | $country_iso = 'US'; |
1389 | - foreach($old_countries as $country_array){ |
|
1389 | + foreach ($old_countries as $country_array) { |
|
1390 | 1390 | //note: index 0 is the 3.1 country ID |
1391 | - if($country_array[0] == $country_id){ |
|
1391 | + if ($country_array[0] == $country_id) { |
|
1392 | 1392 | //note: index 2 is the ISO |
1393 | 1393 | $country_iso = $country_array[2]; |
1394 | 1394 | break; |
@@ -1401,8 +1401,8 @@ discard block |
||
1401 | 1401 | * Gets the ISO3 for the |
1402 | 1402 | * @return string |
1403 | 1403 | */ |
1404 | - public function get_default_country_iso(){ |
|
1405 | - $old_org_options= get_option('events_organization_settings'); |
|
1404 | + public function get_default_country_iso() { |
|
1405 | + $old_org_options = get_option('events_organization_settings'); |
|
1406 | 1406 | $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
1407 | 1407 | return $iso; |
1408 | 1408 | } |
@@ -1414,13 +1414,13 @@ discard block |
||
1414 | 1414 | * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval. |
1415 | 1415 | * @return string STS_ID for use in 4.1 |
1416 | 1416 | */ |
1417 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){ |
|
1417 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) { |
|
1418 | 1418 | |
1419 | 1419 | //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
1420 | - if($this_thing_required_pre_approval){ |
|
1420 | + if ($this_thing_required_pre_approval) { |
|
1421 | 1421 | return 'RNA'; |
1422 | - }else{ |
|
1423 | - $mapping = $default_reg_stati_conversions=array( |
|
1422 | + } else { |
|
1423 | + $mapping = $default_reg_stati_conversions = array( |
|
1424 | 1424 | 'Completed'=>'RAP', |
1425 | 1425 | ''=>'RPP', |
1426 | 1426 | 'Incomplete'=>'RPP', |
@@ -1450,22 +1450,22 @@ discard block |
||
1450 | 1450 | * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
1451 | 1451 | * @return boolean whether or not we had to do the big job of creating an image attachment |
1452 | 1452 | */ |
1453 | - public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1453 | + public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1454 | 1454 | $created_attachment_post = false; |
1455 | 1455 | $guid = $this->_get_original_guid($guid); |
1456 | - if($guid){ |
|
1456 | + if ($guid) { |
|
1457 | 1457 | //check for an existing attachment post with this guid |
1458 | 1458 | $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
1459 | - if( ! $attachment_post_id){ |
|
1459 | + if ( ! $attachment_post_id) { |
|
1460 | 1460 | //post thumbnail with that GUID doesn't exist, we should create one |
1461 | 1461 | $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
1462 | 1462 | $created_attachment_post = true; |
1463 | 1463 | } |
1464 | 1464 | //double-check we actually have an attachment post |
1465 | - if( $attachment_post_id){ |
|
1466 | - update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id); |
|
1467 | - }else{ |
|
1468 | - $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id)); |
|
1465 | + if ($attachment_post_id) { |
|
1466 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1467 | + } else { |
|
1468 | + $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id)); |
|
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | return $created_attachment_post; |
@@ -1479,13 +1479,13 @@ discard block |
||
1479 | 1479 | * @param string $guid_in_old_event |
1480 | 1480 | * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
1481 | 1481 | */ |
1482 | - private function _get_original_guid($guid_in_old_event){ |
|
1483 | - $original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1); |
|
1482 | + private function _get_original_guid($guid_in_old_event) { |
|
1483 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1484 | 1484 | //do a head request to verify the file exists |
1485 | 1485 | $head_response = wp_remote_head($original_guid); |
1486 | - if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){ |
|
1486 | + if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1487 | 1487 | return $original_guid; |
1488 | - }else{ |
|
1488 | + } else { |
|
1489 | 1489 | return $guid_in_old_event; |
1490 | 1490 | } |
1491 | 1491 | } |
@@ -1497,32 +1497,32 @@ discard block |
||
1497 | 1497 | * @param EE_Data_Migration_Script_Stage $migration_stage |
1498 | 1498 | * @return int |
1499 | 1499 | */ |
1500 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1501 | - if ( ! $guid){ |
|
1500 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1501 | + if ( ! $guid) { |
|
1502 | 1502 | $migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso"))); |
1503 | 1503 | return 0; |
1504 | 1504 | } |
1505 | - $wp_filetype = wp_check_filetype(basename($guid), null ); |
|
1505 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1506 | 1506 | $wp_upload_dir = wp_upload_dir(); |
1507 | 1507 | //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
1508 | - if(strpos($guid,$wp_upload_dir['url']) === FALSE){ |
|
1508 | + if (strpos($guid, $wp_upload_dir['url']) === FALSE) { |
|
1509 | 1509 | //image is located remotely. download it and place it in the uploads directory |
1510 | - if( ! is_readable($guid)){ |
|
1511 | - $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid)); |
|
1510 | + if ( ! is_readable($guid)) { |
|
1511 | + $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid)); |
|
1512 | 1512 | return 0; |
1513 | 1513 | } |
1514 | - $contents= file_get_contents($guid); |
|
1515 | - if($contents === FALSE){ |
|
1516 | - $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid)); |
|
1514 | + $contents = file_get_contents($guid); |
|
1515 | + if ($contents === FALSE) { |
|
1516 | + $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid)); |
|
1517 | 1517 | return false; |
1518 | 1518 | } |
1519 | - $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1519 | + $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1520 | 1520 | $savefile = fopen($local_filepath, 'w'); |
1521 | 1521 | fwrite($savefile, $contents); |
1522 | 1522 | fclose($savefile); |
1523 | - $guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath); |
|
1524 | - }else{ |
|
1525 | - $local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid); |
|
1523 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1524 | + } else { |
|
1525 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | $attachment = array( |
@@ -1532,24 +1532,24 @@ discard block |
||
1532 | 1532 | 'post_content' => '', |
1533 | 1533 | 'post_status' => 'inherit' |
1534 | 1534 | ); |
1535 | - $attach_id = wp_insert_attachment( $attachment, $guid ); |
|
1536 | - if( ! $attach_id ){ |
|
1537 | - $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment))); |
|
1535 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1536 | + if ( ! $attach_id) { |
|
1537 | + $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment))); |
|
1538 | 1538 | return $attach_id; |
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | // you must first include the image.php file |
1542 | 1542 | // for the function wp_generate_attachment_metadata() to work |
1543 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1543 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1544 | 1544 | |
1545 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath ); |
|
1546 | - if( ! $attach_data){ |
|
1547 | - $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid)); |
|
1545 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1546 | + if ( ! $attach_data) { |
|
1547 | + $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid)); |
|
1548 | 1548 | return $attach_id; |
1549 | 1549 | } |
1550 | - $metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
1551 | - if( ! $metadata_save_result ){ |
|
1552 | - $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data))); |
|
1550 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1551 | + if ( ! $metadata_save_result) { |
|
1552 | + $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data))); |
|
1553 | 1553 | } |
1554 | 1554 | return $attach_id; |
1555 | 1555 | } |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | * @param string $guid |
1562 | 1562 | * @return int |
1563 | 1563 | */ |
1564 | - private function _get_image_attachment_id_by_GUID($guid){ |
|
1564 | + private function _get_image_attachment_id_by_GUID($guid) { |
|
1565 | 1565 | global $wpdb; |
1566 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid)); |
|
1566 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1567 | 1567 | return $attachment_id; |
1568 | 1568 | } |
1569 | 1569 | /** |
@@ -1575,20 +1575,20 @@ discard block |
||
1575 | 1575 | * @param string $timezone |
1576 | 1576 | * @return string |
1577 | 1577 | */ |
1578 | - public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){ |
|
1578 | + public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) { |
|
1579 | 1579 | $original_tz = $timezone; |
1580 | - if( ! $timezone){ |
|
1580 | + if ( ! $timezone) { |
|
1581 | 1581 | $timezone = $this->_get_wp_timezone(); |
1582 | 1582 | } |
1583 | - if( ! $timezone){ |
|
1584 | - $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data)); |
|
1583 | + if ( ! $timezone) { |
|
1584 | + $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data)); |
|
1585 | 1585 | $timezone = 'UTC'; |
1586 | 1586 | } |
1587 | - try{ |
|
1588 | - $date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) ); |
|
1587 | + try { |
|
1588 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1589 | 1589 | $date_obj->setTimezone(new DateTimeZone('UTC')); |
1590 | - }catch(Exception $e){ |
|
1591 | - $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone)); |
|
1590 | + } catch (Exception $e) { |
|
1591 | + $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone)); |
|
1592 | 1592 | $date_obj = new DateTime(); |
1593 | 1593 | } |
1594 | 1594 | |
@@ -1599,14 +1599,14 @@ discard block |
||
1599 | 1599 | * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset) |
1600 | 1600 | * @return string |
1601 | 1601 | */ |
1602 | - private function _get_wp_timezone(){ |
|
1603 | - $timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone; |
|
1602 | + private function _get_wp_timezone() { |
|
1603 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1604 | 1604 | |
1605 | 1605 | //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
1606 | - if ( empty( $timezone ) ) { |
|
1606 | + if (empty($timezone)) { |
|
1607 | 1607 | //let's get a the WordPress UTC offset |
1608 | 1608 | $offset = get_option('gmt_offset'); |
1609 | - $timezone = $this->timezone_convert_to_string_from_offset( $offset ); |
|
1609 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1610 | 1610 | } |
1611 | 1611 | return $timezone; |
1612 | 1612 | } |
@@ -1615,11 +1615,11 @@ discard block |
||
1615 | 1615 | * @param int $offset |
1616 | 1616 | * @return boolean |
1617 | 1617 | */ |
1618 | - private function timezone_convert_to_string_from_offset($offset){ |
|
1618 | + private function timezone_convert_to_string_from_offset($offset) { |
|
1619 | 1619 | //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable |
1620 | 1620 | $offset *= 3600; // convert hour offset to seconds |
1621 | 1621 | $abbrarray = timezone_abbreviations_list(); |
1622 | - foreach ($abbrarray as $abbr){ |
|
1622 | + foreach ($abbrarray as $abbr) { |
|
1623 | 1623 | foreach ($abbr as $city) |
1624 | 1624 | { |
1625 | 1625 | if ($city['offset'] == $offset) |
@@ -1633,32 +1633,32 @@ discard block |
||
1633 | 1633 | return FALSE; |
1634 | 1634 | } |
1635 | 1635 | |
1636 | - public function migration_page_hooks(){ |
|
1637 | - add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1638 | - add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1639 | - add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1640 | - add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1641 | - add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3); |
|
1642 | - add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4); |
|
1643 | - add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1644 | - add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1645 | - add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table')); |
|
1646 | - add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1647 | - add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1636 | + public function migration_page_hooks() { |
|
1637 | + add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1638 | + add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1639 | + add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1640 | + add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1641 | + add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3); |
|
1642 | + add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4); |
|
1643 | + add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1644 | + add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1645 | + add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table')); |
|
1646 | + add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1647 | + add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | - public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){ |
|
1651 | - return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'), __("EE4", 'event_espresso')),$old_content); |
|
1650 | + public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) { |
|
1651 | + return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content); |
|
1652 | 1652 | } |
1653 | - public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){ |
|
1654 | - return str_replace($next_db_state, __("EE4", 'event_espresso'),$old_content); |
|
1653 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) { |
|
1654 | + return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content); |
|
1655 | 1655 | } |
1656 | - public function _migration_page_hook_option_1_extra_details(){ |
|
1657 | - ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php |
|
1656 | + public function _migration_page_hook_option_1_extra_details() { |
|
1657 | + ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php |
|
1658 | 1658 | } |
1659 | - public function _migration_page_hook_after_migration_options_table(){ |
|
1659 | + public function _migration_page_hook_after_migration_options_table() { |
|
1660 | 1660 | ?><p class="ee-attention"> |
1661 | - <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1661 | + <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1662 | 1662 | </p><?php |
1663 | 1663 | } |
1664 | 1664 | } |