@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function instance() { |
42 | 42 | // check if class object is instantiated |
43 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
43 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
44 | 44 | self::$_instance = new self(); |
45 | 45 | } |
46 | 46 | return self::$_instance; |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | // define global EE_Admin constants |
58 | 58 | $this->_define_all_constants(); |
59 | 59 | // set autoloaders for our admin page classes based on included path information |
60 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
60 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
61 | 61 | // admin hooks |
62 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
62 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
63 | 63 | // load EE_Request_Handler early |
64 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
65 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
64 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
65 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
66 | 66 | // post shortcode tracking |
67 | 67 | add_action( |
68 | 68 | 'AHEE__EE_System__initialize_last', |
69 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' ) |
|
69 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin') |
|
70 | 70 | ); |
71 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
72 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
73 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
74 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
75 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
76 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
77 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
78 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
71 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
72 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
73 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
74 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
75 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
76 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
77 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
78 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
79 | 79 | |
80 | 80 | //reset Environment config (we only do this on admin page loads); |
81 | 81 | EE_Registry::instance()->CFG->environment->recheck_values(); |
82 | 82 | |
83 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
83 | + do_action('AHEE__EE_Admin__loaded'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | private function _define_all_constants() { |
98 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
99 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
100 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
101 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
102 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
98 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
99 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
100 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
101 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
102 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | * @param string $plugin |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function filter_plugin_actions( $links, $plugin ) { |
|
115 | + public function filter_plugin_actions($links, $plugin) { |
|
116 | 116 | // set $main_file in stone |
117 | 117 | static $main_file; |
118 | 118 | // if $main_file is not set yet |
119 | - if ( ! $main_file ) { |
|
120 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
119 | + if ( ! $main_file) { |
|
120 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
121 | 121 | } |
122 | - if ( $plugin === $main_file ) { |
|
122 | + if ($plugin === $main_file) { |
|
123 | 123 | // compare current plugin to this one |
124 | - if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
125 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
126 | - array_unshift( $links, $maintenance_link ); |
|
124 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
125 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
126 | + array_unshift($links, $maintenance_link); |
|
127 | 127 | } else { |
128 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
129 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
128 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
129 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
130 | 130 | // add before other links |
131 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
131 | + array_unshift($links, $org_settings_link, $events_link); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | return $links; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function get_request() { |
146 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
147 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
146 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
147 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param array $admin_page_folder_names |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
159 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
160 | 160 | return array( |
161 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
162 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
163 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
161 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
162 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
163 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function init() { |
176 | 176 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
177 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
177 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
178 | 178 | //ok so we want to enable the entire admin |
179 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
180 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
181 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
179 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
180 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
181 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
182 | 182 | //at a glance dashboard widget |
183 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
183 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
184 | 184 | //filter for get_edit_post_link used on comments for custom post types |
185 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 ); |
|
185 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
186 | 186 | } |
187 | 187 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
188 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
188 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
189 | 189 | try { |
190 | 190 | //this loads the controller for the admin pages which will setup routing etc |
191 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
192 | - } catch ( EE_Error $e ) { |
|
191 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
192 | + } catch (EE_Error $e) { |
|
193 | 193 | $e->get_error(); |
194 | 194 | } |
195 | 195 | } |
196 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
196 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
197 | 197 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
198 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
199 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
198 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
199 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
200 | 200 | //exclude EE critical pages from all nav menus and wp_list_pages |
201 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
201 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * @param object $post_type WP post type object |
212 | 212 | * @return object WP post type object |
213 | 213 | */ |
214 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
214 | + public function remove_pages_from_nav_menu($post_type) { |
|
215 | 215 | //if this isn't the "pages" post type let's get out |
216 | - if ( $post_type->name !== 'page' ) { |
|
216 | + if ($post_type->name !== 'page') { |
|
217 | 217 | return $post_type; |
218 | 218 | } |
219 | 219 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -233,28 +233,28 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function enable_hidden_ee_nav_menu_metaboxes() { |
235 | 235 | global $wp_meta_boxes, $pagenow; |
236 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
236 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | $user = wp_get_current_user(); |
240 | 240 | //has this been done yet? |
241 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
241 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
246 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
245 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
246 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
247 | 247 | |
248 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
249 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
250 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
251 | - unset( $hidden_meta_boxes[ $key ] ); |
|
248 | + if (is_array($hidden_meta_boxes)) { |
|
249 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
250 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
251 | + unset($hidden_meta_boxes[$key]); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
257 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
256 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
257 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return void |
274 | 274 | */ |
275 | 275 | public function register_custom_nav_menu_boxes() { |
276 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
276 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return string the (maybe) modified link |
291 | 291 | */ |
292 | - public function modify_edit_post_link( $link, $id ) { |
|
293 | - if ( ! $post = get_post( $id ) ){ |
|
292 | + public function modify_edit_post_link($link, $id) { |
|
293 | + if ( ! $post = get_post($id)) { |
|
294 | 294 | return $link; |
295 | 295 | } |
296 | - if ( $post->post_type === 'espresso_attendees' ) { |
|
296 | + if ($post->post_type === 'espresso_attendees') { |
|
297 | 297 | $query_args = array( |
298 | 298 | 'action' => 'edit_attendee', |
299 | 299 | 'post' => $id |
300 | 300 | ); |
301 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
301 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
302 | 302 | } |
303 | 303 | return $link; |
304 | 304 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | global $nav_menu_selected_id; |
311 | 311 | |
312 | 312 | $db_fields = false; |
313 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
313 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
314 | 314 | $current_tab = 'event-archives'; |
315 | 315 | |
316 | 316 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | ?> |
330 | 330 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
331 | 331 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
332 | - <li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
333 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
332 | + <li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
333 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
335 | 335 | </a> |
336 | 336 | </li> |
337 | 337 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | <?php */ ?> |
350 | 350 | |
351 | 351 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
352 | - echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
352 | + echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
353 | 353 | ?>"> |
354 | 354 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
355 | 355 | <?php |
356 | 356 | $pages = $this->_get_extra_nav_menu_pages_items(); |
357 | 357 | $args['walker'] = $walker; |
358 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
358 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
359 | 359 | ?> |
360 | 360 | </ul> |
361 | 361 | </div><!-- /.tabs-panel --> |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | <p class="button-controls"> |
364 | 364 | <span class="list-controls"> |
365 | 365 | <a href="<?php |
366 | - echo esc_url( add_query_arg( |
|
366 | + echo esc_url(add_query_arg( |
|
367 | 367 | array( |
368 | 368 | 'extra-nav-menu-pages-tab' => 'event-archives', |
369 | 369 | 'selectall' => 1, |
370 | 370 | ), |
371 | - remove_query_arg( $removed_args ) |
|
371 | + remove_query_arg($removed_args) |
|
372 | 372 | )); |
373 | 373 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
374 | 374 | </span> |
375 | 375 | |
376 | 376 | <span class="add-to-menu"> |
377 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
377 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
378 | 378 | <span class="spinner"></span> |
379 | 379 | </span> |
380 | 380 | </p> |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | private function _get_extra_nav_menu_pages_items() { |
396 | 396 | $menuitems[] = array( |
397 | 397 | 'title' => __('Event List', 'event_espresso'), |
398 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
398 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
399 | 399 | 'description' => __('Archive page for all events.', 'event_espresso') |
400 | 400 | ); |
401 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
401 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param $menu_item_values |
411 | 411 | * @return stdClass |
412 | 412 | */ |
413 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
413 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
414 | 414 | $menu_item = new stdClass(); |
415 | 415 | $keys = array( |
416 | 416 | 'ID' => 0, |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | 'xfn' => '' |
431 | 431 | ); |
432 | 432 | |
433 | - foreach ( $keys as $key => $value) { |
|
434 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
433 | + foreach ($keys as $key => $value) { |
|
434 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
435 | 435 | } |
436 | 436 | return $menu_item; |
437 | 437 | } |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * - check if doing post processing of one of EE CPTs |
471 | 471 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
472 | 472 | */ |
473 | - if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) { |
|
474 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
475 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
473 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
474 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
475 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
482 | 482 | */ |
483 | 483 | global $pagenow; |
484 | - if ( $pagenow === 'options-reading.php' ) { |
|
485 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
484 | + if ($pagenow === 'options-reading.php') { |
|
485 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | } |
@@ -494,25 +494,25 @@ discard block |
||
494 | 494 | * @param string $output Current output. |
495 | 495 | * @return string |
496 | 496 | */ |
497 | - public function modify_dropdown_pages( $output ) { |
|
497 | + public function modify_dropdown_pages($output) { |
|
498 | 498 | //get critical pages |
499 | 499 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
500 | 500 | |
501 | 501 | //split current output by line break for easier parsing. |
502 | - $split_output = explode( "\n", $output ); |
|
502 | + $split_output = explode("\n", $output); |
|
503 | 503 | |
504 | 504 | //loop through to remove any critical pages from the array. |
505 | - foreach ( $critical_pages as $page_id ) { |
|
506 | - $needle = 'value="' . $page_id . '"'; |
|
507 | - foreach( $split_output as $key => $haystack ) { |
|
508 | - if( strpos( $haystack, $needle ) !== false ) { |
|
509 | - unset( $split_output[$key] ); |
|
505 | + foreach ($critical_pages as $page_id) { |
|
506 | + $needle = 'value="'.$page_id.'"'; |
|
507 | + foreach ($split_output as $key => $haystack) { |
|
508 | + if (strpos($haystack, $needle) !== false) { |
|
509 | + unset($split_output[$key]); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | //replace output with the new contents |
515 | - return implode( "\n", $split_output ); |
|
515 | + return implode("\n", $split_output); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -526,36 +526,36 @@ discard block |
||
526 | 526 | public function enqueue_admin_scripts() { |
527 | 527 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
528 | 528 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
529 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
529 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
530 | 530 | // register cookie script for future dependencies |
531 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
531 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
532 | 532 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
533 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
533 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
534 | 534 | // register jQuery Validate |
535 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
535 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
536 | 536 | } |
537 | 537 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
538 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
538 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
539 | 539 | //joyride style |
540 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
542 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
540 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
542 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
543 | 543 | //joyride JS |
544 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
544 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
545 | 545 | // wanna go for a joyride? |
546 | 546 | wp_enqueue_style('ee-joyride-css'); |
547 | 547 | wp_enqueue_script('jquery-joyride'); |
548 | 548 | } |
549 | 549 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
550 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
550 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
551 | 551 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
552 | 552 | } |
553 | 553 | //accounting.js library |
554 | 554 | // @link http://josscrowcroft.github.io/accounting.js/ |
555 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
556 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
557 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
558 | - wp_enqueue_script( 'ee-accounting' ); |
|
555 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
556 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
557 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
558 | + wp_enqueue_script('ee-accounting'); |
|
559 | 559 | // array of settings to get converted to JSON array via wp_localize_script |
560 | 560 | $currency_config = array( |
561 | 561 | 'currency' => array( |
@@ -602,11 +602,11 @@ discard block |
||
602 | 602 | public function get_persistent_admin_notices() { |
603 | 603 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
604 | 604 | $args = array( |
605 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
606 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
605 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
606 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
607 | 607 | ); |
608 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
609 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
608 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
609 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -627,26 +627,26 @@ discard block |
||
627 | 627 | * @param $elements |
628 | 628 | * @return array |
629 | 629 | */ |
630 | - public function dashboard_glance_items( $elements ) { |
|
630 | + public function dashboard_glance_items($elements) { |
|
631 | 631 | $events = EEM_Event::instance()->count(); |
632 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
633 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
632 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
633 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
634 | 634 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
635 | 635 | $registrations = EEM_Registration::instance()->count( |
636 | 636 | array( |
637 | 637 | array( |
638 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
638 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
639 | 639 | ) |
640 | 640 | ) |
641 | 641 | ); |
642 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
643 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
642 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
643 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
644 | 644 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
645 | 645 | |
646 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
646 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
647 | 647 | |
648 | - foreach ( $items as $type => $item_properties ) { |
|
649 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
648 | + foreach ($items as $type => $item_properties) { |
|
649 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
650 | 650 | } |
651 | 651 | return $elements; |
652 | 652 | } |
@@ -663,31 +663,31 @@ discard block |
||
663 | 663 | * @throws EE_Error |
664 | 664 | * @return string |
665 | 665 | */ |
666 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
666 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
667 | 667 | // check for date_format or time_format |
668 | - switch ( $option ) { |
|
668 | + switch ($option) { |
|
669 | 669 | case 'date_format' : |
670 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
670 | + $date_time_format = $value.' '.get_option('time_format'); |
|
671 | 671 | break; |
672 | 672 | case 'time_format' : |
673 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
673 | + $date_time_format = get_option('date_format').' '.$value; |
|
674 | 674 | break; |
675 | 675 | default : |
676 | 676 | $date_time_format = FALSE; |
677 | 677 | } |
678 | 678 | // do we have a date_time format to check ? |
679 | - if ( $date_time_format ) { |
|
680 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
679 | + if ($date_time_format) { |
|
680 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
681 | 681 | |
682 | - if ( is_array( $error_msg ) ) { |
|
683 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
682 | + if (is_array($error_msg)) { |
|
683 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
684 | 684 | |
685 | 685 | |
686 | - foreach ( $error_msg as $error ) { |
|
687 | - $msg .= '<li>' . $error . '</li>'; |
|
686 | + foreach ($error_msg as $error) { |
|
687 | + $msg .= '<li>'.$error.'</li>'; |
|
688 | 688 | } |
689 | 689 | |
690 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
690 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
691 | 691 | |
692 | 692 | // trigger WP settings error |
693 | 693 | add_settings_error( |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ); |
698 | 698 | |
699 | 699 | // set format to something valid |
700 | - switch ( $option ) { |
|
700 | + switch ($option) { |
|
701 | 701 | case 'date_format' : |
702 | 702 | $value = 'F j, Y'; |
703 | 703 | break; |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * @param $content |
720 | 720 | * @return string |
721 | 721 | */ |
722 | - public function its_eSpresso( $content ) { |
|
723 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
722 | + public function its_eSpresso($content) { |
|
723 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -733,9 +733,9 @@ discard block |
||
733 | 733 | */ |
734 | 734 | public function espresso_admin_footer() { |
735 | 735 | return sprintf( |
736 | - __( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ), |
|
736 | + __('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'), |
|
737 | 737 | '<a href="https://eventespresso.com/" title="', |
738 | - '">' . EVENT_ESPRESSO_POWERED_BY . '</a>' |
|
738 | + '">'.EVENT_ESPRESSO_POWERED_BY.'</a>' |
|
739 | 739 | ); |
740 | 740 | } |
741 | 741 | |
@@ -755,12 +755,12 @@ discard block |
||
755 | 755 | * @param array $config |
756 | 756 | * @return void |
757 | 757 | */ |
758 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
759 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
760 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
758 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
759 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
760 | + if (class_exists('EE_Register_Admin_Page')) { |
|
761 | 761 | $config['page_path'] = $page_path; |
762 | 762 | } |
763 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
763 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
764 | 764 | |
765 | 765 | } |
766 | 766 | |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * @param \WP_Post $post |
774 | 774 | * @return void |
775 | 775 | */ |
776 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
776 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
777 | 777 | EE_Error::doing_it_wrong( |
778 | 778 | __METHOD__, |
779 | 779 | __( |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | ), |
783 | 783 | '4.8.41' |
784 | 784 | ); |
785 | - EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $post_ID, $post ); |
|
785 | + EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($post_ID, $post); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @param $value |
796 | 796 | * @return void |
797 | 797 | */ |
798 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
798 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
799 | 799 | EE_Error::doing_it_wrong( |
800 | 800 | __METHOD__, |
801 | 801 | __( |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | ), |
805 | 805 | '4.8.41' |
806 | 806 | ); |
807 | - EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change( $option, $old_value, $value ); |
|
807 | + EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change($option, $old_value, $value); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate |
22 | 22 | * an error occurred which means the ajax script should probably stop executing. |
23 | 23 | */ |
24 | -class EE_Data_Migration_Manager{ |
|
24 | +class EE_Data_Migration_Manager { |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * of this EE installation. Keys should be the name of the version the script upgraded to |
79 | 79 | * @var EE_Data_Migration_Script_Base[] |
80 | 80 | */ |
81 | - private $_data_migrations_ran =null; |
|
81 | + private $_data_migrations_ran = null; |
|
82 | 82 | /** |
83 | 83 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
84 | 84 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public static function instance() { |
124 | 124 | // check if class object is instantiated |
125 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
125 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
126 | 126 | self::$_instance = new self(); |
127 | 127 | } |
128 | 128 | return self::$_instance; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
133 | 133 | * @return EE_Data_Migration_Manager |
134 | 134 | */ |
135 | - public static function reset(){ |
|
135 | + public static function reset() { |
|
136 | 136 | self::$_instance = NULL; |
137 | 137 | return self::instance(); |
138 | 138 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * constructor |
144 | 144 | */ |
145 | - private function __construct(){ |
|
145 | + private function __construct() { |
|
146 | 146 | $this->stati_that_indicate_to_continue_migrations = array( |
147 | 147 | self::status_continue, |
148 | 148 | self::status_completed |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | ); |
162 | 162 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
163 | 163 | //to be defined, because right now it doesn't get autoloaded on its own |
164 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
165 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
166 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
167 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
168 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
164 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
165 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
166 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
167 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
168 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -178,21 +178,21 @@ discard block |
||
178 | 178 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
179 | 179 | * @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') |
180 | 180 | */ |
181 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
181 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
182 | 182 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
183 | 183 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
184 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
184 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
185 | 185 | |
186 | - if(count($parts) == 4){ |
|
186 | + if (count($parts) == 4) { |
|
187 | 187 | //it's 4.2-style.eg Core.4.1.0 |
188 | - $plugin_slug = $parts[0];//eg Core |
|
188 | + $plugin_slug = $parts[0]; //eg Core |
|
189 | 189 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | //it's 4.1-style: eg 4.1.0 |
192 | 192 | $plugin_slug = 'Core'; |
193 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
193 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
194 | 194 | } |
195 | - return array($plugin_slug,$version_string); |
|
195 | + return array($plugin_slug, $version_string); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -203,21 +203,21 @@ discard block |
||
203 | 203 | * @return EE_Data_Migration_Script_Base |
204 | 204 | * @throws EE_Error |
205 | 205 | */ |
206 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
206 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
207 | 207 | $data_migration_data = maybe_unserialize($dms_option_value); |
208 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
208 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
209 | 209 | $class = new $data_migration_data['class']; |
210 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
210 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
211 | 211 | $class->instantiate_from_array_of_properties($data_migration_data); |
212 | 212 | return $class; |
213 | - }else{ |
|
213 | + } else { |
|
214 | 214 | //huh, so its an object but not a data migration script?? that shouldn't happen |
215 | 215 | //just leave it as an array (which will probably just get ignored) |
216 | - 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'])); |
|
216 | + 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'])); |
|
217 | 217 | } |
218 | - }else{ |
|
218 | + } else { |
|
219 | 219 | //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 |
220 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
220 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | /** |
@@ -225,34 +225,34 @@ discard block |
||
225 | 225 | * the last ran which hasn't finished yet |
226 | 226 | * @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) |
227 | 227 | */ |
228 | - public function get_data_migrations_ran(){ |
|
229 | - if( ! $this->_data_migrations_ran ){ |
|
228 | + public function get_data_migrations_ran() { |
|
229 | + if ( ! $this->_data_migrations_ran) { |
|
230 | 230 | //setup autoloaders for each of the scripts in there |
231 | 231 | $this->get_all_data_migration_scripts_available(); |
232 | - $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())); |
|
232 | + $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())); |
|
233 | 233 | |
234 | 234 | $data_migrations_ran = array(); |
235 | 235 | //convert into data migration script classes where possible |
236 | - foreach($data_migrations_options as $data_migration_option){ |
|
237 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
236 | + foreach ($data_migrations_options as $data_migration_option) { |
|
237 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
238 | 238 | |
239 | - try{ |
|
240 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
239 | + try { |
|
240 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
241 | 241 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
242 | 242 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
243 | 243 | $this->_last_ran_script = $class; |
244 | - if( ! $class->is_completed()){ |
|
244 | + if ( ! $class->is_completed()) { |
|
245 | 245 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
246 | 246 | $this->_last_ran_incomplete_script = $class; |
247 | 247 | } |
248 | - }catch(EE_Error $e){ |
|
248 | + } catch (EE_Error $e) { |
|
249 | 249 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
250 | 250 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
251 | 251 | } |
252 | 252 | } |
253 | 253 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
254 | 254 | $this->_data_migrations_ran = $data_migrations_ran; |
255 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
255 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
256 | 256 | $this->_data_migrations_ran = array(); |
257 | 257 | } |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param $new_table |
270 | 270 | * @return mixed string or int |
271 | 271 | */ |
272 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
272 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
273 | 273 | $script = EE_Registry::instance()->load_dms($script_name); |
274 | 274 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
275 | 275 | return $mapping; |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * option returned in this array is the most-recently ran DMS option |
281 | 281 | * @return array |
282 | 282 | */ |
283 | - public function get_all_migration_script_options(){ |
|
283 | + public function get_all_migration_script_options() { |
|
284 | 284 | global $wpdb; |
285 | - 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); |
|
285 | + 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); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
291 | 291 | * folder name. |
292 | 292 | */ |
293 | - public function get_data_migration_script_folders(){ |
|
294 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
293 | + public function get_data_migration_script_folders() { |
|
294 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | * } |
304 | 304 | * @throws EE_Error |
305 | 305 | */ |
306 | - public function script_migrates_to_version($migration_script_name){ |
|
306 | + public function script_migrates_to_version($migration_script_name) { |
|
307 | 307 | $dms_info = $this->parse_dms_classname($migration_script_name); |
308 | 308 | return array( |
309 | - 'slug'=> $dms_info[ 'slug' ], |
|
310 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
309 | + 'slug'=> $dms_info['slug'], |
|
310 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
317 | 317 | * @throws EE_Error |
318 | 318 | */ |
319 | - public function parse_dms_classname($classname){ |
|
319 | + public function parse_dms_classname($classname) { |
|
320 | 320 | $matches = array(); |
321 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
322 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
323 | - 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)); |
|
321 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
322 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
323 | + 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)); |
|
324 | 324 | } |
325 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
325 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
326 | 326 | } |
327 | 327 | /** |
328 | 328 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -331,33 +331,33 @@ discard block |
||
331 | 331 | * to 4.1.x. |
332 | 332 | * @return string of current db state |
333 | 333 | */ |
334 | - public function ensure_current_database_state_is_set(){ |
|
335 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
334 | + public function ensure_current_database_state_is_set() { |
|
335 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
336 | 336 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
337 | - if( ! $db_state ){ |
|
337 | + if ( ! $db_state) { |
|
338 | 338 | //mark the DB as being in the state as the last version in there. |
339 | 339 | //this is done to trigger maintenance mode and do data migration scripts |
340 | 340 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
341 | 341 | //otherwise, the normal maintenance mode code is fine |
342 | 342 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
343 | 343 | $previous_version_installed = end($previous_versions_installed); |
344 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
344 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
345 | 345 | //last installed version was less than 4.1 |
346 | 346 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
347 | 347 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
348 | 348 | $db_state = array('Core'=>$previous_version_installed); |
349 | - }else{ |
|
349 | + } else { |
|
350 | 350 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
351 | 351 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
352 | 352 | } |
353 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
353 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
354 | 354 | } |
355 | 355 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
356 | 356 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
357 | 357 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
358 | - if( ! is_array($db_state)){ |
|
358 | + if ( ! is_array($db_state)) { |
|
359 | 359 | $db_state = array('Core'=>$db_state); |
360 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
360 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
361 | 361 | } |
362 | 362 | return $db_state; |
363 | 363 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * or they don't apply), returns an empty array |
369 | 369 | * @return EE_Data_Migration_Script_Base[] |
370 | 370 | */ |
371 | - public function check_for_applicable_data_migration_scripts(){ |
|
371 | + public function check_for_applicable_data_migration_scripts() { |
|
372 | 372 | //get the option describing what options have already run |
373 | 373 | $scripts_ran = $this->get_data_migrations_ran(); |
374 | 374 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -381,62 +381,62 @@ discard block |
||
381 | 381 | $iteration = 0; |
382 | 382 | $next_database_state_to_consider = $current_database_state; |
383 | 383 | $theoretical_database_state = NULL; |
384 | - do{ |
|
384 | + do { |
|
385 | 385 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
386 | 386 | $theoretical_database_state = $next_database_state_to_consider; |
387 | 387 | //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?) |
388 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
388 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
389 | 389 | |
390 | 390 | $migrates_to_version = $this->script_migrates_to_version($classname); |
391 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
392 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
391 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
392 | + $script_converts_to_version = $migrates_to_version['version']; |
|
393 | 393 | //check if this version script is DONE or not; or if it's never been ran |
394 | - if( ! $scripts_ran || |
|
394 | + if ( ! $scripts_ran || |
|
395 | 395 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
396 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
396 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
397 | 397 | //we haven't ran this conversion script before |
398 | 398 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
399 | 399 | $script = new $classname; |
400 | 400 | /* @var $script EE_Data_Migration_Script_Base */ |
401 | 401 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
402 | - if($can_migrate){ |
|
402 | + if ($can_migrate) { |
|
403 | 403 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
404 | 404 | $migrates_to_version = $script->migrates_to_version(); |
405 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
405 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
406 | 406 | unset($script_class_and_filepaths_available[$classname]); |
407 | 407 | } |
408 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
408 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
409 | 409 | //this script has been ran, or at least started |
410 | 410 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
411 | - if( $script->get_status() != self::status_completed){ |
|
411 | + if ($script->get_status() != self::status_completed) { |
|
412 | 412 | //this script is already underway... keep going with it |
413 | 413 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
414 | 414 | $migrates_to_version = $script->migrates_to_version(); |
415 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
415 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
416 | 416 | unset($script_class_and_filepaths_available[$classname]); |
417 | - }else{ |
|
417 | + } else { |
|
418 | 418 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
419 | 419 | } |
420 | - }else{ |
|
420 | + } else { |
|
421 | 421 | //it exists but it's not a proper data migration script |
422 | 422 | //maybe the script got renamed? or was simply removed from EE? |
423 | 423 | //either way, its certainly not runnable! |
424 | 424 | } |
425 | 425 | } |
426 | 426 | $iteration++; |
427 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
427 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
428 | 428 | //ok we have all the scripts that should run, now let's make them into flat array |
429 | 429 | $scripts_that_should_run = array(); |
430 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
430 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
431 | 431 | ksort($scripts_at_priority); |
432 | - foreach($scripts_at_priority as $scripts){ |
|
433 | - foreach($scripts as $script){ |
|
432 | + foreach ($scripts_at_priority as $scripts) { |
|
433 | + foreach ($scripts as $script) { |
|
434 | 434 | $scripts_that_should_run[get_class($script)] = $script; |
435 | 435 | } |
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
439 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
439 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
440 | 440 | return $scripts_that_should_run; |
441 | 441 | } |
442 | 442 | |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | * @param bool $include_completed_scripts |
451 | 451 | * @return EE_Data_Migration_Script_Base |
452 | 452 | */ |
453 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
453 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
454 | 454 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
455 | - if( ! $this->_data_migrations_ran){ |
|
455 | + if ( ! $this->_data_migrations_ran) { |
|
456 | 456 | $this->get_data_migrations_ran(); |
457 | 457 | } |
458 | - if($include_completed_scripts){ |
|
458 | + if ($include_completed_scripts) { |
|
459 | 459 | return $this->_last_ran_script; |
460 | - }else{ |
|
460 | + } else { |
|
461 | 461 | return $this->_last_ran_incomplete_script; |
462 | 462 | } |
463 | 463 | } |
@@ -480,19 +480,19 @@ discard block |
||
480 | 480 | * @type string $message string describing what was done during this step |
481 | 481 | * } |
482 | 482 | */ |
483 | - public function migration_step( $step_size = 0 ){ |
|
483 | + public function migration_step($step_size = 0) { |
|
484 | 484 | |
485 | 485 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
486 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
487 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
486 | + if (class_exists('EE_CPT_Strategy')) { |
|
487 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
488 | 488 | } |
489 | 489 | |
490 | - try{ |
|
490 | + try { |
|
491 | 491 | $currently_executing_script = $this->get_last_ran_script(); |
492 | - if( ! $currently_executing_script){ |
|
492 | + if ( ! $currently_executing_script) { |
|
493 | 493 | //Find the next script that needs to execute |
494 | 494 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
495 | - if( ! $scripts ){ |
|
495 | + if ( ! $scripts) { |
|
496 | 496 | //huh, no more scripts to run... apparently we're done! |
497 | 497 | //but dont forget to make sure initial data is there |
498 | 498 | //we should be good to allow them to exit maintenance mode now |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | //and add to the array/wp option showing the scripts ran |
514 | 514 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
515 | 515 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
516 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
517 | - $version = $migrates_to[ 'version' ]; |
|
516 | + $plugin_slug = $migrates_to['slug']; |
|
517 | + $version = $migrates_to['version']; |
|
518 | 518 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
519 | 519 | } |
520 | 520 | $current_script_name = get_class($currently_executing_script); |
521 | - }catch(Exception $e){ |
|
521 | + } catch (Exception $e) { |
|
522 | 522 | //an exception occurred while trying to get migration scripts |
523 | 523 | |
524 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
524 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
525 | 525 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
526 | 526 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
527 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
527 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
528 | 528 | return array( |
529 | 529 | 'records_to_migrate'=>1, |
530 | 530 | 'records_migrated'=>0, |
@@ -534,16 +534,16 @@ discard block |
||
534 | 534 | ); |
535 | 535 | } |
536 | 536 | //ok so we definitely have a data migration script |
537 | - try{ |
|
537 | + try { |
|
538 | 538 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
539 | - if( ! absint( $step_size ) > 0 ){ |
|
540 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
539 | + if ( ! absint($step_size) > 0) { |
|
540 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
541 | 541 | } |
542 | 542 | //do what we came to do! |
543 | 543 | $currently_executing_script->migration_step($step_size); |
544 | 544 | //can we wrap it up and verify default data? |
545 | 545 | $init_dbs = false; |
546 | - switch($currently_executing_script->get_status()){ |
|
546 | + switch ($currently_executing_script->get_status()) { |
|
547 | 547 | case EE_Data_Migration_Manager::status_continue: |
548 | 548 | $response_array = array( |
549 | 549 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | case EE_Data_Migration_Manager::status_completed: |
556 | 556 | //ok so THAT script has completed |
557 | 557 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
558 | - $response_array = array( |
|
558 | + $response_array = array( |
|
559 | 559 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
560 | 560 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
561 | 561 | 'status'=> EE_Data_Migration_Manager::status_completed, |
562 | 562 | 'message'=>$currently_executing_script->get_feedback_message(), |
563 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
563 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
564 | 564 | ); |
565 | 565 | //check if there are any more after this one. |
566 | 566 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
567 | - if( ! $scripts_remaining ){ |
|
567 | + if ( ! $scripts_remaining) { |
|
568 | 568 | //we should be good to allow them to exit maintenance mode now |
569 | 569 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
570 | 570 | ////huh, no more scripts to run... apparently we're done! |
@@ -578,39 +578,39 @@ discard block |
||
578 | 578 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
579 | 579 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
580 | 580 | 'status'=> $currently_executing_script->get_status(), |
581 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
581 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
582 | 582 | 'script'=>$currently_executing_script->pretty_name() |
583 | 583 | ); |
584 | 584 | break; |
585 | 585 | } |
586 | - }catch(Exception $e){ |
|
586 | + } catch (Exception $e) { |
|
587 | 587 | //ok so some exception was thrown which killed the data migration script |
588 | 588 | //double-check we have a real script |
589 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
589 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
590 | 590 | $script_name = $currently_executing_script->pretty_name(); |
591 | 591 | $currently_executing_script->set_broken(); |
592 | 592 | $currently_executing_script->add_error($e->getMessage()); |
593 | - }else{ |
|
593 | + } else { |
|
594 | 594 | $script_name = __("Error getting Migration Script", "event_espresso"); |
595 | 595 | } |
596 | 596 | $response_array = array( |
597 | 597 | 'records_to_migrate'=>1, |
598 | 598 | 'records_migrated'=>0, |
599 | 599 | 'status'=>self::status_fatal_error, |
600 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
600 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
601 | 601 | 'script'=>$script_name |
602 | 602 | ); |
603 | 603 | } |
604 | 604 | $successful_save = $this->_save_migrations_ran(); |
605 | - if($successful_save !== TRUE){ |
|
605 | + if ($successful_save !== TRUE) { |
|
606 | 606 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
607 | 607 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
608 | 608 | //however, if we throw an exception, and return that, then the next request |
609 | 609 | //won't have as much info in it, and it may be able to save |
610 | - 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)); |
|
610 | + 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)); |
|
611 | 611 | } |
612 | 612 | //if we're all done, initialize EE plugins' default data etc. |
613 | - if( $init_dbs ) { |
|
613 | + if ($init_dbs) { |
|
614 | 614 | $this->initialize_db_for_enqueued_ee_plugins(); |
615 | 615 | } |
616 | 616 | return $response_array; |
@@ -628,23 +628,23 @@ discard block |
||
628 | 628 | * '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 |
629 | 629 | * 'script'=>a pretty name of the script currently running |
630 | 630 | */ |
631 | - public function response_to_migration_ajax_request(){ |
|
631 | + public function response_to_migration_ajax_request() { |
|
632 | 632 | // //start output buffer just to make sure we don't mess up the json |
633 | 633 | ob_start(); |
634 | - try{ |
|
634 | + try { |
|
635 | 635 | $response = $this->migration_step(); |
636 | - }catch(Exception $e){ |
|
636 | + } catch (Exception $e) { |
|
637 | 637 | $response = array( |
638 | 638 | 'records_to_migrate'=>0, |
639 | 639 | 'records_migrated'=>0, |
640 | 640 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
641 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
641 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
642 | 642 | 'script'=>'Unknown'); |
643 | 643 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
644 | 644 | } |
645 | 645 | $warnings_etc = @ob_get_contents(); |
646 | 646 | ob_end_clean(); |
647 | - $response['message'] .=$warnings_etc; |
|
647 | + $response['message'] .= $warnings_etc; |
|
648 | 648 | return $response; |
649 | 649 | } |
650 | 650 | |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | * } |
658 | 658 | * @return void |
659 | 659 | */ |
660 | - public function update_current_database_state_to($slug_and_version = null){ |
|
661 | - if( ! $slug_and_version ){ |
|
660 | + public function update_current_database_state_to($slug_and_version = null) { |
|
661 | + if ( ! $slug_and_version) { |
|
662 | 662 | //no version was provided, assume it should be at the current code version |
663 | 663 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
664 | 664 | } |
665 | 665 | $current_database_state = get_option(self::current_database_state); |
666 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
667 | - update_option(self::current_database_state,$current_database_state); |
|
666 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
667 | + update_option(self::current_database_state, $current_database_state); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -675,20 +675,20 @@ discard block |
||
675 | 675 | * } |
676 | 676 | * @return boolean |
677 | 677 | */ |
678 | - public function database_needs_updating_to( $slug_and_version ) { |
|
678 | + public function database_needs_updating_to($slug_and_version) { |
|
679 | 679 | |
680 | - $slug = $slug_and_version[ 'slug' ]; |
|
681 | - $version = $slug_and_version[ 'version' ]; |
|
680 | + $slug = $slug_and_version['slug']; |
|
681 | + $version = $slug_and_version['version']; |
|
682 | 682 | $current_database_state = get_option(self::current_database_state); |
683 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
683 | + if ( ! isset($current_database_state[$slug])) { |
|
684 | 684 | return true; |
685 | - }else{ |
|
685 | + } else { |
|
686 | 686 | //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 |
687 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
688 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
687 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
688 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
689 | 689 | $needs_updating = false; |
690 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
691 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
690 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
691 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
692 | 692 | $needs_updating = true; |
693 | 693 | break; |
694 | 694 | } |
@@ -702,29 +702,29 @@ discard block |
||
702 | 702 | * in addons. Has the side effect of adding them for autoloading |
703 | 703 | * @return array keys are expected classnames, values are their filepaths |
704 | 704 | */ |
705 | - public function get_all_data_migration_scripts_available(){ |
|
706 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
705 | + public function get_all_data_migration_scripts_available() { |
|
706 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
707 | 707 | $this->_data_migration_class_to_filepath_map = array(); |
708 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
709 | - if($folder_path[count($folder_path-1)] != DS ){ |
|
710 | - $folder_path.= DS; |
|
708 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
709 | + if ($folder_path[count($folder_path - 1)] != DS) { |
|
710 | + $folder_path .= DS; |
|
711 | 711 | } |
712 | - $files = glob( $folder_path. '*.dms.php' ); |
|
712 | + $files = glob($folder_path.'*.dms.php'); |
|
713 | 713 | |
714 | - if ( empty( $files ) ) { |
|
714 | + if (empty($files)) { |
|
715 | 715 | continue; |
716 | 716 | } |
717 | 717 | |
718 | - foreach($files as $file){ |
|
719 | - $pos_of_last_slash = strrpos($file,DS); |
|
720 | - $classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1)); |
|
721 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
722 | - $slug = $migrates_to[ 'slug' ]; |
|
718 | + foreach ($files as $file) { |
|
719 | + $pos_of_last_slash = strrpos($file, DS); |
|
720 | + $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1)); |
|
721 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
722 | + $slug = $migrates_to['slug']; |
|
723 | 723 | //check that the slug as contained in the DMS is associated with |
724 | 724 | //the slug of an addon or core |
725 | - if( $slug != 'Core' ){ |
|
726 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
727 | - 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' ); |
|
725 | + if ($slug != 'Core') { |
|
726 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
727 | + 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'); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | $this->_data_migration_class_to_filepath_map[$classname] = $file; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * from each addon, and check if they need updating, |
745 | 745 | * @return boolean |
746 | 746 | */ |
747 | - public function addons_need_updating(){ |
|
747 | + public function addons_need_updating() { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | /** |
@@ -753,25 +753,25 @@ discard block |
||
753 | 753 | * @param string $error_message |
754 | 754 | * @throws EE_Error |
755 | 755 | */ |
756 | - public function add_error_to_migrations_ran($error_message){ |
|
756 | + public function add_error_to_migrations_ran($error_message) { |
|
757 | 757 | //get last-ran migration script |
758 | 758 | global $wpdb; |
759 | - $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); |
|
759 | + $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); |
|
760 | 760 | |
761 | 761 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
762 | 762 | //now, tread lightly because we're here because a FATAL non-catchable error |
763 | 763 | //was thrown last time when we were trying to run a data migration script |
764 | 764 | //so the fatal error could have happened while getting the migration script |
765 | 765 | //or doing running it... |
766 | - $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; |
|
766 | + $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; |
|
767 | 767 | |
768 | 768 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
769 | 769 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
770 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
770 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
771 | 771 | //ok then just add this error to its list of errors |
772 | 772 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
773 | 773 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
774 | - }else{ |
|
774 | + } else { |
|
775 | 775 | //so we don't even know which script was last running |
776 | 776 | //use the data migration error stub, which is designed specifically for this type of thing |
777 | 777 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -781,39 +781,39 @@ discard block |
||
781 | 781 | $versions_migrated_to = 'Unknown.1.0.0'; |
782 | 782 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
783 | 783 | //delete the old one |
784 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
784 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
785 | 785 | } |
786 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
786 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
787 | 787 | |
788 | 788 | } |
789 | 789 | /** |
790 | 790 | * saves what data migrations have ran to the database |
791 | 791 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
792 | 792 | */ |
793 | - protected function _save_migrations_ran(){ |
|
794 | - if($this->_data_migrations_ran == null){ |
|
793 | + protected function _save_migrations_ran() { |
|
794 | + if ($this->_data_migrations_ran == null) { |
|
795 | 795 | $this->get_data_migrations_ran(); |
796 | 796 | } |
797 | 797 | //now, we don't want to save actual classes to the DB because that's messy |
798 | 798 | $successful_updates = true; |
799 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
800 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
799 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
800 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
801 | 801 | // echo "saving migration script to $version_string<br>"; |
802 | 802 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
803 | 803 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
804 | 804 | $old_option_value = get_option($option_name); |
805 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
805 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
806 | 806 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
807 | - if( $old_option_value != $script_array_for_saving){ |
|
808 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
807 | + if ($old_option_value != $script_array_for_saving) { |
|
808 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
809 | 809 | } |
810 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
810 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
811 | 811 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
812 | - if($old_option_value != $array_or_migration_obj){ |
|
813 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
812 | + if ($old_option_value != $array_or_migration_obj) { |
|
813 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
814 | 814 | } |
815 | 815 | } |
816 | - if( ! $successful_updates ){ |
|
816 | + if ( ! $successful_updates) { |
|
817 | 817 | global $wpdb; |
818 | 818 | return $wpdb->last_error; |
819 | 819 | } |
@@ -837,17 +837,17 @@ discard block |
||
837 | 837 | * @return EE_Data_Migration_Script_Base |
838 | 838 | * @throws EE_Error |
839 | 839 | */ |
840 | - function _instantiate_script_from_properties_array($properties_array){ |
|
841 | - if( ! isset($properties_array['class'])){ |
|
842 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
840 | + function _instantiate_script_from_properties_array($properties_array) { |
|
841 | + if ( ! isset($properties_array['class'])) { |
|
842 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
843 | 843 | } |
844 | 844 | $class_name = $properties_array['class']; |
845 | - if( ! class_exists($class_name)){ |
|
846 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
845 | + if ( ! class_exists($class_name)) { |
|
846 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
847 | 847 | } |
848 | 848 | $class = new $class_name; |
849 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
850 | - 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))); |
|
849 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
850 | + 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))); |
|
851 | 851 | } |
852 | 852 | $class->instantiate_from_array_of_properties($properties_array); |
853 | 853 | return $class; |
@@ -859,25 +859,25 @@ discard block |
||
859 | 859 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
860 | 860 | * @return string |
861 | 861 | */ |
862 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
862 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
863 | 863 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
864 | 864 | $most_up_to_date_dms_classname = NULL; |
865 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
866 | - if($most_up_to_date_dms_classname === NULL){ |
|
865 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
866 | + if ($most_up_to_date_dms_classname === NULL) { |
|
867 | 867 | $migrates_to = $this->script_migrates_to_version($classname); |
868 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
868 | + $this_plugin_slug = $migrates_to['slug']; |
|
869 | 869 | // $version_string = $migrates_to[ 'version' ]; |
870 | 870 | // $details = $this->parse_dms_classname($classname); |
871 | - if($this_plugin_slug == $plugin_slug){ |
|
871 | + if ($this_plugin_slug == $plugin_slug) { |
|
872 | 872 | //if it's for core, it wins |
873 | 873 | $most_up_to_date_dms_classname = $classname; |
874 | 874 | } |
875 | 875 | //if it wasn't for core, we must keep searching for one that is! |
876 | 876 | continue; |
877 | - }else{ |
|
878 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
877 | + } else { |
|
878 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
879 | 879 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
880 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
880 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
881 | 881 | //so the contenders version is higher and its for Core |
882 | 882 | $most_up_to_date_dms_classname = $classname; |
883 | 883 | } |
@@ -897,11 +897,11 @@ discard block |
||
897 | 897 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
898 | 898 | * @return EE_Data_Migration_Script_Base |
899 | 899 | */ |
900 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
900 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
901 | 901 | $migrations_ran = $this->get_data_migrations_ran(); |
902 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
903 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
904 | - }else{ |
|
902 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
903 | + return $migrations_ran[$plugin_slug][$version]; |
|
904 | + } else { |
|
905 | 905 | return NULL; |
906 | 906 | } |
907 | 907 | } |
@@ -913,20 +913,20 @@ discard block |
||
913 | 913 | * @return bool |
914 | 914 | * @throws \EE_Error |
915 | 915 | */ |
916 | - public function reattempt(){ |
|
916 | + public function reattempt() { |
|
917 | 917 | //find if the last-ran script was borked |
918 | 918 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
919 | 919 | //add an 'error' saying that we attempted to reset |
920 | 920 | //does it have a stage that was borked too? if so make it no longer borked |
921 | 921 | //add an 'error' saying we attempted to reset |
922 | 922 | $last_ran_script = $this->get_last_ran_script(); |
923 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
923 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
924 | 924 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
925 | 925 | $last_ran_script->set_completed(); |
926 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
926 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
927 | 927 | $last_ran_script->reattempt(); |
928 | - }else{ |
|
929 | - 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 ) ) ); |
|
928 | + } else { |
|
929 | + 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))); |
|
930 | 930 | } |
931 | 931 | return $this->_save_migrations_ran(); |
932 | 932 | } |
@@ -936,19 +936,19 @@ discard block |
||
936 | 936 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
937 | 937 | * @return boolean |
938 | 938 | */ |
939 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
940 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
939 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
940 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
941 | 941 | } |
942 | 942 | /** |
943 | 943 | * Enqueues this ee plugin to have its data initialized |
944 | 944 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
945 | 945 | */ |
946 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
946 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
947 | 947 | $queue = $this->get_db_initialization_queue(); |
948 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
948 | + if ( ! in_array($plugin_slug, $queue)) { |
|
949 | 949 | $queue[] = $plugin_slug; |
950 | 950 | } |
951 | - update_option( self::db_init_queue_option_name, $queue ); |
|
951 | + update_option(self::db_init_queue_option_name, $queue); |
|
952 | 952 | } |
953 | 953 | /** |
954 | 954 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -958,26 +958,26 @@ discard block |
||
958 | 958 | public function initialize_db_for_enqueued_ee_plugins() { |
959 | 959 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
960 | 960 | $queue = $this->get_db_initialization_queue(); |
961 | - foreach( $queue as $plugin_slug ) { |
|
962 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
963 | - if( ! $most_up_to_date_dms ) { |
|
961 | + foreach ($queue as $plugin_slug) { |
|
962 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
963 | + if ( ! $most_up_to_date_dms) { |
|
964 | 964 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
965 | 965 | $verify_db = false; |
966 | - }else{ |
|
967 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
968 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
966 | + } else { |
|
967 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
968 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
969 | 969 | } |
970 | - if( $plugin_slug == 'Core' ){ |
|
970 | + if ($plugin_slug == 'Core') { |
|
971 | 971 | EE_System::instance()->initialize_db_if_no_migrations_required( |
972 | 972 | false, |
973 | 973 | $verify_db |
974 | 974 | ); |
975 | - }else{ |
|
975 | + } else { |
|
976 | 976 | //just loop through the addons to make sure their database is setup |
977 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
978 | - if( $addon->name() == $plugin_slug ) { |
|
977 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
978 | + if ($addon->name() == $plugin_slug) { |
|
979 | 979 | |
980 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
980 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
981 | 981 | break; |
982 | 982 | } |
983 | 983 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | // EEH_Debug_Tools::instance()->show_times(); |
988 | 988 | //because we just initialized the DBs for the enqueued ee plugins |
989 | 989 | //we don't need to keep remembering which ones needed to be initialized |
990 | - delete_option( self::db_init_queue_option_name ); |
|
990 | + delete_option(self::db_init_queue_option_name); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | /** |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | * 'Core', or the return value of EE_Addon::name() for an addon |
997 | 997 | * @return array |
998 | 998 | */ |
999 | - public function get_db_initialization_queue(){ |
|
1000 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
999 | + public function get_db_initialization_queue() { |
|
1000 | + return get_option(self::db_init_queue_option_name, array()); |
|
1001 | 1001 | } |
1002 | 1002 | } |
@@ -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 | * Class EE_Select_Reveal_Input |
4 | 4 | * |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.6 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Select_Reveal_Input extends EE_Select_Input{ |
|
14 | +class EE_Select_Reveal_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $answer_options Array keys which match a sibling section's name |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array $input_settings |
28 | 28 | */ |
29 | - public function __construct( $answer_options, $input_settings = array() ){ |
|
30 | - parent::__construct( $answer_options, $input_settings ); |
|
29 | + public function __construct($answer_options, $input_settings = array()) { |
|
30 | + parent::__construct($answer_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function sibling_sections_controlled() { |
38 | 38 | $sibling_sections = array(); |
39 | - foreach( $this->options() as $sibling_section_name => $sibling_section ) { |
|
39 | + foreach ($this->options() as $sibling_section_name => $sibling_section) { |
|
40 | 40 | //if it's an empty string just leave it alone |
41 | - if( empty( $sibling_section_name ) ) { |
|
41 | + if (empty($sibling_section_name)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | - $sibling_section = $this->find_section_from_path( '../' . $sibling_section_name ); |
|
45 | - if( |
|
44 | + $sibling_section = $this->find_section_from_path('../'.$sibling_section_name); |
|
45 | + if ( |
|
46 | 46 | $sibling_section instanceof EE_Form_Section_Base |
47 | - && ! empty( $sibling_section_name ) |
|
47 | + && ! empty($sibling_section_name) |
|
48 | 48 | ) { |
49 | - $sibling_sections[ $sibling_section_name ] = $sibling_section; |
|
49 | + $sibling_sections[$sibling_section_name] = $sibling_section; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | return $sibling_sections; |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | * @param array $form_other_js_data |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
63 | - $form_other_js_data = parent::get_other_js_data( $form_other_js_data ); |
|
64 | - if( ! isset($form_other_js_data[ 'select_reveal_inputs' ] ) ) { |
|
65 | - $form_other_js_data[ 'select_reveal_inputs' ] = array(); |
|
62 | + public function get_other_js_data($form_other_js_data = array()) { |
|
63 | + $form_other_js_data = parent::get_other_js_data($form_other_js_data); |
|
64 | + if ( ! isset($form_other_js_data['select_reveal_inputs'])) { |
|
65 | + $form_other_js_data['select_reveal_inputs'] = array(); |
|
66 | 66 | } |
67 | 67 | $sibling_input_to_html_id_map = array(); |
68 | - foreach( $this->sibling_sections_controlled() as $sibling_section_path => $sibling_section ) { |
|
69 | - $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id(); |
|
68 | + foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) { |
|
69 | + $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id(); |
|
70 | 70 | } |
71 | - $form_other_js_data[ 'select_reveal_inputs' ][ $this->html_id() ] = $sibling_input_to_html_id_map; |
|
71 | + $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map; |
|
72 | 72 | return $form_other_js_data; |
73 | 73 | } |
74 | 74 |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return string |
15 | 15 | */ |
16 | - public function layout_form_begin( $additional_args = array() ) { |
|
16 | + public function layout_form_begin($additional_args = array()) { |
|
17 | 17 | $this->_form_section->set_html_class('form-table'); |
18 | - return parent::layout_form_begin( $additional_args ); |
|
18 | + return parent::layout_form_begin($additional_args); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * @param EE_Form_Section_Proper $form_section |
26 | 26 | * @return string |
27 | 27 | */ |
28 | - public function layout_subsection( $form_section ){ |
|
29 | - if ( $form_section instanceof EE_Form_Section_Proper ) { |
|
30 | - return EEH_HTML::no_row( $form_section->get_html(), 2 ); |
|
31 | - } else if ( $form_section instanceof EE_Form_Section_HTML ) { |
|
28 | + public function layout_subsection($form_section) { |
|
29 | + if ($form_section instanceof EE_Form_Section_Proper) { |
|
30 | + return EEH_HTML::no_row($form_section->get_html(), 2); |
|
31 | + } else if ($form_section instanceof EE_Form_Section_HTML) { |
|
32 | 32 | return $form_section->get_html(); |
33 | 33 | } |
34 | 34 | return ''; |
@@ -41,30 +41,30 @@ discard block |
||
41 | 41 | * @param EE_Form_Input_Base $input |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function layout_input( $input ) { |
|
44 | + public function layout_input($input) { |
|
45 | 45 | |
46 | 46 | if ( |
47 | 47 | $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy || |
48 | 48 | $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy || |
49 | 49 | $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
50 | 50 | ) { |
51 | - $input->set_html_class( $input->html_class() . ' large-text' ); |
|
51 | + $input->set_html_class($input->html_class().' large-text'); |
|
52 | 52 | } |
53 | - if ( $input instanceof EE_Text_Area_Input ) { |
|
54 | - $input->set_rows( 4 ); |
|
55 | - $input->set_cols( 60 ); |
|
53 | + if ($input instanceof EE_Text_Area_Input) { |
|
54 | + $input->set_rows(4); |
|
55 | + $input->set_cols(60); |
|
56 | 56 | } |
57 | 57 | $input_html = $input->get_html_for_input(); |
58 | 58 | // maybe add errors and help text ? |
59 | - $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
60 | - $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
59 | + $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl().$input->get_html_for_errors() : ''; |
|
60 | + $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
61 | 61 | //overriding parent to add wp admin specific things. |
62 | 62 | $html = ''; |
63 | - if ( $input instanceof EE_Hidden_Input ) { |
|
64 | - $html .= EEH_HTML::no_row( $input->get_html_for_input(), 2 ); |
|
63 | + if ($input instanceof EE_Hidden_Input) { |
|
64 | + $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
|
65 | 65 | } else { |
66 | 66 | $html .= EEH_HTML::tr( |
67 | - EEH_HTML::th( $input->get_html_for_label(), '', '', '', 'scope="row"' ) . EEH_HTML::td( $input_html ) |
|
67 | + EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"').EEH_HTML::td($input_html) |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | return $html; |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base{ |
|
3 | +class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base { |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
7 | 7 | * @param array $additional_args |
8 | 8 | * @return string |
9 | 9 | */ |
10 | - public function layout_form_begin( $additional_args = array() ) { |
|
11 | - return EEH_HTML::table( '', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style() ) . EEH_HTML::tbody(); |
|
10 | + public function layout_form_begin($additional_args = array()) { |
|
11 | + return EEH_HTML::table('', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style()).EEH_HTML::tbody(); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * @param array $additional_args |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function layout_form_end( $additional_args = array() ) { |
|
22 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex( $this->_form_section->html_id() ); |
|
21 | + public function layout_form_end($additional_args = array()) { |
|
22 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param EE_Form_Input_Base $input |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function layout_input( $input ) { |
|
32 | + public function layout_input($input) { |
|
33 | 33 | $html = ''; |
34 | - if ( $input instanceof EE_Hidden_Input ) { |
|
34 | + if ($input instanceof EE_Hidden_Input) { |
|
35 | 35 | $html .= $input->get_html_for_input(); |
36 | 36 | } else { |
37 | 37 | $html_for_input = $input->get_html_for_input(); |
38 | - $html_for_input .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
39 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
38 | + $html_for_input .= $input->get_html_for_errors() != '' ? EEH_HTML::nl().$input->get_html_for_errors() : ''; |
|
39 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
40 | 40 | $html .= EEH_HTML::tr( |
41 | - EEH_HTML::th( $input->get_html_for_label() ) . |
|
42 | - EEH_HTML::td( $html_for_input ) |
|
41 | + EEH_HTML::th($input->get_html_for_label()). |
|
42 | + EEH_HTML::td($html_for_input) |
|
43 | 43 | ); |
44 | 44 | } |
45 | 45 | return $html; |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param EE_Form_Section_Proper $form_section |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - public function layout_subsection( $form_section ){ |
|
55 | + public function layout_subsection($form_section) { |
|
56 | 56 | $html = ''; |
57 | - if ( $form_section instanceof EE_Form_Section_HTML ) { |
|
57 | + if ($form_section instanceof EE_Form_Section_HTML) { |
|
58 | 58 | $html .= $form_section->get_html(); |
59 | 59 | } else { |
60 | 60 | $html .= EEH_HTML::tr( |
61 | - EEH_HTML::td( $form_section->get_html(), '', '', '', 'colspan="2"' ) |
|
61 | + EEH_HTML::td($form_section->get_html(), '', '', '', 'colspan="2"') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | return $html; |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | * @param EE_Form_Input_Base $input |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function layout_input( $input ) { |
|
29 | + public function layout_input($input) { |
|
30 | 30 | $html = ''; |
31 | - if ( $input instanceof EE_Hidden_Input ) { |
|
32 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
33 | - } else if ( $input instanceof EE_Submit_Input ) { |
|
31 | + if ($input instanceof EE_Hidden_Input) { |
|
32 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
33 | + } else if ($input instanceof EE_Submit_Input) { |
|
34 | 34 | $html .= EEH_HTML::br(); |
35 | 35 | $html .= $input->get_html_for_input(); |
36 | - } else if ( $input instanceof EE_Select_Input ) { |
|
36 | + } else if ($input instanceof EE_Select_Input) { |
|
37 | 37 | $html .= EEH_HTML::br(); |
38 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
39 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
40 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
41 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
38 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
39 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
40 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
41 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
42 | 42 | $html .= EEH_HTML::br(); |
43 | - } else if ( $input instanceof EE_Form_Input_With_Options_Base ) { |
|
43 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
44 | 44 | $html .= EEH_HTML::br(); |
45 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
46 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
47 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
45 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
46 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
47 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
48 | 48 | } else { |
49 | 49 | $html .= EEH_HTML::br(); |
50 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
51 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
52 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
53 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
50 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
51 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
52 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
53 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
54 | 54 | } |
55 | 55 | $html .= EEH_HTML::nl(-1); |
56 | 56 | return $html; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * @param EE_Form_Section_Proper $form_section |
64 | 64 | * @return string |
65 | 65 | */ |
66 | - public function layout_subsection( $form_section ){ |
|
66 | + public function layout_subsection($form_section) { |
|
67 | 67 | // d( $form_section ); |
68 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
68 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * closing div tag for a form |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - public function layout_form_end(){ |
|
76 | + public function layout_form_end() { |
|
77 | 77 | return EEH_HTML::nl(-1); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | * @since 4.6.0 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base{ |
|
13 | +class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * opening div tag for a form |
17 | 17 | * @return string |
18 | 18 | */ |
19 | 19 | public function layout_form_begin() { |
20 | - return EEH_HTML::div( '', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style() ); |
|
20 | + return EEH_HTML::div('', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style()); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,38 +26,38 @@ discard block |
||
26 | 26 | * @param EE_Form_Input_Base $input |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function layout_input( $input ) { |
|
29 | + public function layout_input($input) { |
|
30 | 30 | $html = ''; |
31 | - if ( $input instanceof EE_Hidden_Input ) { |
|
32 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
33 | - } else if ( $input instanceof EE_Submit_Input ) { |
|
34 | - $html .= EEH_HTML::div( $input->get_html_for_input(), $input->html_id() . '-submit-dv', $input->html_class() . '-submit-dv' ); |
|
35 | - } else if ( $input instanceof EE_Select_Input ) { |
|
31 | + if ($input instanceof EE_Hidden_Input) { |
|
32 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
33 | + } else if ($input instanceof EE_Submit_Input) { |
|
34 | + $html .= EEH_HTML::div($input->get_html_for_input(), $input->html_id().'-submit-dv', $input->html_class().'-submit-dv'); |
|
35 | + } else if ($input instanceof EE_Select_Input) { |
|
36 | 36 | $html .= EEH_HTML::div( |
37 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
38 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
39 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
40 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
41 | - $input->html_id() . '-input-dv', |
|
42 | - $input->html_class() . '-input-dv' |
|
37 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
38 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
39 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
40 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
41 | + $input->html_id().'-input-dv', |
|
42 | + $input->html_class().'-input-dv' |
|
43 | 43 | ); |
44 | - } else if ( $input instanceof EE_Form_Input_With_Options_Base ) { |
|
44 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
45 | 45 | $html .= EEH_HTML::div( |
46 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question( $input ) . |
|
47 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
48 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
49 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
50 | - $input->html_id() . '-input-dv', |
|
51 | - $input->html_class() . '-input-dv' |
|
46 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
47 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
48 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
49 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
50 | + $input->html_id().'-input-dv', |
|
51 | + $input->html_class().'-input-dv' |
|
52 | 52 | ); |
53 | 53 | } else { |
54 | 54 | $html .= EEH_HTML::div( |
55 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
56 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
57 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
58 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
59 | - $input->html_id() . '-input-dv', |
|
60 | - $input->html_class() . '-input-dv' |
|
55 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
56 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
57 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
58 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
59 | + $input->html_id().'-input-dv', |
|
60 | + $input->html_class().'-input-dv' |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | return $html; |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param EE_Form_Input_With_Options_Base $input |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - protected function _display_label_for_option_type_question( EE_Form_Input_With_Options_Base $input ){ |
|
78 | - if ( $input->display_html_label_text() != '' ) { |
|
79 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
80 | - $label_text = $input->required() ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' : $input->html_label_text(); |
|
81 | - $html = '<div id="' . $input->html_label_id() . '"'; |
|
82 | - $html .= ' class="' . $class . '"'; |
|
83 | - $html .= ' style="' . $input->html_label_style() . '">'; |
|
84 | - $html .= $label_text . '</div>'; |
|
77 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) { |
|
78 | + if ($input->display_html_label_text() != '') { |
|
79 | + $class = $input->required() ? 'ee-required-label '.$input->html_label_class() : $input->html_label_class(); |
|
80 | + $label_text = $input->required() ? $input->html_label_text().'<span class="ee-asterisk">*</span>' : $input->html_label_text(); |
|
81 | + $html = '<div id="'.$input->html_label_id().'"'; |
|
82 | + $html .= ' class="'.$class.'"'; |
|
83 | + $html .= ' style="'.$input->html_label_style().'">'; |
|
84 | + $html .= $label_text.'</div>'; |
|
85 | 85 | return $html; |
86 | 86 | } else { |
87 | 87 | return ''; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param EE_Form_Section_Proper $form_section |
96 | 96 | * @return string |
97 | 97 | */ |
98 | - public function layout_subsection( $form_section ){ |
|
98 | + public function layout_subsection($form_section) { |
|
99 | 99 | // d( $form_section ); |
100 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
100 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * closing div tag for a form |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public function layout_form_end(){ |
|
109 | - return EEH_HTML::divx( $this->_form_section->html_id(), $this->_form_section->html_class() ); |
|
108 | + public function layout_form_end() { |
|
109 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
80 | 80 | * } |
81 | 81 | */ |
82 | - public function __construct( $options_array = array() ) { |
|
82 | + public function __construct($options_array = array()) { |
|
83 | 83 | // used by display strategies |
84 | 84 | // assign incoming values to properties |
85 | - foreach( $options_array as $key => $value ) { |
|
86 | - $key = '_' . $key; |
|
87 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
85 | + foreach ($options_array as $key => $value) { |
|
86 | + $key = '_'.$key; |
|
87 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
88 | 88 | $this->{$key} = $value; |
89 | 89 | } |
90 | 90 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param $name |
98 | 98 | * @throws \EE_Error |
99 | 99 | */ |
100 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
100 | + protected function _construct_finalize($parent_form_section, $name) { |
|
101 | 101 | $this->_construction_finalized = TRUE; |
102 | 102 | $this->_parent_section = $parent_form_section; |
103 | 103 | $this->_name = $name; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @param string $action |
120 | 120 | */ |
121 | - public function set_action( $action ) { |
|
121 | + public function set_action($action) { |
|
122 | 122 | $this->_action = $action; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function method() { |
131 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
131 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * @param string $method |
138 | 138 | */ |
139 | - public function set_method( $method ) { |
|
140 | - switch ( $method ) { |
|
139 | + public function set_method($method) { |
|
140 | + switch ($method) { |
|
141 | 141 | case 'get' : |
142 | 142 | case 'GET' : |
143 | 143 | $this->_method = 'GET'; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | - protected function _set_default_html_id_if_empty(){ |
|
160 | - if( ! $this->_html_id ){ |
|
161 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
162 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
163 | - }else{ |
|
164 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
159 | + protected function _set_default_html_id_if_empty() { |
|
160 | + if ( ! $this->_html_id) { |
|
161 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
162 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
163 | + } else { |
|
164 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param $name |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - private function _prep_name_for_html_id( $name ) { |
|
177 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
176 | + private function _prep_name_for_html_id($name) { |
|
177 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * Enqueueing JS after "wp_enqueue_scripts" action may not work |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_html_and_js(){ |
|
188 | + public function get_html_and_js() { |
|
189 | 189 | return $this->get_html(); |
190 | 190 | } |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param bool $add_pound_sign |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function html_id( $add_pound_sign = FALSE ){ |
|
205 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
204 | + public function html_id($add_pound_sign = FALSE) { |
|
205 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public function html_class(){ |
|
213 | + public function html_class() { |
|
214 | 214 | return $this->_html_class; |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - public function html_style(){ |
|
222 | + public function html_style() { |
|
223 | 223 | return $this->_html_style; |
224 | 224 | } |
225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * @param mixed $html_class |
230 | 230 | */ |
231 | - public function set_html_class( $html_class ) { |
|
231 | + public function set_html_class($html_class) { |
|
232 | 232 | $this->_html_class = $html_class; |
233 | 233 | } |
234 | 234 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * @param mixed $html_id |
239 | 239 | */ |
240 | - public function set_html_id( $html_id ) { |
|
240 | + public function set_html_id($html_id) { |
|
241 | 241 | $this->_html_id = $html_id; |
242 | 242 | } |
243 | 243 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * @param mixed $html_style |
248 | 248 | */ |
249 | - public function set_html_style( $html_style ) { |
|
249 | + public function set_html_style($html_style) { |
|
250 | 250 | $this->_html_style = $html_style; |
251 | 251 | } |
252 | 252 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * @param string $other_html_attributes |
257 | 257 | */ |
258 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
258 | + public function set_other_html_attributes($other_html_attributes) { |
|
259 | 259 | $this->_other_html_attributes = $other_html_attributes; |
260 | 260 | } |
261 | 261 | |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @throws EE_Error |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public function name(){ |
|
279 | - if( ! $this->_construction_finalized ){ |
|
280 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
278 | + public function name() { |
|
279 | + if ( ! $this->_construction_finalized) { |
|
280 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
281 | 281 | } |
282 | 282 | return $this->_name; |
283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * Gets the parent section |
289 | 289 | * @return EE_Form_Section_Proper |
290 | 290 | */ |
291 | - public function parent_section(){ |
|
291 | + public function parent_section() { |
|
292 | 292 | return $this->_parent_section; |
293 | 293 | } |
294 | 294 | |
@@ -301,18 +301,18 @@ discard block |
||
301 | 301 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
305 | - if ( ! empty( $action )) { |
|
306 | - $this->set_action( $action ); |
|
304 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
305 | + if ( ! empty($action)) { |
|
306 | + $this->set_action($action); |
|
307 | 307 | } |
308 | - if ( ! empty( $method )) { |
|
309 | - $this->set_method( $method ); |
|
308 | + if ( ! empty($method)) { |
|
309 | + $this->set_method($method); |
|
310 | 310 | } |
311 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
312 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
313 | - $html .= ' action="' . $this->action() . '"'; |
|
314 | - $html .= ' method="' . $this->method() . '"'; |
|
315 | - $html .= $other_attributes . '>'; |
|
311 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
312 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
313 | + $html .= ' action="'.$this->action().'"'; |
|
314 | + $html .= ' method="'.$this->method().'"'; |
|
315 | + $html .= $other_attributes.'>'; |
|
316 | 316 | return $html; |
317 | 317 | } |
318 | 318 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @return string |
324 | 324 | */ |
325 | 325 | public function form_close() { |
326 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
326 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * Default does nothing, but child classes can override |
333 | 333 | * @return string |
334 | 334 | */ |
335 | - public function enqueue_js(){ |
|
335 | + public function enqueue_js() { |
|
336 | 336 | //defaults to enqueue NO js or css |
337 | 337 | } |
338 | 338 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param array $form_other_js_data |
349 | 349 | * @return array |
350 | 350 | */ |
351 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
351 | + public function get_other_js_data($form_other_js_data = array()) { |
|
352 | 352 | return $form_other_js_data; |
353 | 353 | } |
354 | 354 | |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
367 | 367 | * @return EE_Form_Section_Base |
368 | 368 | */ |
369 | - public function find_section_from_path( $form_section_path ) { |
|
370 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
371 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
369 | + public function find_section_from_path($form_section_path) { |
|
370 | + if (strpos($form_section_path, '/') === 0) { |
|
371 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
372 | 372 | } |
373 | - if( empty( $form_section_path ) ) { |
|
373 | + if (empty($form_section_path)) { |
|
374 | 374 | return $this; |
375 | 375 | } |
376 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
376 | + if (strpos($form_section_path, '../') === 0) { |
|
377 | 377 | $parent = $this->parent_section(); |
378 | 378 | |
379 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
380 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
381 | - return $parent->find_section_from_path( $form_section_path ); |
|
382 | - } elseif( empty( $form_section_path ) ) { |
|
379 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
380 | + if ($parent instanceof EE_Form_Section_Base) { |
|
381 | + return $parent->find_section_from_path($form_section_path); |
|
382 | + } elseif (empty($form_section_path)) { |
|
383 | 383 | return $this; |
384 | 384 | } |
385 | 385 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param null $validation_error_message |
24 | 24 | */ |
25 | - public function __construct( $validation_error_message = null ) { |
|
25 | + public function __construct($validation_error_message = null) { |
|
26 | 26 | $this->_validation_error_message = $validation_error_message === null |
27 | - ? __( 'Input invalid', 'event_espresso' ) |
|
27 | + ? __('Input invalid', 'event_espresso') |
|
28 | 28 | : $validation_error_message; |
29 | 29 | parent::__construct(); |
30 | 30 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * this validation strategy is the 'required' validation strategy, |
42 | 42 | * most should be OK with a null, empty string, etc) |
43 | 43 | */ |
44 | - public function validate( $normalized_value ) { |
|
44 | + public function validate($normalized_value) { |
|
45 | 45 | //by default, the validation strategy does no validation. this should be implemented |
46 | 46 | } |
47 | 47 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * in each form's "other_data" javascript object. |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - public function get_other_js_data( $other_js_data = array() ) { |
|
91 | + public function get_other_js_data($other_js_data = array()) { |
|
92 | 92 | return $other_js_data; |
93 | 93 | } |
94 | 94 |