@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @author Mike Nelson |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base{ |
|
18 | +class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return \EE_Default_Where_Conditions |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | return array( |
26 | 26 | //if they can't access users, they can still access themselves |
27 | - EE_Restriction_Generator_Base::get_cap_name( $this->model(), $this->action() ) => new EE_Default_Where_Conditions( array( |
|
27 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array( |
|
28 | 28 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
29 | 29 | )), |
30 | 30 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * |
15 | 15 | */ |
16 | 16 | class EE_Return_None_Where_Conditions extends EE_Default_Where_Conditions { |
17 | - protected function _get_default_where_conditions(){ |
|
18 | - if( $this->_model->has_primary_key_field() ) { |
|
19 | - return array( $this->_model->primary_key_name() => array('<', 0 ) ); |
|
20 | - }else{ |
|
21 | - $fk_field = $this->_model->get_a_field_of_type( 'EE_Foreign_Key_Field_Base' ); |
|
22 | - return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) ); |
|
17 | + protected function _get_default_where_conditions() { |
|
18 | + if ($this->_model->has_primary_key_field()) { |
|
19 | + return array($this->_model->primary_key_name() => array('<', 0)); |
|
20 | + } else { |
|
21 | + $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base'); |
|
22 | + return array('AND*impossible' => array($fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL')); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /* |
4 | 4 | * Strategy specifically for adding where conditions specific to CPT models. |
5 | 5 | */ |
6 | -class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
|
6 | +class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions { |
|
7 | 7 | /** |
8 | 8 | * Strategy for setting default soft delete where conditions. This strategy will find |
9 | 9 | * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | * Eg, |
13 | 13 | * |
14 | 14 | */ |
15 | - function __construct(){} |
|
15 | + function __construct() {} |
|
16 | 16 | /** |
17 | 17 | * Gets the where default where conditions for a custom post type model |
18 | 18 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
19 | 19 | */ |
20 | - protected function _get_default_where_conditions(){ |
|
20 | + protected function _get_default_where_conditions() { |
|
21 | 21 | $trashed_field_name = $this->deleted_field_name(); |
22 | 22 | return array( |
23 | 23 | $trashed_field_name => false |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | * @return string |
30 | 30 | * @throws EE_Error |
31 | 31 | */ |
32 | - private function deleted_field_name(){ |
|
32 | + private function deleted_field_name() { |
|
33 | 33 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
34 | - if($field){ |
|
34 | + if ($field) { |
|
35 | 35 | return $field->get_name(); |
36 | - }else{ |
|
37 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
36 | + } else { |
|
37 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EEH_Activation Helper |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage /helpers/ |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EEH_Activation Helper |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage /helpers/ |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | class EEH_Activation { |
25 | 25 | |
26 | 26 | /** |
@@ -647,6 +647,7 @@ |
||
647 | 647 | * @access public |
648 | 648 | * @static |
649 | 649 | * @param string $table_name, without prefixed $wpdb->prefix |
650 | + * @param string $table_name |
|
650 | 651 | * @return array of database column names |
651 | 652 | */ |
652 | 653 | public static function get_fields_on_table( $table_name = NULL ) { |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @param $table_name |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
53 | + public static function ensure_table_name_has_prefix($table_name) { |
|
54 | 54 | global $wpdb; |
55 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
55 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * be called on plugin activation and reactivation |
79 | 79 | * @return boolean success, whether the database and folders are setup properly |
80 | 80 | */ |
81 | - public static function initialize_db_and_folders(){ |
|
81 | + public static function initialize_db_and_folders() { |
|
82 | 82 | $good_filesystem = EEH_Activation::create_upload_directories(); |
83 | 83 | $good_db = EEH_Activation::create_database_tables(); |
84 | 84 | return $good_filesystem && $good_db; |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * upon activation of a new plugin, reactivation, and at the end |
93 | 93 | * of running migration scripts |
94 | 94 | */ |
95 | - public static function initialize_db_content(){ |
|
95 | + public static function initialize_db_content() { |
|
96 | 96 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
97 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
97 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | EEH_Activation::remove_cron_tasks(); |
112 | 112 | EEH_Activation::create_cron_tasks(); |
113 | 113 | //also, check for CAF default db content |
114 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
114 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
115 | 115 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
116 | 116 | //which users really won't care about on initial activation |
117 | 117 | EE_Error::overwrite_success(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return array |
131 | 131 | * @throws \EE_Error |
132 | 132 | */ |
133 | - public static function get_cron_tasks( $which_to_include ) { |
|
133 | + public static function get_cron_tasks($which_to_include) { |
|
134 | 134 | $cron_tasks = apply_filters( |
135 | 135 | 'FHEE__EEH_Activation__get_cron_tasks', |
136 | 136 | array( |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | // 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use |
139 | 139 | ) |
140 | 140 | ); |
141 | - if( $which_to_include === 'all' ) { |
|
141 | + if ($which_to_include === 'all') { |
|
142 | 142 | //leave as-is |
143 | - }elseif( $which_to_include === 'old' ) { |
|
144 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
143 | + }elseif ($which_to_include === 'old') { |
|
144 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
145 | 145 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
146 | 146 | }); |
147 | - }elseif( $which_to_include === 'current' ) { |
|
148 | - $cron_tasks = array_filter( $cron_tasks ); |
|
149 | - }elseif( WP_DEBUG ) { |
|
150 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
151 | - }else{ |
|
147 | + }elseif ($which_to_include === 'current') { |
|
148 | + $cron_tasks = array_filter($cron_tasks); |
|
149 | + }elseif (WP_DEBUG) { |
|
150 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
151 | + } else { |
|
152 | 152 | //leave as-is |
153 | 153 | } |
154 | 154 | return $cron_tasks; |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function create_cron_tasks() { |
161 | 161 | |
162 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
163 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
164 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
162 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
163 | + if ( ! wp_next_scheduled($hook_name)) { |
|
164 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * Remove the currently-existing and now-removed cron tasks. |
172 | 172 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
173 | 173 | */ |
174 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
174 | + public static function remove_cron_tasks($remove_all = true) { |
|
175 | 175 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
176 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
177 | - while( $scheduled_time = wp_next_scheduled( $hook_name ) ) { |
|
178 | - wp_unschedule_event( $scheduled_time, $hook_name ); |
|
176 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
177 | + while ($scheduled_time = wp_next_scheduled($hook_name)) { |
|
178 | + wp_unschedule_event($scheduled_time, $hook_name); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public static function CPT_initialization() { |
194 | 194 | // register Custom Post Types |
195 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
195 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
196 | 196 | flush_rewrite_rules(); |
197 | 197 | } |
198 | 198 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @return void |
211 | 211 | */ |
212 | 212 | public static function reset_and_update_config() { |
213 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
214 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
213 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
214 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
215 | 215 | //EE_Config::reset(); |
216 | 216 | } |
217 | 217 | |
@@ -224,23 +224,23 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public static function load_calendar_config() { |
226 | 226 | // grab array of all plugin folders and loop thru it |
227 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
228 | - if ( empty( $plugins ) ) { |
|
227 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
228 | + if (empty($plugins)) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | - foreach ( $plugins as $plugin_path ) { |
|
231 | + foreach ($plugins as $plugin_path) { |
|
232 | 232 | // grab plugin folder name from path |
233 | - $plugin = basename( $plugin_path ); |
|
233 | + $plugin = basename($plugin_path); |
|
234 | 234 | // drill down to Espresso plugins |
235 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
235 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
236 | 236 | // then to calendar related plugins |
237 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
237 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
238 | 238 | // this is what we are looking for |
239 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
239 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
240 | 240 | // does it exist in this folder ? |
241 | - if ( is_readable( $calendar_config )) { |
|
241 | + if (is_readable($calendar_config)) { |
|
242 | 242 | // YEAH! let's load it |
243 | - require_once( $calendar_config ); |
|
243 | + require_once($calendar_config); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
@@ -257,21 +257,21 @@ discard block |
||
257 | 257 | * @param \EE_Config $EE_Config |
258 | 258 | * @return \stdClass |
259 | 259 | */ |
260 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
261 | - $convert_from_array = array( 'addons' ); |
|
260 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
261 | + $convert_from_array = array('addons'); |
|
262 | 262 | // in case old settings were saved as an array |
263 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
263 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
264 | 264 | // convert existing settings to an object |
265 | 265 | $config_array = $settings; |
266 | 266 | $settings = new stdClass(); |
267 | - foreach ( $config_array as $key => $value ){ |
|
268 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
269 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
267 | + foreach ($config_array as $key => $value) { |
|
268 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
269 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
270 | 270 | } else { |
271 | 271 | $settings->$key = $value; |
272 | 272 | } |
273 | 273 | } |
274 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
274 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
275 | 275 | } |
276 | 276 | return $settings; |
277 | 277 | } |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public static function deactivate_event_espresso() { |
289 | 289 | // check permissions |
290 | - if ( current_user_can( 'activate_plugins' )) { |
|
291 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
290 | + if (current_user_can('activate_plugins')) { |
|
291 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
@@ -310,79 +310,79 @@ discard block |
||
310 | 310 | $critical_pages = array( |
311 | 311 | array( |
312 | 312 | 'id' =>'reg_page_id', |
313 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
313 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
314 | 314 | 'post' => NULL, |
315 | 315 | 'code' => 'ESPRESSO_CHECKOUT' |
316 | 316 | ), |
317 | 317 | array( |
318 | 318 | 'id' => 'txn_page_id', |
319 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
319 | + 'name' => __('Transactions', 'event_espresso'), |
|
320 | 320 | 'post' => NULL, |
321 | 321 | 'code' => 'ESPRESSO_TXN_PAGE' |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'id' => 'thank_you_page_id', |
325 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
325 | + 'name' => __('Thank You', 'event_espresso'), |
|
326 | 326 | 'post' => NULL, |
327 | 327 | 'code' => 'ESPRESSO_THANK_YOU' |
328 | 328 | ), |
329 | 329 | array( |
330 | 330 | 'id' => 'cancel_page_id', |
331 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
331 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
332 | 332 | 'post' => NULL, |
333 | 333 | 'code' => 'ESPRESSO_CANCELLED' |
334 | 334 | ), |
335 | 335 | ); |
336 | 336 | |
337 | - foreach ( $critical_pages as $critical_page ) { |
|
337 | + foreach ($critical_pages as $critical_page) { |
|
338 | 338 | // is critical page ID set in config ? |
339 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
339 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
340 | 340 | // attempt to find post by ID |
341 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
341 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
342 | 342 | } |
343 | 343 | // no dice? |
344 | - if ( $critical_page['post'] == NULL ) { |
|
344 | + if ($critical_page['post'] == NULL) { |
|
345 | 345 | // attempt to find post by title |
346 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
346 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
347 | 347 | // still nothing? |
348 | - if ( $critical_page['post'] == NULL ) { |
|
349 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
348 | + if ($critical_page['post'] == NULL) { |
|
349 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
350 | 350 | // REALLY? Still nothing ??!?!? |
351 | - if ( $critical_page['post'] == NULL ) { |
|
352 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
353 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
351 | + if ($critical_page['post'] == NULL) { |
|
352 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
353 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
354 | 354 | break; |
355 | 355 | } |
356 | 356 | } |
357 | 357 | } |
358 | 358 | // track post_shortcodes |
359 | - if ( $critical_page['post'] ) { |
|
360 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
359 | + if ($critical_page['post']) { |
|
360 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
361 | 361 | } |
362 | 362 | // check that Post ID matches critical page ID in config |
363 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
363 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
364 | 364 | //update Config with post ID |
365 | 365 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
366 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
367 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
368 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
366 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
367 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
368 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
372 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | - if ( $critical_page_problem ) { |
|
376 | + if ($critical_page_problem) { |
|
377 | 377 | $msg = sprintf( |
378 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
379 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
378 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
379 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
380 | 380 | ); |
381 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
381 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( EE_Error::has_notices() ) { |
|
385 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
384 | + if (EE_Error::has_notices()) { |
|
385 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | * parameter to the shortcode |
396 | 396 | * @return WP_Post or NULl |
397 | 397 | */ |
398 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
398 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
399 | 399 | global $wpdb; |
400 | 400 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
401 | 401 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
402 | - if($post_id){ |
|
402 | + if ($post_id) { |
|
403 | 403 | return get_post($post_id); |
404 | - }else{ |
|
404 | + } else { |
|
405 | 405 | return NULL; |
406 | 406 | } |
407 | 407 | |
@@ -418,32 +418,32 @@ discard block |
||
418 | 418 | * @param array $critical_page |
419 | 419 | * @return array |
420 | 420 | */ |
421 | - public static function create_critical_page( $critical_page ) { |
|
421 | + public static function create_critical_page($critical_page) { |
|
422 | 422 | |
423 | 423 | $post_args = array( |
424 | 424 | 'post_title' => $critical_page['name'], |
425 | 425 | 'post_status' => 'publish', |
426 | 426 | 'post_type' => 'page', |
427 | 427 | 'comment_status' => 'closed', |
428 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
428 | + 'post_content' => '['.$critical_page['code'].']' |
|
429 | 429 | ); |
430 | 430 | |
431 | - $post_id = wp_insert_post( $post_args ); |
|
432 | - if ( ! $post_id ) { |
|
431 | + $post_id = wp_insert_post($post_args); |
|
432 | + if ( ! $post_id) { |
|
433 | 433 | $msg = sprintf( |
434 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
434 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
435 | 435 | $critical_page['name'] |
436 | 436 | ); |
437 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
437 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
438 | 438 | return $critical_page; |
439 | 439 | } |
440 | 440 | // get newly created post's details |
441 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
441 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
442 | 442 | $msg = sprintf( |
443 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
443 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
444 | 444 | $critical_page['name'] |
445 | 445 | ); |
446 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
446 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return $critical_page; |
@@ -462,34 +462,34 @@ discard block |
||
462 | 462 | * @param array $critical_page |
463 | 463 | * @return void |
464 | 464 | */ |
465 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
465 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
466 | 466 | // check the goods |
467 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
467 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
468 | 468 | $msg = sprintf( |
469 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
469 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
470 | 470 | $critical_page['name'] |
471 | 471 | ); |
472 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
472 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
473 | 473 | return; |
474 | 474 | } |
475 | 475 | // map shortcode to post |
476 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
476 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
477 | 477 | // and make sure it's NOT added to the WP "Posts Page" |
478 | 478 | // name of the WP Posts Page |
479 | 479 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
480 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
481 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
480 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
481 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
482 | 482 | } |
483 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
484 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
483 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
484 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
485 | 485 | } |
486 | 486 | // update post_shortcode CFG |
487 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
487 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
488 | 488 | $msg = sprintf( |
489 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
489 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
490 | 490 | $critical_page['name'] |
491 | 491 | ); |
492 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
492 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
@@ -507,24 +507,24 @@ discard block |
||
507 | 507 | public static function get_default_creator_id() { |
508 | 508 | global $wpdb; |
509 | 509 | |
510 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
510 | + if ( ! empty(self::$_default_creator_id)) { |
|
511 | 511 | return self::$_default_creator_id; |
512 | 512 | }/**/ |
513 | 513 | |
514 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
514 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
515 | 515 | |
516 | 516 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
517 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
518 | - if ( $pre_filtered_id !== false ) { |
|
517 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
518 | + if ($pre_filtered_id !== false) { |
|
519 | 519 | return (int) $pre_filtered_id; |
520 | 520 | } |
521 | 521 | |
522 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
523 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
524 | - $user_id = $wpdb->get_var( $query ); |
|
525 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
526 | - if ( $user_id && intval( $user_id ) ) { |
|
527 | - self::$_default_creator_id = intval( $user_id ); |
|
522 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
523 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
524 | + $user_id = $wpdb->get_var($query); |
|
525 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
526 | + if ($user_id && intval($user_id)) { |
|
527 | + self::$_default_creator_id = intval($user_id); |
|
528 | 528 | return self::$_default_creator_id; |
529 | 529 | } else { |
530 | 530 | return NULL; |
@@ -551,29 +551,29 @@ discard block |
||
551 | 551 | * @return void |
552 | 552 | * @throws EE_Error if there are database errors |
553 | 553 | */ |
554 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
555 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
554 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
555 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
556 | 556 | return; |
557 | 557 | } |
558 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
559 | - if ( ! function_exists( 'dbDelta' )) { |
|
560 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
558 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
559 | + if ( ! function_exists('dbDelta')) { |
|
560 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
561 | 561 | } |
562 | 562 | /** @var WPDB $wpdb */ |
563 | 563 | global $wpdb; |
564 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
564 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
565 | 565 | // do we need to first delete an existing version of this table ? |
566 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
566 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
567 | 567 | // ok, delete the table... but ONLY if it's empty |
568 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
568 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
569 | 569 | // table is NOT empty, are you SURE you want to delete this table ??? |
570 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
571 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
572 | - } else if ( ! $deleted_safely ) { |
|
570 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
571 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
572 | + } else if ( ! $deleted_safely) { |
|
573 | 573 | // so we should be more cautious rather than just dropping tables so easily |
574 | 574 | EE_Error::add_persistent_admin_notice( |
575 | - 'bad_table_' . $wp_table_name . '_detected', |
|
576 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
575 | + 'bad_table_'.$wp_table_name.'_detected', |
|
576 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
577 | 577 | $wp_table_name, |
578 | 578 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
579 | 579 | '<b>wp-config.php</b>', |
@@ -582,25 +582,25 @@ discard block |
||
582 | 582 | } |
583 | 583 | } |
584 | 584 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
585 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
585 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
586 | 586 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
587 | 587 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
588 | 588 | //happened. And then we can choose to tell the end user |
589 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
590 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
589 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
590 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
591 | 591 | ob_start(); |
592 | - dbDelta( $SQL ); |
|
592 | + dbDelta($SQL); |
|
593 | 593 | $output = ob_get_contents(); |
594 | 594 | ob_end_clean(); |
595 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
596 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
597 | - if( ! empty( $output ) ){ |
|
598 | - throw new EE_Error( $output ); |
|
595 | + $wpdb->show_errors($old_show_errors_policy); |
|
596 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
597 | + if ( ! empty($output)) { |
|
598 | + throw new EE_Error($output); |
|
599 | 599 | } |
600 | 600 | } else { |
601 | 601 | throw new EE_Error( |
602 | 602 | sprintf( |
603 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
603 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
604 | 604 | '<br />', |
605 | 605 | $sql |
606 | 606 | ) |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)' |
623 | 623 | * @return bool|int |
624 | 624 | */ |
625 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
626 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
625 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
626 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
627 | 627 | return FALSE; |
628 | 628 | } |
629 | 629 | global $wpdb; |
630 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
630 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
631 | 631 | $fields = self::get_fields_on_table($table_name); |
632 | - if (!in_array($column_name, $fields)){ |
|
633 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
632 | + if ( ! in_array($column_name, $fields)) { |
|
633 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
634 | 634 | //echo "alter query:$alter_query"; |
635 | 635 | return $wpdb->query($alter_query); |
636 | 636 | } |
@@ -649,15 +649,15 @@ discard block |
||
649 | 649 | * @param string $table_name, without prefixed $wpdb->prefix |
650 | 650 | * @return array of database column names |
651 | 651 | */ |
652 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
652 | + public static function get_fields_on_table($table_name = NULL) { |
|
653 | 653 | global $wpdb; |
654 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
655 | - if ( ! empty( $table_name )) { |
|
654 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
655 | + if ( ! empty($table_name)) { |
|
656 | 656 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
657 | 657 | if ($columns !== FALSE) { |
658 | 658 | $field_array = array(); |
659 | - foreach($columns as $column ){ |
|
660 | - $field_array[] = $column->Field;; |
|
659 | + foreach ($columns as $column) { |
|
660 | + $field_array[] = $column->Field; ; |
|
661 | 661 | } |
662 | 662 | return $field_array; |
663 | 663 | } |
@@ -675,12 +675,12 @@ discard block |
||
675 | 675 | * @param string $table_name |
676 | 676 | * @return bool |
677 | 677 | */ |
678 | - public static function db_table_is_empty( $table_name ) { |
|
678 | + public static function db_table_is_empty($table_name) { |
|
679 | 679 | global $wpdb; |
680 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
681 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
682 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
683 | - return absint( $count ) === 0 ? true : false; |
|
680 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
681 | + if (EEH_Activation::table_exists($table_name)) { |
|
682 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
683 | + return absint($count) === 0 ? true : false; |
|
684 | 684 | } |
685 | 685 | return false; |
686 | 686 | } |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | * @param string $table_name |
696 | 696 | * @return bool | int |
697 | 697 | */ |
698 | - public static function delete_db_table_if_empty( $table_name ) { |
|
699 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
700 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
698 | + public static function delete_db_table_if_empty($table_name) { |
|
699 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
700 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
701 | 701 | } |
702 | 702 | return false; |
703 | 703 | } |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param string $table_name |
713 | 713 | * @return bool | int |
714 | 714 | */ |
715 | - public static function delete_unused_db_table( $table_name ) { |
|
715 | + public static function delete_unused_db_table($table_name) { |
|
716 | 716 | global $wpdb; |
717 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
718 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
719 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
717 | + if (EEH_Activation::table_exists($table_name)) { |
|
718 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
719 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
720 | 720 | } |
721 | 721 | return false; |
722 | 722 | } |
@@ -732,18 +732,18 @@ discard block |
||
732 | 732 | * @param string $index_name |
733 | 733 | * @return bool | int |
734 | 734 | */ |
735 | - public static function drop_index( $table_name, $index_name ) { |
|
736 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
735 | + public static function drop_index($table_name, $index_name) { |
|
736 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
737 | 737 | return FALSE; |
738 | 738 | } |
739 | 739 | global $wpdb; |
740 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
740 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
741 | 741 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
742 | 742 | if ( |
743 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
744 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
743 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
744 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
745 | 745 | ) { |
746 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
746 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
747 | 747 | } |
748 | 748 | return TRUE; |
749 | 749 | } |
@@ -759,27 +759,27 @@ discard block |
||
759 | 759 | * @return boolean success (whether database is setup properly or not) |
760 | 760 | */ |
761 | 761 | public static function create_database_tables() { |
762 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
762 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
763 | 763 | //find the migration script that sets the database to be compatible with the code |
764 | 764 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
765 | - if( $dms_name ){ |
|
766 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
767 | - $current_data_migration_script->set_migrating( false ); |
|
765 | + if ($dms_name) { |
|
766 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
767 | + $current_data_migration_script->set_migrating(false); |
|
768 | 768 | $current_data_migration_script->schema_changes_before_migration(); |
769 | 769 | $current_data_migration_script->schema_changes_after_migration(); |
770 | - if( $current_data_migration_script->get_errors() ){ |
|
771 | - if( WP_DEBUG ){ |
|
772 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
773 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
770 | + if ($current_data_migration_script->get_errors()) { |
|
771 | + if (WP_DEBUG) { |
|
772 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
773 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
774 | 774 | } |
775 | - }else{ |
|
776 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
775 | + } else { |
|
776 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
777 | 777 | } |
778 | 778 | return false; |
779 | 779 | } |
780 | 780 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
781 | - }else{ |
|
782 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
781 | + } else { |
|
782 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
783 | 783 | return false; |
784 | 784 | } |
785 | 785 | return true; |
@@ -799,27 +799,27 @@ discard block |
||
799 | 799 | public static function initialize_system_questions() { |
800 | 800 | // QUESTION GROUPS |
801 | 801 | global $wpdb; |
802 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
802 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
803 | 803 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
804 | 804 | // what we have |
805 | - $question_groups = $wpdb->get_col( $SQL ); |
|
805 | + $question_groups = $wpdb->get_col($SQL); |
|
806 | 806 | // check the response |
807 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
807 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
808 | 808 | // what we should have |
809 | - $QSG_systems = array( 1, 2 ); |
|
809 | + $QSG_systems = array(1, 2); |
|
810 | 810 | // loop thru what we should have and compare to what we have |
811 | - foreach ( $QSG_systems as $QSG_system ) { |
|
811 | + foreach ($QSG_systems as $QSG_system) { |
|
812 | 812 | // reset values array |
813 | 813 | $QSG_values = array(); |
814 | 814 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
815 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
815 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
816 | 816 | // add it |
817 | - switch ( $QSG_system ) { |
|
817 | + switch ($QSG_system) { |
|
818 | 818 | |
819 | 819 | case 1: |
820 | 820 | $QSG_values = array( |
821 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
822 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
821 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
822 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
823 | 823 | 'QSG_desc' => '', |
824 | 824 | 'QSG_order' => 1, |
825 | 825 | 'QSG_show_group_name' => 1, |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | case 2: |
833 | 833 | $QSG_values = array( |
834 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
835 | - 'QSG_identifier' => 'address-information-' . time(), |
|
834 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
835 | + 'QSG_identifier' => 'address-information-'.time(), |
|
836 | 836 | 'QSG_desc' => '', |
837 | 837 | 'QSG_order' => 2, |
838 | 838 | 'QSG_show_group_name' => 1, |
@@ -844,14 +844,14 @@ discard block |
||
844 | 844 | |
845 | 845 | } |
846 | 846 | // make sure we have some values before inserting them |
847 | - if ( ! empty( $QSG_values )) { |
|
847 | + if ( ! empty($QSG_values)) { |
|
848 | 848 | // insert system question |
849 | 849 | $wpdb->insert( |
850 | 850 | $table_name, |
851 | 851 | $QSG_values, |
852 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
852 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
853 | 853 | ); |
854 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
854 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -860,10 +860,10 @@ discard block |
||
860 | 860 | |
861 | 861 | // QUESTIONS |
862 | 862 | global $wpdb; |
863 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
863 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
864 | 864 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
865 | 865 | // what we have |
866 | - $questions = $wpdb->get_col( $SQL ); |
|
866 | + $questions = $wpdb->get_col($SQL); |
|
867 | 867 | // what we should have |
868 | 868 | $QST_systems = array( |
869 | 869 | 'fname', |
@@ -880,22 +880,22 @@ discard block |
||
880 | 880 | $order_for_group_1 = 1; |
881 | 881 | $order_for_group_2 = 1; |
882 | 882 | // loop thru what we should have and compare to what we have |
883 | - foreach ( $QST_systems as $QST_system ) { |
|
883 | + foreach ($QST_systems as $QST_system) { |
|
884 | 884 | // reset values array |
885 | 885 | $QST_values = array(); |
886 | 886 | // if we don't have what we should have |
887 | - if ( ! in_array( $QST_system, $questions )) { |
|
887 | + if ( ! in_array($QST_system, $questions)) { |
|
888 | 888 | // add it |
889 | - switch ( $QST_system ) { |
|
889 | + switch ($QST_system) { |
|
890 | 890 | |
891 | 891 | case 'fname': |
892 | 892 | $QST_values = array( |
893 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
894 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
893 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
894 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
895 | 895 | 'QST_system' => 'fname', |
896 | 896 | 'QST_type' => 'TEXT', |
897 | 897 | 'QST_required' => 1, |
898 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
898 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
899 | 899 | 'QST_order' => 1, |
900 | 900 | 'QST_admin_only' => 0, |
901 | 901 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | |
906 | 906 | case 'lname': |
907 | 907 | $QST_values = array( |
908 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
909 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
908 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
909 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
910 | 910 | 'QST_system' => 'lname', |
911 | 911 | 'QST_type' => 'TEXT', |
912 | 912 | 'QST_required' => 1, |
913 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
913 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
914 | 914 | 'QST_order' => 2, |
915 | 915 | 'QST_admin_only' => 0, |
916 | 916 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -920,12 +920,12 @@ discard block |
||
920 | 920 | |
921 | 921 | case 'email': |
922 | 922 | $QST_values = array( |
923 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
924 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
923 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
924 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
925 | 925 | 'QST_system' => 'email', |
926 | 926 | 'QST_type' => 'TEXT', |
927 | 927 | 'QST_required' => 1, |
928 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
928 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
929 | 929 | 'QST_order' => 3, |
930 | 930 | 'QST_admin_only' => 0, |
931 | 931 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -935,12 +935,12 @@ discard block |
||
935 | 935 | |
936 | 936 | case 'address': |
937 | 937 | $QST_values = array( |
938 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
939 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
938 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
939 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
940 | 940 | 'QST_system' => 'address', |
941 | 941 | 'QST_type' => 'TEXT', |
942 | 942 | 'QST_required' => 0, |
943 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
943 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
944 | 944 | 'QST_order' => 4, |
945 | 945 | 'QST_admin_only' => 0, |
946 | 946 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -950,12 +950,12 @@ discard block |
||
950 | 950 | |
951 | 951 | case 'address2': |
952 | 952 | $QST_values = array( |
953 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
954 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
953 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
954 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
955 | 955 | 'QST_system' => 'address2', |
956 | 956 | 'QST_type' => 'TEXT', |
957 | 957 | 'QST_required' => 0, |
958 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
958 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
959 | 959 | 'QST_order' => 5, |
960 | 960 | 'QST_admin_only' => 0, |
961 | 961 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | |
966 | 966 | case 'city': |
967 | 967 | $QST_values = array( |
968 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
969 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
968 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
969 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
970 | 970 | 'QST_system' => 'city', |
971 | 971 | 'QST_type' => 'TEXT', |
972 | 972 | 'QST_required' => 0, |
973 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
973 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
974 | 974 | 'QST_order' => 6, |
975 | 975 | 'QST_admin_only' => 0, |
976 | 976 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -980,12 +980,12 @@ discard block |
||
980 | 980 | |
981 | 981 | case 'state': |
982 | 982 | $QST_values = array( |
983 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
984 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
983 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
984 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
985 | 985 | 'QST_system' => 'state', |
986 | 986 | 'QST_type' => 'STATE', |
987 | 987 | 'QST_required' => 0, |
988 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
988 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
989 | 989 | 'QST_order' => 7, |
990 | 990 | 'QST_admin_only' => 0, |
991 | 991 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -995,12 +995,12 @@ discard block |
||
995 | 995 | |
996 | 996 | case 'country' : |
997 | 997 | $QST_values = array( |
998 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
999 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
998 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
999 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1000 | 1000 | 'QST_system' => 'country', |
1001 | 1001 | 'QST_type' => 'COUNTRY', |
1002 | 1002 | 'QST_required' => 0, |
1003 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1003 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1004 | 1004 | 'QST_order' => 8, |
1005 | 1005 | 'QST_admin_only' => 0, |
1006 | 1006 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1010,12 +1010,12 @@ discard block |
||
1010 | 1010 | |
1011 | 1011 | case 'zip': |
1012 | 1012 | $QST_values = array( |
1013 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1014 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1013 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1014 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1015 | 1015 | 'QST_system' => 'zip', |
1016 | 1016 | 'QST_type' => 'TEXT', |
1017 | 1017 | 'QST_required' => 0, |
1018 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1018 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1019 | 1019 | 'QST_order' => 9, |
1020 | 1020 | 'QST_admin_only' => 0, |
1021 | 1021 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1025,12 +1025,12 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | case 'phone': |
1027 | 1027 | $QST_values = array( |
1028 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1029 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1028 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1029 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1030 | 1030 | 'QST_system' => 'phone', |
1031 | 1031 | 'QST_type' => 'TEXT', |
1032 | 1032 | 'QST_required' => 0, |
1033 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1033 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1034 | 1034 | 'QST_order' => 10, |
1035 | 1035 | 'QST_admin_only' => 0, |
1036 | 1036 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1039,22 +1039,22 @@ discard block |
||
1039 | 1039 | break; |
1040 | 1040 | |
1041 | 1041 | } |
1042 | - if ( ! empty( $QST_values )) { |
|
1042 | + if ( ! empty($QST_values)) { |
|
1043 | 1043 | // insert system question |
1044 | 1044 | $wpdb->insert( |
1045 | 1045 | $table_name, |
1046 | 1046 | $QST_values, |
1047 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1047 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1048 | 1048 | ); |
1049 | 1049 | $QST_ID = $wpdb->insert_id; |
1050 | 1050 | |
1051 | 1051 | // QUESTION GROUP QUESTIONS |
1052 | - $QSG_ID = in_array( $QST_system, array('fname','lname','email')) ? 1 : 2; |
|
1052 | + $QSG_ID = in_array($QST_system, array('fname', 'lname', 'email')) ? 1 : 2; |
|
1053 | 1053 | // add system questions to groups |
1054 | 1054 | $wpdb->insert( |
1055 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1056 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1057 | - array( '%d', '%d','%d' ) |
|
1055 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1056 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1057 | + array('%d', '%d', '%d') |
|
1058 | 1058 | ); |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1066,11 +1066,11 @@ discard block |
||
1066 | 1066 | * Makes sure the default payment method (Invoice) is active. |
1067 | 1067 | * This used to be done automatically as part of constructing the old gateways config |
1068 | 1068 | */ |
1069 | - public static function insert_default_payment_methods(){ |
|
1070 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1071 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1072 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1073 | - }else{ |
|
1069 | + public static function insert_default_payment_methods() { |
|
1070 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1071 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1072 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1073 | + } else { |
|
1074 | 1074 | EEM_Payment_Method::instance()->verify_button_urls(); |
1075 | 1075 | } |
1076 | 1076 | } |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | |
1087 | 1087 | global $wpdb; |
1088 | 1088 | |
1089 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1089 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1090 | 1090 | |
1091 | 1091 | $table_name = EEM_Status::instance()->table(); |
1092 | 1092 | |
@@ -1157,26 +1157,26 @@ discard block |
||
1157 | 1157 | * @return boolean success of verifying upload directories exist |
1158 | 1158 | */ |
1159 | 1159 | public static function create_upload_directories() { |
1160 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1160 | + EE_Registry::instance()->load_helper('File'); |
|
1161 | 1161 | // Create the required folders |
1162 | 1162 | $folders = array( |
1163 | 1163 | EVENT_ESPRESSO_UPLOAD_DIR, |
1164 | 1164 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1165 | 1165 | EVENT_ESPRESSO_GATEWAY_DIR, |
1166 | - EVENT_ESPRESSO_UPLOAD_DIR . '/logs/', |
|
1167 | - EVENT_ESPRESSO_UPLOAD_DIR . '/css/', |
|
1168 | - EVENT_ESPRESSO_UPLOAD_DIR . '/tickets/' |
|
1166 | + EVENT_ESPRESSO_UPLOAD_DIR.'/logs/', |
|
1167 | + EVENT_ESPRESSO_UPLOAD_DIR.'/css/', |
|
1168 | + EVENT_ESPRESSO_UPLOAD_DIR.'/tickets/' |
|
1169 | 1169 | ); |
1170 | - foreach ( $folders as $folder ) { |
|
1170 | + foreach ($folders as $folder) { |
|
1171 | 1171 | try { |
1172 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1173 | - @ chmod( $folder, 0755 ); |
|
1174 | - } catch( EE_Error $e ){ |
|
1172 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1173 | + @ chmod($folder, 0755); |
|
1174 | + } catch (EE_Error $e) { |
|
1175 | 1175 | EE_Error::add_error( |
1176 | 1176 | sprintf( |
1177 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1177 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1178 | 1178 | $folder, |
1179 | - '<br />' . $e->getMessage() |
|
1179 | + '<br />'.$e->getMessage() |
|
1180 | 1180 | ), |
1181 | 1181 | __FILE__, __FUNCTION__, __LINE__ |
1182 | 1182 | ); |
@@ -1202,16 +1202,16 @@ discard block |
||
1202 | 1202 | $installed_messengers = $default_messengers = array(); |
1203 | 1203 | |
1204 | 1204 | //include our helper |
1205 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1205 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1206 | 1206 | |
1207 | 1207 | //get all installed messenger objects |
1208 | 1208 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1209 | 1209 | |
1210 | 1210 | //let's setup the $installed messengers in an array AND the messengers that are set to be activated on install. |
1211 | - foreach ( $installed['messengers'] as $msgr ) { |
|
1212 | - if ( $msgr instanceof EE_messenger ) { |
|
1211 | + foreach ($installed['messengers'] as $msgr) { |
|
1212 | + if ($msgr instanceof EE_messenger) { |
|
1213 | 1213 | $installed_messengers[$msgr->name] = $msgr; |
1214 | - if ( $msgr->activate_on_install ) { |
|
1214 | + if ($msgr->activate_on_install) { |
|
1215 | 1215 | $default_messengers[] = $msgr->name; |
1216 | 1216 | } |
1217 | 1217 | } |
@@ -1221,36 +1221,36 @@ discard block |
||
1221 | 1221 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1222 | 1222 | |
1223 | 1223 | //things that have already been activated before |
1224 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
1224 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
1225 | 1225 | |
1226 | 1226 | //do an initial loop to determine if we need to continue |
1227 | 1227 | $def_ms = array(); |
1228 | - foreach ( $default_messengers as $msgr ) { |
|
1229 | - if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue; |
|
1228 | + foreach ($default_messengers as $msgr) { |
|
1229 | + if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue; |
|
1230 | 1230 | $def_ms[] = $msgr; |
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | //setup the $installed_mts in an array |
1234 | - foreach ( $installed['message_types'] as $imt ) { |
|
1235 | - if ( $imt instanceof EE_message_type ) { |
|
1234 | + foreach ($installed['message_types'] as $imt) { |
|
1235 | + if ($imt instanceof EE_message_type) { |
|
1236 | 1236 | $installed_mts[$imt->name] = $imt; |
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | //loop through default array for default messengers (if present) |
1241 | - if ( ! empty( $def_ms ) ) { |
|
1242 | - foreach ( $def_ms as $messenger ) { |
|
1241 | + if ( ! empty($def_ms)) { |
|
1242 | + foreach ($def_ms as $messenger) { |
|
1243 | 1243 | //all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger. |
1244 | - if ( ! isset( $installed_messengers[$messenger] )) { |
|
1244 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1245 | 1245 | continue; |
1246 | 1246 | } |
1247 | 1247 | /** @var EE_messenger[] $installed_messengers */ |
1248 | 1248 | $default_mts = $installed_messengers[$messenger]->get_default_message_types(); |
1249 | 1249 | $active_messengers[$messenger]['obj'] = $installed_messengers[$messenger]; |
1250 | - foreach ( $default_mts as $index => $mt ) { |
|
1250 | + foreach ($default_mts as $index => $mt) { |
|
1251 | 1251 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1252 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1253 | - unset( $default_mts[$index] ); |
|
1252 | + if ( ! isset($installed_mts[$mt])) { |
|
1253 | + unset($default_mts[$index]); |
|
1254 | 1254 | continue; |
1255 | 1255 | } |
1256 | 1256 | |
@@ -1259,41 +1259,41 @@ discard block |
||
1259 | 1259 | /** @var EE_message_type[] $installed_mts */ |
1260 | 1260 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1261 | 1261 | $settings = array(); |
1262 | - if ( is_array( $settings_fields ) ) { |
|
1263 | - foreach ( $settings_fields as $field => $values ) { |
|
1264 | - if ( isset( $values['default'] ) ) { |
|
1262 | + if (is_array($settings_fields)) { |
|
1263 | + foreach ($settings_fields as $field => $values) { |
|
1264 | + if (isset($values['default'])) { |
|
1265 | 1265 | $settings[$field] = $values['default']; |
1266 | 1266 | } |
1267 | 1267 | } |
1268 | 1268 | } |
1269 | 1269 | |
1270 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1270 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1271 | 1271 | $has_activated[$messenger][] = $mt; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | //setup any initial settings for the messenger |
1275 | 1275 | $msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields(); |
1276 | 1276 | |
1277 | - if ( !empty( $msgr_settings ) ) { |
|
1278 | - foreach ( $msgr_settings as $field => $value ) { |
|
1277 | + if ( ! empty($msgr_settings)) { |
|
1278 | + foreach ($msgr_settings as $field => $value) { |
|
1279 | 1279 | $active_messengers[$messenger]['settings'][$field] = $value; |
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | //now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate. |
1284 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1284 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1285 | 1285 | |
1286 | 1286 | //let's generate all the templates but only if the messenger has default_mts (otherwise its just activated). |
1287 | - if ( !empty( $default_mts ) ) { |
|
1288 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE ); |
|
1287 | + if ( ! empty($default_mts)) { |
|
1288 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE); |
|
1289 | 1289 | } |
1290 | 1290 | } |
1291 | 1291 | } //end check for empty( $def_ms ) |
1292 | 1292 | |
1293 | 1293 | //still need to see if there are any message types to activate for active messengers |
1294 | - foreach ( $active_messengers as $messenger => $settings ) { |
|
1294 | + foreach ($active_messengers as $messenger => $settings) { |
|
1295 | 1295 | $msg_obj = $settings['obj']; |
1296 | - if ( ! $msg_obj instanceof EE_messenger ) { |
|
1296 | + if ( ! $msg_obj instanceof EE_messenger) { |
|
1297 | 1297 | continue; |
1298 | 1298 | } |
1299 | 1299 | |
@@ -1301,45 +1301,45 @@ discard block |
||
1301 | 1301 | $new_default_mts = array(); |
1302 | 1302 | |
1303 | 1303 | //loop through each default mt reported by the messenger and make sure its set in its active db entry. |
1304 | - foreach( $all_default_mts as $index => $mt ) { |
|
1304 | + foreach ($all_default_mts as $index => $mt) { |
|
1305 | 1305 | //already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated). |
1306 | - if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) || EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) { |
|
1306 | + if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) { |
|
1307 | 1307 | continue; |
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1311 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1312 | - unset( $all_default_mts[$mt] ); |
|
1311 | + if ( ! isset($installed_mts[$mt])) { |
|
1312 | + unset($all_default_mts[$mt]); |
|
1313 | 1313 | continue; |
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1317 | 1317 | $settings = array(); |
1318 | - if ( is_array( $settings_fields ) ) { |
|
1319 | - foreach ( $settings_fields as $field => $values ) { |
|
1320 | - if ( isset( $values['default'] ) ) { |
|
1318 | + if (is_array($settings_fields)) { |
|
1319 | + foreach ($settings_fields as $field => $values) { |
|
1320 | + if (isset($values['default'])) { |
|
1321 | 1321 | $settings[$field] = $values['default']; |
1322 | 1322 | } |
1323 | 1323 | } |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1326 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1327 | 1327 | $new_default_mts[] = $mt; |
1328 | 1328 | $has_activated[$messenger][] = $mt; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | |
1332 | - if ( ! empty( $new_default_mts ) ) { |
|
1333 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE ); |
|
1332 | + if ( ! empty($new_default_mts)) { |
|
1333 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | //now let's save the settings for this messenger! |
1339 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1339 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1340 | 1340 | |
1341 | 1341 | //update $has_activated record |
1342 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
1342 | + update_option('ee_has_activated_messenger', $has_activated); |
|
1343 | 1343 | |
1344 | 1344 | //that's it! |
1345 | 1345 | return $success; |
@@ -1359,47 +1359,47 @@ discard block |
||
1359 | 1359 | */ |
1360 | 1360 | public static function validate_messages_system() { |
1361 | 1361 | //include our helper |
1362 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1362 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1363 | 1363 | |
1364 | 1364 | //get active and installed messengers/message types. |
1365 | 1365 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1366 | 1366 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1367 | 1367 | $installed_messengers = $installed_mts = array(); |
1368 | 1368 | //set up the arrays so they can be handled easier. |
1369 | - foreach( $installed['messengers'] as $im ) { |
|
1370 | - if ( $im instanceof EE_messenger ) { |
|
1369 | + foreach ($installed['messengers'] as $im) { |
|
1370 | + if ($im instanceof EE_messenger) { |
|
1371 | 1371 | $installed_messengers[$im->name] = $im; |
1372 | 1372 | } |
1373 | 1373 | } |
1374 | - foreach( $installed['message_types'] as $imt ) { |
|
1375 | - if ( $imt instanceof EE_message_type ) { |
|
1374 | + foreach ($installed['message_types'] as $imt) { |
|
1375 | + if ($imt instanceof EE_message_type) { |
|
1376 | 1376 | $installed_mts[$imt->name] = $imt; |
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | //now let's loop through the active array and validate |
1381 | - foreach( $active_messengers as $messenger => $active_details ) { |
|
1381 | + foreach ($active_messengers as $messenger => $active_details) { |
|
1382 | 1382 | //first let's see if this messenger is installed. |
1383 | - if ( ! isset( $installed_messengers[$messenger] ) ) { |
|
1383 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1384 | 1384 | //not set so let's just remove from actives and make sure templates are inactive. |
1385 | - unset( $active_messengers[$messenger] ); |
|
1386 | - EEH_MSG_Template::update_to_inactive( $messenger ); |
|
1385 | + unset($active_messengers[$messenger]); |
|
1386 | + EEH_MSG_Template::update_to_inactive($messenger); |
|
1387 | 1387 | continue; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | //messenger is active, so let's just make sure that any active message types not installed are deactivated. |
1391 | - $mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array(); |
|
1392 | - foreach ( $mts as $mt_name => $mt ) { |
|
1393 | - if ( ! isset( $installed_mts[$mt_name] ) ) { |
|
1394 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
1395 | - EEH_MSG_Template::update_to_inactive( $messenger, $mt_name ); |
|
1391 | + $mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array(); |
|
1392 | + foreach ($mts as $mt_name => $mt) { |
|
1393 | + if ( ! isset($installed_mts[$mt_name])) { |
|
1394 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]); |
|
1395 | + EEH_MSG_Template::update_to_inactive($messenger, $mt_name); |
|
1396 | 1396 | } |
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | //all done! let's update the active_messengers. |
1401 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1402 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1401 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1402 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1403 | 1403 | return; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1413,12 +1413,12 @@ discard block |
||
1413 | 1413 | * @static |
1414 | 1414 | * @return void |
1415 | 1415 | */ |
1416 | - public static function create_no_ticket_prices_array(){ |
|
1416 | + public static function create_no_ticket_prices_array() { |
|
1417 | 1417 | // this creates an array for tracking events that have no active ticket prices created |
1418 | 1418 | // this allows us to warn admins of the situation so that it can be corrected |
1419 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1420 | - if ( ! $espresso_no_ticket_prices ) { |
|
1421 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1419 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1420 | + if ( ! $espresso_no_ticket_prices) { |
|
1421 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1422 | 1422 | } |
1423 | 1423 | } |
1424 | 1424 | |
@@ -1440,24 +1440,24 @@ discard block |
||
1440 | 1440 | * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/ |
1441 | 1441 | * @global wpdb $wpdb |
1442 | 1442 | */ |
1443 | - public static function delete_all_espresso_cpt_data(){ |
|
1443 | + public static function delete_all_espresso_cpt_data() { |
|
1444 | 1444 | global $wpdb; |
1445 | 1445 | //get all the CPT post_types |
1446 | 1446 | $ee_post_types = array(); |
1447 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1448 | - if ( method_exists( $model_name, 'instance' )) { |
|
1449 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1450 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1451 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1447 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1448 | + if (method_exists($model_name, 'instance')) { |
|
1449 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1450 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1451 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1452 | 1452 | } |
1453 | 1453 | } |
1454 | 1454 | } |
1455 | 1455 | //get all our CPTs |
1456 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1456 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1457 | 1457 | $cpt_ids = $wpdb->get_col($query); |
1458 | 1458 | //delete each post meta and term relations too |
1459 | - foreach($cpt_ids as $post_id){ |
|
1460 | - wp_delete_post($post_id,true); |
|
1459 | + foreach ($cpt_ids as $post_id) { |
|
1460 | + wp_delete_post($post_id, true); |
|
1461 | 1461 | } |
1462 | 1462 | } |
1463 | 1463 | |
@@ -1471,18 +1471,18 @@ discard block |
||
1471 | 1471 | * @param bool $remove_all |
1472 | 1472 | * @return void |
1473 | 1473 | */ |
1474 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1474 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1475 | 1475 | global $wpdb; |
1476 | 1476 | $undeleted_tables = array(); |
1477 | 1477 | |
1478 | 1478 | // load registry |
1479 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1480 | - if ( method_exists( $model_name, 'instance' )) { |
|
1481 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1482 | - if ( $model_obj instanceof EEM_Base ) { |
|
1483 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1484 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1485 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1479 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1480 | + if (method_exists($model_name, 'instance')) { |
|
1481 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1482 | + if ($model_obj instanceof EEM_Base) { |
|
1483 | + foreach ($model_obj->get_tables() as $table) { |
|
1484 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1485 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1486 | 1486 | case false : |
1487 | 1487 | $undeleted_tables[] = $table->get_table_name(); |
1488 | 1488 | break; |
@@ -1507,8 +1507,8 @@ discard block |
||
1507 | 1507 | 'wp_esp_promotion_rule', |
1508 | 1508 | 'wp_esp_rule' |
1509 | 1509 | ); |
1510 | - foreach( $tables_without_models as $table ){ |
|
1511 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1510 | + foreach ($tables_without_models as $table) { |
|
1511 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | |
@@ -1544,56 +1544,56 @@ discard block |
||
1544 | 1544 | 'ee_rte_n_tx_' => false, |
1545 | 1545 | 'ee_pers_admin_notices' => true, |
1546 | 1546 | ); |
1547 | - if( is_main_site() ) { |
|
1548 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1547 | + if (is_main_site()) { |
|
1548 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | $undeleted_options = array(); |
1552 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1552 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1553 | 1553 | |
1554 | - if( $no_wildcard ){ |
|
1555 | - if( ! delete_option( $option_name ) ){ |
|
1554 | + if ($no_wildcard) { |
|
1555 | + if ( ! delete_option($option_name)) { |
|
1556 | 1556 | $undeleted_options[] = $option_name; |
1557 | 1557 | } |
1558 | - }else{ |
|
1559 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1560 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1561 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1558 | + } else { |
|
1559 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1560 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1561 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1562 | 1562 | $undeleted_options[] = $option_name_from_wildcard; |
1563 | 1563 | } |
1564 | 1564 | } |
1565 | 1565 | } |
1566 | 1566 | } |
1567 | 1567 | |
1568 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1568 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1569 | 1569 | $db_update_sans_ee4 = array(); |
1570 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1571 | - if( $version[0] =='3'){//if its NON EE4 |
|
1570 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1571 | + if ($version[0] == '3') {//if its NON EE4 |
|
1572 | 1572 | $db_update_sans_ee4[$version] = $times_activated; |
1573 | 1573 | } |
1574 | 1574 | } |
1575 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1575 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | $errors = ''; |
1579 | - if ( ! empty( $undeleted_tables )) { |
|
1579 | + if ( ! empty($undeleted_tables)) { |
|
1580 | 1580 | $errors .= sprintf( |
1581 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1581 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1582 | 1582 | '<br/>', |
1583 | - implode( ',<br/>', $undeleted_tables ) |
|
1583 | + implode(',<br/>', $undeleted_tables) |
|
1584 | 1584 | ); |
1585 | 1585 | } |
1586 | - if ( ! empty( $undeleted_options )) { |
|
1587 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1586 | + if ( ! empty($undeleted_options)) { |
|
1587 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1588 | 1588 | $errors .= sprintf( |
1589 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1589 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1590 | 1590 | '<br/>', |
1591 | - implode( ',<br/>', $undeleted_options ) |
|
1591 | + implode(',<br/>', $undeleted_options) |
|
1592 | 1592 | ); |
1593 | 1593 | |
1594 | 1594 | } |
1595 | - if ( $errors != '' ) { |
|
1596 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1595 | + if ($errors != '') { |
|
1596 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1597 | 1597 | } |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1603,23 +1603,23 @@ discard block |
||
1603 | 1603 | * @param string $table_name with or without $wpdb->prefix |
1604 | 1604 | * @return boolean |
1605 | 1605 | */ |
1606 | - public static function table_exists( $table_name ){ |
|
1606 | + public static function table_exists($table_name) { |
|
1607 | 1607 | global $wpdb, $EZSQL_ERROR; |
1608 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1608 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1609 | 1609 | //ignore if this causes an sql error |
1610 | 1610 | $old_error = $wpdb->last_error; |
1611 | 1611 | $old_suppress_errors = $wpdb->suppress_errors(); |
1612 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1612 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1613 | 1613 | $ezsql_error_cache = $EZSQL_ERROR; |
1614 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1615 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1616 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1614 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1615 | + $wpdb->show_errors($old_show_errors_value); |
|
1616 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1617 | 1617 | $new_error = $wpdb->last_error; |
1618 | 1618 | $wpdb->last_error = $old_error; |
1619 | 1619 | $EZSQL_ERROR = $ezsql_error_cache; |
1620 | - if( empty( $new_error ) ){ |
|
1620 | + if (empty($new_error)) { |
|
1621 | 1621 | return TRUE; |
1622 | - }else{ |
|
1622 | + } else { |
|
1623 | 1623 | return FALSE; |
1624 | 1624 | } |
1625 | 1625 | } |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | /** |
1628 | 1628 | * Resets the cache on EEH_Activation |
1629 | 1629 | */ |
1630 | - public static function reset(){ |
|
1630 | + public static function reset() { |
|
1631 | 1631 | self::$_default_creator_id = NULL; |
1632 | 1632 | self::$_initialized_db_content_already_in_this_request = false; |
1633 | 1633 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -140,15 +142,15 @@ discard block |
||
140 | 142 | ); |
141 | 143 | if( $which_to_include === 'all' ) { |
142 | 144 | //leave as-is |
143 | - }elseif( $which_to_include === 'old' ) { |
|
145 | + } elseif( $which_to_include === 'old' ) { |
|
144 | 146 | $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
145 | 147 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
146 | 148 | }); |
147 | - }elseif( $which_to_include === 'current' ) { |
|
149 | + } elseif( $which_to_include === 'current' ) { |
|
148 | 150 | $cron_tasks = array_filter( $cron_tasks ); |
149 | - }elseif( WP_DEBUG ) { |
|
151 | + } elseif( WP_DEBUG ) { |
|
150 | 152 | throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
151 | - }else{ |
|
153 | + } else{ |
|
152 | 154 | //leave as-is |
153 | 155 | } |
154 | 156 | return $cron_tasks; |
@@ -401,7 +403,7 @@ discard block |
||
401 | 403 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
402 | 404 | if($post_id){ |
403 | 405 | return get_post($post_id); |
404 | - }else{ |
|
406 | + } else{ |
|
405 | 407 | return NULL; |
406 | 408 | } |
407 | 409 | |
@@ -772,13 +774,13 @@ discard block |
||
772 | 774 | foreach( $current_data_migration_script->get_errors() as $error ){ |
773 | 775 | EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
774 | 776 | } |
775 | - }else{ |
|
777 | + } else{ |
|
776 | 778 | EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
777 | 779 | } |
778 | 780 | return false; |
779 | 781 | } |
780 | 782 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
781 | - }else{ |
|
783 | + } else{ |
|
782 | 784 | EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
783 | 785 | return false; |
784 | 786 | } |
@@ -1070,7 +1072,7 @@ discard block |
||
1070 | 1072 | if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
1071 | 1073 | EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
1072 | 1074 | EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
1073 | - }else{ |
|
1075 | + } else{ |
|
1074 | 1076 | EEM_Payment_Method::instance()->verify_button_urls(); |
1075 | 1077 | } |
1076 | 1078 | } |
@@ -1226,7 +1228,9 @@ discard block |
||
1226 | 1228 | //do an initial loop to determine if we need to continue |
1227 | 1229 | $def_ms = array(); |
1228 | 1230 | foreach ( $default_messengers as $msgr ) { |
1229 | - if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue; |
|
1231 | + if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) { |
|
1232 | + continue; |
|
1233 | + } |
|
1230 | 1234 | $def_ms[] = $msgr; |
1231 | 1235 | } |
1232 | 1236 | |
@@ -1555,7 +1559,7 @@ discard block |
||
1555 | 1559 | if( ! delete_option( $option_name ) ){ |
1556 | 1560 | $undeleted_options[] = $option_name; |
1557 | 1561 | } |
1558 | - }else{ |
|
1562 | + } else{ |
|
1559 | 1563 | $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
1560 | 1564 | foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
1561 | 1565 | if( ! delete_option( $option_name_from_wildcard ) ){ |
@@ -1619,7 +1623,7 @@ discard block |
||
1619 | 1623 | $EZSQL_ERROR = $ezsql_error_cache; |
1620 | 1624 | if( empty( $new_error ) ){ |
1621 | 1625 | return TRUE; |
1622 | - }else{ |
|
1626 | + } else{ |
|
1623 | 1627 | return FALSE; |
1624 | 1628 | } |
1625 | 1629 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
3 | 3 | |
4 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
4 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EE_Array |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $array2 an array of objects |
27 | 27 | * @return array an array of objects found in array 1 that aren't found in array 2. |
28 | 28 | */ |
29 | - public static function object_array_diff( $array1, $array2 ) { |
|
30 | - return array_udiff( $array1, $array2, array('self', '_compare_objects' )); |
|
29 | + public static function object_array_diff($array1, $array2) { |
|
30 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param array $arr |
36 | 36 | * @return boolean |
37 | 37 | */ |
38 | - public static function is_associative_array($arr){ |
|
38 | + public static function is_associative_array($arr) { |
|
39 | 39 | return array_keys($arr) !== range(0, count($arr) - 1); |
40 | 40 | } |
41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param array $arr |
46 | 46 | * @return mixed what ever is in the array |
47 | 47 | */ |
48 | - public static function get_one_item_from_array($arr){ |
|
48 | + public static function get_one_item_from_array($arr) { |
|
49 | 49 | $item = end($arr); |
50 | 50 | reset($arr); |
51 | 51 | return $item; |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @param mixed $arr |
57 | 57 | * @return boolean |
58 | 58 | */ |
59 | - public static function is_multi_dimensional_array($arr){ |
|
60 | - if(is_array($arr)){ |
|
59 | + public static function is_multi_dimensional_array($arr) { |
|
60 | + if (is_array($arr)) { |
|
61 | 61 | $first_item = reset($arr); |
62 | - if(is_array($first_item)){ |
|
63 | - return true;//yep, there's at least 2 levels to this array |
|
64 | - }else{ |
|
65 | - return false;//nope, only 1 level |
|
62 | + if (is_array($first_item)) { |
|
63 | + return true; //yep, there's at least 2 levels to this array |
|
64 | + } else { |
|
65 | + return false; //nope, only 1 level |
|
66 | 66 | } |
67 | - }else{ |
|
68 | - return false;//its not an array at all! |
|
67 | + } else { |
|
68 | + return false; //its not an array at all! |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param mixed $default |
77 | 77 | * @return mixed |
78 | 78 | */ |
79 | - public static function is_set( $arr, $index, $default ) { |
|
80 | - return isset( $arr[ $index ] ) ? $arr[ $index ] : $default; |
|
79 | + public static function is_set($arr, $index, $default) { |
|
80 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
93 | 93 | * @return array |
94 | 94 | */ |
95 | - public static function insert_into_array( $target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true ) { |
|
95 | + public static function insert_into_array($target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true) { |
|
96 | 96 | // ensure incoming arrays are actually arrays |
97 | - $target_array = (array)$target_array; |
|
98 | - $array_to_insert = (array)$array_to_insert; |
|
97 | + $target_array = (array) $target_array; |
|
98 | + $array_to_insert = (array) $array_to_insert; |
|
99 | 99 | // if no offset key was supplied |
100 | - if ( empty( $offset )) { |
|
100 | + if (empty($offset)) { |
|
101 | 101 | // use start or end of $target_array based on whether we are adding before or not |
102 | - $offset = $add_before ? 0 : count( $target_array ); |
|
102 | + $offset = $add_before ? 0 : count($target_array); |
|
103 | 103 | } |
104 | 104 | // if offset key is a string, then find the corresponding numeric location for that element |
105 | - $offset = is_int( $offset ) ? $offset : array_search( $offset, array_keys( $target_array ) ); |
|
105 | + $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
106 | 106 | // add one to the offset if adding after |
107 | 107 | $offset = $add_before ? $offset : $offset + 1; |
108 | 108 | // but ensure offset does not exceed the length of the array |
109 | - $offset = $offset > count( $target_array ) ? count( $target_array ) : $offset; |
|
109 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
110 | 110 | // reindex array ??? |
111 | - if ( $preserve_keys ) { |
|
111 | + if ($preserve_keys) { |
|
112 | 112 | // take a slice of the target array from the beginning till the offset, |
113 | 113 | // then add the new data |
114 | 114 | // then add another slice that starts at the offset and goes till the end |
115 | - return array_slice( $target_array, 0, $offset, true ) + $array_to_insert + array_slice( $target_array, $offset, null, true ); |
|
115 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset, null, true); |
|
116 | 116 | } else { |
117 | 117 | // since we don't want to preserve keys, we can use array_splice |
118 | - array_splice( $target_array, $offset, 0, $array_to_insert ); |
|
118 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
119 | 119 | return $target_array; |
120 | 120 | } |
121 | 121 | } |
@@ -61,10 +61,10 @@ |
||
61 | 61 | $first_item = reset($arr); |
62 | 62 | if(is_array($first_item)){ |
63 | 63 | return true;//yep, there's at least 2 levels to this array |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | return false;//nope, only 1 level |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else{ |
|
68 | 68 | return false;//its not an array at all! |
69 | 69 | } |
70 | 70 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | private static $_instance = NULL; |
24 | 24 | |
25 | 25 | /** |
26 | - * $_autoloaders |
|
27 | - * @var array $_autoloaders |
|
28 | - * @access private |
|
29 | - */ |
|
26 | + * $_autoloaders |
|
27 | + * @var array $_autoloaders |
|
28 | + * @access private |
|
29 | + */ |
|
30 | 30 | private static $_autoloaders; |
31 | 31 | |
32 | 32 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function instance() { |
40 | 40 | // check if class object is instantiated, and instantiated properly |
41 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
41 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
42 | 42 | self::$_instance = new self(); |
43 | 43 | } |
44 | 44 | return self::$_instance; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | private function __construct() { |
56 | 56 | self::$_autoloaders = array(); |
57 | 57 | $this->_register_custom_autoloaders(); |
58 | - spl_autoload_register( array( $this, 'espresso_autoloader' )); |
|
58 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @internal param string $class_name - simple class name ie: session |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - public static function espresso_autoloader( $class_name ) { |
|
73 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
74 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
72 | + public static function espresso_autoloader($class_name) { |
|
73 | + if (isset(self::$_autoloaders[$class_name])) { |
|
74 | + require_once(self::$_autoloaders[$class_name]); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -87,26 +87,26 @@ discard block |
||
87 | 87 | * @return void |
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | - public static function register_autoloader( $class_paths, $read_check = true, $debug = false ) { |
|
91 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
92 | - foreach ( $class_paths as $class => $path ) { |
|
90 | + public static function register_autoloader($class_paths, $read_check = true, $debug = false) { |
|
91 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
92 | + foreach ($class_paths as $class => $path) { |
|
93 | 93 | // don't give up! you gotta... |
94 | 94 | // get some class |
95 | - if ( empty( $class )) { |
|
96 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
95 | + if (empty($class)) { |
|
96 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
97 | 97 | } |
98 | 98 | // one day you will find the path young grasshopper |
99 | - if ( empty( $path )) { |
|
100 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
99 | + if (empty($path)) { |
|
100 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
101 | 101 | } |
102 | 102 | // is file readable ? |
103 | - if ( $read_check && ! is_readable( $path )) { |
|
104 | - throw new EE_Error ( sprintf( __( 'The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s','event_espresso' ), $class, $path )); |
|
103 | + if ($read_check && ! is_readable($path)) { |
|
104 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
105 | 105 | } |
106 | - if ( ! isset( self::$_autoloaders[ $class ] )) { |
|
107 | - self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path ); |
|
108 | - if ( WP_DEBUG && $debug ) { |
|
109 | - printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ ); |
|
106 | + if ( ! isset(self::$_autoloaders[$class])) { |
|
107 | + self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path); |
|
108 | + if (WP_DEBUG && $debug) { |
|
109 | + printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | * @return void |
136 | 136 | */ |
137 | 137 | private function _register_custom_autoloaders() { |
138 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' ); |
|
139 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
140 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true ); |
|
141 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true ); |
|
142 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
143 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
138 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
139 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
140 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
141 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
142 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
143 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return void |
167 | 167 | */ |
168 | 168 | public static function register_line_item_display_autoloaders() { |
169 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , true ); |
|
169 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | */ |
181 | 181 | public static function register_line_item_filter_autoloaders() { |
182 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_filters' , true ); |
|
182 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -197,30 +197,30 @@ discard block |
||
197 | 197 | * @return void |
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false, $debug = false ){ |
|
200 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) { |
|
201 | 201 | // make sure last char is a / |
202 | - $folder .= $folder[strlen($folder)-1] != DS ? DS : ''; |
|
202 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
203 | 203 | $class_to_filepath_map = array(); |
204 | - $exclude = array( 'index' ); |
|
204 | + $exclude = array('index'); |
|
205 | 205 | //get all the files in that folder that end in php |
206 | - $filepaths = glob( $folder.'*'); |
|
206 | + $filepaths = glob($folder.'*'); |
|
207 | 207 | |
208 | - if ( empty( $filepaths ) ) { |
|
208 | + if (empty($filepaths)) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - foreach( $filepaths as $filepath ) { |
|
213 | - if ( substr( $filepath, -4, 4 ) == '.php' ) { |
|
214 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
215 | - if ( ! in_array( $class_name, $exclude )) { |
|
216 | - $class_to_filepath_map [ $class_name ] = str_replace( array( '\/', '/' ), DS, $filepath ); |
|
212 | + foreach ($filepaths as $filepath) { |
|
213 | + if (substr($filepath, -4, 4) == '.php') { |
|
214 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
215 | + if ( ! in_array($class_name, $exclude)) { |
|
216 | + $class_to_filepath_map [$class_name] = str_replace(array('\/', '/'), DS, $filepath); |
|
217 | 217 | } |
218 | - } else if ( $recursive ) { |
|
219 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive ); |
|
218 | + } else if ($recursive) { |
|
219 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
223 | - self::register_autoloader( $class_to_filepath_map, false, $debug ); |
|
223 | + self::register_autoloader($class_to_filepath_map, false, $debug); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @ override magic methods |
34 | 34 | * @ return void |
35 | 35 | */ |
36 | - public function __set($a,$b) { return FALSE; } |
|
36 | + public function __set($a, $b) { return FALSE; } |
|
37 | 37 | public function __get($a) { return FALSE; } |
38 | 38 | public function __isset($a) { return FALSE; } |
39 | 39 | public function __unset($a) { return FALSE; } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function get_called_class() { |
37 | 37 | $backtrace = debug_backtrace(); |
38 | - if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) { |
|
38 | + if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) { |
|
39 | 39 | return $backtrace[2]['class']; |
40 | - } else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) { |
|
40 | + } else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
|
41 | 41 | return $backtrace[3]['class']; |
42 | - } else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) { |
|
43 | - if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) { |
|
42 | + } else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
|
43 | + if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) { |
|
44 | 44 | self::$i++; |
45 | 45 | } else { |
46 | 46 | self::$i = 0; |
47 | - self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
47 | + self::$file_line = $backtrace[2]['file'].$backtrace[2]['line']; |
|
48 | 48 | } |
49 | 49 | // was class method called via call_user_func ? |
50 | - if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){ |
|
51 | - if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) { |
|
50 | + if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
|
51 | + if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) { |
|
52 | 52 | $called_class = $backtrace[2]['args'][0][0]; |
53 | 53 | // is it an EE function ? |
54 | - if ( strpos( $called_class, 'EE' ) === 0 ) { |
|
55 | - $prefix_chars = strpos( $called_class, '_' ) + 1; |
|
56 | - $prefix = substr( $called_class, 0, $prefix_chars ); |
|
57 | - $classname = substr( $called_class, $prefix_chars, strlen( $called_class )); |
|
58 | - $classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname )))); |
|
54 | + if (strpos($called_class, 'EE') === 0) { |
|
55 | + $prefix_chars = strpos($called_class, '_') + 1; |
|
56 | + $prefix = substr($called_class, 0, $prefix_chars); |
|
57 | + $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
|
58 | + $classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
59 | 59 | return $classname; |
60 | 60 | } |
61 | 61 | } |
62 | 62 | } else { |
63 | - $lines = file( $backtrace[2]['file'] ); |
|
64 | - preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches ); |
|
65 | - if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) { |
|
66 | - return $matches[1][ self::$i ]; |
|
63 | + $lines = file($backtrace[2]['file']); |
|
64 | + preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches); |
|
65 | + if (isset($matches[1]) && isset($matches[1][self::$i])) { |
|
66 | + return $matches[1][self::$i]; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @param string $hook |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) { |
|
83 | + public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) { |
|
84 | 84 | global $wp_filter; |
85 | 85 | $class_names = array(); |
86 | 86 | // are any callbacks registered for this hook ? |
87 | - if ( isset( $wp_filter[ $hook ] )) { |
|
87 | + if (isset($wp_filter[$hook])) { |
|
88 | 88 | // loop thru all of the callbacks attached to the deprecated hookpoint |
89 | - foreach( $wp_filter[ $hook ] as $priority ) { |
|
90 | - foreach( $priority as $callback ) { |
|
89 | + foreach ($wp_filter[$hook] as $priority) { |
|
90 | + foreach ($priority as $callback) { |
|
91 | 91 | // is the callback a non-static class method ? |
92 | - if ( isset( $callback['function'] ) && is_array( $callback['function'] )) { |
|
93 | - if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) { |
|
94 | - $class_names[] = get_class( $callback['function'][0] ); |
|
92 | + if (isset($callback['function']) && is_array($callback['function'])) { |
|
93 | + if (isset($callback['function'][0]) && is_object($callback['function'][0])) { |
|
94 | + $class_names[] = get_class($callback['function'][0]); |
|
95 | 95 | } |
96 | 96 | // test for static method |
97 | - } else if ( strpos( $callback['function'], '::' ) !== FALSE ) { |
|
98 | - $class = explode( '::', $callback['function'] ); |
|
97 | + } else if (strpos($callback['function'], '::') !== FALSE) { |
|
98 | + $class = explode('::', $callback['function']); |
|
99 | 99 | $class_names[] = $class[0]; |
100 | 100 | } else { |
101 | 101 | // just a function |
@@ -116,24 +116,24 @@ discard block |
||
116 | 116 | * @param string $property |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function has_property( $class = NULL, $property = NULL ) { |
|
119 | + public static function has_property($class = NULL, $property = NULL) { |
|
120 | 120 | // if $class or $property don't exist, then get out, cuz that would be like... fatal dude |
121 | - if ( empty( $class ) || empty( $property )) { |
|
121 | + if (empty($class) || empty($property)) { |
|
122 | 122 | return FALSE; |
123 | 123 | } |
124 | 124 | // if your hosting company doesn't cut the mustard |
125 | - if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { |
|
125 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
126 | 126 | // just in case $class is an actual instantiated object |
127 | - if ( is_object( $class )) { |
|
128 | - return isset( $class->$property ) ? TRUE : FALSE; |
|
127 | + if (is_object($class)) { |
|
128 | + return isset($class->$property) ? TRUE : FALSE; |
|
129 | 129 | } else { |
130 | 130 | // use reflection for < PHP 5.3 to get details using just the class name |
131 | - $reflector = new ReflectionClass( $class ); |
|
132 | - return $reflector->hasProperty( $property ); |
|
131 | + $reflector = new ReflectionClass($class); |
|
132 | + return $reflector->hasProperty($property); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | 135 | // or try regular property exists method which works as expected in PHP 5.3+ |
136 | - return property_exists( $class, $property ); |
|
136 | + return property_exists($class, $property); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // if PHP version < 5.3 |
146 | -if ( ! function_exists( 'get_called_class' )) { |
|
146 | +if ( ! function_exists('get_called_class')) { |
|
147 | 147 | /** |
148 | 148 | * @return bool|string |
149 | 149 | */ |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -799,7 +799,6 @@ |
||
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | - |
|
803 | 802 | * |
804 | 803 | * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
805 | 804 | * very next day then this method will return true. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public static function get_valid_timezone_string( $timezone_string = '' ) { |
|
56 | + public static function get_valid_timezone_string($timezone_string = '') { |
|
57 | 57 | // if passed a value, then use that, else get WP option |
58 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
58 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
59 | 59 | // value from above exists, use that, else get timezone string from gmt_offset |
60 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | - EEH_DTT_Helper::validate_timezone( $timezone_string ); |
|
60 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
62 | 62 | return $timezone_string; |
63 | 63 | } |
64 | 64 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | * @throws \EE_Error |
76 | 76 | */ |
77 | - public static function validate_timezone( $timezone_string, $throw_error = true ) { |
|
77 | + public static function validate_timezone($timezone_string, $throw_error = true) { |
|
78 | 78 | // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
79 | 79 | try { |
80 | - new DateTimeZone( $timezone_string ); |
|
81 | - } catch ( Exception $e ) { |
|
80 | + new DateTimeZone($timezone_string); |
|
81 | + } catch (Exception $e) { |
|
82 | 82 | // sometimes we take exception to exceptions |
83 | - if ( ! $throw_error ) { |
|
83 | + if ( ! $throw_error) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | throw new EE_Error( |
87 | 87 | sprintf( |
88 | - __( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
88 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
89 | 89 | $timezone_string, |
90 | 90 | '<a href="http://www.php.net/manual/en/timezones.php">', |
91 | 91 | '</a>' |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $gmt_offset |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) { |
|
107 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') { |
|
108 | 108 | $timezone_string = 'UTC'; |
109 | - $gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' ); |
|
110 | - if ( $gmt_offset !== '' ) { |
|
109 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
110 | + if ($gmt_offset !== '') { |
|
111 | 111 | // convert GMT offset to seconds |
112 | 112 | $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
113 | 113 | // account for WP offsets that aren't valid UTC |
114 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset ); |
|
114 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
115 | 115 | // although we don't know the TZ abbreviation, we know the UTC offset |
116 | - $timezone_string = timezone_name_from_abbr( null, $gmt_offset ); |
|
116 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
117 | 117 | } |
118 | 118 | // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
119 | - $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset ); |
|
119 | + $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
120 | 120 | return $timezone_string; |
121 | 121 | } |
122 | 122 | |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | * @param int $gmt_offset |
130 | 130 | * @return int |
131 | 131 | */ |
132 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
132 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
133 | 133 | //make sure $gmt_offset is int |
134 | 134 | $gmt_offset = (int) $gmt_offset; |
135 | - switch ( $gmt_offset ) { |
|
135 | + switch ($gmt_offset) { |
|
136 | 136 | |
137 | 137 | // case -30600 : |
138 | 138 | // $gmt_offset = -28800; |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | * @throws \EE_Error |
186 | 186 | */ |
187 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
187 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
188 | 188 | $abbreviations = timezone_abbreviations_list(); |
189 | - foreach ( $abbreviations as $abbreviation ) { |
|
190 | - foreach ( $abbreviation as $city ) { |
|
191 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
189 | + foreach ($abbreviations as $abbreviation) { |
|
190 | + foreach ($abbreviation as $city) { |
|
191 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
192 | 192 | // check if the timezone is valid but don't throw any errors if it isn't |
193 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
193 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
194 | 194 | return $city['timezone_id']; |
195 | 195 | } |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | throw new EE_Error( |
200 | 200 | sprintf( |
201 | - __( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
201 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
202 | 202 | $gmt_offset, |
203 | 203 | '<a href="http://www.php.net/manual/en/timezones.php">', |
204 | 204 | '</a>' |
@@ -212,23 +212,23 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @param string $timezone_string |
214 | 214 | */ |
215 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
215 | + public static function timezone_select_input($timezone_string = '') { |
|
216 | 216 | // get WP date time format |
217 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
217 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
218 | 218 | // if passed a value, then use that, else get WP option |
219 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
219 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
220 | 220 | // check if the timezone is valid but don't throw any errors if it isn't |
221 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
221 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
222 | 222 | $gmt_offset = get_option('gmt_offset'); |
223 | 223 | |
224 | 224 | $check_zone_info = true; |
225 | - if ( empty( $timezone_string )) { |
|
225 | + if (empty($timezone_string)) { |
|
226 | 226 | // Create a UTC+- zone if no timezone string exists |
227 | 227 | $check_zone_info = false; |
228 | - if ( $gmt_offset > 0 ) { |
|
229 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
230 | - } elseif ( $gmt_offset < 0 ) { |
|
231 | - $timezone_string = 'UTC' . $gmt_offset; |
|
228 | + if ($gmt_offset > 0) { |
|
229 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
230 | + } elseif ($gmt_offset < 0) { |
|
231 | + $timezone_string = 'UTC'.$gmt_offset; |
|
232 | 232 | } else { |
233 | 233 | $timezone_string = 'UTC'; |
234 | 234 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | __('%1$sUTC%2$s time is %3$s'), |
251 | 251 | '<abbr title="Coordinated Universal Time">', |
252 | 252 | '</abbr>', |
253 | - '<code>' . date_i18n( $datetime_format , false, 'gmt') . '</code>' |
|
253 | + '<code>'.date_i18n($datetime_format, false, 'gmt').'</code>' |
|
254 | 254 | ); |
255 | 255 | ?></span> |
256 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
257 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
256 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
257 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
258 | 258 | <?php endif; ?> |
259 | 259 | |
260 | 260 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -286,10 +286,9 @@ discard block |
||
286 | 286 | |
287 | 287 | if ($found) { |
288 | 288 | $message = $tr['isdst'] ? |
289 | - __(' Daylight saving time begins on: %s.' ) : |
|
290 | - __(' Standard time begins on: %s.'); |
|
289 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
291 | 290 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
292 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
291 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
293 | 292 | } else { |
294 | 293 | _e('This timezone does not observe daylight saving time.'); |
295 | 294 | } |
@@ -319,14 +318,14 @@ discard block |
||
319 | 318 | * |
320 | 319 | * @return int $unix_timestamp with the offset applied for the given timezone. |
321 | 320 | */ |
322 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
321 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
323 | 322 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
324 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
325 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
323 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
324 | + $TimeZone = new DateTimeZone($timezone_string); |
|
326 | 325 | |
327 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
328 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
329 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
326 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
327 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
328 | + return (int) $DateTime->format('U') + (int) $offset; |
|
330 | 329 | } |
331 | 330 | |
332 | 331 | |
@@ -341,17 +340,17 @@ discard block |
||
341 | 340 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
342 | 341 | * @return EE_Base_Class |
343 | 342 | */ |
344 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
343 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
345 | 344 | // grab current datetime format |
346 | 345 | $current_format = $obj->get_format(); |
347 | 346 | // set new full timestamp format |
348 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
349 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
347 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
348 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
350 | 349 | // set the new date value using a full timestamp format so that no data is lost |
351 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
350 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
352 | 351 | // reset datetime formats |
353 | - $obj->set_date_format( $current_format[0] ); |
|
354 | - $obj->set_time_format( $current_format[1] ); |
|
352 | + $obj->set_date_format($current_format[0]); |
|
353 | + $obj->set_time_format($current_format[1]); |
|
355 | 354 | return $obj; |
356 | 355 | } |
357 | 356 | |
@@ -368,11 +367,11 @@ discard block |
||
368 | 367 | * @param integer $value what you want to increment the time by |
369 | 368 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
370 | 369 | */ |
371 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
370 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
372 | 371 | //get the raw UTC date. |
373 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
374 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value ); |
|
375 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
372 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
373 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
374 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | |
@@ -387,11 +386,11 @@ discard block |
||
387 | 386 | * @param int $value |
388 | 387 | * @return \EE_Base_Class |
389 | 388 | */ |
390 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
389 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
391 | 390 | //get the raw UTC date |
392 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
393 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
394 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
391 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
392 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
393 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
395 | 394 | } |
396 | 395 | |
397 | 396 | |
@@ -404,44 +403,44 @@ discard block |
||
404 | 403 | * @return \DateTime return whatever type came in. |
405 | 404 | * @throws \EE_Error |
406 | 405 | */ |
407 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
408 | - if ( ! $DateTime instanceof DateTime ) { |
|
406 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
407 | + if ( ! $DateTime instanceof DateTime) { |
|
409 | 408 | throw new EE_Error( |
410 | 409 | sprintf( |
411 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
412 | - print_r( $DateTime, true ) |
|
410 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
411 | + print_r($DateTime, true) |
|
413 | 412 | ) |
414 | 413 | ); |
415 | 414 | } |
416 | - switch ( $period ) { |
|
415 | + switch ($period) { |
|
417 | 416 | case 'years' : |
418 | - $value = 'P' . $value . 'Y'; |
|
417 | + $value = 'P'.$value.'Y'; |
|
419 | 418 | break; |
420 | 419 | case 'months' : |
421 | - $value = 'P' . $value . 'M'; |
|
420 | + $value = 'P'.$value.'M'; |
|
422 | 421 | break; |
423 | 422 | case 'weeks' : |
424 | - $value = 'P' . $value . 'W'; |
|
423 | + $value = 'P'.$value.'W'; |
|
425 | 424 | break; |
426 | 425 | case 'days' : |
427 | - $value = 'P' . $value . 'D'; |
|
426 | + $value = 'P'.$value.'D'; |
|
428 | 427 | break; |
429 | 428 | case 'hours' : |
430 | - $value = 'PT' . $value . 'H'; |
|
429 | + $value = 'PT'.$value.'H'; |
|
431 | 430 | break; |
432 | 431 | case 'minutes' : |
433 | - $value = 'PT' . $value . 'M'; |
|
432 | + $value = 'PT'.$value.'M'; |
|
434 | 433 | break; |
435 | 434 | case 'seconds' : |
436 | - $value = 'PT' . $value . 'S'; |
|
435 | + $value = 'PT'.$value.'S'; |
|
437 | 436 | break; |
438 | 437 | } |
439 | - switch ( $operand ) { |
|
438 | + switch ($operand) { |
|
440 | 439 | case '+': |
441 | - $DateTime->add( new DateInterval( $value ) ); |
|
440 | + $DateTime->add(new DateInterval($value)); |
|
442 | 441 | break; |
443 | 442 | case '-': |
444 | - $DateTime->sub( new DateInterval( $value ) ); |
|
443 | + $DateTime->sub(new DateInterval($value)); |
|
445 | 444 | break; |
446 | 445 | } |
447 | 446 | return $DateTime; |
@@ -457,16 +456,16 @@ discard block |
||
457 | 456 | * @return \DateTime return whatever type came in. |
458 | 457 | * @throws \EE_Error |
459 | 458 | */ |
460 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
461 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
459 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
460 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
462 | 461 | throw new EE_Error( |
463 | 462 | sprintf( |
464 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
465 | - print_r( $timestamp, true ) |
|
463 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
464 | + print_r($timestamp, true) |
|
466 | 465 | ) |
467 | 466 | ); |
468 | 467 | } |
469 | - switch ( $period ) { |
|
468 | + switch ($period) { |
|
470 | 469 | case 'years' : |
471 | 470 | $value = YEAR_IN_SECONDS * $value; |
472 | 471 | break; |
@@ -486,9 +485,9 @@ discard block |
||
486 | 485 | $value = MINUTE_IN_SECONDS * $value; |
487 | 486 | break; |
488 | 487 | } |
489 | - switch ( $operand ) { |
|
488 | + switch ($operand) { |
|
490 | 489 | case '+': |
491 | - $timestamp += $value; |
|
490 | + $timestamp += $value; |
|
492 | 491 | break; |
493 | 492 | case '-': |
494 | 493 | $timestamp -= $value; |
@@ -508,11 +507,11 @@ discard block |
||
508 | 507 | * @param string $operand What operand you wish to use for the calculation |
509 | 508 | * @return mixed string|DateTime return whatever type came in. |
510 | 509 | */ |
511 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
512 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
513 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
514 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
515 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
510 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
511 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
512 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
513 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
514 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
516 | 515 | } else { |
517 | 516 | //error |
518 | 517 | return $DateTime_or_timestamp; |
@@ -542,24 +541,24 @@ discard block |
||
542 | 541 | * 'moment' => //date and time format. |
543 | 542 | * ) |
544 | 543 | */ |
545 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
546 | - if ( $date_format_string === null ) { |
|
547 | - $date_format_string = get_option( 'date_format' ); |
|
544 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
545 | + if ($date_format_string === null) { |
|
546 | + $date_format_string = get_option('date_format'); |
|
548 | 547 | } |
549 | 548 | |
550 | - if ( $time_format_string === null ) { |
|
551 | - $time_format_string = get_option( 'time_format' ); |
|
549 | + if ($time_format_string === null) { |
|
550 | + $time_format_string = get_option('time_format'); |
|
552 | 551 | } |
553 | 552 | |
554 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
555 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
553 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
554 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
556 | 555 | |
557 | 556 | return array( |
558 | 557 | 'js' => array( |
559 | 558 | 'date' => $date_format['js'], |
560 | 559 | 'time' => $time_format['js'] |
561 | 560 | ), |
562 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
561 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
563 | 562 | ); |
564 | 563 | } |
565 | 564 | |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | * |
574 | 573 | * @return array js and moment formats. |
575 | 574 | */ |
576 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
575 | + protected static function _php_to_js_moment_converter($format_string) { |
|
577 | 576 | /** |
578 | 577 | * This is a map of symbols for formats. |
579 | 578 | * The index is the php symbol, the equivalent values are in the array. |
@@ -730,15 +729,15 @@ discard block |
||
730 | 729 | $jquery_ui_format = ""; |
731 | 730 | $moment_format = ""; |
732 | 731 | $escaping = false; |
733 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
732 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
734 | 733 | $char = $format_string[$i]; |
735 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
734 | + if ($char === '\\') { // PHP date format escaping character |
|
736 | 735 | $i++; |
737 | - if ( $escaping ) { |
|
736 | + if ($escaping) { |
|
738 | 737 | $jquery_ui_format .= $format_string[$i]; |
739 | 738 | $moment_format .= $format_string[$i]; |
740 | 739 | } else { |
741 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
740 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
742 | 741 | $moment_format .= $format_string[$i]; |
743 | 742 | } |
744 | 743 | $escaping = true; |
@@ -757,7 +756,7 @@ discard block |
||
757 | 756 | } |
758 | 757 | } |
759 | 758 | } |
760 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
759 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
761 | 760 | } |
762 | 761 | |
763 | 762 | |
@@ -772,25 +771,25 @@ discard block |
||
772 | 771 | * errors is returned. So for client code calling, check for is_array() to |
773 | 772 | * indicate failed validations. |
774 | 773 | */ |
775 | - public static function validate_format_string( $format_string ) { |
|
774 | + public static function validate_format_string($format_string) { |
|
776 | 775 | $error_msg = array(); |
777 | 776 | //time format checks |
778 | - switch ( true ) { |
|
779 | - case strpos( $format_string, 'h' ) !== false : |
|
780 | - case strpos( $format_string, 'g' ) !== false : |
|
777 | + switch (true) { |
|
778 | + case strpos($format_string, 'h') !== false : |
|
779 | + case strpos($format_string, 'g') !== false : |
|
781 | 780 | /** |
782 | 781 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
783 | 782 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
784 | 783 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
785 | 784 | */ |
786 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
787 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' ); |
|
785 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
786 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso'); |
|
788 | 787 | } |
789 | 788 | break; |
790 | 789 | |
791 | 790 | } |
792 | 791 | |
793 | - return empty( $error_msg ) ? true : $error_msg; |
|
792 | + return empty($error_msg) ? true : $error_msg; |
|
794 | 793 | } |
795 | 794 | |
796 | 795 | |
@@ -812,11 +811,11 @@ discard block |
||
812 | 811 | * @param mixed $date_2 |
813 | 812 | * @return bool |
814 | 813 | */ |
815 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
814 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
816 | 815 | |
817 | 816 | if ( |
818 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
819 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
817 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
818 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
820 | 819 | ) { |
821 | 820 | return false; |
822 | 821 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -264,10 +265,11 @@ discard block |
||
264 | 265 | // Set TZ so localtime works. |
265 | 266 | date_default_timezone_set($timezone_string); |
266 | 267 | $now = localtime(time(), true); |
267 | - if ($now['tm_isdst']) |
|
268 | - _e('This timezone is currently in daylight saving time.'); |
|
269 | - else |
|
270 | - _e('This timezone is currently in standard time.'); |
|
268 | + if ($now['tm_isdst']) { |
|
269 | + _e('This timezone is currently in daylight saving time.'); |
|
270 | + } else { |
|
271 | + _e('This timezone is currently in standard time.'); |
|
272 | + } |
|
271 | 273 | ?> |
272 | 274 | <br /> |
273 | 275 | <?php |