@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\interfaces\InterminableInterface; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | 4 | /** |
5 | 5 | * EE_PUE |
6 | 6 | * |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | public function __construct() { |
20 | 20 | // throw new EE_Error('error'); |
21 | 21 | |
22 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
22 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
23 | 23 | |
24 | 24 | //wp have no MONTH_IN_SECONDS constant. So we approximate our own assuming all months are 4 weeks long. |
25 | - if ( !defined('MONTH_IN_SECONDS' ) ) |
|
26 | - define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
25 | + if ( ! defined('MONTH_IN_SECONDS')) |
|
26 | + define('MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4); |
|
27 | 27 | |
28 | - if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){ |
|
28 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
29 | 29 | $this->_uxip_hooks(); |
30 | 30 | } |
31 | 31 | |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
35 | 35 | |
36 | 36 | //has optin been selected for data collection? |
37 | - $espresso_data_optin = !empty($ueip_optin) ? $ueip_optin : NULL; |
|
37 | + $espresso_data_optin = ! empty($ueip_optin) ? $ueip_optin : NULL; |
|
38 | 38 | |
39 | - if ( empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
40 | - add_action('admin_notices', array( $this, 'espresso_data_collection_optin_notice' ), 10 ); |
|
41 | - add_action('admin_enqueue_scripts', array( $this, 'espresso_data_collection_enqueue_scripts' ), 10 ); |
|
42 | - add_action('wp_ajax_espresso_data_optin', array( $this, 'espresso_data_optin_ajax_handler' ), 10 ); |
|
39 | + if (empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
40 | + add_action('admin_notices', array($this, 'espresso_data_collection_optin_notice'), 10); |
|
41 | + add_action('admin_enqueue_scripts', array($this, 'espresso_data_collection_enqueue_scripts'), 10); |
|
42 | + add_action('wp_ajax_espresso_data_optin', array($this, 'espresso_data_optin_ajax_handler'), 10); |
|
43 | 43 | update_option('ee_ueip_optin', 'yes'); |
44 | 44 | $espresso_data_optin = 'yes'; |
45 | 45 | } |
@@ -48,80 +48,80 @@ discard block |
||
48 | 48 | $extra_stats = array(); |
49 | 49 | |
50 | 50 | //only collect extra stats if the plugin user has opted in. |
51 | - if ( !empty($espresso_data_optin) && $espresso_data_optin == 'yes' ) { |
|
51 | + if ( ! empty($espresso_data_optin) && $espresso_data_optin == 'yes') { |
|
52 | 52 | //let's only setup extra data if transient has expired |
53 | - if ( false === ( $transient = get_transient('ee_extra_data') ) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
53 | + if (false === ($transient = get_transient('ee_extra_data')) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
54 | 54 | |
55 | 55 | $current_site = is_multisite() ? get_current_site() : NULL; |
56 | - $site_pre = ! is_main_site() && ! empty($current_site) ? trim( preg_replace('/\b\w\S\w\b/', '', $current_site->domain ), '.' ) . '_' : ''; |
|
56 | + $site_pre = ! is_main_site() && ! empty($current_site) ? trim(preg_replace('/\b\w\S\w\b/', '', $current_site->domain), '.').'_' : ''; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | //active gateways |
60 | 60 | $active_gateways = get_option('event_espresso_active_gateways'); |
61 | - if ( !empty($active_gateways ) ) { |
|
62 | - foreach ( (array) $active_gateways as $gateway => $ignore ) { |
|
63 | - $extra_stats[$site_pre . $gateway . '_gateway_active'] = 1; |
|
61 | + if ( ! empty($active_gateways)) { |
|
62 | + foreach ((array) $active_gateways as $gateway => $ignore) { |
|
63 | + $extra_stats[$site_pre.$gateway.'_gateway_active'] = 1; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - if ( is_multisite() && is_main_site() ) { |
|
67 | + if (is_multisite() && is_main_site()) { |
|
68 | 68 | $extra_stats['is_multisite'] = true; |
69 | 69 | } |
70 | 70 | |
71 | 71 | //what is the current active theme? |
72 | 72 | $active_theme = get_option('uxip_ee_active_theme'); |
73 | - if ( !empty( $active_theme ) ) |
|
74 | - $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
73 | + if ( ! empty($active_theme)) |
|
74 | + $extra_stats[$site_pre.'active_theme'] = $active_theme; |
|
75 | 75 | |
76 | 76 | //event info regarding an all event count and all "active" event count |
77 | 77 | $all_events_count = get_option('uxip_ee4_all_events_count'); |
78 | - if ( !empty( $all_events_count ) ) |
|
79 | - $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
78 | + if ( ! empty($all_events_count)) |
|
79 | + $extra_stats[$site_pre.'ee4_all_events_count'] = $all_events_count; |
|
80 | 80 | $active_events_count = get_option('uxip_ee4_active_events_count'); |
81 | - if ( !empty( $active_events_count ) ) |
|
82 | - $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
81 | + if ( ! empty($active_events_count)) |
|
82 | + $extra_stats[$site_pre.'ee4_active_events_count'] = $active_events_count; |
|
83 | 83 | |
84 | 84 | //datetime stuff |
85 | 85 | $dtt_count = get_option('uxip_ee_all_dtts_count'); |
86 | - if ( !empty( $dtt_count ) ) |
|
87 | - $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
86 | + if ( ! empty($dtt_count)) |
|
87 | + $extra_stats[$site_pre.'all_dtts_count'] = $dtt_count; |
|
88 | 88 | |
89 | 89 | $dtt_sold = get_option('uxip_ee_dtt_sold'); |
90 | - if ( !empty( $dtt_sold ) ) |
|
91 | - $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
90 | + if ( ! empty($dtt_sold)) |
|
91 | + $extra_stats[$site_pre.'dtt_sold'] = $dtt_sold; |
|
92 | 92 | |
93 | 93 | //ticket stuff |
94 | 94 | $all_tkt_count = get_option('uxip_ee_all_tkt_count'); |
95 | - if ( !empty( $all_tkt_count ) ) |
|
96 | - $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
95 | + if ( ! empty($all_tkt_count)) |
|
96 | + $extra_stats[$site_pre.'all_tkt_count'] = $all_tkt_count; |
|
97 | 97 | |
98 | 98 | $free_tkt_count = get_option('uxip_ee_free_tkt_count'); |
99 | - if ( !empty( $free_tkt_count ) ) |
|
100 | - $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
99 | + if ( ! empty($free_tkt_count)) |
|
100 | + $extra_stats[$site_pre.'free_tkt_count'] = $free_tkt_count; |
|
101 | 101 | |
102 | 102 | $paid_tkt_count = get_option('uxip_ee_paid_tkt_count'); |
103 | - if ( !empty( $paid_tkt_count ) ) |
|
104 | - $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
103 | + if ( ! empty($paid_tkt_count)) |
|
104 | + $extra_stats[$site_pre.'paid_tkt_count'] = $paid_tkt_count; |
|
105 | 105 | |
106 | - $tkt_sold = get_option('uxip_ee_tkt_sold' ); |
|
107 | - if ( !empty($tkt_sold) ) |
|
108 | - $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
106 | + $tkt_sold = get_option('uxip_ee_tkt_sold'); |
|
107 | + if ( ! empty($tkt_sold)) |
|
108 | + $extra_stats[$site_pre.'tkt_sold'] = $tkt_sold; |
|
109 | 109 | |
110 | 110 | //phpversion checking |
111 | 111 | $extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown'; |
112 | 112 | |
113 | 113 | //set transient |
114 | - set_transient( 'ee_extra_data', $extra_stats, WEEK_IN_SECONDS ); |
|
114 | + set_transient('ee_extra_data', $extra_stats, WEEK_IN_SECONDS); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | 119 | |
120 | 120 | // PUE Auto Upgrades stuff |
121 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file |
|
122 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php' ); |
|
121 | + if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { //include the file |
|
122 | + require_once(EE_THIRD_PARTY.'pue/pue-client.php'); |
|
123 | 123 | |
124 | - $api_key = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->site_license_key : ''; |
|
124 | + $api_key = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->site_license_key : ''; |
|
125 | 125 | $host_server_url = 'https://eventespresso.com'; //this needs to be the host server where plugin update engine is installed. Note, if you leave this blank then it is assumed the WordPress repo will be used and we'll just check there. |
126 | 126 | |
127 | 127 | //Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. So it's important that you use a key for the version type that is unique and not found in another key. |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | //$plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
134 | 134 | //..WOULD work! |
135 | 135 | $plugin_slug = array( |
136 | - 'free' => array( 'decaf' => 'event-espresso-core-decaf' ), |
|
137 | - 'premium' => array( 'p' => 'event-espresso-core-reg' ), |
|
138 | - 'prerelease' => array( 'beta' => 'event-espresso-core-pr' ) |
|
136 | + 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
137 | + 'premium' => array('p' => 'event-espresso-core-reg'), |
|
138 | + 'prerelease' => array('beta' => 'event-espresso-core-pr') |
|
139 | 139 | ); |
140 | 140 | |
141 | 141 | |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | * @param bool $extra |
166 | 166 | * @return string html. |
167 | 167 | */ |
168 | - public static function espresso_data_collection_optin_text( $extra = true ) { |
|
169 | - if ( ! $extra ) { |
|
170 | - echo '<h2 class="ee-admin-settings-hdr" '. (!$extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>'; |
|
171 | - echo sprintf( __('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>','<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">','</a>','<br><br>','<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">','</a>' ); |
|
168 | + public static function espresso_data_collection_optin_text($extra = true) { |
|
169 | + if ( ! $extra) { |
|
170 | + echo '<h2 class="ee-admin-settings-hdr" '.( ! $extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>'; |
|
171 | + echo sprintf(__('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>', '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<br><br>', '<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">', '</a>'); |
|
172 | 172 | } else { |
173 | - $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
|
173 | + $settings_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), admin_url('admin.php?page=espresso_general_settings')); |
|
174 | 174 | $settings_url .= '#UXIP_settings'; |
175 | - echo sprintf( __( 'The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso' ), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<a href="' . $settings_url . '" target="_blank">', '</a>' ); |
|
175 | + echo sprintf(__('The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso'), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<a href="'.$settings_url.'" target="_blank">', '</a>'); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | function espresso_data_collection_optin_notice() { |
183 | 183 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
184 | - if ( $ueip_has_notified ) return; |
|
184 | + if ($ueip_has_notified) return; |
|
185 | 185 | // $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
186 | 186 | // $settings_url = $settings_url . '#UXIP_settings'; |
187 | 187 | ?> |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @return void |
206 | 206 | */ |
207 | 207 | function espresso_data_collection_enqueue_scripts() { |
208 | - wp_register_script( 'ee-data-optin-js', EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
209 | - wp_register_style( 'ee-data-optin-css', EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
208 | + wp_register_script('ee-data-optin-js', EE_GLOBAL_ASSETS_URL.'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
209 | + wp_register_style('ee-data-optin-css', EE_GLOBAL_ASSETS_URL.'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION); |
|
210 | 210 | |
211 | 211 | wp_enqueue_script('ee-data-optin-js'); |
212 | 212 | wp_enqueue_style('ee-data-optin-css'); |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | function espresso_data_optin_ajax_handler() { |
222 | 222 | |
223 | 223 | //verify nonce |
224 | - if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit(); |
|
224 | + if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) exit(); |
|
225 | 225 | |
226 | 226 | //made it here so let's save the selection |
227 | 227 | // $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no'; |
228 | 228 | |
229 | 229 | //update_option('ee_ueip_optin', $ueip_optin); |
230 | 230 | EE_Registry::instance()->CFG->core->ee_ueip_has_notified = 1; |
231 | - EE_Registry::instance()->CFG->update_espresso_config( FALSE, FALSE ); |
|
231 | + EE_Registry::instance()->CFG->update_espresso_config(FALSE, FALSE); |
|
232 | 232 | exit(); |
233 | 233 | } |
234 | 234 | |
@@ -241,22 +241,22 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public static function is_update_available($basename = '') { |
243 | 243 | |
244 | - $basename = ! empty( $basename ) ? $basename : EE_PLUGIN_BASENAME; |
|
244 | + $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
245 | 245 | |
246 | 246 | $update = false; |
247 | 247 | |
248 | - $folder = DS . dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
248 | + $folder = DS.dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
249 | 249 | |
250 | 250 | $plugins = get_plugins($folder); |
251 | - $current = get_site_transient( 'update_plugins' ); |
|
251 | + $current = get_site_transient('update_plugins'); |
|
252 | 252 | |
253 | - foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
|
254 | - if ( isset( $current->response['plugin_file'] ) ) |
|
253 | + foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
254 | + if (isset($current->response['plugin_file'])) |
|
255 | 255 | $update = true; |
256 | 256 | } |
257 | 257 | |
258 | 258 | //it's possible that there is an update but an invalid site-license-key is in use |
259 | - if ( get_site_option('pue_json_error_' . $basename ) ) |
|
259 | + if (get_site_option('pue_json_error_'.$basename)) |
|
260 | 260 | $update = true; |
261 | 261 | |
262 | 262 | return $update; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * @return void |
275 | 275 | */ |
276 | 276 | public function _uxip_hooks() { |
277 | - if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
278 | - add_action('admin_init', array( $this, 'track_active_theme' ) ); |
|
279 | - add_action('admin_init', array( $this, 'track_event_info' ) ); |
|
277 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
278 | + add_action('admin_init', array($this, 'track_active_theme')); |
|
279 | + add_action('admin_init', array($this, 'track_event_info')); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -285,66 +285,66 @@ discard block |
||
285 | 285 | |
286 | 286 | public function track_active_theme() { |
287 | 287 | //we only check this once a month. |
288 | - if ( false === ( $transient = get_transient( 'ee_active_theme_check' ) ) ) { |
|
288 | + if (false === ($transient = get_transient('ee_active_theme_check'))) { |
|
289 | 289 | $theme = wp_get_theme(); |
290 | - update_option('uxip_ee_active_theme', $theme->get('Name') ); |
|
291 | - set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS ); |
|
290 | + update_option('uxip_ee_active_theme', $theme->get('Name')); |
|
291 | + set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | 295 | |
296 | 296 | public function track_event_info() { |
297 | 297 | //we only check this once every couple weeks. |
298 | - if ( false === ( $transient = get_transient( 'ee4_event_info_check') ) ) { |
|
298 | + if (false === ($transient = get_transient('ee4_event_info_check'))) { |
|
299 | 299 | //first let's get the number for ALL events |
300 | 300 | /** @var EEM_Event $EVT */ |
301 | - $EVT = EE_Registry::instance()->load_model( 'Event'); |
|
301 | + $EVT = EE_Registry::instance()->load_model('Event'); |
|
302 | 302 | $DTT = EE_Registry::instance()->load_model('Datetime'); |
303 | 303 | $TKT = EE_Registry::instance()->load_model('Ticket'); |
304 | 304 | $count = $EVT->count(); |
305 | - if ( $count > 0 ) |
|
305 | + if ($count > 0) |
|
306 | 306 | update_option('uxip_ee4_all_events_count', $count); |
307 | 307 | |
308 | 308 | //next let's just get the number of ACTIVE events |
309 | 309 | $count_active = $EVT->get_active_events(array(), TRUE); |
310 | - if ( $count_active > 0 ) |
|
310 | + if ($count_active > 0) |
|
311 | 311 | update_option('uxip_ee4_active_events_count', $count_active); |
312 | 312 | |
313 | 313 | //datetimes! |
314 | 314 | $dtt_count = $DTT->count(); |
315 | - if ( $dtt_count > 0 ) |
|
316 | - update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
315 | + if ($dtt_count > 0) |
|
316 | + update_option('uxip_ee_all_dtts_count', $dtt_count); |
|
317 | 317 | |
318 | 318 | |
319 | 319 | //dttsold |
320 | 320 | $dtt_sold = $DTT->sum(array(), 'DTT_sold'); |
321 | - if ( $dtt_sold > 0 ) |
|
322 | - update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
321 | + if ($dtt_sold > 0) |
|
322 | + update_option('uxip_ee_dtt_sold', $dtt_sold); |
|
323 | 323 | |
324 | 324 | //allticketcount |
325 | 325 | $all_tkt_count = $TKT->count(); |
326 | - if ( $all_tkt_count > 0 ) |
|
327 | - update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
326 | + if ($all_tkt_count > 0) |
|
327 | + update_option('uxip_ee_all_tkt_count', $all_tkt_count); |
|
328 | 328 | |
329 | 329 | //freetktcount |
330 | - $_where = array( 'TKT_price' => 0 ); |
|
330 | + $_where = array('TKT_price' => 0); |
|
331 | 331 | $free_tkt_count = $TKT->count(array($_where)); |
332 | - if ( $free_tkt_count > 0 ) |
|
333 | - update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
332 | + if ($free_tkt_count > 0) |
|
333 | + update_option('uxip_ee_free_tkt_count', $free_tkt_count); |
|
334 | 334 | |
335 | 335 | //paidtktcount |
336 | - $_where = array( 'TKT_price' => array('>', 0) ); |
|
337 | - $paid_tkt_count = $TKT->count( array( $_where ) ); |
|
338 | - if ( $paid_tkt_count > 0 ) |
|
339 | - update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
336 | + $_where = array('TKT_price' => array('>', 0)); |
|
337 | + $paid_tkt_count = $TKT->count(array($_where)); |
|
338 | + if ($paid_tkt_count > 0) |
|
339 | + update_option('uxip_ee_paid_tkt_count', $paid_tkt_count); |
|
340 | 340 | |
341 | 341 | //tktsold |
342 | - $tkt_sold = $TKT->sum( array(), 'TKT_sold' ); |
|
343 | - if( $tkt_sold > 0 ) |
|
344 | - update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
342 | + $tkt_sold = $TKT->sum(array(), 'TKT_sold'); |
|
343 | + if ($tkt_sold > 0) |
|
344 | + update_option('uxip_ee_tkt_sold', $tkt_sold); |
|
345 | 345 | |
346 | 346 | |
347 | - set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 ); |
|
347 | + set_transient('ee4_event_info_check', 1, WEEK_IN_SECONDS * 2); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 |
@@ -1,6 +1,8 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\interfaces\InterminableInterface; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | +} |
|
4 | 6 | /** |
5 | 7 | * EE_PUE |
6 | 8 | * |
@@ -22,8 +24,9 @@ discard block |
||
22 | 24 | do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
23 | 25 | |
24 | 26 | //wp have no MONTH_IN_SECONDS constant. So we approximate our own assuming all months are 4 weeks long. |
25 | - if ( !defined('MONTH_IN_SECONDS' ) ) |
|
26 | - define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
27 | + if ( !defined('MONTH_IN_SECONDS' ) ) { |
|
28 | + define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
29 | + } |
|
27 | 30 | |
28 | 31 | if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){ |
29 | 32 | $this->_uxip_hooks(); |
@@ -70,42 +73,51 @@ discard block |
||
70 | 73 | |
71 | 74 | //what is the current active theme? |
72 | 75 | $active_theme = get_option('uxip_ee_active_theme'); |
73 | - if ( !empty( $active_theme ) ) |
|
74 | - $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
76 | + if ( !empty( $active_theme ) ) { |
|
77 | + $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
78 | + } |
|
75 | 79 | |
76 | 80 | //event info regarding an all event count and all "active" event count |
77 | 81 | $all_events_count = get_option('uxip_ee4_all_events_count'); |
78 | - if ( !empty( $all_events_count ) ) |
|
79 | - $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
82 | + if ( !empty( $all_events_count ) ) { |
|
83 | + $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
84 | + } |
|
80 | 85 | $active_events_count = get_option('uxip_ee4_active_events_count'); |
81 | - if ( !empty( $active_events_count ) ) |
|
82 | - $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
86 | + if ( !empty( $active_events_count ) ) { |
|
87 | + $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
88 | + } |
|
83 | 89 | |
84 | 90 | //datetime stuff |
85 | 91 | $dtt_count = get_option('uxip_ee_all_dtts_count'); |
86 | - if ( !empty( $dtt_count ) ) |
|
87 | - $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
92 | + if ( !empty( $dtt_count ) ) { |
|
93 | + $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
94 | + } |
|
88 | 95 | |
89 | 96 | $dtt_sold = get_option('uxip_ee_dtt_sold'); |
90 | - if ( !empty( $dtt_sold ) ) |
|
91 | - $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
97 | + if ( !empty( $dtt_sold ) ) { |
|
98 | + $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
99 | + } |
|
92 | 100 | |
93 | 101 | //ticket stuff |
94 | 102 | $all_tkt_count = get_option('uxip_ee_all_tkt_count'); |
95 | - if ( !empty( $all_tkt_count ) ) |
|
96 | - $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
103 | + if ( !empty( $all_tkt_count ) ) { |
|
104 | + $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
105 | + } |
|
97 | 106 | |
98 | 107 | $free_tkt_count = get_option('uxip_ee_free_tkt_count'); |
99 | - if ( !empty( $free_tkt_count ) ) |
|
100 | - $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
108 | + if ( !empty( $free_tkt_count ) ) { |
|
109 | + $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
110 | + } |
|
101 | 111 | |
102 | 112 | $paid_tkt_count = get_option('uxip_ee_paid_tkt_count'); |
103 | - if ( !empty( $paid_tkt_count ) ) |
|
104 | - $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
113 | + if ( !empty( $paid_tkt_count ) ) { |
|
114 | + $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
115 | + } |
|
105 | 116 | |
106 | 117 | $tkt_sold = get_option('uxip_ee_tkt_sold' ); |
107 | - if ( !empty($tkt_sold) ) |
|
108 | - $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
118 | + if ( !empty($tkt_sold) ) { |
|
119 | + $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
120 | + } |
|
109 | 121 | |
110 | 122 | //phpversion checking |
111 | 123 | $extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown'; |
@@ -181,7 +193,9 @@ discard block |
||
181 | 193 | |
182 | 194 | function espresso_data_collection_optin_notice() { |
183 | 195 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
184 | - if ( $ueip_has_notified ) return; |
|
196 | + if ( $ueip_has_notified ) { |
|
197 | + return; |
|
198 | + } |
|
185 | 199 | // $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
186 | 200 | // $settings_url = $settings_url . '#UXIP_settings'; |
187 | 201 | ?> |
@@ -221,7 +235,9 @@ discard block |
||
221 | 235 | function espresso_data_optin_ajax_handler() { |
222 | 236 | |
223 | 237 | //verify nonce |
224 | - if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit(); |
|
238 | + if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) { |
|
239 | + exit(); |
|
240 | + } |
|
225 | 241 | |
226 | 242 | //made it here so let's save the selection |
227 | 243 | // $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no'; |
@@ -251,13 +267,15 @@ discard block |
||
251 | 267 | $current = get_site_transient( 'update_plugins' ); |
252 | 268 | |
253 | 269 | foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
254 | - if ( isset( $current->response['plugin_file'] ) ) |
|
255 | - $update = true; |
|
270 | + if ( isset( $current->response['plugin_file'] ) ) { |
|
271 | + $update = true; |
|
272 | + } |
|
256 | 273 | } |
257 | 274 | |
258 | 275 | //it's possible that there is an update but an invalid site-license-key is in use |
259 | - if ( get_site_option('pue_json_error_' . $basename ) ) |
|
260 | - $update = true; |
|
276 | + if ( get_site_option('pue_json_error_' . $basename ) ) { |
|
277 | + $update = true; |
|
278 | + } |
|
261 | 279 | |
262 | 280 | return $update; |
263 | 281 | } |
@@ -302,46 +320,54 @@ discard block |
||
302 | 320 | $DTT = EE_Registry::instance()->load_model('Datetime'); |
303 | 321 | $TKT = EE_Registry::instance()->load_model('Ticket'); |
304 | 322 | $count = $EVT->count(); |
305 | - if ( $count > 0 ) |
|
306 | - update_option('uxip_ee4_all_events_count', $count); |
|
323 | + if ( $count > 0 ) { |
|
324 | + update_option('uxip_ee4_all_events_count', $count); |
|
325 | + } |
|
307 | 326 | |
308 | 327 | //next let's just get the number of ACTIVE events |
309 | 328 | $count_active = $EVT->get_active_events(array(), TRUE); |
310 | - if ( $count_active > 0 ) |
|
311 | - update_option('uxip_ee4_active_events_count', $count_active); |
|
329 | + if ( $count_active > 0 ) { |
|
330 | + update_option('uxip_ee4_active_events_count', $count_active); |
|
331 | + } |
|
312 | 332 | |
313 | 333 | //datetimes! |
314 | 334 | $dtt_count = $DTT->count(); |
315 | - if ( $dtt_count > 0 ) |
|
316 | - update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
335 | + if ( $dtt_count > 0 ) { |
|
336 | + update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
337 | + } |
|
317 | 338 | |
318 | 339 | |
319 | 340 | //dttsold |
320 | 341 | $dtt_sold = $DTT->sum(array(), 'DTT_sold'); |
321 | - if ( $dtt_sold > 0 ) |
|
322 | - update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
342 | + if ( $dtt_sold > 0 ) { |
|
343 | + update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
344 | + } |
|
323 | 345 | |
324 | 346 | //allticketcount |
325 | 347 | $all_tkt_count = $TKT->count(); |
326 | - if ( $all_tkt_count > 0 ) |
|
327 | - update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
348 | + if ( $all_tkt_count > 0 ) { |
|
349 | + update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
350 | + } |
|
328 | 351 | |
329 | 352 | //freetktcount |
330 | 353 | $_where = array( 'TKT_price' => 0 ); |
331 | 354 | $free_tkt_count = $TKT->count(array($_where)); |
332 | - if ( $free_tkt_count > 0 ) |
|
333 | - update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
355 | + if ( $free_tkt_count > 0 ) { |
|
356 | + update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
357 | + } |
|
334 | 358 | |
335 | 359 | //paidtktcount |
336 | 360 | $_where = array( 'TKT_price' => array('>', 0) ); |
337 | 361 | $paid_tkt_count = $TKT->count( array( $_where ) ); |
338 | - if ( $paid_tkt_count > 0 ) |
|
339 | - update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
362 | + if ( $paid_tkt_count > 0 ) { |
|
363 | + update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
364 | + } |
|
340 | 365 | |
341 | 366 | //tktsold |
342 | 367 | $tkt_sold = $TKT->sum( array(), 'TKT_sold' ); |
343 | - if( $tkt_sold > 0 ) |
|
344 | - update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
368 | + if( $tkt_sold > 0 ) { |
|
369 | + update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
370 | + } |
|
345 | 371 | |
346 | 372 | |
347 | 373 | set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\interfaces\ResettableInterface; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | 4 | /** |
5 | 5 | * Event Espresso |
6 | 6 | * |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @var WP $WP |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public abstract function run( $WP ); |
|
86 | + public abstract function run($WP); |
|
87 | 87 | |
88 | 88 | |
89 | 89 | |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * @param $module_name |
107 | 107 | * @return EED_Module |
108 | 108 | */ |
109 | - protected static function get_instance( $module_name = '' ) { |
|
110 | - $module_name = ! empty( $module_name ) ? $module_name : get_called_class(); |
|
111 | - if ( ! isset( EE_Registry::instance()->modules->{$module_name} ) || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module ) { |
|
112 | - EE_Registry::instance()->add_module( $module_name ); |
|
109 | + protected static function get_instance($module_name = '') { |
|
110 | + $module_name = ! empty($module_name) ? $module_name : get_called_class(); |
|
111 | + if ( ! isset(EE_Registry::instance()->modules->{$module_name} ) || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module) { |
|
112 | + EE_Registry::instance()->add_module($module_name); |
|
113 | 113 | } |
114 | - return EE_Registry::instance()->get_module( $module_name ); |
|
114 | + return EE_Registry::instance()->get_module($module_name); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return string |
124 | 124 | */ |
125 | 125 | public function module_name() { |
126 | - return get_class( $this ); |
|
126 | + return get_class($this); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php use EventEspresso\core\interfaces\ResettableInterface; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | +} |
|
4 | 6 | /** |
5 | 7 | * Event Espresso |
6 | 8 | * |
@@ -1,6 +1,8 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\interfaces\ResettableInterface; |
2 | 2 | |
3 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if (!defined( 'EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | +} |
|
4 | 6 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
5 | 7 | /** |
6 | 8 | * EE_Import class |
@@ -297,7 +299,7 @@ discard block |
||
297 | 299 | if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){ |
298 | 300 | EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso"))); |
299 | 301 | $export_from_site_a_to_b = false; |
300 | - }else{ |
|
302 | + } else{ |
|
301 | 303 | $old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url; |
302 | 304 | EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url())); |
303 | 305 | }; |
@@ -378,7 +380,7 @@ discard block |
||
378 | 380 | //now check that assumption was correct. If |
379 | 381 | if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) { |
380 | 382 | $model_name = $model_name_in_csv_data; |
381 | - }else { |
|
383 | + } else { |
|
382 | 384 | // no table info in the array and no table name passed to the function?? FAIL |
383 | 385 | EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
384 | 386 | return FALSE; |
@@ -402,7 +404,7 @@ discard block |
||
402 | 404 | //there is no primary key) |
403 | 405 | if($model->has_primary_key_field()){ |
404 | 406 | $id_in_csv = $model_object_data[$model->primary_key_name()]; |
405 | - }else{ |
|
407 | + } else{ |
|
406 | 408 | $id_in_csv = $model->get_index_primary_key_string($model_object_data); |
407 | 409 | } |
408 | 410 | |
@@ -412,7 +414,7 @@ discard block |
||
412 | 414 | //or just update. |
413 | 415 | if($export_from_site_a_to_b){ |
414 | 416 | $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
415 | - }else{//this is just a re-import |
|
417 | + } else{//this is just a re-import |
|
416 | 418 | $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
417 | 419 | } |
418 | 420 | if( $what_to_do == self::do_nothing ) { |
@@ -432,7 +434,7 @@ discard block |
||
432 | 434 | if($model->has_primary_key_field()){ |
433 | 435 | $old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID(); |
434 | 436 | $model_object_data[$model->primary_key_name()] = $conflicting->ID(); |
435 | - }else{ |
|
437 | + } else{ |
|
436 | 438 | //we want to update this conflicting item, instead of inserting a conflicting item |
437 | 439 | //so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields |
438 | 440 | //for the WHERE conditions in the update). At the time of this comment, there were no models like this |
@@ -444,9 +446,9 @@ discard block |
||
444 | 446 | } |
445 | 447 | if( $what_to_do == self::do_insert ) { |
446 | 448 | $old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
447 | - }elseif( $what_to_do == self::do_update ) { |
|
449 | + } elseif( $what_to_do == self::do_update ) { |
|
448 | 450 | $old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
449 | - }else{ |
|
451 | + } else{ |
|
450 | 452 | throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) ); |
451 | 453 | } |
452 | 454 | } |
@@ -474,7 +476,7 @@ discard block |
||
474 | 476 | //in the old data that we know of |
475 | 477 | if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){ |
476 | 478 | return self::do_update; |
477 | - }else{ |
|
479 | + } else{ |
|
478 | 480 | return self::do_insert; |
479 | 481 | } |
480 | 482 | } |
@@ -493,7 +495,7 @@ discard block |
||
493 | 495 | //in this case, check if this thing ACTUALLY exists in the database |
494 | 496 | if( $model->get_one_conflicting( $model_object_data ) ){ |
495 | 497 | return self::do_update; |
496 | - }else{ |
|
498 | + } else{ |
|
497 | 499 | return self::do_insert; |
498 | 500 | } |
499 | 501 | } |
@@ -524,7 +526,7 @@ discard block |
||
524 | 526 | try{ |
525 | 527 | $model_name_field = $model->get_field_containing_related_model_name(); |
526 | 528 | $models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to(); |
527 | - }catch( EE_Error $e ){ |
|
529 | + } catch( EE_Error $e ){ |
|
528 | 530 | $model_name_field = NULL; |
529 | 531 | $models_pointed_to_by_model_name_field = array(); |
530 | 532 | } |
@@ -545,7 +547,7 @@ discard block |
||
545 | 547 | $found_a_mapping = true; |
546 | 548 | break; |
547 | 549 | } |
548 | - }else{ |
|
550 | + } else{ |
|
549 | 551 | $model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in( |
550 | 552 | $model_object_data[ $field_obj->get_name() ], |
551 | 553 | $model_pointed_to_by_fk, |
@@ -560,7 +562,7 @@ discard block |
||
560 | 562 | |
561 | 563 | |
562 | 564 | } |
563 | - }else{ |
|
565 | + } else{ |
|
564 | 566 | //it's a string foreign key (which we leave alone, because those are things |
565 | 567 | //like country names, which we'd really rather not make 2 USAs etc (we'd actually |
566 | 568 | //prefer to just update one) |
@@ -603,14 +605,14 @@ discard block |
||
603 | 605 | if( isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){ |
604 | 606 | |
605 | 607 | return $old_db_to_new_db_mapping[ $model_name ][ $object_id ]; |
606 | - }elseif( $object_id == '0' || $object_id == '' ) { |
|
608 | + } elseif( $object_id == '0' || $object_id == '' ) { |
|
607 | 609 | //leave as-is |
608 | 610 | return $object_id; |
609 | - }elseif( $export_from_site_a_to_b ){ |
|
611 | + } elseif( $export_from_site_a_to_b ){ |
|
610 | 612 | //we couldn't find a mapping for this, and it's from a different site, |
611 | 613 | //so blank it out |
612 | 614 | return NULL; |
613 | - }elseif( ! $export_from_site_a_to_b ) { |
|
615 | + } elseif( ! $export_from_site_a_to_b ) { |
|
614 | 616 | //we coudln't find a mapping for this, but it's from thsi DB anyway |
615 | 617 | //so let's just leave it as-is |
616 | 618 | return $object_id; |
@@ -631,7 +633,7 @@ discard block |
||
631 | 633 | if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){ |
632 | 634 | $effective_id = $model_object_data[$model->primary_key_name()]; |
633 | 635 | unset($model_object_data[$model->primary_key_name()]); |
634 | - }else{ |
|
636 | + } else{ |
|
635 | 637 | $effective_id = $model->get_index_primary_key_string( $model_object_data ); |
636 | 638 | } |
637 | 639 | //the model takes care of validating the CSV's input |
@@ -641,7 +643,7 @@ discard block |
||
641 | 643 | $old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id; |
642 | 644 | $this->_total_inserts++; |
643 | 645 | EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data))); |
644 | - }else{ |
|
646 | + } else{ |
|
645 | 647 | $this->_total_insert_errors++; |
646 | 648 | //put the ID used back in there for the error message |
647 | 649 | if($model->has_primary_key_field()){ |
@@ -649,7 +651,7 @@ discard block |
||
649 | 651 | } |
650 | 652 | EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ ); |
651 | 653 | } |
652 | - }catch(EE_Error $e){ |
|
654 | + } catch(EE_Error $e){ |
|
653 | 655 | $this->_total_insert_errors++; |
654 | 656 | if($model->has_primary_key_field()){ |
655 | 657 | $model_object_data[$model->primary_key_name()] = $effective_id; |
@@ -676,12 +678,12 @@ discard block |
||
676 | 678 | $conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]); |
677 | 679 | //remove the primary key because we shouldn't use it for updating |
678 | 680 | unset($model_object_data_for_update[$model->primary_key_name()]); |
679 | - }elseif($model->get_combined_primary_key_fields() > 1 ){ |
|
681 | + } elseif($model->get_combined_primary_key_fields() > 1 ){ |
|
680 | 682 | $conditions = array(); |
681 | 683 | foreach($model->get_combined_primary_key_fields() as $key_field){ |
682 | 684 | $conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()]; |
683 | 685 | } |
684 | - }else{ |
|
686 | + } else{ |
|
685 | 687 | $model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey) |
686 | 688 | } |
687 | 689 | |
@@ -695,23 +697,23 @@ discard block |
||
695 | 697 | //and so we record what record ended up being updated using the mapping |
696 | 698 | if( $model->has_primary_key_field() ){ |
697 | 699 | $new_key_for_mapping = $model_object_data[ $model->primary_key_name() ]; |
698 | - }else{ |
|
700 | + } else{ |
|
699 | 701 | //no primary key just a combined key |
700 | 702 | $new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data ); |
701 | 703 | } |
702 | 704 | $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping; |
703 | - }else{ |
|
705 | + } else{ |
|
704 | 706 | $matched_items = $model->get_all(array($conditions)); |
705 | 707 | if( ! $matched_items){ |
706 | 708 | //no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck? |
707 | 709 | $this->_total_update_errors++; |
708 | 710 | EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ ); |
709 | - }else{ |
|
711 | + } else{ |
|
710 | 712 | $this->_total_updates++; |
711 | 713 | EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data))); |
712 | 714 | } |
713 | 715 | } |
714 | - }catch(EE_Error $e){ |
|
716 | + } catch(EE_Error $e){ |
|
715 | 717 | $this->_total_update_errors++; |
716 | 718 | $basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage()); |
717 | 719 | $debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\interfaces\ResettableInterface; |
2 | 2 | |
3 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
5 | 5 | /** |
6 | 6 | * EE_Import class |
7 | 7 | * |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Import )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Import)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * Resets the importer |
69 | 69 | * @return EE_Import |
70 | 70 | */ |
71 | - public static function reset(){ |
|
71 | + public static function reset() { |
|
72 | 72 | self::$_instance = null; |
73 | 73 | return self::instance(); |
74 | 74 | } |
@@ -86,27 +86,27 @@ discard block |
||
86 | 86 | * @param string $type - type of file to import |
87 | 87 | * @ return string |
88 | 88 | */ |
89 | - public function upload_form ( $title, $intro, $form_url, $action, $type ) { |
|
89 | + public function upload_form($title, $intro, $form_url, $action, $type) { |
|
90 | 90 | |
91 | - $form_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => $action ), $form_url ); |
|
91 | + $form_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => $action), $form_url); |
|
92 | 92 | |
93 | 93 | ob_start(); |
94 | 94 | ?> |
95 | 95 | <div class="ee-upload-form-dv"> |
96 | - <h3><?php echo $title;?></h3> |
|
97 | - <p><?php echo $intro;?></p> |
|
96 | + <h3><?php echo $title; ?></h3> |
|
97 | + <p><?php echo $intro; ?></p> |
|
98 | 98 | |
99 | 99 | <form action="<?php echo $form_url?>" method="post" enctype="multipart/form-data"> |
100 | - <input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time();?>"> |
|
101 | - <input name="import" type="hidden" value="<?php echo $type;?>" /> |
|
100 | + <input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time(); ?>"> |
|
101 | + <input name="import" type="hidden" value="<?php echo $type; ?>" /> |
|
102 | 102 | <input type="file" name="file[]" size="90" > |
103 | - <input class="button-primary" type="submit" value="<?php _e( 'Upload File', 'event_espresso' );?>"> |
|
103 | + <input class="button-primary" type="submit" value="<?php _e('Upload File', 'event_espresso'); ?>"> |
|
104 | 104 | </form> |
105 | 105 | |
106 | 106 | <p class="ee-attention"> |
107 | - <b><?php _e( 'Attention', 'event_espresso' );?></b><br/> |
|
108 | - <?php echo sprintf( __( 'Accepts .%s file types only.', 'event_espresso' ), $type ) ;?> |
|
109 | - <?php echo __( 'Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso' );?> |
|
107 | + <b><?php _e('Attention', 'event_espresso'); ?></b><br/> |
|
108 | + <?php echo sprintf(__('Accepts .%s file types only.', 'event_espresso'), $type); ?> |
|
109 | + <?php echo __('Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso'); ?> |
|
110 | 110 | </p> |
111 | 111 | |
112 | 112 | </div> |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function import() { |
129 | 129 | |
130 | - require_once( EE_CLASSES . 'EE_CSV.class.php' ); |
|
130 | + require_once(EE_CLASSES.'EE_CSV.class.php'); |
|
131 | 131 | $this->EE_CSV = EE_CSV::instance(); |
132 | 132 | |
133 | - if ( isset( $_REQUEST['import'] )) { |
|
134 | - if( isset( $_POST['csv_submitted'] )) { |
|
133 | + if (isset($_REQUEST['import'])) { |
|
134 | + if (isset($_POST['csv_submitted'])) { |
|
135 | 135 | |
136 | - switch ( $_FILES['file']['error'][0] ) { |
|
136 | + switch ($_FILES['file']['error'][0]) { |
|
137 | 137 | case UPLOAD_ERR_OK: |
138 | 138 | $error_msg = FALSE; |
139 | 139 | break; |
@@ -163,32 +163,32 @@ discard block |
||
163 | 163 | break; |
164 | 164 | } |
165 | 165 | |
166 | - if ( ! $error_msg ) { |
|
166 | + if ( ! $error_msg) { |
|
167 | 167 | |
168 | - $filename = $_FILES['file']['name'][0]; |
|
169 | - $file_ext = substr( strrchr( $filename, '.' ), 1 ); |
|
170 | - $file_type = $_FILES['file']['type'][0]; |
|
171 | - $temp_file = $_FILES['file']['tmp_name'][0]; |
|
172 | - $filesize = $_FILES['file']['size'][0] / 1024;//convert from bytes to KB |
|
168 | + $filename = $_FILES['file']['name'][0]; |
|
169 | + $file_ext = substr(strrchr($filename, '.'), 1); |
|
170 | + $file_type = $_FILES['file']['type'][0]; |
|
171 | + $temp_file = $_FILES['file']['tmp_name'][0]; |
|
172 | + $filesize = $_FILES['file']['size'][0] / 1024; //convert from bytes to KB |
|
173 | 173 | |
174 | - if ( $file_ext=='csv' ) { |
|
174 | + if ($file_ext == 'csv') { |
|
175 | 175 | |
176 | - $max_upload = $this->EE_CSV->get_max_upload_size();//max upload size in KB |
|
177 | - if ( $filesize < $max_upload || true) { |
|
176 | + $max_upload = $this->EE_CSV->get_max_upload_size(); //max upload size in KB |
|
177 | + if ($filesize < $max_upload || true) { |
|
178 | 178 | |
179 | - $wp_upload_dir = str_replace( array( '\\', '/' ), DS, wp_upload_dir()); |
|
180 | - $path_to_file = $wp_upload_dir['basedir'] . DS . 'espresso' . DS . $filename; |
|
179 | + $wp_upload_dir = str_replace(array('\\', '/'), DS, wp_upload_dir()); |
|
180 | + $path_to_file = $wp_upload_dir['basedir'].DS.'espresso'.DS.$filename; |
|
181 | 181 | |
182 | - if( move_uploaded_file( $temp_file, $path_to_file )) { |
|
182 | + if (move_uploaded_file($temp_file, $path_to_file)) { |
|
183 | 183 | |
184 | 184 | // convert csv to array |
185 | - $this->csv_array = $this->EE_CSV->import_csv_to_model_data_array( $path_to_file ); |
|
185 | + $this->csv_array = $this->EE_CSV->import_csv_to_model_data_array($path_to_file); |
|
186 | 186 | |
187 | 187 | // was data successfully stored in an array? |
188 | - if ( is_array( $this->csv_array ) ) { |
|
188 | + if (is_array($this->csv_array)) { |
|
189 | 189 | |
190 | - $import_what = str_replace( 'csv_import_', '', $_REQUEST['action'] ); |
|
191 | - $import_what = str_replace( '_', ' ', ucwords( $import_what )); |
|
190 | + $import_what = str_replace('csv_import_', '', $_REQUEST['action']); |
|
191 | + $import_what = str_replace('_', ' ', ucwords($import_what)); |
|
192 | 192 | $processed_data = $this->csv_array; |
193 | 193 | $this->columns_to_save = FALSE; |
194 | 194 | |
@@ -207,33 +207,33 @@ discard block |
||
207 | 207 | |
208 | 208 | } |
209 | 209 | // save processed codes to db |
210 | - if ( $this->save_csv_data_array_to_db( $processed_data, $this->columns_to_save ) ) { |
|
210 | + if ($this->save_csv_data_array_to_db($processed_data, $this->columns_to_save)) { |
|
211 | 211 | return TRUE; |
212 | 212 | |
213 | 213 | } |
214 | 214 | } else { |
215 | 215 | // no array? must be an error |
216 | - EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ ); |
|
216 | + EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__); |
|
217 | 217 | return FALSE; |
218 | 218 | } |
219 | 219 | |
220 | 220 | } else { |
221 | - EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ ); |
|
221 | + EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__); |
|
222 | 222 | return FALSE; |
223 | 223 | } |
224 | 224 | |
225 | 225 | } else { |
226 | - EE_Error::add_error( sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"),$filename,$max_upload), __FILE__, __FUNCTION__, __LINE__ ); |
|
226 | + EE_Error::add_error(sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"), $filename, $max_upload), __FILE__, __FUNCTION__, __LINE__); |
|
227 | 227 | return FALSE; |
228 | 228 | } |
229 | 229 | |
230 | 230 | } else { |
231 | - EE_Error::add_error( sprintf(__("%s had an invalid file extension, not uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ ); |
|
231 | + EE_Error::add_error(sprintf(__("%s had an invalid file extension, not uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__); |
|
232 | 232 | return FALSE; |
233 | 233 | } |
234 | 234 | |
235 | 235 | } else { |
236 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
236 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
237 | 237 | return FALSE; |
238 | 238 | } |
239 | 239 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return TRUE on success, FALSE on fail |
279 | 279 | * @throws \EE_Error |
280 | 280 | */ |
281 | - public function save_csv_data_array_to_db( $csv_data_array, $model_name = FALSE ) { |
|
281 | + public function save_csv_data_array_to_db($csv_data_array, $model_name = FALSE) { |
|
282 | 282 | |
283 | 283 | |
284 | 284 | $success = FALSE; |
@@ -288,22 +288,22 @@ discard block |
||
288 | 288 | $export_from_site_a_to_b = true; |
289 | 289 | // first level of array is not table information but a table name was passed to the function |
290 | 290 | // array is only two levels deep, so let's fix that by adding a level, else the next steps will fail |
291 | - if($model_name){ |
|
291 | + if ($model_name) { |
|
292 | 292 | $csv_data_array = array($csv_data_array); |
293 | 293 | } |
294 | 294 | // begin looking through the $csv_data_array, expecting the toplevel key to be the model's name... |
295 | 295 | $old_site_url = 'none-specified'; |
296 | 296 | |
297 | 297 | //hanlde metadata |
298 | - if(isset($csv_data_array[EE_CSV::metadata_header]) ){ |
|
298 | + if (isset($csv_data_array[EE_CSV::metadata_header])) { |
|
299 | 299 | $csv_metadata = array_shift($csv_data_array[EE_CSV::metadata_header]); |
300 | 300 | //ok so its metadata, dont try to save it to ehte db obviously... |
301 | - if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){ |
|
301 | + if (isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()) { |
|
302 | 302 | EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso"))); |
303 | 303 | $export_from_site_a_to_b = false; |
304 | - }else{ |
|
305 | - $old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url; |
|
306 | - EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url())); |
|
304 | + } else { |
|
305 | + $old_site_url = isset($csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url; |
|
306 | + EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"), $old_site_url, site_url())); |
|
307 | 307 | }; |
308 | 308 | unset($csv_data_array[EE_CSV::metadata_header]); |
309 | 309 | } |
@@ -312,30 +312,30 @@ discard block |
||
312 | 312 | * the value will be the newly-inserted ID. |
313 | 313 | * If we have already imported data from the same website via CSV, it shoudl be kept in this wp option |
314 | 314 | */ |
315 | - $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url),array()); |
|
316 | - if( $old_db_to_new_db_mapping){ |
|
317 | - EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"),$old_site_url,site_url())); |
|
315 | + $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url), array()); |
|
316 | + if ($old_db_to_new_db_mapping) { |
|
317 | + EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"), $old_site_url, site_url())); |
|
318 | 318 | } |
319 | 319 | $old_db_to_new_db_mapping = $this->save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping); |
320 | 320 | |
321 | 321 | //save the mapping from old db to new db in case they try re-importing the same data from the same website again |
322 | - update_option('ee_id_mapping_from'.sanitize_title($old_site_url),$old_db_to_new_db_mapping); |
|
322 | + update_option('ee_id_mapping_from'.sanitize_title($old_site_url), $old_db_to_new_db_mapping); |
|
323 | 323 | |
324 | - if ( $this->_total_updates > 0 ) { |
|
325 | - EE_Error::add_success( sprintf(__("%s existing records in the database were updated.", "event_espresso"),$this->_total_updates)); |
|
324 | + if ($this->_total_updates > 0) { |
|
325 | + EE_Error::add_success(sprintf(__("%s existing records in the database were updated.", "event_espresso"), $this->_total_updates)); |
|
326 | 326 | $success = true; |
327 | 327 | } |
328 | - if ( $this->_total_inserts > 0 ) { |
|
329 | - EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"),$this->_total_inserts)); |
|
328 | + if ($this->_total_inserts > 0) { |
|
329 | + EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"), $this->_total_inserts)); |
|
330 | 330 | $success = true; |
331 | 331 | } |
332 | 332 | |
333 | - if ( $this->_total_update_errors > 0 ) { |
|
334 | - EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"),$this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__ ); |
|
333 | + if ($this->_total_update_errors > 0) { |
|
334 | + EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"), $this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__); |
|
335 | 335 | $error = true; |
336 | 336 | } |
337 | - if ( $this->_total_insert_errors > 0 ) { |
|
338 | - EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"),$this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__ ); |
|
337 | + if ($this->_total_insert_errors > 0) { |
|
338 | + EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"), $this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__); |
|
339 | 339 | $error = true; |
340 | 340 | } |
341 | 341 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | EEM_Ticket::instance()->update_tickets_sold(EEM_Ticket::instance()->get_all()); |
345 | 345 | |
346 | 346 | // if there was at least one success and absolutely no errors |
347 | - if ( $success && ! $error ) { |
|
347 | + if ($success && ! $error) { |
|
348 | 348 | return TRUE; |
349 | 349 | } else { |
350 | 350 | return FALSE; |
@@ -376,81 +376,81 @@ discard block |
||
376 | 376 | * @param type $old_db_to_new_db_mapping |
377 | 377 | * @return array updated $old_db_to_new_db_mapping |
378 | 378 | */ |
379 | - public function save_data_rows_to_db( $csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping ) { |
|
380 | - foreach ( $csv_data_array as $model_name_in_csv_data => $model_data_from_import ) { |
|
379 | + public function save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping) { |
|
380 | + foreach ($csv_data_array as $model_name_in_csv_data => $model_data_from_import) { |
|
381 | 381 | //now check that assumption was correct. If |
382 | - if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) { |
|
382 | + if (EE_Registry::instance()->is_model_name($model_name_in_csv_data)) { |
|
383 | 383 | $model_name = $model_name_in_csv_data; |
384 | - }else { |
|
384 | + } else { |
|
385 | 385 | // no table info in the array and no table name passed to the function?? FAIL |
386 | - EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
386 | + EE_Error::add_error(__('No table information was specified and/or found, therefore the import could not be completed', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
387 | 387 | return FALSE; |
388 | 388 | } |
389 | 389 | /* @var $model EEM_Base */ |
390 | 390 | $model = EE_Registry::instance()->load_model($model_name); |
391 | 391 | |
392 | 392 | //so without further ado, scanning all the data provided for primary keys and their inital values |
393 | - foreach ( $model_data_from_import as $model_object_data ) { |
|
393 | + foreach ($model_data_from_import as $model_object_data) { |
|
394 | 394 | //before we do ANYTHING, make sure the csv row wasn't just completely blank |
395 | 395 | $row_is_completely_empty = true; |
396 | - foreach($model_object_data as $field){ |
|
397 | - if($field){ |
|
396 | + foreach ($model_object_data as $field) { |
|
397 | + if ($field) { |
|
398 | 398 | $row_is_completely_empty = false; |
399 | 399 | } |
400 | 400 | } |
401 | - if($row_is_completely_empty){ |
|
401 | + if ($row_is_completely_empty) { |
|
402 | 402 | continue; |
403 | 403 | } |
404 | 404 | //find the PK in the row of data (or a combined key if |
405 | 405 | //there is no primary key) |
406 | - if($model->has_primary_key_field()){ |
|
407 | - $id_in_csv = $model_object_data[$model->primary_key_name()]; |
|
408 | - }else{ |
|
406 | + if ($model->has_primary_key_field()) { |
|
407 | + $id_in_csv = $model_object_data[$model->primary_key_name()]; |
|
408 | + } else { |
|
409 | 409 | $id_in_csv = $model->get_index_primary_key_string($model_object_data); |
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | - $model_object_data = $this->_replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b ); |
|
413 | + $model_object_data = $this->_replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b); |
|
414 | 414 | //now we need to decide if we're going to add a new model object given the $model_object_data, |
415 | 415 | //or just update. |
416 | - if($export_from_site_a_to_b){ |
|
417 | - $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
|
418 | - }else{//this is just a re-import |
|
419 | - $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
|
416 | + if ($export_from_site_a_to_b) { |
|
417 | + $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping); |
|
418 | + } else {//this is just a re-import |
|
419 | + $what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping); |
|
420 | 420 | } |
421 | - if( $what_to_do == self::do_nothing ) { |
|
421 | + if ($what_to_do == self::do_nothing) { |
|
422 | 422 | continue; |
423 | 423 | } |
424 | 424 | |
425 | 425 | //double-check we actually want to insert, if that's what we're planning |
426 | 426 | //based on whether this item would be unique in the DB or not |
427 | - if( $what_to_do == self::do_insert ) { |
|
427 | + if ($what_to_do == self::do_insert) { |
|
428 | 428 | //we're supposed to be inserting. But wait, will this thing |
429 | 429 | //be acceptable if inserted? |
430 | - $conflicting = $model->get_one_conflicting( $model_object_data, false ); |
|
431 | - if($conflicting){ |
|
430 | + $conflicting = $model->get_one_conflicting($model_object_data, false); |
|
431 | + if ($conflicting) { |
|
432 | 432 | //ok, this item would conflict if inserted. Just update the item that it conflicts with. |
433 | 433 | $what_to_do = self::do_update; |
434 | 434 | //and if this model has a primary key, remember its mapping |
435 | - if($model->has_primary_key_field()){ |
|
435 | + if ($model->has_primary_key_field()) { |
|
436 | 436 | $old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID(); |
437 | 437 | $model_object_data[$model->primary_key_name()] = $conflicting->ID(); |
438 | - }else{ |
|
438 | + } else { |
|
439 | 439 | //we want to update this conflicting item, instead of inserting a conflicting item |
440 | 440 | //so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields |
441 | 441 | //for the WHERE conditions in the update). At the time of this comment, there were no models like this |
442 | - foreach($model->get_combined_primary_key_fields() as $key_field){ |
|
442 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
443 | 443 | $model_object_data[$key_field->get_name()] = $conflicting->get($key_field->get_name()); |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
447 | 447 | } |
448 | - if( $what_to_do == self::do_insert ) { |
|
449 | - $old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
|
450 | - }elseif( $what_to_do == self::do_update ) { |
|
451 | - $old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ); |
|
452 | - }else{ |
|
453 | - throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) ); |
|
448 | + if ($what_to_do == self::do_insert) { |
|
449 | + $old_db_to_new_db_mapping = $this->_insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping); |
|
450 | + }elseif ($what_to_do == self::do_update) { |
|
451 | + $old_db_to_new_db_mapping = $this->_update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping); |
|
452 | + } else { |
|
453 | + throw new EE_Error(sprintf(__('Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso'), $what_to_do)); |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | } |
@@ -471,13 +471,13 @@ discard block |
||
471 | 471 | * @param array $old_db_to_new_db_mapping by reference so it can be modified |
472 | 472 | * @return string one of the consts on this class that starts with do_* |
473 | 473 | */ |
474 | - protected function _decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) { |
|
474 | + protected function _decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) { |
|
475 | 475 | $model_name = $model->get_this_model_name(); |
476 | 476 | //if it's a site-to-site export-and-import, see if this modelobject's id |
477 | 477 | //in the old data that we know of |
478 | - if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){ |
|
478 | + if (isset($old_db_to_new_db_mapping[$model_name][$id_in_csv])) { |
|
479 | 479 | return self::do_update; |
480 | - }else{ |
|
480 | + } else { |
|
481 | 481 | return self::do_insert; |
482 | 482 | } |
483 | 483 | } |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | * @param type $old_db_to_new_db_mapping |
493 | 493 | * @return |
494 | 494 | */ |
495 | - protected function _decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model ) { |
|
495 | + protected function _decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model) { |
|
496 | 496 | //in this case, check if this thing ACTUALLY exists in the database |
497 | - if( $model->get_one_conflicting( $model_object_data ) ){ |
|
497 | + if ($model->get_one_conflicting($model_object_data)) { |
|
498 | 498 | return self::do_update; |
499 | - }else{ |
|
499 | + } else { |
|
500 | 500 | return self::do_insert; |
501 | 501 | } |
502 | 502 | } |
@@ -515,55 +515,55 @@ discard block |
||
515 | 515 | * @param boolean $export_from_site_a_to_b |
516 | 516 | * @return array updated model object data with temp IDs removed |
517 | 517 | */ |
518 | - protected function _replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b ) { |
|
518 | + protected function _replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b) { |
|
519 | 519 | //if this model object's primary key is in the mapping, replace it |
520 | - if( $model->has_primary_key_field() && |
|
520 | + if ($model->has_primary_key_field() && |
|
521 | 521 | $model->get_primary_key_field()->is_auto_increment() && |
522 | - isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ] ) && |
|
523 | - isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ] ) ) { |
|
524 | - $model_object_data[ $model->primary_key_name() ] = $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ]; |
|
522 | + isset($old_db_to_new_db_mapping[$model->get_this_model_name()]) && |
|
523 | + isset($old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]])) { |
|
524 | + $model_object_data[$model->primary_key_name()] = $old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]]; |
|
525 | 525 | } |
526 | 526 | |
527 | - try{ |
|
527 | + try { |
|
528 | 528 | $model_name_field = $model->get_field_containing_related_model_name(); |
529 | 529 | $models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to(); |
530 | - }catch( EE_Error $e ){ |
|
530 | + } catch (EE_Error $e) { |
|
531 | 531 | $model_name_field = NULL; |
532 | 532 | $models_pointed_to_by_model_name_field = array(); |
533 | 533 | } |
534 | - foreach( $model->field_settings( true ) as $field_obj ){ |
|
535 | - if( $field_obj instanceof EE_Foreign_Key_Int_Field ) { |
|
534 | + foreach ($model->field_settings(true) as $field_obj) { |
|
535 | + if ($field_obj instanceof EE_Foreign_Key_Int_Field) { |
|
536 | 536 | $models_pointed_to = $field_obj->get_model_names_pointed_to(); |
537 | 537 | $found_a_mapping = false; |
538 | - foreach( $models_pointed_to as $model_pointed_to_by_fk ) { |
|
538 | + foreach ($models_pointed_to as $model_pointed_to_by_fk) { |
|
539 | 539 | |
540 | - if( $model_name_field ){ |
|
541 | - $value_of_model_name_field = $model_object_data[ $model_name_field->get_name() ]; |
|
542 | - if( $value_of_model_name_field == $model_pointed_to_by_fk ) { |
|
543 | - $model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in( |
|
544 | - $model_object_data[ $field_obj->get_name() ], |
|
540 | + if ($model_name_field) { |
|
541 | + $value_of_model_name_field = $model_object_data[$model_name_field->get_name()]; |
|
542 | + if ($value_of_model_name_field == $model_pointed_to_by_fk) { |
|
543 | + $model_object_data[$field_obj->get_name()] = $this->_find_mapping_in( |
|
544 | + $model_object_data[$field_obj->get_name()], |
|
545 | 545 | $model_pointed_to_by_fk, |
546 | 546 | $old_db_to_new_db_mapping, |
547 | 547 | $export_from_site_a_to_b ); |
548 | 548 | $found_a_mapping = true; |
549 | 549 | break; |
550 | 550 | } |
551 | - }else{ |
|
552 | - $model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in( |
|
553 | - $model_object_data[ $field_obj->get_name() ], |
|
551 | + } else { |
|
552 | + $model_object_data[$field_obj->get_name()] = $this->_find_mapping_in( |
|
553 | + $model_object_data[$field_obj->get_name()], |
|
554 | 554 | $model_pointed_to_by_fk, |
555 | 555 | $old_db_to_new_db_mapping, |
556 | 556 | $export_from_site_a_to_b ); |
557 | 557 | $found_a_mapping = true; |
558 | 558 | } |
559 | 559 | //once we've found a mapping for this field no need to continue |
560 | - if( $found_a_mapping ) { |
|
560 | + if ($found_a_mapping) { |
|
561 | 561 | break; |
562 | 562 | } |
563 | 563 | |
564 | 564 | |
565 | 565 | } |
566 | - }else{ |
|
566 | + } else { |
|
567 | 567 | //it's a string foreign key (which we leave alone, because those are things |
568 | 568 | //like country names, which we'd really rather not make 2 USAs etc (we'd actually |
569 | 569 | //prefer to just update one) |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | } |
572 | 572 | } |
573 | 573 | // |
574 | - if( $model instanceof EEM_Term_Taxonomy ){ |
|
575 | - $model_object_data = $this->_handle_split_term_ids( $model_object_data ); |
|
574 | + if ($model instanceof EEM_Term_Taxonomy) { |
|
575 | + $model_object_data = $this->_handle_split_term_ids($model_object_data); |
|
576 | 576 | } |
577 | 577 | return $model_object_data; |
578 | 578 | } |
@@ -584,11 +584,11 @@ discard block |
||
584 | 584 | * @param type $model_object_data |
585 | 585 | * @return array new model object data |
586 | 586 | */ |
587 | - protected function _handle_split_term_ids( $model_object_data ){ |
|
588 | - if( isset( $model_object_data['term_id'] ) && isset( $model_object_data[ 'taxonomy' ]) && apply_filters( 'FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists( 'wp_get_split_term' ), $model_object_data ) ) { |
|
589 | - $new_term_id = wp_get_split_term( $model_object_data[ 'term_id' ], $model_object_data[ 'taxonomy' ] ); |
|
590 | - if( $new_term_id ){ |
|
591 | - $model_object_data[ 'term_id' ] = $new_term_id; |
|
587 | + protected function _handle_split_term_ids($model_object_data) { |
|
588 | + if (isset($model_object_data['term_id']) && isset($model_object_data['taxonomy']) && apply_filters('FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists('wp_get_split_term'), $model_object_data)) { |
|
589 | + $new_term_id = wp_get_split_term($model_object_data['term_id'], $model_object_data['taxonomy']); |
|
590 | + if ($new_term_id) { |
|
591 | + $model_object_data['term_id'] = $new_term_id; |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | return $model_object_data; |
@@ -602,18 +602,18 @@ discard block |
||
602 | 602 | * @param type $export_from_site_a_to_b |
603 | 603 | * @return int |
604 | 604 | */ |
605 | - protected function _find_mapping_in( $object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) { |
|
606 | - if( isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){ |
|
605 | + protected function _find_mapping_in($object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) { |
|
606 | + if (isset($old_db_to_new_db_mapping[$model_name][$object_id])) { |
|
607 | 607 | |
608 | - return $old_db_to_new_db_mapping[ $model_name ][ $object_id ]; |
|
609 | - }elseif( $object_id == '0' || $object_id == '' ) { |
|
608 | + return $old_db_to_new_db_mapping[$model_name][$object_id]; |
|
609 | + }elseif ($object_id == '0' || $object_id == '') { |
|
610 | 610 | //leave as-is |
611 | 611 | return $object_id; |
612 | - }elseif( $export_from_site_a_to_b ){ |
|
612 | + }elseif ($export_from_site_a_to_b) { |
|
613 | 613 | //we couldn't find a mapping for this, and it's from a different site, |
614 | 614 | //so blank it out |
615 | 615 | return NULL; |
616 | - }elseif( ! $export_from_site_a_to_b ) { |
|
616 | + }elseif ( ! $export_from_site_a_to_b) { |
|
617 | 617 | //we coudln't find a mapping for this, but it's from thsi DB anyway |
618 | 618 | //so let's just leave it as-is |
619 | 619 | return $object_id; |
@@ -628,36 +628,36 @@ discard block |
||
628 | 628 | * @param type $old_db_to_new_db_mapping |
629 | 629 | * @return array updated $old_db_to_new_db_mapping |
630 | 630 | */ |
631 | - protected function _insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) { |
|
631 | + protected function _insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) { |
|
632 | 632 | //remove the primary key, if there is one (we don't want it for inserts OR updates) |
633 | 633 | //we'll put it back in if we need it |
634 | - if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){ |
|
634 | + if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()) { |
|
635 | 635 | $effective_id = $model_object_data[$model->primary_key_name()]; |
636 | 636 | unset($model_object_data[$model->primary_key_name()]); |
637 | - }else{ |
|
638 | - $effective_id = $model->get_index_primary_key_string( $model_object_data ); |
|
637 | + } else { |
|
638 | + $effective_id = $model->get_index_primary_key_string($model_object_data); |
|
639 | 639 | } |
640 | 640 | //the model takes care of validating the CSV's input |
641 | - try{ |
|
641 | + try { |
|
642 | 642 | $new_id = $model->insert($model_object_data); |
643 | - if( $new_id ){ |
|
643 | + if ($new_id) { |
|
644 | 644 | $old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id; |
645 | 645 | $this->_total_inserts++; |
646 | - EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data))); |
|
647 | - }else{ |
|
646 | + EE_Error::add_success(sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"), $model->get_this_model_name(), $new_id, implode(",", $model_object_data))); |
|
647 | + } else { |
|
648 | 648 | $this->_total_insert_errors++; |
649 | 649 | //put the ID used back in there for the error message |
650 | - if($model->has_primary_key_field()){ |
|
650 | + if ($model->has_primary_key_field()) { |
|
651 | 651 | $model_object_data[$model->primary_key_name()] = $effective_id; |
652 | 652 | } |
653 | - EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ ); |
|
653 | + EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__); |
|
654 | 654 | } |
655 | - }catch(EE_Error $e){ |
|
655 | + } catch (EE_Error $e) { |
|
656 | 656 | $this->_total_insert_errors++; |
657 | - if($model->has_primary_key_field()){ |
|
657 | + if ($model->has_primary_key_field()) { |
|
658 | 658 | $model_object_data[$model->primary_key_name()] = $effective_id; |
659 | 659 | } |
660 | - EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage()), __FILE__, __FUNCTION__, __LINE__ ); |
|
660 | + EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
661 | 661 | } |
662 | 662 | return $old_db_to_new_db_mapping; |
663 | 663 | } |
@@ -670,55 +670,55 @@ discard block |
||
670 | 670 | * @param array $old_db_to_new_db_mapping |
671 | 671 | * @return array updated $old_db_to_new_db_mapping |
672 | 672 | */ |
673 | - protected function _update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) { |
|
674 | - try{ |
|
673 | + protected function _update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) { |
|
674 | + try { |
|
675 | 675 | //let's keep two copies of the model object data: |
676 | 676 | //one for performing an update, one for everthing else |
677 | 677 | $model_object_data_for_update = $model_object_data; |
678 | - if($model->has_primary_key_field()){ |
|
678 | + if ($model->has_primary_key_field()) { |
|
679 | 679 | $conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]); |
680 | 680 | //remove the primary key because we shouldn't use it for updating |
681 | 681 | unset($model_object_data_for_update[$model->primary_key_name()]); |
682 | - }elseif($model->get_combined_primary_key_fields() > 1 ){ |
|
682 | + }elseif ($model->get_combined_primary_key_fields() > 1) { |
|
683 | 683 | $conditions = array(); |
684 | - foreach($model->get_combined_primary_key_fields() as $key_field){ |
|
684 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
685 | 685 | $conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()]; |
686 | 686 | } |
687 | - }else{ |
|
688 | - $model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey) |
|
687 | + } else { |
|
688 | + $model->primary_key_name(); //this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey) |
|
689 | 689 | } |
690 | 690 | |
691 | - $success = $model->update($model_object_data_for_update,array($conditions)); |
|
692 | - if($success){ |
|
691 | + $success = $model->update($model_object_data_for_update, array($conditions)); |
|
692 | + if ($success) { |
|
693 | 693 | $this->_total_updates++; |
694 | - EE_Error::add_success( sprintf(__("Successfully updated %s with csv data %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data_for_update))); |
|
694 | + EE_Error::add_success(sprintf(__("Successfully updated %s with csv data %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data_for_update))); |
|
695 | 695 | //we should still record the mapping even though it was an update |
696 | 696 | //because if we were going to insert somethign but it was going to conflict |
697 | 697 | //we would have last-minute decided to update. So we'd like to know what we updated |
698 | 698 | //and so we record what record ended up being updated using the mapping |
699 | - if( $model->has_primary_key_field() ){ |
|
700 | - $new_key_for_mapping = $model_object_data[ $model->primary_key_name() ]; |
|
701 | - }else{ |
|
699 | + if ($model->has_primary_key_field()) { |
|
700 | + $new_key_for_mapping = $model_object_data[$model->primary_key_name()]; |
|
701 | + } else { |
|
702 | 702 | //no primary key just a combined key |
703 | - $new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data ); |
|
703 | + $new_key_for_mapping = $model->get_index_primary_key_string($model_object_data); |
|
704 | 704 | } |
705 | - $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping; |
|
706 | - }else{ |
|
705 | + $old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_key_for_mapping; |
|
706 | + } else { |
|
707 | 707 | $matched_items = $model->get_all(array($conditions)); |
708 | - if( ! $matched_items){ |
|
708 | + if ( ! $matched_items) { |
|
709 | 709 | //no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck? |
710 | 710 | $this->_total_update_errors++; |
711 | - EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ ); |
|
712 | - }else{ |
|
711 | + EE_Error::add_error(sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data), http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__); |
|
712 | + } else { |
|
713 | 713 | $this->_total_updates++; |
714 | - EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data))); |
|
714 | + EE_Error::add_success(sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data))); |
|
715 | 715 | } |
716 | 716 | } |
717 | - }catch(EE_Error $e){ |
|
717 | + } catch (EE_Error $e) { |
|
718 | 718 | $this->_total_update_errors++; |
719 | - $basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage()); |
|
720 | - $debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString(); |
|
721 | - EE_Error::add_error( "$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__ ); |
|
719 | + $basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage()); |
|
720 | + $debug_message = $basic_message.' Stack trace: '.$e->getTraceAsString(); |
|
721 | + EE_Error::add_error("$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__); |
|
722 | 722 | } |
723 | 723 | return $old_db_to_new_db_mapping; |
724 | 724 | } |
@@ -727,28 +727,28 @@ discard block |
||
727 | 727 | * Gets the number of inserts performed since importer was instantiated or reset |
728 | 728 | * @return int |
729 | 729 | */ |
730 | - public function get_total_inserts(){ |
|
730 | + public function get_total_inserts() { |
|
731 | 731 | return $this->_total_inserts; |
732 | 732 | } |
733 | 733 | /** |
734 | 734 | * Gets the number of insert errors since importer was instantiated or reset |
735 | 735 | * @return int |
736 | 736 | */ |
737 | - public function get_total_insert_errors(){ |
|
737 | + public function get_total_insert_errors() { |
|
738 | 738 | return $this->_total_insert_errors; |
739 | 739 | } |
740 | 740 | /** |
741 | 741 | * Gets the number of updates performed since importer was instantiated or reset |
742 | 742 | * @return int |
743 | 743 | */ |
744 | - public function get_total_updates(){ |
|
744 | + public function get_total_updates() { |
|
745 | 745 | return $this->_total_updates; |
746 | 746 | } |
747 | 747 | /** |
748 | 748 | * Gets the number of update errors since importer was instantiated or reset |
749 | 749 | * @return int |
750 | 750 | */ |
751 | - public function get_total_update_errors(){ |
|
751 | + public function get_total_update_errors() { |
|
752 | 752 | return $this->_total_update_errors; |
753 | 753 | } |
754 | 754 |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\interfaces\ResettableInterface; |
3 | - |
|
4 | 3 | use EventEspresso\core\services\database\TableManager; |
5 | 4 | use EventEspresso\core\services\database\TableAnalysis; |
6 | 5 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * of this EE installation. Keys should be the name of the version the script upgraded to |
83 | 83 | * @var EE_Data_Migration_Script_Base[] |
84 | 84 | */ |
85 | - private $_data_migrations_ran =null; |
|
85 | + private $_data_migrations_ran = null; |
|
86 | 86 | /** |
87 | 87 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
88 | 88 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public static function instance() { |
144 | 144 | // check if class object is instantiated |
145 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
145 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
146 | 146 | self::$_instance = new self(); |
147 | 147 | } |
148 | 148 | return self::$_instance; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
153 | 153 | * @return EE_Data_Migration_Manager |
154 | 154 | */ |
155 | - public static function reset(){ |
|
155 | + public static function reset() { |
|
156 | 156 | self::$_instance = NULL; |
157 | 157 | return self::instance(); |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * constructor |
164 | 164 | */ |
165 | - private function __construct(){ |
|
165 | + private function __construct() { |
|
166 | 166 | $this->stati_that_indicate_to_continue_migrations = array( |
167 | 167 | self::status_continue, |
168 | 168 | self::status_completed |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | ); |
182 | 182 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
183 | 183 | //to be defined, because right now it doesn't get autoloaded on its own |
184 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
185 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
186 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
187 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
188 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
189 | - $this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
190 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
184 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
185 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
186 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
187 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
188 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
189 | + $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
190 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
201 | 201 | * @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') |
202 | 202 | */ |
203 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
203 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
204 | 204 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
205 | 205 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
206 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
206 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
207 | 207 | |
208 | - if(count($parts) == 4){ |
|
208 | + if (count($parts) == 4) { |
|
209 | 209 | //it's 4.2-style.eg Core.4.1.0 |
210 | - $plugin_slug = $parts[0];//eg Core |
|
210 | + $plugin_slug = $parts[0]; //eg Core |
|
211 | 211 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
212 | - }else{ |
|
212 | + } else { |
|
213 | 213 | //it's 4.1-style: eg 4.1.0 |
214 | 214 | $plugin_slug = 'Core'; |
215 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
215 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
216 | 216 | } |
217 | - return array($plugin_slug,$version_string); |
|
217 | + return array($plugin_slug, $version_string); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,21 +225,21 @@ discard block |
||
225 | 225 | * @return EE_Data_Migration_Script_Base |
226 | 226 | * @throws EE_Error |
227 | 227 | */ |
228 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
228 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
229 | 229 | $data_migration_data = maybe_unserialize($dms_option_value); |
230 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
230 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
231 | 231 | $class = new $data_migration_data['class']; |
232 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
232 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
233 | 233 | $class->instantiate_from_array_of_properties($data_migration_data); |
234 | 234 | return $class; |
235 | - }else{ |
|
235 | + } else { |
|
236 | 236 | //huh, so its an object but not a data migration script?? that shouldn't happen |
237 | 237 | //just leave it as an array (which will probably just get ignored) |
238 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
238 | + 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'])); |
|
239 | 239 | } |
240 | - }else{ |
|
240 | + } else { |
|
241 | 241 | //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 |
242 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
242 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | /** |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | * the last ran which hasn't finished yet |
248 | 248 | * @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) |
249 | 249 | */ |
250 | - public function get_data_migrations_ran(){ |
|
251 | - if( ! $this->_data_migrations_ran ){ |
|
250 | + public function get_data_migrations_ran() { |
|
251 | + if ( ! $this->_data_migrations_ran) { |
|
252 | 252 | //setup autoloaders for each of the scripts in there |
253 | 253 | $this->get_all_data_migration_scripts_available(); |
254 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
254 | + $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())); |
|
255 | 255 | |
256 | 256 | $data_migrations_ran = array(); |
257 | 257 | //convert into data migration script classes where possible |
258 | - foreach($data_migrations_options as $data_migration_option){ |
|
259 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
258 | + foreach ($data_migrations_options as $data_migration_option) { |
|
259 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
260 | 260 | |
261 | - try{ |
|
262 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
261 | + try { |
|
262 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
263 | 263 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
264 | 264 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
265 | 265 | $this->_last_ran_script = $class; |
266 | - if( ! $class->is_completed()){ |
|
266 | + if ( ! $class->is_completed()) { |
|
267 | 267 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
268 | 268 | $this->_last_ran_incomplete_script = $class; |
269 | 269 | } |
270 | - }catch(EE_Error $e){ |
|
270 | + } catch (EE_Error $e) { |
|
271 | 271 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
272 | 272 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
276 | 276 | $this->_data_migrations_ran = $data_migrations_ran; |
277 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
277 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
278 | 278 | $this->_data_migrations_ran = array(); |
279 | 279 | } |
280 | 280 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param $new_table |
292 | 292 | * @return mixed string or int |
293 | 293 | */ |
294 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
294 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
295 | 295 | $script = EE_Registry::instance()->load_dms($script_name); |
296 | 296 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
297 | 297 | return $mapping; |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | * option returned in this array is the most-recently ran DMS option |
303 | 303 | * @return array |
304 | 304 | */ |
305 | - public function get_all_migration_script_options(){ |
|
305 | + public function get_all_migration_script_options() { |
|
306 | 306 | global $wpdb; |
307 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
307 | + 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); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
313 | 313 | * folder name. |
314 | 314 | */ |
315 | - public function get_data_migration_script_folders(){ |
|
316 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
315 | + public function get_data_migration_script_folders() { |
|
316 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * } |
326 | 326 | * @throws EE_Error |
327 | 327 | */ |
328 | - public function script_migrates_to_version($migration_script_name){ |
|
328 | + public function script_migrates_to_version($migration_script_name) { |
|
329 | 329 | $dms_info = $this->parse_dms_classname($migration_script_name); |
330 | 330 | return array( |
331 | - 'slug'=> $dms_info[ 'slug' ], |
|
332 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
331 | + 'slug'=> $dms_info['slug'], |
|
332 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
339 | 339 | * @throws EE_Error |
340 | 340 | */ |
341 | - public function parse_dms_classname($classname){ |
|
341 | + public function parse_dms_classname($classname) { |
|
342 | 342 | $matches = array(); |
343 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
344 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
345 | - 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)); |
|
343 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
344 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
345 | + 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)); |
|
346 | 346 | } |
347 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
347 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
348 | 348 | } |
349 | 349 | /** |
350 | 350 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -353,33 +353,33 @@ discard block |
||
353 | 353 | * to 4.1.x. |
354 | 354 | * @return string of current db state |
355 | 355 | */ |
356 | - public function ensure_current_database_state_is_set(){ |
|
357 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
356 | + public function ensure_current_database_state_is_set() { |
|
357 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
358 | 358 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
359 | - if( ! $db_state ){ |
|
359 | + if ( ! $db_state) { |
|
360 | 360 | //mark the DB as being in the state as the last version in there. |
361 | 361 | //this is done to trigger maintenance mode and do data migration scripts |
362 | 362 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
363 | 363 | //otherwise, the normal maintenance mode code is fine |
364 | 364 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
365 | 365 | $previous_version_installed = end($previous_versions_installed); |
366 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
366 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
367 | 367 | //last installed version was less than 4.1 |
368 | 368 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
369 | 369 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
370 | 370 | $db_state = array('Core'=>$previous_version_installed); |
371 | - }else{ |
|
371 | + } else { |
|
372 | 372 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
373 | 373 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
374 | 374 | } |
375 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
375 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
376 | 376 | } |
377 | 377 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
378 | 378 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
379 | 379 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
380 | - if( ! is_array($db_state)){ |
|
380 | + if ( ! is_array($db_state)) { |
|
381 | 381 | $db_state = array('Core'=>$db_state); |
382 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
382 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
383 | 383 | } |
384 | 384 | return $db_state; |
385 | 385 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * or they don't apply), returns an empty array |
391 | 391 | * @return EE_Data_Migration_Script_Base[] |
392 | 392 | */ |
393 | - public function check_for_applicable_data_migration_scripts(){ |
|
393 | + public function check_for_applicable_data_migration_scripts() { |
|
394 | 394 | //get the option describing what options have already run |
395 | 395 | $scripts_ran = $this->get_data_migrations_ran(); |
396 | 396 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -403,62 +403,62 @@ discard block |
||
403 | 403 | $iteration = 0; |
404 | 404 | $next_database_state_to_consider = $current_database_state; |
405 | 405 | $theoretical_database_state = NULL; |
406 | - do{ |
|
406 | + do { |
|
407 | 407 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
408 | 408 | $theoretical_database_state = $next_database_state_to_consider; |
409 | 409 | //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?) |
410 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
410 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
411 | 411 | |
412 | 412 | $migrates_to_version = $this->script_migrates_to_version($classname); |
413 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
414 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
413 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
414 | + $script_converts_to_version = $migrates_to_version['version']; |
|
415 | 415 | //check if this version script is DONE or not; or if it's never been ran |
416 | - if( ! $scripts_ran || |
|
416 | + if ( ! $scripts_ran || |
|
417 | 417 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
418 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
418 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
419 | 419 | //we haven't ran this conversion script before |
420 | 420 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
421 | - $script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() ); |
|
421 | + $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis()); |
|
422 | 422 | /* @var $script EE_Data_Migration_Script_Base */ |
423 | 423 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
424 | - if($can_migrate){ |
|
424 | + if ($can_migrate) { |
|
425 | 425 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
426 | 426 | $migrates_to_version = $script->migrates_to_version(); |
427 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
427 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
428 | 428 | unset($script_class_and_filepaths_available[$classname]); |
429 | 429 | } |
430 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
430 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
431 | 431 | //this script has been ran, or at least started |
432 | 432 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
433 | - if( $script->get_status() != self::status_completed){ |
|
433 | + if ($script->get_status() != self::status_completed) { |
|
434 | 434 | //this script is already underway... keep going with it |
435 | 435 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
436 | 436 | $migrates_to_version = $script->migrates_to_version(); |
437 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
437 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
438 | 438 | unset($script_class_and_filepaths_available[$classname]); |
439 | - }else{ |
|
439 | + } else { |
|
440 | 440 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
441 | 441 | } |
442 | - }else{ |
|
442 | + } else { |
|
443 | 443 | //it exists but it's not a proper data migration script |
444 | 444 | //maybe the script got renamed? or was simply removed from EE? |
445 | 445 | //either way, its certainly not runnable! |
446 | 446 | } |
447 | 447 | } |
448 | 448 | $iteration++; |
449 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
449 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
450 | 450 | //ok we have all the scripts that should run, now let's make them into flat array |
451 | 451 | $scripts_that_should_run = array(); |
452 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
452 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
453 | 453 | ksort($scripts_at_priority); |
454 | - foreach($scripts_at_priority as $scripts){ |
|
455 | - foreach($scripts as $script){ |
|
454 | + foreach ($scripts_at_priority as $scripts) { |
|
455 | + foreach ($scripts as $script) { |
|
456 | 456 | $scripts_that_should_run[get_class($script)] = $script; |
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
461 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
462 | 462 | return $scripts_that_should_run; |
463 | 463 | } |
464 | 464 | |
@@ -472,14 +472,14 @@ discard block |
||
472 | 472 | * @param bool $include_completed_scripts |
473 | 473 | * @return EE_Data_Migration_Script_Base |
474 | 474 | */ |
475 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
475 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
476 | 476 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
477 | - if( ! $this->_data_migrations_ran){ |
|
477 | + if ( ! $this->_data_migrations_ran) { |
|
478 | 478 | $this->get_data_migrations_ran(); |
479 | 479 | } |
480 | - if($include_completed_scripts){ |
|
480 | + if ($include_completed_scripts) { |
|
481 | 481 | return $this->_last_ran_script; |
482 | - }else{ |
|
482 | + } else { |
|
483 | 483 | return $this->_last_ran_incomplete_script; |
484 | 484 | } |
485 | 485 | } |
@@ -502,19 +502,19 @@ discard block |
||
502 | 502 | * @type string $message string describing what was done during this step |
503 | 503 | * } |
504 | 504 | */ |
505 | - public function migration_step( $step_size = 0 ){ |
|
505 | + public function migration_step($step_size = 0) { |
|
506 | 506 | |
507 | 507 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
508 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
509 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
508 | + if (class_exists('EE_CPT_Strategy')) { |
|
509 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
510 | 510 | } |
511 | 511 | |
512 | - try{ |
|
512 | + try { |
|
513 | 513 | $currently_executing_script = $this->get_last_ran_script(); |
514 | - if( ! $currently_executing_script){ |
|
514 | + if ( ! $currently_executing_script) { |
|
515 | 515 | //Find the next script that needs to execute |
516 | 516 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
517 | - if( ! $scripts ){ |
|
517 | + if ( ! $scripts) { |
|
518 | 518 | //huh, no more scripts to run... apparently we're done! |
519 | 519 | //but dont forget to make sure initial data is there |
520 | 520 | //we should be good to allow them to exit maintenance mode now |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | //and add to the array/wp option showing the scripts ran |
536 | 536 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
537 | 537 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
538 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
539 | - $version = $migrates_to[ 'version' ]; |
|
538 | + $plugin_slug = $migrates_to['slug']; |
|
539 | + $version = $migrates_to['version']; |
|
540 | 540 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
541 | 541 | } |
542 | 542 | $current_script_name = get_class($currently_executing_script); |
543 | - }catch(Exception $e){ |
|
543 | + } catch (Exception $e) { |
|
544 | 544 | //an exception occurred while trying to get migration scripts |
545 | 545 | |
546 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
546 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
547 | 547 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
548 | 548 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
549 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
549 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
550 | 550 | return array( |
551 | 551 | 'records_to_migrate'=>1, |
552 | 552 | 'records_migrated'=>0, |
@@ -556,16 +556,16 @@ discard block |
||
556 | 556 | ); |
557 | 557 | } |
558 | 558 | //ok so we definitely have a data migration script |
559 | - try{ |
|
559 | + try { |
|
560 | 560 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
561 | - if( ! absint( $step_size ) > 0 ){ |
|
562 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
561 | + if ( ! absint($step_size) > 0) { |
|
562 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
563 | 563 | } |
564 | 564 | //do what we came to do! |
565 | 565 | $currently_executing_script->migration_step($step_size); |
566 | 566 | //can we wrap it up and verify default data? |
567 | 567 | $init_dbs = false; |
568 | - switch($currently_executing_script->get_status()){ |
|
568 | + switch ($currently_executing_script->get_status()) { |
|
569 | 569 | case EE_Data_Migration_Manager::status_continue: |
570 | 570 | $response_array = array( |
571 | 571 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -577,16 +577,16 @@ discard block |
||
577 | 577 | case EE_Data_Migration_Manager::status_completed: |
578 | 578 | //ok so THAT script has completed |
579 | 579 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
580 | - $response_array = array( |
|
580 | + $response_array = array( |
|
581 | 581 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
582 | 582 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
583 | 583 | 'status'=> EE_Data_Migration_Manager::status_completed, |
584 | 584 | 'message'=>$currently_executing_script->get_feedback_message(), |
585 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
585 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
586 | 586 | ); |
587 | 587 | //check if there are any more after this one. |
588 | 588 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
589 | - if( ! $scripts_remaining ){ |
|
589 | + if ( ! $scripts_remaining) { |
|
590 | 590 | //we should be good to allow them to exit maintenance mode now |
591 | 591 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
592 | 592 | ////huh, no more scripts to run... apparently we're done! |
@@ -600,39 +600,39 @@ discard block |
||
600 | 600 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
601 | 601 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
602 | 602 | 'status'=> $currently_executing_script->get_status(), |
603 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
603 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
604 | 604 | 'script'=>$currently_executing_script->pretty_name() |
605 | 605 | ); |
606 | 606 | break; |
607 | 607 | } |
608 | - }catch(Exception $e){ |
|
608 | + } catch (Exception $e) { |
|
609 | 609 | //ok so some exception was thrown which killed the data migration script |
610 | 610 | //double-check we have a real script |
611 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
611 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
612 | 612 | $script_name = $currently_executing_script->pretty_name(); |
613 | 613 | $currently_executing_script->set_broken(); |
614 | 614 | $currently_executing_script->add_error($e->getMessage()); |
615 | - }else{ |
|
615 | + } else { |
|
616 | 616 | $script_name = __("Error getting Migration Script", "event_espresso"); |
617 | 617 | } |
618 | 618 | $response_array = array( |
619 | 619 | 'records_to_migrate'=>1, |
620 | 620 | 'records_migrated'=>0, |
621 | 621 | 'status'=>self::status_fatal_error, |
622 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
622 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
623 | 623 | 'script'=>$script_name |
624 | 624 | ); |
625 | 625 | } |
626 | 626 | $successful_save = $this->_save_migrations_ran(); |
627 | - if($successful_save !== TRUE){ |
|
627 | + if ($successful_save !== TRUE) { |
|
628 | 628 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
629 | 629 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
630 | 630 | //however, if we throw an exception, and return that, then the next request |
631 | 631 | //won't have as much info in it, and it may be able to save |
632 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
632 | + 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)); |
|
633 | 633 | } |
634 | 634 | //if we're all done, initialize EE plugins' default data etc. |
635 | - if( $init_dbs ) { |
|
635 | + if ($init_dbs) { |
|
636 | 636 | $this->initialize_db_for_enqueued_ee_plugins(); |
637 | 637 | } |
638 | 638 | return $response_array; |
@@ -650,23 +650,23 @@ discard block |
||
650 | 650 | * '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 |
651 | 651 | * 'script'=>a pretty name of the script currently running |
652 | 652 | */ |
653 | - public function response_to_migration_ajax_request(){ |
|
653 | + public function response_to_migration_ajax_request() { |
|
654 | 654 | // //start output buffer just to make sure we don't mess up the json |
655 | 655 | ob_start(); |
656 | - try{ |
|
656 | + try { |
|
657 | 657 | $response = $this->migration_step(); |
658 | - }catch(Exception $e){ |
|
658 | + } catch (Exception $e) { |
|
659 | 659 | $response = array( |
660 | 660 | 'records_to_migrate'=>0, |
661 | 661 | 'records_migrated'=>0, |
662 | 662 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
663 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
663 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
664 | 664 | 'script'=>'Unknown'); |
665 | 665 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
666 | 666 | } |
667 | 667 | $warnings_etc = @ob_get_contents(); |
668 | 668 | ob_end_clean(); |
669 | - $response['message'] .=$warnings_etc; |
|
669 | + $response['message'] .= $warnings_etc; |
|
670 | 670 | return $response; |
671 | 671 | } |
672 | 672 | |
@@ -679,14 +679,14 @@ discard block |
||
679 | 679 | * } |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function update_current_database_state_to($slug_and_version = null){ |
|
683 | - if( ! $slug_and_version ){ |
|
682 | + public function update_current_database_state_to($slug_and_version = null) { |
|
683 | + if ( ! $slug_and_version) { |
|
684 | 684 | //no version was provided, assume it should be at the current code version |
685 | 685 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
686 | 686 | } |
687 | 687 | $current_database_state = get_option(self::current_database_state); |
688 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
689 | - update_option(self::current_database_state,$current_database_state); |
|
688 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
689 | + update_option(self::current_database_state, $current_database_state); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -697,20 +697,20 @@ discard block |
||
697 | 697 | * } |
698 | 698 | * @return boolean |
699 | 699 | */ |
700 | - public function database_needs_updating_to( $slug_and_version ) { |
|
700 | + public function database_needs_updating_to($slug_and_version) { |
|
701 | 701 | |
702 | - $slug = $slug_and_version[ 'slug' ]; |
|
703 | - $version = $slug_and_version[ 'version' ]; |
|
702 | + $slug = $slug_and_version['slug']; |
|
703 | + $version = $slug_and_version['version']; |
|
704 | 704 | $current_database_state = get_option(self::current_database_state); |
705 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
705 | + if ( ! isset($current_database_state[$slug])) { |
|
706 | 706 | return true; |
707 | - }else{ |
|
707 | + } else { |
|
708 | 708 | //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 |
709 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
710 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
709 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
710 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
711 | 711 | $needs_updating = false; |
712 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
713 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
712 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
713 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
714 | 714 | $needs_updating = true; |
715 | 715 | break; |
716 | 716 | } |
@@ -728,33 +728,33 @@ discard block |
||
728 | 728 | * @return array keys are expected classnames, values are their filepaths |
729 | 729 | * @throws \EE_Error |
730 | 730 | */ |
731 | - public function get_all_data_migration_scripts_available(){ |
|
732 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
731 | + public function get_all_data_migration_scripts_available() { |
|
732 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
733 | 733 | $this->_data_migration_class_to_filepath_map = array(); |
734 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
734 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
735 | 735 | $folder_path = EEH_File::end_with_directory_separator($folder_path); |
736 | - $files = glob( $folder_path. '*.dms.php' ); |
|
736 | + $files = glob($folder_path.'*.dms.php'); |
|
737 | 737 | |
738 | - if ( empty( $files ) ) { |
|
738 | + if (empty($files)) { |
|
739 | 739 | continue; |
740 | 740 | } |
741 | 741 | |
742 | - foreach($files as $file){ |
|
743 | - $pos_of_last_slash = strrpos($file,DS); |
|
742 | + foreach ($files as $file) { |
|
743 | + $pos_of_last_slash = strrpos($file, DS); |
|
744 | 744 | $classname = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1)); |
745 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
746 | - $slug = $migrates_to[ 'slug' ]; |
|
745 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
746 | + $slug = $migrates_to['slug']; |
|
747 | 747 | //check that the slug as contained in the DMS is associated with |
748 | 748 | //the slug of an addon or core |
749 | - if( $slug !== 'Core' ){ |
|
750 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
749 | + if ($slug !== 'Core') { |
|
750 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
751 | 751 | EE_Error::doing_it_wrong( |
752 | 752 | __FUNCTION__, |
753 | 753 | sprintf( |
754 | - __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ), |
|
754 | + __('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), |
|
755 | 755 | $classname, |
756 | 756 | $slug, |
757 | - implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) ) |
|
757 | + implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name())) |
|
758 | 758 | ), |
759 | 759 | '4.3.0.alpha.019' |
760 | 760 | ); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | * from each addon, and check if they need updating, |
778 | 778 | * @return boolean |
779 | 779 | */ |
780 | - public function addons_need_updating(){ |
|
780 | + public function addons_need_updating() { |
|
781 | 781 | return false; |
782 | 782 | } |
783 | 783 | /** |
@@ -786,25 +786,25 @@ discard block |
||
786 | 786 | * @param string $error_message |
787 | 787 | * @throws EE_Error |
788 | 788 | */ |
789 | - public function add_error_to_migrations_ran($error_message){ |
|
789 | + public function add_error_to_migrations_ran($error_message) { |
|
790 | 790 | //get last-ran migration script |
791 | 791 | global $wpdb; |
792 | - $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); |
|
792 | + $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); |
|
793 | 793 | |
794 | 794 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
795 | 795 | //now, tread lightly because we're here because a FATAL non-catchable error |
796 | 796 | //was thrown last time when we were trying to run a data migration script |
797 | 797 | //so the fatal error could have happened while getting the migration script |
798 | 798 | //or doing running it... |
799 | - $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; |
|
799 | + $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; |
|
800 | 800 | |
801 | 801 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
802 | 802 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
803 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
803 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
804 | 804 | //ok then just add this error to its list of errors |
805 | 805 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
806 | 806 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
807 | - }else{ |
|
807 | + } else { |
|
808 | 808 | //so we don't even know which script was last running |
809 | 809 | //use the data migration error stub, which is designed specifically for this type of thing |
810 | 810 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -814,39 +814,39 @@ discard block |
||
814 | 814 | $versions_migrated_to = 'Unknown.1.0.0'; |
815 | 815 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
816 | 816 | //delete the old one |
817 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
817 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
818 | 818 | } |
819 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
819 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
820 | 820 | |
821 | 821 | } |
822 | 822 | /** |
823 | 823 | * saves what data migrations have ran to the database |
824 | 824 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
825 | 825 | */ |
826 | - protected function _save_migrations_ran(){ |
|
827 | - if($this->_data_migrations_ran == null){ |
|
826 | + protected function _save_migrations_ran() { |
|
827 | + if ($this->_data_migrations_ran == null) { |
|
828 | 828 | $this->get_data_migrations_ran(); |
829 | 829 | } |
830 | 830 | //now, we don't want to save actual classes to the DB because that's messy |
831 | 831 | $successful_updates = true; |
832 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
833 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
832 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
833 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
834 | 834 | // echo "saving migration script to $version_string<br>"; |
835 | 835 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
836 | 836 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
837 | 837 | $old_option_value = get_option($option_name); |
838 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
838 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
839 | 839 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
840 | - if( $old_option_value != $script_array_for_saving){ |
|
841 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
840 | + if ($old_option_value != $script_array_for_saving) { |
|
841 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
842 | 842 | } |
843 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
843 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
844 | 844 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
845 | - if($old_option_value != $array_or_migration_obj){ |
|
846 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
845 | + if ($old_option_value != $array_or_migration_obj) { |
|
846 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
847 | 847 | } |
848 | 848 | } |
849 | - if( ! $successful_updates ){ |
|
849 | + if ( ! $successful_updates) { |
|
850 | 850 | global $wpdb; |
851 | 851 | return $wpdb->last_error; |
852 | 852 | } |
@@ -870,17 +870,17 @@ discard block |
||
870 | 870 | * @return EE_Data_Migration_Script_Base |
871 | 871 | * @throws EE_Error |
872 | 872 | */ |
873 | - function _instantiate_script_from_properties_array($properties_array){ |
|
874 | - if( ! isset($properties_array['class'])){ |
|
875 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
873 | + function _instantiate_script_from_properties_array($properties_array) { |
|
874 | + if ( ! isset($properties_array['class'])) { |
|
875 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
876 | 876 | } |
877 | 877 | $class_name = $properties_array['class']; |
878 | - if( ! class_exists($class_name)){ |
|
879 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
878 | + if ( ! class_exists($class_name)) { |
|
879 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
880 | 880 | } |
881 | 881 | $class = new $class_name; |
882 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
883 | - 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))); |
|
882 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
883 | + 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))); |
|
884 | 884 | } |
885 | 885 | $class->instantiate_from_array_of_properties($properties_array); |
886 | 886 | return $class; |
@@ -892,25 +892,25 @@ discard block |
||
892 | 892 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
893 | 893 | * @return string |
894 | 894 | */ |
895 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
895 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
896 | 896 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
897 | 897 | $most_up_to_date_dms_classname = NULL; |
898 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
899 | - if($most_up_to_date_dms_classname === NULL){ |
|
898 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
899 | + if ($most_up_to_date_dms_classname === NULL) { |
|
900 | 900 | $migrates_to = $this->script_migrates_to_version($classname); |
901 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
901 | + $this_plugin_slug = $migrates_to['slug']; |
|
902 | 902 | // $version_string = $migrates_to[ 'version' ]; |
903 | 903 | // $details = $this->parse_dms_classname($classname); |
904 | - if($this_plugin_slug == $plugin_slug){ |
|
904 | + if ($this_plugin_slug == $plugin_slug) { |
|
905 | 905 | //if it's for core, it wins |
906 | 906 | $most_up_to_date_dms_classname = $classname; |
907 | 907 | } |
908 | 908 | //if it wasn't for core, we must keep searching for one that is! |
909 | 909 | continue; |
910 | - }else{ |
|
911 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
910 | + } else { |
|
911 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
912 | 912 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
913 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
913 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
914 | 914 | //so the contenders version is higher and its for Core |
915 | 915 | $most_up_to_date_dms_classname = $classname; |
916 | 916 | } |
@@ -930,11 +930,11 @@ discard block |
||
930 | 930 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
931 | 931 | * @return EE_Data_Migration_Script_Base |
932 | 932 | */ |
933 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
933 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
934 | 934 | $migrations_ran = $this->get_data_migrations_ran(); |
935 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
936 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
937 | - }else{ |
|
935 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
936 | + return $migrations_ran[$plugin_slug][$version]; |
|
937 | + } else { |
|
938 | 938 | return NULL; |
939 | 939 | } |
940 | 940 | } |
@@ -946,20 +946,20 @@ discard block |
||
946 | 946 | * @return bool |
947 | 947 | * @throws \EE_Error |
948 | 948 | */ |
949 | - public function reattempt(){ |
|
949 | + public function reattempt() { |
|
950 | 950 | //find if the last-ran script was borked |
951 | 951 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
952 | 952 | //add an 'error' saying that we attempted to reset |
953 | 953 | //does it have a stage that was borked too? if so make it no longer borked |
954 | 954 | //add an 'error' saying we attempted to reset |
955 | 955 | $last_ran_script = $this->get_last_ran_script(); |
956 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
956 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
957 | 957 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
958 | 958 | $last_ran_script->set_completed(); |
959 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
959 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
960 | 960 | $last_ran_script->reattempt(); |
961 | - }else{ |
|
962 | - throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
|
961 | + } else { |
|
962 | + throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true))); |
|
963 | 963 | } |
964 | 964 | return $this->_save_migrations_ran(); |
965 | 965 | } |
@@ -969,19 +969,19 @@ discard block |
||
969 | 969 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
970 | 970 | * @return boolean |
971 | 971 | */ |
972 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
973 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
972 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
973 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
974 | 974 | } |
975 | 975 | /** |
976 | 976 | * Enqueues this ee plugin to have its data initialized |
977 | 977 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
978 | 978 | */ |
979 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
979 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
980 | 980 | $queue = $this->get_db_initialization_queue(); |
981 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
981 | + if ( ! in_array($plugin_slug, $queue)) { |
|
982 | 982 | $queue[] = $plugin_slug; |
983 | 983 | } |
984 | - update_option( self::db_init_queue_option_name, $queue ); |
|
984 | + update_option(self::db_init_queue_option_name, $queue); |
|
985 | 985 | } |
986 | 986 | /** |
987 | 987 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -991,26 +991,26 @@ discard block |
||
991 | 991 | public function initialize_db_for_enqueued_ee_plugins() { |
992 | 992 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
993 | 993 | $queue = $this->get_db_initialization_queue(); |
994 | - foreach( $queue as $plugin_slug ) { |
|
995 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
996 | - if( ! $most_up_to_date_dms ) { |
|
994 | + foreach ($queue as $plugin_slug) { |
|
995 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
996 | + if ( ! $most_up_to_date_dms) { |
|
997 | 997 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
998 | 998 | $verify_db = false; |
999 | - }else{ |
|
1000 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
1001 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
999 | + } else { |
|
1000 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
1001 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
1002 | 1002 | } |
1003 | - if( $plugin_slug == 'Core' ){ |
|
1003 | + if ($plugin_slug == 'Core') { |
|
1004 | 1004 | EE_System::instance()->initialize_db_if_no_migrations_required( |
1005 | 1005 | false, |
1006 | 1006 | $verify_db |
1007 | 1007 | ); |
1008 | - }else{ |
|
1008 | + } else { |
|
1009 | 1009 | //just loop through the addons to make sure their database is setup |
1010 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
1011 | - if( $addon->name() == $plugin_slug ) { |
|
1010 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
1011 | + if ($addon->name() == $plugin_slug) { |
|
1012 | 1012 | |
1013 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
1013 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
1014 | 1014 | break; |
1015 | 1015 | } |
1016 | 1016 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | // EEH_Debug_Tools::instance()->show_times(); |
1021 | 1021 | //because we just initialized the DBs for the enqueued ee plugins |
1022 | 1022 | //we don't need to keep remembering which ones needed to be initialized |
1023 | - delete_option( self::db_init_queue_option_name ); |
|
1023 | + delete_option(self::db_init_queue_option_name); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * 'Core', or the return value of EE_Addon::name() for an addon |
1030 | 1030 | * @return array |
1031 | 1031 | */ |
1032 | - public function get_db_initialization_queue(){ |
|
1033 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
1032 | + public function get_db_initialization_queue() { |
|
1033 | + return get_option(self::db_init_queue_option_name, array()); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1039,13 +1039,13 @@ discard block |
||
1039 | 1039 | * @throws \EE_Error |
1040 | 1040 | */ |
1041 | 1041 | protected function _get_table_analysis() { |
1042 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
1042 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
1043 | 1043 | return $this->_table_analysis; |
1044 | 1044 | } else { |
1045 | 1045 | throw new \EE_Error( |
1046 | 1046 | sprintf( |
1047 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1048 | - get_class( $this ) |
|
1047 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1048 | + get_class($this) |
|
1049 | 1049 | ) |
1050 | 1050 | ); |
1051 | 1051 | } |
@@ -1057,13 +1057,13 @@ discard block |
||
1057 | 1057 | * @throws \EE_Error |
1058 | 1058 | */ |
1059 | 1059 | protected function _get_table_manager() { |
1060 | - if( $this->_table_manager instanceof TableManager ) { |
|
1060 | + if ($this->_table_manager instanceof TableManager) { |
|
1061 | 1061 | return $this->_table_manager; |
1062 | 1062 | } else { |
1063 | 1063 | throw new \EE_Error( |
1064 | 1064 | sprintf( |
1065 | - __( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1066 | - get_class( $this ) |
|
1065 | + __('Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1066 | + get_class($this) |
|
1067 | 1067 | ) |
1068 | 1068 | ); |
1069 | 1069 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | |
2 | 2 | <div class="misc-pub-section"> |
3 | 3 | <span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span> |
4 | - <a href="<?php echo $view_approved_reg_url;?>"> |
|
5 | - <?php printf( __('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') ); ?> |
|
4 | + <a href="<?php echo $view_approved_reg_url; ?>"> |
|
5 | + <?php printf(__('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')); ?> |
|
6 | 6 | </a>: |
7 | 7 | <?php echo $approved_regs; ?> |
8 | 8 | </div> |
9 | 9 | <div class="misc-pub-section"> |
10 | 10 | <span class="dashicons dashicons-groups ee-icon-color-ee-blue ee-icon-size-20"></span> |
11 | - <a href="<?php echo $view_pending_payment_reg_url;?>"> |
|
12 | - <?php printf( __('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') ); ?> |
|
11 | + <a href="<?php echo $view_pending_payment_reg_url; ?>"> |
|
12 | + <?php printf(__('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')); ?> |
|
13 | 13 | </a>: |
14 | 14 | <?php echo $pending_payment_regs; ?> |
15 | 15 | </div> |
16 | 16 | <div class="misc-pub-section"> |
17 | 17 | <span class="dashicons dashicons-groups ee-icon-color-ee-orange ee-icon-size-20"></span> |
18 | - <a href="<?php echo $view_not_approved_reg_url;?>"> |
|
19 | - <?php printf( __('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') ); ?> |
|
18 | + <a href="<?php echo $view_not_approved_reg_url; ?>"> |
|
19 | + <?php printf(__('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')); ?> |
|
20 | 20 | </a>: |
21 | 21 | <?php echo $not_approved_regs; ?> |
22 | 22 | </div> |
@@ -29,5 +29,5 @@ discard block |
||
29 | 29 | </a> |
30 | 30 | </div> /**/ ?> |
31 | 31 | |
32 | -<?php echo $event_editor_overview_add;?> |
|
32 | +<?php echo $event_editor_overview_add; ?> |
|
33 | 33 | <br/> |
@@ -588,6 +588,7 @@ |
||
588 | 588 | * @param EE_Registration $registration |
589 | 589 | * @param EE_Question $question |
590 | 590 | * @param mixed EE_Answer|NULL $answer |
591 | + * @param EE_Answer $answer |
|
591 | 592 | * @return EE_Form_Input_Base |
592 | 593 | * @throws \EE_Error |
593 | 594 | */ |
@@ -2,17 +2,17 @@ discard block |
||
2 | 2 | |
3 | 3 | if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
4 | 4 | /** |
5 | - * |
|
6 | - * Class EE_SPCO_Reg_Step_Attendee_Information |
|
7 | - * |
|
8 | - * Description |
|
9 | - * |
|
10 | - * @package Event Espresso |
|
11 | - * @subpackage core |
|
12 | - * @author Brent Christensen |
|
13 | - * @since 4.5.0 |
|
14 | - * |
|
15 | - */ |
|
5 | + * |
|
6 | + * Class EE_SPCO_Reg_Step_Attendee_Information |
|
7 | + * |
|
8 | + * Description |
|
9 | + * |
|
10 | + * @package Event Espresso |
|
11 | + * @subpackage core |
|
12 | + * @author Brent Christensen |
|
13 | + * @since 4.5.0 |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step { |
17 | 17 | |
18 | 18 | /** |
@@ -137,28 +137,28 @@ discard block |
||
137 | 137 | $registration instanceof EE_Registration |
138 | 138 | && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
139 | 139 | ) { |
140 | - $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
141 | - if ( ! $this->checkout->admin_request) { |
|
142 | - $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
143 | - $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
144 | - $template_args['ticket_count'][$registration->ticket()->ID()] |
|
145 | - ) |
|
146 | - ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
147 | - : 1; |
|
148 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
149 | - $this->checkout->cart->get_grand_total(), |
|
150 | - 'Ticket', |
|
151 | - array($registration->ticket()->ID()) |
|
152 | - ); |
|
153 | - $ticket_line_item = is_array($ticket_line_item) |
|
154 | - ? reset($ticket_line_item) |
|
155 | - : $ticket_line_item; |
|
156 | - $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
157 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
158 | - } |
|
159 | - if ($registration->is_primary_registrant()) { |
|
160 | - $primary_registrant = $registration->reg_url_link(); |
|
161 | - } |
|
140 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
141 | + if ( ! $this->checkout->admin_request) { |
|
142 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
143 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
144 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
145 | + ) |
|
146 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
147 | + : 1; |
|
148 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
149 | + $this->checkout->cart->get_grand_total(), |
|
150 | + 'Ticket', |
|
151 | + array($registration->ticket()->ID()) |
|
152 | + ); |
|
153 | + $ticket_line_item = is_array($ticket_line_item) |
|
154 | + ? reset($ticket_line_item) |
|
155 | + : $ticket_line_item; |
|
156 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
157 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
158 | + } |
|
159 | + if ($registration->is_primary_registrant()) { |
|
160 | + $primary_registrant = $registration->reg_url_link(); |
|
161 | + } |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | 172 | isset( $subsections[ $primary_registrant ] ) |
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
173 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | 175 | $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
176 | 176 | } |
@@ -198,42 +198,42 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | - /** |
|
201 | + /** |
|
202 | 202 | * @param EE_Registration $registration |
203 | 203 | * @return EE_Form_Section_Base |
204 | 204 | * @throws \EE_Error |
205 | 205 | */ |
206 | 206 | private function _registrations_reg_form( EE_Registration $registration ) { |
207 | 207 | static $attendee_nmbr = 1; |
208 | - $form_args = array(); |
|
208 | + $form_args = array(); |
|
209 | 209 | // verify that registration has valid event |
210 | 210 | if ( $registration->event() instanceof EE_Event ) { |
211 | 211 | $question_groups = $registration->event()->question_groups( |
212 | - array( |
|
213 | - array( |
|
214 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
215 | - 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
216 | - ), |
|
217 | - 'order_by' => array('QSG_order' => 'ASC') |
|
218 | - ) |
|
219 | - ); |
|
212 | + array( |
|
213 | + array( |
|
214 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
215 | + 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
216 | + ), |
|
217 | + 'order_by' => array('QSG_order' => 'ASC') |
|
218 | + ) |
|
219 | + ); |
|
220 | 220 | if ( $question_groups ) { |
221 | - // array of params to pass to parent constructor |
|
222 | - $form_args = array( |
|
223 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
224 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
225 | - 'html_style' => $this->checkout->admin_request |
|
226 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
227 | - : '', |
|
228 | - 'subsections' => array(), |
|
229 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
230 | - array( |
|
231 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
232 | - 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
233 | - ) |
|
234 | - ) |
|
235 | - ); |
|
236 | - foreach ( $question_groups as $question_group ) { |
|
221 | + // array of params to pass to parent constructor |
|
222 | + $form_args = array( |
|
223 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
224 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
225 | + 'html_style' => $this->checkout->admin_request |
|
226 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
227 | + : '', |
|
228 | + 'subsections' => array(), |
|
229 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
230 | + array( |
|
231 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
232 | + 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
233 | + ) |
|
234 | + ) |
|
235 | + ); |
|
236 | + foreach ( $question_groups as $question_group ) { |
|
237 | 237 | if ( $question_group instanceof EE_Question_Group ) { |
238 | 238 | $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
239 | 239 | $registration, |
@@ -241,19 +241,19 @@ discard block |
||
241 | 241 | ); |
242 | 242 | } |
243 | 243 | } |
244 | - // add hidden input |
|
245 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
246 | - $registration |
|
247 | - ); |
|
248 | - // if we have question groups for additional attendees, then display the copy options |
|
244 | + // add hidden input |
|
245 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
246 | + $registration |
|
247 | + ); |
|
248 | + // if we have question groups for additional attendees, then display the copy options |
|
249 | 249 | $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
250 | - if ($registration->is_primary_registrant()) { |
|
251 | - // generate hidden input |
|
252 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
253 | - } |
|
254 | - } |
|
250 | + if ($registration->is_primary_registrant()) { |
|
251 | + // generate hidden input |
|
252 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
253 | + } |
|
254 | + } |
|
255 | 255 | } |
256 | - $attendee_nmbr++; |
|
256 | + $attendee_nmbr++; |
|
257 | 257 | return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
258 | 258 | } |
259 | 259 | |
@@ -745,16 +745,16 @@ discard block |
||
745 | 745 | $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
746 | 746 | // verify we got the goods |
747 | 747 | if ( empty( $registrations )) { |
748 | - //combine the old translated string with a new one, in order to not break translations |
|
749 | - $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ) |
|
750 | - . sprintf( |
|
751 | - esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'), |
|
752 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
753 | - '</a>', |
|
754 | - '<br />' |
|
755 | - ); |
|
748 | + //combine the old translated string with a new one, in order to not break translations |
|
749 | + $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ) |
|
750 | + . sprintf( |
|
751 | + esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'), |
|
752 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
753 | + '</a>', |
|
754 | + '<br />' |
|
755 | + ); |
|
756 | 756 | EE_Error::add_error( |
757 | - $error_message, |
|
757 | + $error_message, |
|
758 | 758 | __FILE__, |
759 | 759 | __FUNCTION__, |
760 | 760 | __LINE__ |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | if ( isset( $valid_data[ $reg_url_link ] ) ) { |
895 | 895 | // do we need to copy basic info from primary attendee ? |
896 | 896 | $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
897 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
897 | + && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
898 | 898 | ? true |
899 | 899 | : false; |
900 | 900 | // filter form input data for this registration |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | ) ) { |
1055 | 1055 | return true; |
1056 | 1056 | } |
1057 | - /* |
|
1057 | + /* |
|
1058 | 1058 | * $answer_cache_id is the key used to find the EE_Answer we want |
1059 | 1059 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1060 | 1060 | */ |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | ? $form_input . '-' . $registration->reg_url_link() |
1063 | 1063 | : $form_input; |
1064 | 1064 | $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
1065 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1065 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1066 | 1066 | ? true |
1067 | 1067 | : false; |
1068 | 1068 | //rename form_inputs if they are EE_Attendee properties |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | } |
1230 | 1230 | foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
1231 | 1231 | if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
1232 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1232 | + || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1233 | 1233 | ) { |
1234 | 1234 | $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
1235 | 1235 | $critical_attendee_detail |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\services\commands\attendee\CreateAttendeeCommand; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Class EE_SPCO_Reg_Step_Attendee_Information |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | * @access public |
44 | 44 | * @param EE_Checkout $checkout |
45 | 45 | */ |
46 | - public function __construct( EE_Checkout $checkout ) { |
|
46 | + public function __construct(EE_Checkout $checkout) { |
|
47 | 47 | $this->_slug = 'attendee_information'; |
48 | 48 | $this->_name = __('Attendee Information', 'event_espresso'); |
49 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
49 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
50 | 50 | $this->checkout = $checkout; |
51 | 51 | $this->_reset_success_message(); |
52 | 52 | $this->set_instructions( |
53 | - __( 'Please answer the following registration questions before proceeding.', 'event_espresso' ) |
|
53 | + __('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | 59 | public function translate_js_strings() { |
60 | - EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' ); |
|
60 | + EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso'); |
|
61 | 61 | EE_Registry::$i18n_js_strings['required_multi_field'] = __( |
62 | 62 | ' is a required question. Please enter a value for at least one of the options.', |
63 | 63 | 'event_espresso' |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // calculate taxes |
118 | 118 | $Line_Item_Display->display_line_item( |
119 | 119 | $this->checkout->cart->get_grand_total(), |
120 | - array( 'set_tax_rate' => true ) |
|
120 | + array('set_tax_rate' => true) |
|
121 | 121 | ); |
122 | 122 | /** @var $subsections EE_Form_Section_Proper[] */ |
123 | 123 | $subsections = array( |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | 'ticket_count' => array() |
130 | 130 | ); |
131 | 131 | // grab the saved registrations from the transaction |
132 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
133 | - if ( $registrations ) { |
|
134 | - foreach ( $registrations as $registration ) { |
|
132 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
133 | + if ($registrations) { |
|
134 | + foreach ($registrations as $registration) { |
|
135 | 135 | // can this registration be processed during this visit ? |
136 | 136 | if ( |
137 | 137 | $registration instanceof EE_Registration |
138 | - && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
|
138 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
139 | 139 | ) { |
140 | 140 | $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
141 | 141 | if ( ! $this->checkout->admin_request) { |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
165 | - if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) { |
|
165 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
166 | 166 | // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info |
167 | 167 | $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
168 | 168 | ? $this->_copy_attendee_info_form() |
169 | 169 | : $this->_auto_copy_attendee_info(); |
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | - isset( $subsections[ $primary_registrant ] ) |
|
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
172 | + isset($subsections[$primary_registrant]) |
|
173 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | - $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
|
175 | + $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | 'html_id' => $this->reg_form_name(), |
185 | 185 | 'subsections' => $subsections, |
186 | 186 | 'layout_strategy' => $this->checkout->admin_request ? |
187 | - new EE_Div_Per_Section_Layout() : |
|
188 | - new EE_Template_Layout( |
|
187 | + new EE_Div_Per_Section_Layout() : new EE_Template_Layout( |
|
189 | 188 | array( |
190 | 189 | 'layout_template_file' => $this->_template, // layout_template |
191 | 190 | 'template_args' => $template_args |
@@ -203,11 +202,11 @@ discard block |
||
203 | 202 | * @return EE_Form_Section_Base |
204 | 203 | * @throws \EE_Error |
205 | 204 | */ |
206 | - private function _registrations_reg_form( EE_Registration $registration ) { |
|
205 | + private function _registrations_reg_form(EE_Registration $registration) { |
|
207 | 206 | static $attendee_nmbr = 1; |
208 | 207 | $form_args = array(); |
209 | 208 | // verify that registration has valid event |
210 | - if ( $registration->event() instanceof EE_Event ) { |
|
209 | + if ($registration->event() instanceof EE_Event) { |
|
211 | 210 | $question_groups = $registration->event()->question_groups( |
212 | 211 | array( |
213 | 212 | array( |
@@ -217,10 +216,10 @@ discard block |
||
217 | 216 | 'order_by' => array('QSG_order' => 'ASC') |
218 | 217 | ) |
219 | 218 | ); |
220 | - if ( $question_groups ) { |
|
219 | + if ($question_groups) { |
|
221 | 220 | // array of params to pass to parent constructor |
222 | 221 | $form_args = array( |
223 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
222 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
224 | 223 | 'html_class' => 'ee-reg-form-attendee-dv', |
225 | 224 | 'html_style' => $this->checkout->admin_request |
226 | 225 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -233,9 +232,9 @@ discard block |
||
233 | 232 | ) |
234 | 233 | ) |
235 | 234 | ); |
236 | - foreach ( $question_groups as $question_group ) { |
|
237 | - if ( $question_group instanceof EE_Question_Group ) { |
|
238 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
235 | + foreach ($question_groups as $question_group) { |
|
236 | + if ($question_group instanceof EE_Question_Group) { |
|
237 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
239 | 238 | $registration, |
240 | 239 | $question_group |
241 | 240 | ); |
@@ -254,7 +253,7 @@ discard block |
||
254 | 253 | } |
255 | 254 | } |
256 | 255 | $attendee_nmbr++; |
257 | - return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
|
256 | + return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML(); |
|
258 | 257 | } |
259 | 258 | |
260 | 259 | |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | // generate hidden input |
276 | 275 | return new EE_Hidden_Input( |
277 | 276 | array( |
278 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
277 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
279 | 278 | 'default' => $additional_attendee_reg_info |
280 | 279 | ) |
281 | 280 | ); |
@@ -289,26 +288,26 @@ discard block |
||
289 | 288 | * @return EE_Form_Section_Proper |
290 | 289 | * @throws \EE_Error |
291 | 290 | */ |
292 | - private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){ |
|
291 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) { |
|
293 | 292 | // array of params to pass to parent constructor |
294 | 293 | $form_args = array( |
295 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier(), |
|
294 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier(), |
|
296 | 295 | 'html_class' => $this->checkout->admin_request |
297 | 296 | ? 'form-table ee-reg-form-qstn-grp-dv' |
298 | 297 | : 'ee-reg-form-qstn-grp-dv', |
299 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl', |
|
298 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl', |
|
300 | 299 | 'subsections' => array( |
301 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group ) |
|
300 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group) |
|
302 | 301 | ), |
303 | 302 | 'layout_strategy' => $this->checkout->admin_request |
304 | 303 | ? new EE_Admin_Two_Column_Layout() |
305 | 304 | : new EE_Div_Per_Section_Layout() |
306 | 305 | ); |
307 | 306 | // where params |
308 | - $query_params = array( 'QST_deleted' => 0 ); |
|
307 | + $query_params = array('QST_deleted' => 0); |
|
309 | 308 | // don't load admin only questions on the frontend |
310 | - if ( ! $this->checkout->admin_request ) { |
|
311 | - $query_params['QST_admin_only'] = array( '!=', true ); |
|
309 | + if ( ! $this->checkout->admin_request) { |
|
310 | + $query_params['QST_admin_only'] = array('!=', true); |
|
312 | 311 | } |
313 | 312 | $questions = $question_group->get_many_related( |
314 | 313 | 'Question', |
@@ -330,10 +329,10 @@ discard block |
||
330 | 329 | ) |
331 | 330 | ); |
332 | 331 | // loop thru questions |
333 | - foreach ( $questions as $question ) { |
|
334 | - if( $question instanceof EE_Question ){ |
|
332 | + foreach ($questions as $question) { |
|
333 | + if ($question instanceof EE_Question) { |
|
335 | 334 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
336 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question ); |
|
335 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
337 | 336 | } |
338 | 337 | } |
339 | 338 | $form_args['subsections'] = apply_filters( |
@@ -354,7 +353,7 @@ discard block |
||
354 | 353 | ) |
355 | 354 | ); |
356 | 355 | // d( $form_args ); |
357 | - $question_group_reg_form = new EE_Form_Section_Proper( $form_args ); |
|
356 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
358 | 357 | return apply_filters( |
359 | 358 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
360 | 359 | $question_group_reg_form, |
@@ -371,11 +370,11 @@ discard block |
||
371 | 370 | * @param EE_Question_Group $question_group |
372 | 371 | * @return EE_Form_Section_HTML |
373 | 372 | */ |
374 | - private function _question_group_header( EE_Question_Group $question_group ){ |
|
373 | + private function _question_group_header(EE_Question_Group $question_group) { |
|
375 | 374 | $html = ''; |
376 | 375 | // group_name |
377 | - if ( $question_group->show_group_name() && $question_group->name() !== '' ) { |
|
378 | - if ( $this->checkout->admin_request ) { |
|
376 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
377 | + if ($this->checkout->admin_request) { |
|
379 | 378 | $html .= EEH_HTML::br(); |
380 | 379 | $html .= EEH_HTML::h3( |
381 | 380 | $question_group->name(), |
@@ -389,7 +388,7 @@ discard block |
||
389 | 388 | } |
390 | 389 | } |
391 | 390 | // group_desc |
392 | - if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) { |
|
391 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
393 | 392 | $html .= EEH_HTML::p( |
394 | 393 | $question_group->desc(), |
395 | 394 | '', |
@@ -399,7 +398,7 @@ discard block |
||
399 | 398 | ); |
400 | 399 | |
401 | 400 | } |
402 | - return new EE_Form_Section_HTML( $html ); |
|
401 | + return new EE_Form_Section_HTML($html); |
|
403 | 402 | } |
404 | 403 | |
405 | 404 | |
@@ -409,7 +408,7 @@ discard block |
||
409 | 408 | * @return EE_Form_Section_Proper |
410 | 409 | * @throws \EE_Error |
411 | 410 | */ |
412 | - private function _copy_attendee_info_form(){ |
|
411 | + private function _copy_attendee_info_form() { |
|
413 | 412 | // array of params to pass to parent constructor |
414 | 413 | return new EE_Form_Section_Proper( |
415 | 414 | array( |
@@ -438,7 +437,7 @@ discard block |
||
438 | 437 | private function _auto_copy_attendee_info() { |
439 | 438 | return new EE_Form_Section_HTML( |
440 | 439 | EEH_Template::locate_template( |
441 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
440 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
442 | 441 | apply_filters( |
443 | 442 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
444 | 443 | array() |
@@ -462,32 +461,32 @@ discard block |
||
462 | 461 | $copy_attendee_info_inputs = array(); |
463 | 462 | $prev_ticket = NULL; |
464 | 463 | // grab the saved registrations from the transaction |
465 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
466 | - foreach ( $registrations as $registration ) { |
|
464 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
465 | + foreach ($registrations as $registration) { |
|
467 | 466 | // for all attendees other than the primary attendee |
468 | - if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) { |
|
467 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
469 | 468 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
470 | - if ( $registration->ticket()->ID() !== $prev_ticket ) { |
|
469 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
471 | 470 | $item_name = $registration->ticket()->name(); |
472 | 471 | $item_name .= $registration->ticket()->description() !== '' |
473 | - ? ' - ' . $registration->ticket()->description() |
|
472 | + ? ' - '.$registration->ticket()->description() |
|
474 | 473 | : ''; |
475 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML( |
|
476 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
474 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML( |
|
475 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
477 | 476 | ); |
478 | 477 | $prev_ticket = $registration->ticket()->ID(); |
479 | 478 | } |
480 | 479 | |
481 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new |
|
480 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new |
|
482 | 481 | EE_Checkbox_Multi_Input( |
483 | 482 | array( |
484 | 483 | $registration->ID() => sprintf( |
485 | - __( 'Attendee #%s', 'event_espresso' ), |
|
484 | + __('Attendee #%s', 'event_espresso'), |
|
486 | 485 | $registration->count() |
487 | 486 | ) |
488 | 487 | ), |
489 | 488 | array( |
490 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
489 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
491 | 490 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
492 | 491 | 'display_html_label_text' => false |
493 | 492 | ) |
@@ -507,7 +506,7 @@ discard block |
||
507 | 506 | * @return EE_Form_Input_Base |
508 | 507 | * @throws \EE_Error |
509 | 508 | */ |
510 | - private function _additional_primary_registrant_inputs( EE_Registration $registration ){ |
|
509 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) { |
|
511 | 510 | // generate hidden input |
512 | 511 | return new EE_Hidden_Input( |
513 | 512 | array( |
@@ -526,7 +525,7 @@ discard block |
||
526 | 525 | * @return EE_Form_Input_Base |
527 | 526 | * @throws \EE_Error |
528 | 527 | */ |
529 | - public function reg_form_question( EE_Registration $registration, EE_Question $question ){ |
|
528 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) { |
|
530 | 529 | |
531 | 530 | // if this question was for an attendee detail, then check for that answer |
532 | 531 | $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
@@ -535,32 +534,32 @@ discard block |
||
535 | 534 | ); |
536 | 535 | $answer = $answer_value === null |
537 | 536 | ? EEM_Answer::instance()->get_one( |
538 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
537 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
539 | 538 | ) |
540 | 539 | : null; |
541 | 540 | // if NOT returning to edit an existing registration |
542 | 541 | // OR if this question is for an attendee property |
543 | 542 | // OR we still don't have an EE_Answer object |
544 | - if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) { |
|
543 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
545 | 544 | // create an EE_Answer object for storing everything in |
546 | - $answer = EE_Answer::new_instance ( array( |
|
545 | + $answer = EE_Answer::new_instance(array( |
|
547 | 546 | 'QST_ID'=> $question->ID(), |
548 | 547 | 'REG_ID'=> $registration->ID() |
549 | 548 | )); |
550 | 549 | } |
551 | 550 | // verify instance |
552 | - if( $answer instanceof EE_Answer ){ |
|
553 | - if ( ! empty( $answer_value )) { |
|
554 | - $answer->set( 'ANS_value', $answer_value ); |
|
551 | + if ($answer instanceof EE_Answer) { |
|
552 | + if ( ! empty($answer_value)) { |
|
553 | + $answer->set('ANS_value', $answer_value); |
|
555 | 554 | } |
556 | - $answer->cache( 'Question', $question ); |
|
555 | + $answer->cache('Question', $question); |
|
557 | 556 | //remember system ID had a bug where sometimes it could be null |
558 | - $answer_cache_id =$question->is_system_question() |
|
559 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
560 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
561 | - $registration->cache( 'Answer', $answer, $answer_cache_id ); |
|
557 | + $answer_cache_id = $question->is_system_question() |
|
558 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
559 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
560 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
562 | 561 | } |
563 | - return $this->_generate_question_input( $registration, $question, $answer ); |
|
562 | + return $this->_generate_question_input($registration, $question, $answer); |
|
564 | 563 | |
565 | 564 | } |
566 | 565 | |
@@ -573,46 +572,46 @@ discard block |
||
573 | 572 | * @return EE_Form_Input_Base |
574 | 573 | * @throws \EE_Error |
575 | 574 | */ |
576 | - private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){ |
|
575 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { |
|
577 | 576 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
578 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
577 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
579 | 578 | add_filter( |
580 | 579 | 'FHEE__EE_Question__generate_form_input__country_options', |
581 | - array( $this, 'use_cached_countries_for_form_input' ), |
|
580 | + array($this, 'use_cached_countries_for_form_input'), |
|
582 | 581 | 10, |
583 | 582 | 4 |
584 | 583 | ); |
585 | 584 | add_filter( |
586 | 585 | 'FHEE__EE_Question__generate_form_input__state_options', |
587 | - array( $this, 'use_cached_states_for_form_input' ), |
|
586 | + array($this, 'use_cached_states_for_form_input'), |
|
588 | 587 | 10, |
589 | 588 | 4 |
590 | 589 | ); |
591 | 590 | $input_constructor_args = array( |
592 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
593 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
594 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
595 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
591 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
592 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
593 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
594 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
596 | 595 | 'html_label_class' => 'ee-reg-qstn', |
597 | 596 | ); |
598 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
599 | - if ( $answer instanceof EE_Answer && $answer->ID() ) { |
|
600 | - $input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']'; |
|
601 | - $input_constructor_args[ 'html_id' ] .= '-' . $answer->ID(); |
|
602 | - $input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID(); |
|
597 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
598 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
599 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
600 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
601 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
603 | 602 | } |
604 | - $form_input = $question->generate_form_input( |
|
603 | + $form_input = $question->generate_form_input( |
|
605 | 604 | $registration, |
606 | 605 | $answer, |
607 | 606 | $input_constructor_args |
608 | 607 | ); |
609 | 608 | remove_filter( |
610 | 609 | 'FHEE__EE_Question__generate_form_input__country_options', |
611 | - array( $this, 'use_cached_countries_for_form_input' ) |
|
610 | + array($this, 'use_cached_countries_for_form_input') |
|
612 | 611 | ); |
613 | 612 | remove_filter( |
614 | 613 | 'FHEE__EE_Question__generate_form_input__state_options', |
615 | - array( $this, 'use_cached_states_for_form_input' ) |
|
614 | + array($this, 'use_cached_states_for_form_input') |
|
616 | 615 | ); |
617 | 616 | return $form_input; |
618 | 617 | } |
@@ -634,22 +633,22 @@ discard block |
||
634 | 633 | \EE_Registration $registration = null, |
635 | 634 | \EE_Answer $answer = null |
636 | 635 | ) { |
637 | - $country_options = array( '' => '' ); |
|
636 | + $country_options = array('' => ''); |
|
638 | 637 | // get possibly cached list of countries |
639 | 638 | $countries = $this->checkout->action === 'process_reg_step' |
640 | 639 | ? EEM_Country::instance()->get_all_countries() |
641 | 640 | : EEM_Country::instance()->get_all_active_countries(); |
642 | - if ( ! empty( $countries )) { |
|
643 | - foreach( $countries as $country ){ |
|
644 | - if ( $country instanceof EE_Country ) { |
|
645 | - $country_options[ $country->ID() ] = $country->name(); |
|
641 | + if ( ! empty($countries)) { |
|
642 | + foreach ($countries as $country) { |
|
643 | + if ($country instanceof EE_Country) { |
|
644 | + $country_options[$country->ID()] = $country->name(); |
|
646 | 645 | } |
647 | 646 | } |
648 | 647 | } |
649 | - if( $question instanceof EE_Question |
|
650 | - && $registration instanceof EE_Registration ) { |
|
648 | + if ($question instanceof EE_Question |
|
649 | + && $registration instanceof EE_Registration) { |
|
651 | 650 | $answer = EEM_Answer::instance()->get_one( |
652 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
651 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
653 | 652 | ); |
654 | 653 | } else { |
655 | 654 | $answer = EE_Answer::new_instance(); |
@@ -682,14 +681,14 @@ discard block |
||
682 | 681 | \EE_Registration $registration = null, |
683 | 682 | \EE_Answer $answer = null |
684 | 683 | ) { |
685 | - $state_options = array( '' => array( '' => '')); |
|
684 | + $state_options = array('' => array('' => '')); |
|
686 | 685 | $states = $this->checkout->action === 'process_reg_step' |
687 | 686 | ? EEM_State::instance()->get_all_states() |
688 | 687 | : EEM_State::instance()->get_all_active_states(); |
689 | - if ( ! empty( $states )) { |
|
690 | - foreach( $states as $state ){ |
|
691 | - if ( $state instanceof EE_State ) { |
|
692 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
688 | + if ( ! empty($states)) { |
|
689 | + foreach ($states as $state) { |
|
690 | + if ($state instanceof EE_State) { |
|
691 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
693 | 692 | } |
694 | 693 | } |
695 | 694 | } |
@@ -717,24 +716,24 @@ discard block |
||
717 | 716 | * @throws \EE_Error |
718 | 717 | */ |
719 | 718 | public function process_reg_step() { |
720 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
719 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
721 | 720 | // grab validated data from form |
722 | 721 | $valid_data = $this->checkout->current_step->valid_data(); |
723 | 722 | // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
724 | 723 | // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
725 | 724 | // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
726 | - if ( empty( $valid_data )) { |
|
725 | + if (empty($valid_data)) { |
|
727 | 726 | EE_Error::add_error( |
728 | - __( 'No valid question responses were received.', 'event_espresso' ), |
|
727 | + __('No valid question responses were received.', 'event_espresso'), |
|
729 | 728 | __FILE__, |
730 | 729 | __FUNCTION__, |
731 | 730 | __LINE__ |
732 | 731 | ); |
733 | 732 | return false; |
734 | 733 | } |
735 | - if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) { |
|
734 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
736 | 735 | EE_Error::add_error( |
737 | - __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), |
|
736 | + __('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), |
|
738 | 737 | __FILE__, |
739 | 738 | __FUNCTION__, |
740 | 739 | __LINE__ |
@@ -742,14 +741,14 @@ discard block |
||
742 | 741 | return false; |
743 | 742 | } |
744 | 743 | // get cached registrations |
745 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
744 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
746 | 745 | // verify we got the goods |
747 | - if ( empty( $registrations )) { |
|
746 | + if (empty($registrations)) { |
|
748 | 747 | //combine the old translated string with a new one, in order to not break translations |
749 | - $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ) |
|
748 | + $error_message = esc_html__('Your form data could not be applied to any valid registrations.', 'event_espresso') |
|
750 | 749 | . sprintf( |
751 | 750 | esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'), |
752 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
751 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
753 | 752 | '</a>', |
754 | 753 | '<br />' |
755 | 754 | ); |
@@ -762,15 +761,15 @@ discard block |
||
762 | 761 | return false; |
763 | 762 | } |
764 | 763 | // extract attendee info from form data and save to model objects |
765 | - $registrations_processed = $this->_process_registrations( $registrations, $valid_data ); |
|
764 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
766 | 765 | // if first pass thru SPCO, |
767 | 766 | // then let's check processed registrations against the total number of tickets in the cart |
768 | - if ( $registrations_processed === false ) { |
|
767 | + if ($registrations_processed === false) { |
|
769 | 768 | // but return immediately if the previous step exited early due to errors |
770 | 769 | return false; |
771 | - } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) { |
|
770 | + } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
772 | 771 | // generate a correctly translated string for all possible singular/plural combinations |
773 | - if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) { |
|
772 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
774 | 773 | $error_msg = sprintf( |
775 | 774 | __( |
776 | 775 | 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
@@ -779,7 +778,7 @@ discard block |
||
779 | 778 | $this->checkout->total_ticket_count, |
780 | 779 | $registrations_processed |
781 | 780 | ); |
782 | - } else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) { |
|
781 | + } else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
783 | 782 | $error_msg = sprintf( |
784 | 783 | __( |
785 | 784 | 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
@@ -798,17 +797,17 @@ discard block |
||
798 | 797 | $registrations_processed |
799 | 798 | ); |
800 | 799 | } |
801 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
800 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
802 | 801 | return false; |
803 | 802 | } |
804 | 803 | // mark this reg step as completed |
805 | 804 | $this->set_completed(); |
806 | 805 | $this->_set_success_message( |
807 | - __( 'The Attendee Information Step has been successfully completed.', 'event_espresso' ) |
|
806 | + __('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
808 | 807 | ); |
809 | 808 | //do action in case a plugin wants to do something with the data submitted in step 1. |
810 | 809 | //passes EE_Single_Page_Checkout, and it's posted data |
811 | - do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data ); |
|
810 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
812 | 811 | return true; |
813 | 812 | } |
814 | 813 | |
@@ -822,9 +821,9 @@ discard block |
||
822 | 821 | * @return boolean | int |
823 | 822 | * @throws \EE_Error |
824 | 823 | */ |
825 | - private function _process_registrations( $registrations = array(), $valid_data = array() ) { |
|
824 | + private function _process_registrations($registrations = array(), $valid_data = array()) { |
|
826 | 825 | // load resources and set some defaults |
827 | - EE_Registry::instance()->load_model( 'Attendee' ); |
|
826 | + EE_Registry::instance()->load_model('Attendee'); |
|
828 | 827 | // holder for primary registrant attendee object |
829 | 828 | $this->checkout->primary_attendee_obj = NULL; |
830 | 829 | // array for tracking reg form data for the primary registrant |
@@ -841,9 +840,9 @@ discard block |
||
841 | 840 | // attendee counter |
842 | 841 | $att_nmbr = 0; |
843 | 842 | // grab the saved registrations from the transaction |
844 | - foreach ( $registrations as $registration ) { |
|
843 | + foreach ($registrations as $registration) { |
|
845 | 844 | // verify EE_Registration object |
846 | - if ( ! $registration instanceof EE_Registration ) { |
|
845 | + if ( ! $registration instanceof EE_Registration) { |
|
847 | 846 | EE_Error::add_error( |
848 | 847 | __( |
849 | 848 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -858,12 +857,12 @@ discard block |
||
858 | 857 | /** @var string $reg_url_link */ |
859 | 858 | $reg_url_link = $registration->reg_url_link(); |
860 | 859 | // reg_url_link exists ? |
861 | - if ( ! empty( $reg_url_link ) ) { |
|
860 | + if ( ! empty($reg_url_link)) { |
|
862 | 861 | // should this registration be processed during this visit ? |
863 | - if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) { |
|
862 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
864 | 863 | // if NOT revisiting, then let's save the registration now, |
865 | 864 | // so that we have a REG_ID to use when generating other objects |
866 | - if ( ! $this->checkout->revisit ) { |
|
865 | + if ( ! $this->checkout->revisit) { |
|
867 | 866 | $registration->save(); |
868 | 867 | } |
869 | 868 | /** |
@@ -873,7 +872,7 @@ discard block |
||
873 | 872 | * @var bool if true is returned by the plugin then the |
874 | 873 | * registration processing is halted. |
875 | 874 | */ |
876 | - if ( apply_filters( |
|
875 | + if (apply_filters( |
|
877 | 876 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
878 | 877 | false, |
879 | 878 | $att_nmbr, |
@@ -881,38 +880,38 @@ discard block |
||
881 | 880 | $registrations, |
882 | 881 | $valid_data, |
883 | 882 | $this |
884 | - ) ) { |
|
883 | + )) { |
|
885 | 884 | return false; |
886 | 885 | } |
887 | 886 | |
888 | 887 | // Houston, we have a registration! |
889 | 888 | $att_nmbr++; |
890 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
889 | + $this->_attendee_data[$reg_url_link] = array(); |
|
891 | 890 | // grab any existing related answer objects |
892 | 891 | $this->_registration_answers = $registration->answers(); |
893 | 892 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
894 | - if ( isset( $valid_data[ $reg_url_link ] ) ) { |
|
893 | + if (isset($valid_data[$reg_url_link])) { |
|
895 | 894 | // do we need to copy basic info from primary attendee ? |
896 | - $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
|
897 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
895 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
896 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 |
|
898 | 897 | ? true |
899 | 898 | : false; |
900 | 899 | // filter form input data for this registration |
901 | - $valid_data[ $reg_url_link ] = (array)apply_filters( |
|
900 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
902 | 901 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
903 | - $valid_data[ $reg_url_link ] |
|
902 | + $valid_data[$reg_url_link] |
|
904 | 903 | ); |
905 | 904 | // EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ ); |
906 | - if ( isset( $valid_data['primary_attendee'] )) { |
|
907 | - $primary_registrant['line_item_id'] = ! empty( $valid_data['primary_attendee'] ) |
|
905 | + if (isset($valid_data['primary_attendee'])) { |
|
906 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
908 | 907 | ? $valid_data['primary_attendee'] |
909 | 908 | : false; |
910 | - unset( $valid_data['primary_attendee'] ); |
|
909 | + unset($valid_data['primary_attendee']); |
|
911 | 910 | } |
912 | 911 | // now loop through our array of valid post data && process attendee reg forms |
913 | - foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) { |
|
914 | - if ( ! in_array( $form_section, $non_input_form_sections )) { |
|
915 | - foreach ( $form_inputs as $form_input => $input_value ) { |
|
912 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
913 | + if ( ! in_array($form_section, $non_input_form_sections)) { |
|
914 | + foreach ($form_inputs as $form_input => $input_value) { |
|
916 | 915 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
917 | 916 | // check for critical inputs |
918 | 917 | if ( |
@@ -926,16 +925,16 @@ discard block |
||
926 | 925 | // store a bit of data about the primary attendee |
927 | 926 | if ( |
928 | 927 | $att_nmbr === 1 |
929 | - && ! empty( $input_value ) |
|
928 | + && ! empty($input_value) |
|
930 | 929 | && $reg_url_link === $primary_registrant['line_item_id'] |
931 | 930 | ) { |
932 | - $primary_registrant[ $form_input ] = $input_value; |
|
931 | + $primary_registrant[$form_input] = $input_value; |
|
933 | 932 | } else if ( |
934 | 933 | $copy_primary |
935 | 934 | && $input_value === null |
936 | - && isset( $primary_registrant[ $form_input ] ) |
|
935 | + && isset($primary_registrant[$form_input]) |
|
937 | 936 | ) { |
938 | - $input_value = $primary_registrant[ $form_input ]; |
|
937 | + $input_value = $primary_registrant[$form_input]; |
|
939 | 938 | } |
940 | 939 | // now attempt to save the input data |
941 | 940 | if ( |
@@ -975,47 +974,47 @@ discard block |
||
975 | 974 | $attendee = $this->checkout->primary_attendee_obj; |
976 | 975 | } else { |
977 | 976 | // ensure critical details are set for additional attendees |
978 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
977 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
979 | 978 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
980 | - $this->_attendee_data[ $reg_url_link ] |
|
979 | + $this->_attendee_data[$reg_url_link] |
|
981 | 980 | ) |
982 | - : $this->_attendee_data[ $reg_url_link ]; |
|
981 | + : $this->_attendee_data[$reg_url_link]; |
|
983 | 982 | // execute create attendee command (which may return an existing attendee) |
984 | 983 | $attendee = EE_Registry::instance()->BUS->execute( |
985 | 984 | new CreateAttendeeCommand( |
986 | - $this->_attendee_data[ $reg_url_link ], |
|
985 | + $this->_attendee_data[$reg_url_link], |
|
987 | 986 | $registration |
988 | 987 | ) |
989 | 988 | ); |
990 | 989 | // who's #1 ? |
991 | - if ( $att_nmbr === 1 ) { |
|
990 | + if ($att_nmbr === 1) { |
|
992 | 991 | $this->checkout->primary_attendee_obj = $attendee; |
993 | 992 | } |
994 | 993 | } |
995 | 994 | // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
996 | 995 | // add relation to registration, set attendee ID, and cache attendee |
997 | - $this->_associate_attendee_with_registration( $registration, $attendee ); |
|
996 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
998 | 997 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
999 | - if ( ! $registration->attendee() instanceof EE_Attendee ) { |
|
1000 | - EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ ); |
|
998 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
999 | + EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__); |
|
1001 | 1000 | return false; |
1002 | 1001 | } |
1003 | 1002 | /** @type EE_Registration_Processor $registration_processor */ |
1004 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1003 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1005 | 1004 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1006 | - $registration_processor->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
1005 | + $registration_processor->toggle_incomplete_registration_status_to_default($registration, false); |
|
1007 | 1006 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1008 | 1007 | $this->checkout->transaction->toggle_failed_transaction_status(); |
1009 | 1008 | // if we've gotten this far, then let's save what we have |
1010 | 1009 | $registration->save(); |
1011 | 1010 | // add relation between TXN and registration |
1012 | - $this->_associate_registration_with_transaction( $registration ); |
|
1011 | + $this->_associate_registration_with_transaction($registration); |
|
1013 | 1012 | } // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) { |
1014 | 1013 | |
1015 | - } else { |
|
1016 | - EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1014 | + } else { |
|
1015 | + EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1017 | 1016 | // remove malformed data |
1018 | - unset( $valid_data[ $reg_url_link ] ); |
|
1017 | + unset($valid_data[$reg_url_link]); |
|
1019 | 1018 | return false; |
1020 | 1019 | } |
1021 | 1020 | |
@@ -1044,14 +1043,14 @@ discard block |
||
1044 | 1043 | // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
1045 | 1044 | // allow for plugins to hook in and do their own processing of the form input. |
1046 | 1045 | // For plugins to bypass normal processing here, they just need to return a boolean value. |
1047 | - if ( apply_filters( |
|
1046 | + if (apply_filters( |
|
1048 | 1047 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
1049 | 1048 | false, |
1050 | 1049 | $registration, |
1051 | 1050 | $form_input, |
1052 | 1051 | $input_value, |
1053 | 1052 | $this |
1054 | - ) ) { |
|
1053 | + )) { |
|
1055 | 1054 | return true; |
1056 | 1055 | } |
1057 | 1056 | /* |
@@ -1059,14 +1058,14 @@ discard block |
||
1059 | 1058 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1060 | 1059 | */ |
1061 | 1060 | $answer_cache_id = $this->checkout->reg_url_link |
1062 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1061 | + ? $form_input.'-'.$registration->reg_url_link() |
|
1063 | 1062 | : $form_input; |
1064 | - $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
|
1065 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1063 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1064 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer |
|
1066 | 1065 | ? true |
1067 | 1066 | : false; |
1068 | 1067 | //rename form_inputs if they are EE_Attendee properties |
1069 | - switch( (string)$form_input ) { |
|
1068 | + switch ((string) $form_input) { |
|
1070 | 1069 | |
1071 | 1070 | case 'state' : |
1072 | 1071 | case 'STA_ID' : |
@@ -1081,32 +1080,32 @@ discard block |
||
1081 | 1080 | break; |
1082 | 1081 | |
1083 | 1082 | default : |
1084 | - $ATT_input = 'ATT_' . $form_input; |
|
1083 | + $ATT_input = 'ATT_'.$form_input; |
|
1085 | 1084 | //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1086 | - $attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false; |
|
1087 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1085 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1086 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1088 | 1087 | } |
1089 | 1088 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1090 | 1089 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1091 | 1090 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1092 | 1091 | // if this form input has a corresponding attendee property |
1093 | - if ( $attendee_property ) { |
|
1094 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1095 | - if ( $answer_is_obj ) { |
|
1092 | + if ($attendee_property) { |
|
1093 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1094 | + if ($answer_is_obj) { |
|
1096 | 1095 | // and delete the corresponding answer since we won't be storing this data in that object |
1097 | - $registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' ); |
|
1098 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1096 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1097 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1099 | 1098 | } |
1100 | 1099 | return true; |
1101 | - } elseif ( $answer_is_obj ) { |
|
1100 | + } elseif ($answer_is_obj) { |
|
1102 | 1101 | // save this data to the answer object |
1103 | - $this->_registration_answers[ $answer_cache_id ]->set_value( $input_value ); |
|
1104 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1102 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1103 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1105 | 1104 | return $result !== false ? true : false; |
1106 | 1105 | } else { |
1107 | - foreach ( $this->_registration_answers as $answer ) { |
|
1108 | - if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) { |
|
1109 | - $answer->set_value( $input_value ); |
|
1106 | + foreach ($this->_registration_answers as $answer) { |
|
1107 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1108 | + $answer->set_value($input_value); |
|
1110 | 1109 | $result = $answer->save(); |
1111 | 1110 | return $result !== false ? true : false; |
1112 | 1111 | } |
@@ -1128,15 +1127,15 @@ discard block |
||
1128 | 1127 | $form_input = '', |
1129 | 1128 | $input_value = '' |
1130 | 1129 | ) { |
1131 | - if ( empty( $input_value ) ) { |
|
1130 | + if (empty($input_value)) { |
|
1132 | 1131 | // if the form input isn't marked as being required, then just return |
1133 | - if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) { |
|
1132 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1134 | 1133 | return true; |
1135 | 1134 | } |
1136 | - switch ( $form_input ) { |
|
1135 | + switch ($form_input) { |
|
1137 | 1136 | case 'fname' : |
1138 | 1137 | EE_Error::add_error( |
1139 | - __( 'First Name is a required value.', 'event_espresso' ), |
|
1138 | + __('First Name is a required value.', 'event_espresso'), |
|
1140 | 1139 | __FILE__, |
1141 | 1140 | __FUNCTION__, |
1142 | 1141 | __LINE__ |
@@ -1145,7 +1144,7 @@ discard block |
||
1145 | 1144 | break; |
1146 | 1145 | case 'lname' : |
1147 | 1146 | EE_Error::add_error( |
1148 | - __( 'Last Name is a required value.', 'event_espresso' ), |
|
1147 | + __('Last Name is a required value.', 'event_espresso'), |
|
1149 | 1148 | __FILE__, |
1150 | 1149 | __FUNCTION__, |
1151 | 1150 | __LINE__ |
@@ -1154,7 +1153,7 @@ discard block |
||
1154 | 1153 | break; |
1155 | 1154 | case 'email' : |
1156 | 1155 | EE_Error::add_error( |
1157 | - __( 'Please enter a valid email address.', 'event_espresso' ), |
|
1156 | + __('Please enter a valid email address.', 'event_espresso'), |
|
1158 | 1157 | __FILE__, |
1159 | 1158 | __FUNCTION__, |
1160 | 1159 | __LINE__ |
@@ -1176,11 +1175,11 @@ discard block |
||
1176 | 1175 | * @return void |
1177 | 1176 | * @throws \EE_Error |
1178 | 1177 | */ |
1179 | - private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) { |
|
1178 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) { |
|
1180 | 1179 | // add relation to attendee |
1181 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1182 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1183 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1180 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1181 | + $registration->set_attendee_id($attendee->ID()); |
|
1182 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1184 | 1183 | } |
1185 | 1184 | |
1186 | 1185 | |
@@ -1192,10 +1191,10 @@ discard block |
||
1192 | 1191 | * @return void |
1193 | 1192 | * @throws \EE_Error |
1194 | 1193 | */ |
1195 | - private function _associate_registration_with_transaction( EE_Registration $registration ) { |
|
1194 | + private function _associate_registration_with_transaction(EE_Registration $registration) { |
|
1196 | 1195 | // add relation to registration |
1197 | - $this->checkout->transaction->_add_relation_to( $registration, 'Registration' ); |
|
1198 | - $this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration ); |
|
1196 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1197 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1199 | 1198 | } |
1200 | 1199 | |
1201 | 1200 | |
@@ -1208,14 +1207,14 @@ discard block |
||
1208 | 1207 | * @return array |
1209 | 1208 | * @throws \EE_Error |
1210 | 1209 | */ |
1211 | - private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) { |
|
1210 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) { |
|
1212 | 1211 | // bare minimum critical details include first name, last name, email address |
1213 | - $critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1212 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1214 | 1213 | // add address info to critical details? |
1215 | - if ( apply_filters( |
|
1214 | + if (apply_filters( |
|
1216 | 1215 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
1217 | 1216 | false |
1218 | - ) ) { |
|
1217 | + )) { |
|
1219 | 1218 | $address_details = array( |
1220 | 1219 | 'ATT_address', |
1221 | 1220 | 'ATT_address2', |
@@ -1225,13 +1224,13 @@ discard block |
||
1225 | 1224 | 'ATT_zip', |
1226 | 1225 | 'ATT_phone' |
1227 | 1226 | ); |
1228 | - $critical_attendee_details = array_merge( $critical_attendee_details, $address_details ); |
|
1227 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1229 | 1228 | } |
1230 | - foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
|
1231 | - if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
|
1232 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1229 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1230 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1231 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1233 | 1232 | ) { |
1234 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1233 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1235 | 1234 | $critical_attendee_detail |
1236 | 1235 | ); |
1237 | 1236 | } |
@@ -1251,7 +1250,7 @@ discard block |
||
1251 | 1250 | */ |
1252 | 1251 | public function update_reg_step() { |
1253 | 1252 | // save everything |
1254 | - if ( $this->process_reg_step() ) { |
|
1253 | + if ($this->process_reg_step()) { |
|
1255 | 1254 | $this->checkout->redirect = true; |
1256 | 1255 | $this->checkout->redirect_url = add_query_arg( |
1257 | 1256 | array( |
@@ -1260,7 +1259,7 @@ discard block |
||
1260 | 1259 | ), |
1261 | 1260 | $this->checkout->thank_you_page_url |
1262 | 1261 | ); |
1263 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1262 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1264 | 1263 | return true; |
1265 | 1264 | } |
1266 | 1265 | return false; |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\CommandHandler; |
7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
50 | 50 | * @throws \EE_Error |
51 | 51 | */ |
52 | - public function handle( CommandInterface $command ) { |
|
52 | + public function handle(CommandInterface $command) { |
|
53 | 53 | /** @var CreateTicketLineItemCommand $command */ |
54 | - if ( ! $command instanceof CreateTicketLineItemCommand ) { |
|
55 | - throw new InvalidEntityException( get_class( $command ), 'CreateTicketLineItemCommand' ); |
|
54 | + if ( ! $command instanceof CreateTicketLineItemCommand) { |
|
55 | + throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
56 | 56 | } |
57 | 57 | // create new line item for ticket |
58 | 58 | return $this->factory->create( |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\interfaces\InterminableInterface; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | +if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | +} |
|
5 | 7 | /** |
6 | 8 | * Event Espresso |
7 | 9 | * |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\interfaces\InterminableInterface; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
5 | 5 | /** |
6 | 6 | * Event Espresso |
7 | 7 | * |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function instance() { |
45 | 45 | // check if class object is instantiated |
46 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
46 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
47 | 47 | self::$_instance = new self(); |
48 | 48 | } |
49 | 49 | return self::$_instance; |
@@ -70,25 +70,25 @@ discard block |
||
70 | 70 | // define global EE_Admin constants |
71 | 71 | $this->_define_all_constants(); |
72 | 72 | // set autoloaders for our admin page classes based on included path information |
73 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
73 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
74 | 74 | // admin hooks |
75 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
75 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
76 | 76 | // load EE_Request_Handler early |
77 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
78 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
79 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
80 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
81 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
82 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
83 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
84 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
85 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
86 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
77 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
78 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
79 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
80 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
81 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
82 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
83 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
84 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
85 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
86 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
87 | 87 | |
88 | 88 | //reset Environment config (we only do this on admin page loads); |
89 | 89 | EE_Registry::instance()->CFG->environment->recheck_values(); |
90 | 90 | |
91 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
91 | + do_action('AHEE__EE_Admin__loaded'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * @return void |
104 | 104 | */ |
105 | 105 | private function _define_all_constants() { |
106 | - if ( ! defined( 'EE_ADMIN_URL' ) ) { |
|
107 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
108 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
109 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
110 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
111 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ) ); |
|
106 | + if ( ! defined('EE_ADMIN_URL')) { |
|
107 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
108 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
109 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
110 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
111 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -122,23 +122,23 @@ discard block |
||
122 | 122 | * @param string $plugin |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - public function filter_plugin_actions( $links, $plugin ) { |
|
125 | + public function filter_plugin_actions($links, $plugin) { |
|
126 | 126 | // set $main_file in stone |
127 | 127 | static $main_file; |
128 | 128 | // if $main_file is not set yet |
129 | - if ( ! $main_file ) { |
|
130 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
129 | + if ( ! $main_file) { |
|
130 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
131 | 131 | } |
132 | - if ( $plugin === $main_file ) { |
|
132 | + if ($plugin === $main_file) { |
|
133 | 133 | // compare current plugin to this one |
134 | - if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
135 | - $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>'; |
|
136 | - array_unshift( $links, $maintenance_link ); |
|
134 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
135 | + $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>'; |
|
136 | + array_unshift($links, $maintenance_link); |
|
137 | 137 | } else { |
138 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
139 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
138 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
139 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
140 | 140 | // add before other links |
141 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
141 | + array_unshift($links, $org_settings_link, $events_link); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | return $links; |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @return void |
154 | 154 | */ |
155 | 155 | public function get_request() { |
156 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
157 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
156 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
157 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param array $admin_page_folder_names |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
169 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
170 | 170 | return array( |
171 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
172 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
173 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
171 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
172 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
173 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
174 | 174 | ); |
175 | 175 | } |
176 | 176 | |
@@ -184,31 +184,31 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function init() { |
186 | 186 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
187 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
187 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
188 | 188 | //ok so we want to enable the entire admin |
189 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
190 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
191 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
189 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
190 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
191 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
192 | 192 | //at a glance dashboard widget |
193 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
193 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
194 | 194 | //filter for get_edit_post_link used on comments for custom post types |
195 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 ); |
|
195 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
196 | 196 | } |
197 | 197 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
198 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
198 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
199 | 199 | try { |
200 | 200 | //this loads the controller for the admin pages which will setup routing etc |
201 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
202 | - } catch ( EE_Error $e ) { |
|
201 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
202 | + } catch (EE_Error $e) { |
|
203 | 203 | $e->get_error(); |
204 | 204 | } |
205 | 205 | } |
206 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
206 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
207 | 207 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
208 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
209 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
208 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
209 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
210 | 210 | //exclude EE critical pages from all nav menus and wp_list_pages |
211 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
211 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * @param object $post_type WP post type object |
222 | 222 | * @return object WP post type object |
223 | 223 | */ |
224 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
224 | + public function remove_pages_from_nav_menu($post_type) { |
|
225 | 225 | //if this isn't the "pages" post type let's get out |
226 | - if ( $post_type->name !== 'page' ) { |
|
226 | + if ($post_type->name !== 'page') { |
|
227 | 227 | return $post_type; |
228 | 228 | } |
229 | 229 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function enable_hidden_ee_nav_menu_metaboxes() { |
245 | 245 | global $wp_meta_boxes, $pagenow; |
246 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
246 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | $user = wp_get_current_user(); |
250 | 250 | //has this been done yet? |
251 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
251 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
256 | - $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' ) ); |
|
255 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
256 | + $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')); |
|
257 | 257 | |
258 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
259 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
260 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
261 | - unset( $hidden_meta_boxes[ $key ] ); |
|
258 | + if (is_array($hidden_meta_boxes)) { |
|
259 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
260 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
261 | + unset($hidden_meta_boxes[$key]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
267 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
266 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
267 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return void |
284 | 284 | */ |
285 | 285 | public function register_custom_nav_menu_boxes() { |
286 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
286 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -299,16 +299,16 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return string the (maybe) modified link |
301 | 301 | */ |
302 | - public function modify_edit_post_link( $link, $id ) { |
|
303 | - if ( ! $post = get_post( $id ) ){ |
|
302 | + public function modify_edit_post_link($link, $id) { |
|
303 | + if ( ! $post = get_post($id)) { |
|
304 | 304 | return $link; |
305 | 305 | } |
306 | - if ( $post->post_type === 'espresso_attendees' ) { |
|
306 | + if ($post->post_type === 'espresso_attendees') { |
|
307 | 307 | $query_args = array( |
308 | 308 | 'action' => 'edit_attendee', |
309 | 309 | 'post' => $id |
310 | 310 | ); |
311 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
311 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
312 | 312 | } |
313 | 313 | return $link; |
314 | 314 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | global $nav_menu_selected_id; |
321 | 321 | |
322 | 322 | $db_fields = false; |
323 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
323 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
324 | 324 | $current_tab = 'event-archives'; |
325 | 325 | |
326 | 326 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | ?> |
340 | 340 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
341 | 341 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
342 | - <li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
343 | - <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"> |
|
344 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
342 | + <li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
343 | + <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"> |
|
344 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
345 | 345 | </a> |
346 | 346 | </li> |
347 | 347 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | <?php */ ?> |
360 | 360 | |
361 | 361 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
362 | - echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
362 | + echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
363 | 363 | ?>"> |
364 | 364 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
365 | 365 | <?php |
366 | 366 | $pages = $this->_get_extra_nav_menu_pages_items(); |
367 | 367 | $args['walker'] = $walker; |
368 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
368 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
369 | 369 | ?> |
370 | 370 | </ul> |
371 | 371 | </div><!-- /.tabs-panel --> |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | <p class="button-controls"> |
374 | 374 | <span class="list-controls"> |
375 | 375 | <a href="<?php |
376 | - echo esc_url( add_query_arg( |
|
376 | + echo esc_url(add_query_arg( |
|
377 | 377 | array( |
378 | 378 | 'extra-nav-menu-pages-tab' => 'event-archives', |
379 | 379 | 'selectall' => 1, |
380 | 380 | ), |
381 | - remove_query_arg( $removed_args ) |
|
381 | + remove_query_arg($removed_args) |
|
382 | 382 | )); |
383 | 383 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
384 | 384 | </span> |
385 | 385 | |
386 | 386 | <span class="add-to-menu"> |
387 | - <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' ); ?>" /> |
|
387 | + <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'); ?>" /> |
|
388 | 388 | <span class="spinner"></span> |
389 | 389 | </span> |
390 | 390 | </p> |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | private function _get_extra_nav_menu_pages_items() { |
406 | 406 | $menuitems[] = array( |
407 | 407 | 'title' => __('Event List', 'event_espresso'), |
408 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
408 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
409 | 409 | 'description' => __('Archive page for all events.', 'event_espresso') |
410 | 410 | ); |
411 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
411 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @param $menu_item_values |
421 | 421 | * @return stdClass |
422 | 422 | */ |
423 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
423 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
424 | 424 | $menu_item = new stdClass(); |
425 | 425 | $keys = array( |
426 | 426 | 'ID' => 0, |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | 'xfn' => '' |
441 | 441 | ); |
442 | 442 | |
443 | - foreach ( $keys as $key => $value) { |
|
444 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
443 | + foreach ($keys as $key => $value) { |
|
444 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
445 | 445 | } |
446 | 446 | return $menu_item; |
447 | 447 | } |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | * - check if doing post processing of one of EE CPTs |
481 | 481 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
482 | 482 | */ |
483 | - if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) { |
|
484 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
485 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
483 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
484 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
485 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * tab in the EE General Settings Admin page. |
493 | 493 | * This is for user-proofing. |
494 | 494 | */ |
495 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
495 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | |
@@ -503,25 +503,25 @@ discard block |
||
503 | 503 | * @param string $output Current output. |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public function modify_dropdown_pages( $output ) { |
|
506 | + public function modify_dropdown_pages($output) { |
|
507 | 507 | //get critical pages |
508 | 508 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
509 | 509 | |
510 | 510 | //split current output by line break for easier parsing. |
511 | - $split_output = explode( "\n", $output ); |
|
511 | + $split_output = explode("\n", $output); |
|
512 | 512 | |
513 | 513 | //loop through to remove any critical pages from the array. |
514 | - foreach ( $critical_pages as $page_id ) { |
|
515 | - $needle = 'value="' . $page_id . '"'; |
|
516 | - foreach( $split_output as $key => $haystack ) { |
|
517 | - if( strpos( $haystack, $needle ) !== false ) { |
|
518 | - unset( $split_output[$key] ); |
|
514 | + foreach ($critical_pages as $page_id) { |
|
515 | + $needle = 'value="'.$page_id.'"'; |
|
516 | + foreach ($split_output as $key => $haystack) { |
|
517 | + if (strpos($haystack, $needle) !== false) { |
|
518 | + unset($split_output[$key]); |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | 523 | //replace output with the new contents |
524 | - return implode( "\n", $split_output ); |
|
524 | + return implode("\n", $split_output); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -535,17 +535,17 @@ discard block |
||
535 | 535 | public function enqueue_admin_scripts() { |
536 | 536 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
537 | 537 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
538 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
538 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
539 | 539 | // register cookie script for future dependencies |
540 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
540 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
541 | 541 | //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' ); |
542 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
542 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
543 | 543 | //joyride style |
544 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
545 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
546 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
544 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
545 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
546 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
547 | 547 | //joyride JS |
548 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
548 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
549 | 549 | // wanna go for a joyride? |
550 | 550 | wp_enqueue_style('ee-joyride-css'); |
551 | 551 | wp_enqueue_script('jquery-joyride'); |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | public function get_persistent_admin_notices() { |
576 | 576 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
577 | 577 | $args = array( |
578 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
579 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
578 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
579 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
580 | 580 | ); |
581 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
582 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
581 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
582 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -604,24 +604,24 @@ discard block |
||
604 | 604 | public function dashboard_glance_items($elements) { |
605 | 605 | $elements = is_array($elements) ? $elements : array($elements); |
606 | 606 | $events = EEM_Event::instance()->count(); |
607 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
608 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
607 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
608 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
609 | 609 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
610 | 610 | $registrations = EEM_Registration::instance()->count( |
611 | 611 | array( |
612 | 612 | array( |
613 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
613 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
614 | 614 | ) |
615 | 615 | ) |
616 | 616 | ); |
617 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
618 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
617 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
618 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
619 | 619 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
620 | 620 | |
621 | - $items = (array) apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
621 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
622 | 622 | |
623 | - foreach ( $items as $type => $item_properties ) { |
|
624 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
623 | + foreach ($items as $type => $item_properties) { |
|
624 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
625 | 625 | } |
626 | 626 | return $elements; |
627 | 627 | } |
@@ -638,31 +638,31 @@ discard block |
||
638 | 638 | * @throws EE_Error |
639 | 639 | * @return string |
640 | 640 | */ |
641 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
641 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
642 | 642 | // check for date_format or time_format |
643 | - switch ( $option ) { |
|
643 | + switch ($option) { |
|
644 | 644 | case 'date_format' : |
645 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
645 | + $date_time_format = $value.' '.get_option('time_format'); |
|
646 | 646 | break; |
647 | 647 | case 'time_format' : |
648 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
648 | + $date_time_format = get_option('date_format').' '.$value; |
|
649 | 649 | break; |
650 | 650 | default : |
651 | 651 | $date_time_format = FALSE; |
652 | 652 | } |
653 | 653 | // do we have a date_time format to check ? |
654 | - if ( $date_time_format ) { |
|
655 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
654 | + if ($date_time_format) { |
|
655 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
656 | 656 | |
657 | - if ( is_array( $error_msg ) ) { |
|
658 | - $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>'; |
|
657 | + if (is_array($error_msg)) { |
|
658 | + $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>'; |
|
659 | 659 | |
660 | 660 | |
661 | - foreach ( $error_msg as $error ) { |
|
662 | - $msg .= '<li>' . $error . '</li>'; |
|
661 | + foreach ($error_msg as $error) { |
|
662 | + $msg .= '<li>'.$error.'</li>'; |
|
663 | 663 | } |
664 | 664 | |
665 | - $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>'; |
|
665 | + $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>'; |
|
666 | 666 | |
667 | 667 | // trigger WP settings error |
668 | 668 | add_settings_error( |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | ); |
673 | 673 | |
674 | 674 | // set format to something valid |
675 | - switch ( $option ) { |
|
675 | + switch ($option) { |
|
676 | 676 | case 'date_format' : |
677 | 677 | $value = 'F j, Y'; |
678 | 678 | break; |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | * @param $content |
695 | 695 | * @return string |
696 | 696 | */ |
697 | - public function its_eSpresso( $content ) { |
|
698 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
697 | + public function its_eSpresso($content) { |
|
698 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @return string |
708 | 708 | */ |
709 | 709 | public function espresso_admin_footer() { |
710 | - return \EEH_Template::powered_by_event_espresso( 'aln-cntr', '', array( 'utm_content' => 'admin_footer' )); |
|
710 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | |
@@ -726,12 +726,12 @@ discard block |
||
726 | 726 | * @param array $config |
727 | 727 | * @return void |
728 | 728 | */ |
729 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
730 | - 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' ); |
|
731 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
729 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
730 | + 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'); |
|
731 | + if (class_exists('EE_Register_Admin_Page')) { |
|
732 | 732 | $config['page_path'] = $page_path; |
733 | 733 | } |
734 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
734 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
735 | 735 | |
736 | 736 | } |
737 | 737 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * @param \WP_Post $post |
745 | 745 | * @return void |
746 | 746 | */ |
747 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
747 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
748 | 748 | EE_Error::doing_it_wrong( |
749 | 749 | __METHOD__, |
750 | 750 | __('Usage is deprecated', 'event_espresso'), |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * @param $value |
763 | 763 | * @return void |
764 | 764 | */ |
765 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
765 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
766 | 766 | EE_Error::doing_it_wrong( |
767 | 767 | __METHOD__, |
768 | 768 | __('Usage is deprecated', 'event_espresso'), |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\interfaces; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 |